mFrame
載入中...
搜尋中...
無符合項目
PArraySet.h
1
7#ifndef MFRAME_24343078_A5C5_46DB_9823_EC2385331C5D
8#define MFRAME_24343078_A5C5_46DB_9823_EC2385331C5D
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../lang/Memory.h"
16#include "./../util/PArray.h"
17#include "./../util/Set.h"
18
19//----------------------------------------------------------------------------------------
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace ufm::util {
25 class PArraySet;
26} // namespace ufm::util
27
28/* ***************************************************************************************
29 * Class/Interface/Struct/Enum
30 */
31
41 /* *************************************************************************************
42 * Variable
43 */
44 private:
45 ufm::lang::Memory vMemory;
46
47 public:
48 int const vLength;
49
50 /* *************************************************************************************
51 * Abstract Method
52 */
53
54 /* *************************************************************************************
55 * Construct Method
56 */
57 public:
65 PArraySet(ufm::lang::Memory memory) noexcept;
66
74 inline PArraySet(int length)
75 : PArraySet(ufm::lang::Memory(length * static_cast<int>(sizeof(void*)))) {
76 return;
77 }
78
86 PArraySet(PArraySet& other) noexcept = default;
87
95 PArraySet(PArraySet&& other) noexcept = default;
96
101 virtual ~PArraySet(void) override;
102
103 /* *************************************************************************************
104 * Operator Method
105 */
106 public:
113 template <typename E>
114 inline operator const Set<E>&(void) const {
115 const Set<>* src = this;
116 return *reinterpret_cast<const Set<E>*>(src);
117 }
118
125 template <typename E>
126 inline operator Set<E>&(void) {
127 Set<>* src = this;
128 return *reinterpret_cast<Set<E>*>(src);
129 }
130
131 /* *************************************************************************************
132 * Override - ufm::util::Set<>
133 */
134 public:
142 virtual bool add(void* v) override;
143
151 virtual bool remove(void* v) override;
152
164 virtual bool replace(void* oldValue, void* newValue) override;
165
173 virtual bool contains(void* v) const override;
174
175 /* *************************************************************************************
176 * Override - ufm::util::Container
177 */
178 public:
184 virtual void clear(void) override;
185
192 virtual bool isEmpty(void) const override;
193
200 virtual int size(void) const override;
201
202 /* *************************************************************************************
203 * Override - ufm::lang::Iterable<>
204 */
205 public:
213 virtual void forEach(ufm::func::Consumer<void*&>& action) override;
214
221 virtual void** elementAt(int index) const override;
222
231 virtual int nextIndex(int index) const override;
232
238 virtual ufm::util::Iterator<void*> begin(void) override;
239
245 virtual ufm::util::Iterator<void*> end(void) override;
246
247 /* *************************************************************************************
248 * Public Method
249 */
250
251 /* *************************************************************************************
252 * Protected Method
253 */
254
255 /* *************************************************************************************
256 * Private Method
257 */
258
259 /* *************************************************************************************
260 * Static Variable
261 */
262
263 /* *************************************************************************************
264 * Static Method
265 */
266};
267
268#endif /* MFRAME_24343078_A5C5_46DB_9823_EC2385331C5D */
存儲資料的類別,提供動態記憶體管理功能。
Definition Memory.h:44
物件基底類別
Definition Object.h:63
[Class] 迭代器介面
Definition Iterator.h:42
PArraySet 類別
Definition PArraySet.h:40
virtual ~PArraySet(void) override
Destroy the object.
PArraySet(ufm::lang::Memory memory) noexcept
Construct a new PArraySet object with specified memory.
virtual void ** elementAt(int index) const override
獲取集合中指定索引處的元素。
virtual bool replace(void *oldValue, void *newValue) override
替換此集合中的指定元素。
virtual void clear(void) override
清除集合中的所有元素
PArraySet(int length)
Construct a new PArraySet object with specified length.
Definition PArraySet.h:74
virtual bool contains(void *v) const override
檢查集合是否包含指定元素
virtual int nextIndex(int index) const override
返回當前索引的下一個有效索引。
virtual int size(void) const override
返回集合中的元素數量
virtual bool isEmpty(void) const override
檢查集合是否為空
virtual bool add(void *v) override
將元素添加到集合中
virtual ufm::util::Iterator< void * > end(void) override
返回一個迭代器,用於遍歷集合的結尾
PArraySet(PArraySet &other) noexcept=default
Construct a new PArraySet object with existing PArraySet.
virtual ufm::util::Iterator< void * > begin(void) override
返回一個迭代器,用於遍歷集合中的元素
virtual bool remove(void *v) override
從集合中移除指定元素
int const vLength
陣列長度
Definition PArraySet.h:48
virtual void forEach(ufm::func::Consumer< void *& > &action) override
遍歷集合中的所有元素,對每個元素執行指定操作
PArraySet(PArraySet &&other) noexcept=default
Construct a new PArraySet object with existing memory.
Definition Iterable.h:28
[Interface] 消費者函數式介面模板
Definition Consumer.h:43
[Interface] 集合介面
Definition Set.h:44