![]() |
mFrame
|
索引化有效載荷記憶體區域管理器 更多...
#include <IndexedPayloadArena.h>
複合項目 | |
| struct | Handle |
| 資料塊控制結構 更多... | |
公開方法(Public Methods) | |
| IndexedPayloadArena (ufm::lang::Memory memory) | |
| 建構索引化有效載荷記憶體區域管理器 | |
| virtual | ~IndexedPayloadArena (void) override |
| 析構函數,釋放資源 | |
| virtual void | clear (void) override |
| 從此集合中刪除所有元素(可選操作) | |
| virtual bool | isEmpty (void) const override |
| 檢查此集合是否不包含任何元素 | |
| virtual int | size (void) const override |
| 返回此集合中的元素數量 | |
| template<typename T , size_t N> | |
| bool | insert (T(&array)[N], int index) |
| 在指定索引位置插入陣列資料 | |
| bool | insert (const void *data, int length, int index) |
| 在指定索引位置插入資料 | |
| bool | remove (int index) |
| 移除指定索引的資料塊 | |
| int | get (void *&data, int index) const |
| 獲取指定索引的資料 | |
| template<typename T > | |
| int | get (T *&data, int index) const |
| 獲取指定索引的資料,並轉換為指定型別指標 | |
| template<typename T , size_t N> | |
| bool | set (T(&array)[N], int index) |
| 設定指定索引位置的陣列資料 | |
| bool | set (const void *data, int length, int index) |
| 設定指定索引位置的資料 | |
| int | availableGap (void) const |
| 獲取可用的記憶體間隙大小 | |
| int | compact (void) |
| 壓縮記憶體,整理碎片空間 | |
公開方法(Public Methods) 繼承自 ufm::lang::Object | |
| void * | operator new (size_t n) |
| 使用運算子 new 分配記憶體 | |
| void * | operator new (size_t n, void *p) |
| 在指定記憶體上調用運算子 new | |
| virtual ufm::lang::Object & | getObject (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::Thread * | currentThread (void) const |
| 取得當前執行緒指標 | |
| virtual int | hashcode (void) const |
| 返回對象的哈希碼值。支持這種方法是為了散列表,如HashMap提供的那樣。 | |
公開方法(Public Methods) 繼承自 ufm::lang::Interface | |
| virtual | ~Interface (void)=default |
| 虛擬析構函式 | |
靜態公開屬性 | |
| static constexpr uint16 | ELEMENT_SHIFT = 3 |
| 元素對齊位移量(8位元組對齊) | |
| static constexpr uint16 | ELEMENT_MASK = ((1 << ELEMENT_SHIFT) - 1) |
| 元素對齊遮罩 | |
索引化有效載荷記憶體區域管理器
此類別提供一個可索引的記憶體區域管理系統,允許在指定記憶體區域中插入、刪除、 獲取和修改任意大小的資料塊。每個資料塊都有對應的索引,支援隨機存取。 內部使用Handle結構來追蹤每個資料塊的位置和大小資訊。
| ufm::util::IndexedPayloadArena::IndexedPayloadArena | ( | ufm::lang::Memory | memory | ) |
建構索引化有效載荷記憶體區域管理器
| memory | 要管理的記憶體區域 |
| int ufm::util::IndexedPayloadArena::availableGap | ( | void | ) | const |
獲取可用的記憶體間隙大小
|
overridevirtual |
從此集合中刪除所有元素(可選操作)
此方法執行後,集合將變為空狀態。請注意,某些容器實作可能不支援此操作。
| 如果容器不支援清空操作,實作類別可能會拋出例外 |
| int ufm::util::IndexedPayloadArena::compact | ( | void | ) |
壓縮記憶體,整理碎片空間
將所有有效的資料塊向前移動,釋放碎片化的空間, 提高記憶體使用效率。
|
inline |
獲取指定索引的資料,並轉換為指定型別指標
此方法會將獲取的資料指標轉換為指定型別的指標,方便直接使用。
| T | 資料型別 |
| data | 輸出參數,指向資料的型別指標 |
| index | 資料的索引 |
| int ufm::util::IndexedPayloadArena::get | ( | void *& | data, |
| int | index ) const |
獲取指定索引的資料
| data | 輸出參數,指向資料的指標 |
| index | 資料的索引 |
| bool ufm::util::IndexedPayloadArena::insert | ( | const void * | data, |
| int | length, | ||
| int | index ) |
在指定索引位置插入資料
| data | 要插入的資料指標 |
| length | 資料長度(位元組) |
| index | 插入的索引位置 |
|
inline |
在指定索引位置插入陣列資料
| T | 陣列元素型別 |
| N | 陣列大小 |
| array | 要插入的陣列 |
| index | 插入的索引位置 |
|
overridevirtual |
| bool ufm::util::IndexedPayloadArena::remove | ( | int | index | ) |
移除指定索引的資料塊
| index | 要移除的索引 |
| bool ufm::util::IndexedPayloadArena::set | ( | const void * | data, |
| int | length, | ||
| int | index ) |
設定指定索引位置的資料
| data | 要設定的資料指標 |
| length | 資料長度(位元組) |
| index | 設定的索引位置 |
|
inline |
設定指定索引位置的陣列資料
| T | 陣列元素型別 |
| N | 陣列大小 |
| array | 要設定的陣列 |
| index | 設定的索引位置 |
|
overridevirtual |
返回此集合中的元素數量
如果此集合包含超過 INT_MAX 個元素,則返回 INT_MAX。