From 4104f1cb75ce707948f1239bff7c91fc6e19ec25 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 25 Apr 2025 00:20:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95IndexedList=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/type/ArrayList.h | 2 +- inc/hgl/type/IndexedList.h | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/inc/hgl/type/ArrayList.h b/inc/hgl/type/ArrayList.h index fcde68d..ced7639 100644 --- a/inc/hgl/type/ArrayList.h +++ b/inc/hgl/type/ArrayList.h @@ -91,7 +91,7 @@ namespace hgl data_array.AddCount(n); - hgl_set(data_array.data()+ec,data,n); + hgl_set(data_array.data()+ec,&data,n); return(ec); } diff --git a/inc/hgl/type/IndexedList.h b/inc/hgl/type/IndexedList.h index 668ed99..1d8bb03 100644 --- a/inc/hgl/type/IndexedList.h +++ b/inc/hgl/type/IndexedList.h @@ -2,6 +2,7 @@ #include #include +#include namespace hgl { @@ -34,6 +35,7 @@ namespace hgl data_array.Alloc(count); data_index.Alloc(count); + free_index.PreAlloc(count); return(true); } @@ -49,9 +51,6 @@ namespace hgl public: - using iterator_category = std::forward_iterator_tag; - using value_type = T; - using difference_type = std::ptrdiff_t; using pointer = T*; using reference = T&; @@ -235,9 +234,9 @@ namespace hgl * @param count 删除个数 * @return 删除成功的数据个数 */ - virtual int32 DeleteAt(int32 start,int32 count=1) + virtual int32 Delete(int32 start,int32 count=1) { - if(!IsValidIndex(start)return(-1); + if(!IsValidIndex(start))return(-1); if(count<=0)return(count); if(start+count>data_index.GetCount()) @@ -245,7 +244,7 @@ namespace hgl if(count<=0)return(0); - for(int32 i=start;i()); //查找空的位置 { @@ -334,7 +330,7 @@ namespace hgl { overflow_index.Pop(index); - hgl_cpy(data_array.At(new_location),data_array.At(data_index[index])); + hgl_cpy(data_array[new_location],data_array[data_index[index]]); data_index[index]=new_location; }