From 0ba4eb4919be99855a2f443dd313b1b3b7daff51 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 25 Apr 2025 01:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0IndexedListTest.cpp=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=85=B6=E8=BF=AD=E4=BB=A3=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + datatype/collection/IndexedListTest.cpp | 71 +++++++++++++++++++++++++ datatype/collection/LinkedListTest.cpp | 12 ----- 3 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 datatype/collection/IndexedListTest.cpp delete mode 100644 datatype/collection/LinkedListTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e403ca..ad9e101 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ cm_example_project("DataType/Collection" StackTest datatype/collection/Sta cm_example_project("DataType/Collection" QueueTest datatype/collection/QueueTest.cpp) cm_example_project("DataType/Collection" PoolTest datatype/collection/PoolTest.cpp) cm_example_project("DataType/Collection" ListTest datatype/collection/ListTest.cpp) +cm_example_project("DataType/Collection" IndexedListTest datatype/collection/IndexedListTest.cpp) cm_example_project("DataType/Collection" MapTest datatype/collection/MapTest.cpp) cm_example_project("DataType/Collection" MultiMapTest datatype/collection/MultiMapTest.cpp) cm_example_project("DataType/Collection" StackPoolTest datatype/collection/StackPoolTest.cpp) diff --git a/datatype/collection/IndexedListTest.cpp b/datatype/collection/IndexedListTest.cpp new file mode 100644 index 0000000..e8444a5 --- /dev/null +++ b/datatype/collection/IndexedListTest.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +using namespace hgl; + +template +void out_list(const char *type,const DataArray &da) +{ + const T *p=da.GetData(); + + std::cout<0) + std::cout<<","; + + std::cout<<*p; + + ++p; + } + + std::cout<<"]"; +} + +void out_list(const char *info,const IndexedList &il) +{ + const int32 count=il.GetCount(); + + std::cout< il; + + for(int i=0;i<10;i++) + il.Add(generator()%100); + + out_list("origin",il); + + for(int i=0;i<5;i++) + { + int pos=generator()%il.GetCount(); + + std::cout<<"Delete "< - struct DataPair - { - KEY key; - VALUE value; - }; - -template -class UnorderedMap -{ - ObjectList> data_list; -}; \ No newline at end of file