mFrame
載入中...
搜尋中...
無符合項目
Iterable.h
1
7#ifndef MFRAME_11DE2BBA_4823_4E3F_884E_9A333C00AD9F
8#define MFRAME_11DE2BBA_4823_4E3F_884E_9A333C00AD9F
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../func/Consumer.h"
16#include "./../lang/Interface.h"
17
18//----------------------------------------------------------------------------------------
19
20/* ***************************************************************************************
21 * Namespace
22 */
23namespace ufm::lang {
24 template <typename E>
25 struct Iterable;
26} // namespace ufm::lang
27
28namespace ufm::util {
29 template <typename E>
30 class Iterator;
31} // namespace ufm::util
32
33/* ***************************************************************************************
34 * Class/Interface/Struct/Enum
35 */
36
48template <typename E = void*>
50 /* *************************************************************************************
51 * Method
52 */
53
62 virtual void forEach(ufm::func::Consumer<E&>& action) abstract;
63
70 virtual E* elementAt(int index) const abstract;
71
80 virtual int nextIndex(int index) const abstract;
81
87 virtual ufm::util::Iterator<E> begin(void) abstract;
88
94 virtual ufm::util::Iterator<E> end(void) abstract;
95};
96
97/* ***************************************************************************************
98 * End of file
99 */
100
101#endif /* MFRAME_11DE2BBA_4823_4E3F_884E_9A333C00AD9F */
[Class] 迭代器介面
Definition Iterator.h:42
Definition Appendable.h:23
Definition Iterable.h:28
[Interface] 消費者函數式介面模板
Definition Consumer.h:43
[Interface] 定義可迭代集合介面
Definition Iterable.h:49
virtual E * elementAt(int index) const override
獲取集合中指定索引處的元素。
virtual ufm::util::Iterator< E > begin(void) override
返回一個迭代器,用於遍歷集合中的元素
virtual int nextIndex(int index) const override
返回當前索引的下一個有效索引。
virtual ufm::util::Iterator< E > end(void) override
返回一個迭代器,用於遍歷集合的結尾
virtual void forEach(ufm::func::Consumer< E & > &action) override
遍歷集合中所有元素,對每個元素執行指定操作。 若所有元素處理完畢或操作中發生異常則停止。