mFrame
載入中...
搜尋中...
無符合項目
ufm::util::Iterator< E > 類別 樣版 參考文件

[Class] 迭代器介面 更多...

#include <Iterator.h>

類別ufm::util::Iterator< E >的繼承圖:
ufm::lang::Object ufm::lang::Interface

公開方法(Public Methods)

 Iterator (ufm::lang::Iterable< E > &iterable, int index=0) noexcept
 建構 Iterator 物件。
 
virtual ~Iterator (void) override
 解構 Iterator 物件。
 
E & operator* () const
 取得目前元素的參考(解引用運算子)。
 
Iteratoroperator++ ()
 前置遞增運算子,將迭代器移動到下一個元素。
 
bool operator!= (const Iterator &other) const
 不等於運算子,判斷兩個迭代器是否指向不同位置。
 
bool hasNext (void) const
 判斷是否還有下一個元素可供遍歷。
 
void next (void)
 將迭代器移動到下一個元素。
 
E * get (void) const
 取得目前元素的參考。
 
int index (void) const
 重新設定該迭代器至初始狀態。
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Object
void * operator new (size_t n)
 使用運算子 new 分配記憶體
 
void * operator new (size_t n, void *p)
 在指定記憶體上調用運算子 new
 
virtual ufm::lang::ObjectgetObject (void) override
 取得對應的 Object 物件
 
void delay (int milliseconds) const
 延遲指定的毫秒數進行執行緒等待
 
bool equals (Object *object) const
 判斷與另一物件是否為相同參照(指標型態比較)
 
bool equals (Object &object) const
 判斷與另一物件是否為相同參照(參照型態比較)
 
void wait (void) const
 使當前線程等待直到被通知
 
bool wait (int timeout) const
 等待通知或超時
 
bool yield (void) const
 讓執行緒讓渡控制權給同優先權的下一個執行緒
 
int lock (void) const
 核心鎖定,鎖定期間禁止線程切換
 
int unlock (void) const
 核心解鎖
 
ufm::sys::ThreadcurrentThread (void) const
 取得當前執行緒指標
 
virtual int hashcode (void) const
 返回對象的哈希碼值。支持這種方法是為了散列表,如HashMap提供的那樣。
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Interface
virtual ~Interface (void)=default
 虛擬析構函式
 

詳細描述

template<class E = void*>
class ufm::util::Iterator< E >

[Class] 迭代器介面

此介面定義了迭代器的基本操作。迭代器用於遍歷集合中的元素, 提供一種標準方式來存取集合元素,而無需了解集合的底層結構。

樣版參數
E迭代器元素的型別
1.0.0

建構子與解構子說明文件

◆ Iterator()

template<class E = void*>
ufm::util::Iterator< E >::Iterator ( ufm::lang::Iterable< E > & iterable,
int index = 0 )
inlinenoexcept

建構 Iterator 物件。

建立一個新的迭代器物件。

◆ ~Iterator()

template<class E = void*>
virtual ufm::util::Iterator< E >::~Iterator ( void )
inlineoverridevirtual

解構 Iterator 物件。

銷毀迭代器物件並釋放相關資源。

函式成員說明文件

◆ get()

template<class E = void*>
E * ufm::util::Iterator< E >::get ( void ) const
inline

取得目前元素的參考。

傳回值
E* 目前元素的指標。

如果迭代器已經到達結尾,則應該拋出異常。

◆ hasNext()

template<class E = void*>
bool ufm::util::Iterator< E >::hasNext ( void ) const
inline

判斷是否還有下一個元素可供遍歷。

傳回值
true尚有更多元素可遍歷
false已無更多元素

◆ index()

template<class E = void*>
int ufm::util::Iterator< E >::index ( void ) const
inline

重新設定該迭代器至初始狀態。

將迭代器重置到初始位置,這樣可以重新開始遍歷集合中的元素。

◆ next()

template<class E = void*>
void ufm::util::Iterator< E >::next ( void )
inline

將迭代器移動到下一個元素。

呼叫此方法後,迭代器將指向集合中的下一個元素。

◆ operator!=()

template<class E = void*>
bool ufm::util::Iterator< E >::operator!= ( const Iterator< E > & other) const
inline

不等於運算子,判斷兩個迭代器是否指向不同位置。

主要用於 for 迴圈等結構中判斷是否到達結尾。

參數
other另一個迭代器
傳回值
true兩者位置不同
false兩者位置相同

◆ operator*()

template<class E = void*>
E & ufm::util::Iterator< E >::operator* ( ) const
inline

取得目前元素的參考(解引用運算子)。

允許使用 *it 取得目前元素。

傳回值
E& 目前元素的參考。

◆ operator++()

template<class E = void*>
Iterator & ufm::util::Iterator< E >::operator++ ( )
inline

前置遞增運算子,將迭代器移動到下一個元素。

允許使用 ++it 移動到下一個元素。

傳回值
Iterator& 參考自身。

此類別(class) 文件是由下列檔案中產生: