diff options
Diffstat (limited to 'core/fxcrt/fx_basic.h')
-rw-r--r-- | core/fxcrt/fx_basic.h | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index a4069fddbd..ee630e100d 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -378,130 +378,6 @@ class CFX_AutoRestorer { const T m_OldValue; }; -#define FX_DATALIST_LENGTH 1024 -template <size_t unit> -class CFX_SortListArray { - protected: - struct DataList { - int32_t start; - - int32_t count; - uint8_t* data; - }; - - public: - CFX_SortListArray() : m_CurList(0) {} - - ~CFX_SortListArray() { Clear(); } - - void Clear() { - for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) { - DataList list = m_DataLists.ElementAt(i); - FX_Free(list.data); - } - m_DataLists.RemoveAll(); - m_CurList = 0; - } - - void Append(int32_t nStart, int32_t nCount) { - if (nStart < 0) { - return; - } - while (nCount > 0) { - int32_t temp_count = std::min(nCount, FX_DATALIST_LENGTH); - DataList list; - list.data = FX_Alloc2D(uint8_t, temp_count, unit); - list.start = nStart; - list.count = temp_count; - Append(list); - nCount -= temp_count; - nStart += temp_count; - } - } - - uint8_t* GetAt(int32_t nIndex) { - if (nIndex < 0) { - return nullptr; - } - if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) { - return nullptr; - } - DataList* pCurList = m_DataLists.GetDataPtr(m_CurList); - if (!pCurList || nIndex < pCurList->start || - nIndex >= pCurList->start + pCurList->count) { - pCurList = nullptr; - int32_t iStart = 0; - int32_t iEnd = m_DataLists.GetUpperBound(); - int32_t iMid = 0; - while (iStart <= iEnd) { - iMid = (iStart + iEnd) / 2; - DataList* list = m_DataLists.GetDataPtr(iMid); - if (nIndex < list->start) { - iEnd = iMid - 1; - } else if (nIndex >= list->start + list->count) { - iStart = iMid + 1; - } else { - pCurList = list; - m_CurList = iMid; - break; - } - } - } - return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit - : nullptr; - } - - protected: - void Append(const DataList& list) { - int32_t iStart = 0; - int32_t iEnd = m_DataLists.GetUpperBound(); - int32_t iFind = 0; - while (iStart <= iEnd) { - int32_t iMid = (iStart + iEnd) / 2; - DataList* cur_list = m_DataLists.GetDataPtr(iMid); - if (list.start < cur_list->start + cur_list->count) { - iEnd = iMid - 1; - } else { - if (iMid == iEnd) { - iFind = iMid + 1; - break; - } - DataList* next_list = m_DataLists.GetDataPtr(iMid + 1); - if (list.start < next_list->start) { - iFind = iMid + 1; - break; - } else { - iStart = iMid + 1; - } - } - } - m_DataLists.InsertAt(iFind, list); - } - int32_t m_CurList; - CFX_ArrayTemplate<DataList> m_DataLists; -}; -template <typename T1, typename T2> -class CFX_ListArrayTemplate { - public: - void Clear() { m_Data.Clear(); } - - void Add(int32_t nStart, int32_t nCount) { m_Data.Append(nStart, nCount); } - - T2& operator[](int32_t nIndex) { - uint8_t* data = m_Data.GetAt(nIndex); - ASSERT(data); - return (T2&)(*(volatile T2*)data); - } - - T2* GetPtrAt(int32_t nIndex) { return (T2*)m_Data.GetAt(nIndex); } - - protected: - T1 m_Data; -}; -typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, - FX_FILESIZE> - CFX_FileSizeListArray; - class CFX_Vector_3by1 { public: CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {} |