diff --git a/CMakeLists.txt b/CMakeLists.txt index 729ce5c..6e403ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ cm_example_project("DataType/Collection" DataArrayTest datatype/collection/Dat cm_example_project("DataType/Collection" StackTest datatype/collection/StackTest.cpp) 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" 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/ListTest.cpp b/datatype/collection/ListTest.cpp new file mode 100644 index 0000000..78190f6 --- /dev/null +++ b/datatype/collection/ListTest.cpp @@ -0,0 +1,163 @@ +#include +#include +#include +#include +#include +#include + +using namespace hgl; + +constexpr const uint MAX_LIST_COUNT=1000000; +constexpr const uint DELETE_COUNT=MAX_LIST_COUNT/10; + +template +void out_list(const T &list) +{ + std::cout<<"List("<0) + std::cout<<","; + + std::cout< +void TestListType(bool pre_alloc) +{ + double start,end; + + std::random_device device; + std::mt19937 generator(device()); + + ArrayList al; + IndexedList il; + + double ar,ir; + + if(pre_alloc) + { + al.PreAlloc(MAX_LIST_COUNT); + il.PreAlloc(MAX_LIST_COUNT); + } + + AutoDeleteArray origin_data(MAX_LIST_COUNT); + AutoDeleteArray delete_index(DELETE_COUNT); + + std::cout<<"Type: "<(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); + TestListType(pre_alloc); +} + +int main(int,char **argv) +{ + std::cout<<"No pre-alloc"<