7#ifndef MFRAME_9DAB1F2F_D976_4CB4_9CDD_36EE14C28322
8#define MFRAME_9DAB1F2F_D976_4CB4_9CDD_36EE14C28322
15#include "./../lang/Iterable.h"
16#include "./../lang/Object.h"
256template <
class E =
void*>
278 : vIterable(iterable), vIndex(
index) {
333 return (this->vIterable.
nextIndex(this->vIndex) != -1);
342 this->vIndex = this->vIterable.
nextIndex(this->vIndex);
343 if (this->vIndex == -1) {
344 UFM_THROW(
"Iterator has reached the end of the collection.",
355 return this->vIterable.
elementAt(this->vIndex);
物件基底類別
Definition Object.h:63
迭代器類別,提供遍歷集合元素的標準介面。
Definition Iterator.h:257
Iterator & operator++()
前置遞增運算子,移動到下一個元素
Definition Iterator.h:309
bool hasNext(void) const
檢查是否還有下一個元素
Definition Iterator.h:332
void next(void)
移動迭代器到下一個元素
Definition Iterator.h:341
bool operator!=(const Iterator &other) const
不等於運算子,比較兩個迭代器位置
Definition Iterator.h:320
virtual ~Iterator(void) override
解構 Iterator 物件
Definition Iterator.h:287
E * get(void) const
取得目前元素的指標
Definition Iterator.h:354
int index(void) const
取得目前迭代位置的索引
Definition Iterator.h:363
E & operator*() const
解引用運算子,取得目前元素的參考
Definition Iterator.h:300
Iterator(ufm::lang::Iterable< E > &iterable, int index=0) noexcept
建構 Iterator 物件
Definition Iterator.h:277
@ INDEX_OUT_OF_BOUNDS
索引超出範圍,泛指各種集合
[Interface] 定義可迭代集合介面
Definition Iterable.h:49
virtual E * elementAt(int index) const override
獲取集合中指定索引處的元素。
virtual int nextIndex(int index) const override
返回當前索引的下一個有效索引。