List模板改名为ArrayList

This commit is contained in:
hyzboy 2025-04-23 00:21:59 +08:00
parent cf494b4f86
commit a7b0cb6112
18 changed files with 55 additions and 53 deletions

View File

@ -77,7 +77,7 @@ namespace hgl
}
};
using VolumeInfoList=List<VolumeInfo>;
using VolumeInfoList=ArrayList<VolumeInfo>;
/**
*

View File

@ -111,7 +111,7 @@ namespace hgl
bool GetFileInfo(const os_char *filename,struct FileInfo &); ///<取得文件信息
int GetFileInfoList(List<FileInfo> &, const OSString &folder_name, bool proc_folder, bool proc_file, bool sub_folder);
int GetFileInfoList(ArrayList<FileInfo> &, const OSString &folder_name, bool proc_folder, bool proc_file, bool sub_folder);
}//namespace filesystem
}//namespace hgl
#endif//HGL_FILE_SYSTEM_INCLUDE

View File

@ -50,7 +50,7 @@ namespace hgl
}
};
using FontInfoList=List<FontInfo>;
using FontInfoList=ArrayList<FontInfo>;
void EnumOSFonts(FontInfoList *);
}//namespace hgl

View File

@ -15,7 +15,7 @@ namespace hgl
{
protected:
List<T *> data_list[2];
ArrayList<T *> data_list[2];
int post_index,recv_index;
int recv_offset;

View File

@ -64,7 +64,7 @@ namespace hgl
operator S<T> &(){return proc_list;}
};//template<typename T> class SwapColl
template<typename T> using SwapList=SwapColl<T,List>; ///<安全交换列表
template<typename T> using SwapList=SwapColl<T,ArrayList>; ///<安全交换列表
template<typename T> using SwapSet=SwapColl<T,Set>; ///<安全交换集合
/**
@ -150,7 +150,7 @@ namespace hgl
operator S<T> &(){return proc_list;}
};//template<typename T> class SemSwapColl
template<typename T> using SemSwapList=SemSwapColl<T,List>; ///<安全信号交换列表
template<typename T> using SemSwapList=SemSwapColl<T,ArrayList>; ///<安全信号交换列表
template<typename T> using SemSwapSet=SemSwapColl<T,Set>; ///<安全信号交换集合
}//namespace hgl
#endif//HGL_THREAD_SWAP_LIST_INCLUDE

View File

@ -54,7 +54,7 @@ namespace hgl
{
public:
using WorkList=List<W *>;
using WorkList=ArrayList<W *>;
private:
@ -214,7 +214,7 @@ namespace hgl
{
protected:
using WorkList=List<W *>;
using WorkList=ArrayList<W *>;
WorkProc<W> *work_proc;

View File

@ -21,7 +21,7 @@ namespace hgl
private:
List<Block> block_list; ///<数据块列表
ArrayList<Block> block_list; ///<数据块列表
DataArray<char> data_array; ///<数据
public:

View File

@ -72,7 +72,7 @@ namespace hgl
SortedSet<ConstStringView<SC>> str_set; ///<字符串集合
List<ConstStringView<SC>> str_list; ///<字符串列表
ArrayList<ConstStringView<SC>> str_list; ///<字符串列表
Map<int,size_t> str_offset_map; ///<字符串映射
public:
@ -83,7 +83,7 @@ namespace hgl
const DataArray<SC> &GetStringData()const{return str_data;} ///<取得字符串数据
const List<ConstStringView<SC>> &GetConstStringList()const{return str_list;} ///<取得字符串列表
const ArrayList<ConstStringView<SC>> &GetConstStringList()const{return str_list;} ///<取得字符串列表
public:

View File

@ -19,7 +19,7 @@ namespace hgl
{
using GS=GradientStop<P,T>;
List<GS> stop_list;
ArrayList<GS> stop_list;
bool dirty;

View File

@ -7,9 +7,11 @@
namespace hgl
{
/**
* List类用于保存数据列表访
* ArrayList类用于保存数据列表访<br>
* ArrayList使用真实的数组保存数据访<br>
* 使使IndexedList.
*/
template<typename T> class List ///列表处理类
template<typename T> class ArrayList ///阵列列表处理类
{
protected:
@ -41,12 +43,12 @@ namespace hgl
public: //方法
List()=default; ///<本类构造函数
List(const T *lt,const int n){Add(lt,n);} ///<本类构造函数
List(const List<T> &lt){operator=(lt);} ///<本类构造函数
List(const std::initializer_list<T> &lt){operator=(lt);}
ArrayList()=default; ///<本类构造函数
ArrayList(const T *lt,const int n){Add(lt,n);} ///<本类构造函数
ArrayList(const ArrayList<T> &lt){operator=(lt);} ///<本类构造函数
ArrayList(const std::initializer_list<T> &lt){operator=(lt);}
virtual ~List(){Free();} ///<本类析构函数
virtual ~ArrayList(){Free();} ///<本类析构函数
/**
*
@ -114,7 +116,7 @@ namespace hgl
return(ec);
}
int Add(const List<T> &l){return Add(l.items,l.count);} ///<增加一批数据
int Add(const ArrayList<T> &l){return Add(l.items,l.count);} ///<增加一批数据
virtual void Free(){data_array.Free();} ///<清除所有数据,并释放内存
virtual void Clear(){data_array.Clear();} ///<清除所有数据,但不清空缓冲区
@ -201,9 +203,9 @@ namespace hgl
virtual bool GetFirst (T &data)const{return data_array.ReadAt(data,0);} ///<取第一个数据
virtual bool GetLast (T &data)const{return data_array.ReadAt(data,GetCount()-1);} ///<取最后一个数据
};//template <typename T> class List
};//template <typename T> class ArrayList
template<typename T> T *GetObjectFromList(const List<T *> &list,const int index)
template<typename T> T *GetObjectFromList(const ArrayList<T *> &list,const int index)
{
T *obj;
@ -213,5 +215,5 @@ namespace hgl
return(nullptr);
}
using CharPointerList=hgl::List<const char *>;
using CharPointerList=hgl::ArrayList<const char *>;
}//namespace hgl

View File

@ -605,7 +605,7 @@ namespace hgl
* in_list中出现的数据with_list
*/
template<typename K,typename V,typename KVData>
void MapTemplate<K,V,KVData>::WithList(MapTemplate<K,V,KVData>::KVDataList &with_list,const List<K> &in_list)
void MapTemplate<K,V,KVData>::WithList(MapTemplate<K,V,KVData>::KVDataList &with_list,const ArrayList<K> &in_list)
{
with_list.Clear();
const int count=this->GetCount();
@ -629,7 +629,7 @@ namespace hgl
* in_list中的数据without_list
*/
template<typename K,typename V,typename KVData>
void MapTemplate<K,V,KVData>::WithoutList(MapTemplate<K,V,KVData>::KVDataList &without_list,const List<K> &in_list)
void MapTemplate<K,V,KVData>::WithoutList(MapTemplate<K,V,KVData>::KVDataList &without_list,const ArrayList<K> &in_list)
{
without_list.Clear();
const int count=this->GetCount();

View File

@ -18,7 +18,7 @@ namespace hgl
using ThisClass=MapTemplate<K,V,KVData>;
using KVDataPool=ObjectPool<KVData>;
using KVDataList=List<KVData *>;
using KVDataList=ArrayList<KVData *>;
KVDataPool data_pool;
KVDataList data_list;
@ -134,8 +134,8 @@ namespace hgl
void EnumAllValue(void (*enum_func)(V &)); ///<枚举所有数值
void EnumValue(bool (*enum_func)(V &)); ///<枚举所有数值(返回true/false表示是否继续)
void WithList(KVDataList &with_list,const List<K> &in_list); ///<统计出所有在in_list中出现的数据产生的结果写入with_list
void WithoutList(KVDataList &without_list,const List<K> &in_list); ///<统计出所有没有出现在in_list中的数据产生的结果写入without_list
void WithList(KVDataList &with_list,const ArrayList<K> &in_list); ///<统计出所有在in_list中出现的数据产生的结果写入with_list
void WithoutList(KVDataList &without_list,const ArrayList<K> &in_list); ///<统计出所有没有出现在in_list中的数据产生的结果写入without_list
};//class MapTemplate
template<typename K,typename V> class Map:public MapTemplate<K,V,KeyValue<K,V> >

View File

@ -8,7 +8,7 @@ namespace hgl
/**
* delete
*/
template<typename T> class ObjectListTemplate:public List<T *> ///对象列表处理类
template<typename T> class ObjectListTemplate:public ArrayList<T *> ///对象列表处理类
{
protected:
@ -20,7 +20,7 @@ namespace hgl
public: //方法
ObjectListTemplate(ObjectLifecycleManager<T> *_dlm):List<T *>(){dlm=_dlm;}
ObjectListTemplate(ObjectLifecycleManager<T> *_dlm):ArrayList<T *>(){dlm=_dlm;}
virtual ~ObjectListTemplate(){Free();}
public:
@ -30,39 +30,39 @@ namespace hgl
*/
bool Insert(int index,const ItemPointer &obj) override
{
return List<T *>::Insert(index,obj);
return ArrayList<T *>::Insert(index,obj);
}
virtual void Free() override ///<清除所有数据
{
Clear();
List<T *>::Free();
ArrayList<T *>::Free();
}
virtual void Clear() override ///<清除所有数据,但不清空缓冲区
{
dlm->Clear(this->data_array.GetData(),this->data_array.GetCount());
List<T *>::Clear();
ArrayList<T *>::Clear();
}
virtual bool Contains(const ItemPointer &flag)const override ///<确认数据项是否存在
{
return List<T *>::Find((T *)flag)!=-1;
return ArrayList<T *>::Find((T *)flag)!=-1;
}
virtual bool Unlink(int index){return List<T *>::Delete(index);} ///<将指定索引处的数据与列表断开
virtual bool UnlinkMove(int index){return List<T *>::DeleteShift(index);} ///<将指定索引处的数据与列表断开,将前移后面的数据
virtual bool Unlink(int start,int number){return List<T *>::Delete(start,number);} ///<将指定索引处的数据与列表断开
virtual bool UnlinkByValue(ItemPointer &ip){return List<T *>::DeleteByValue(ip);} ///<将一个指定数据与列表断开
virtual void UnlinkByValue(ItemPointer *ip,int n){List<T *>::DeleteByValue(ip,n);} ///<将一批指定数据与列表断开
virtual void UnlinkAll(){List<T *>::Clear();} ///<断开所有数据
virtual bool Unlink(int index){return ArrayList<T *>::Delete(index);} ///<将指定索引处的数据与列表断开
virtual bool UnlinkMove(int index){return ArrayList<T *>::DeleteShift(index);} ///<将指定索引处的数据与列表断开,将前移后面的数据
virtual bool Unlink(int start,int number){return ArrayList<T *>::Delete(start,number);} ///<将指定索引处的数据与列表断开
virtual bool UnlinkByValue(ItemPointer &ip){return ArrayList<T *>::DeleteByValue(ip);} ///<将一个指定数据与列表断开
virtual void UnlinkByValue(ItemPointer *ip,int n){ArrayList<T *>::DeleteByValue(ip,n);} ///<将一批指定数据与列表断开
virtual void UnlinkAll(){ArrayList<T *>::Clear();} ///<断开所有数据
private:
bool _Delete(int index,int num)
{
if(index<0||num<=0||index+num>=List<T *>::GetCount())
if(index<0||num<=0||index+num>=ArrayList<T *>::GetCount())
return(false);
dlm->Clear(this->data_array.GetData()+index,num);
@ -85,7 +85,7 @@ namespace hgl
if(!_Delete(index,num))
return(false);
return List<T *>::Delete(index,num);
return ArrayList<T *>::Delete(index,num);
}
/**
@ -101,7 +101,7 @@ namespace hgl
if(!_Delete(index,num))
return(false);
return List<T *>::DeleteShift(index,num);
return ArrayList<T *>::DeleteShift(index,num);
}
virtual bool DeleteByValue(ItemPointer &obj) override ///<删除指定的一个数据
@ -110,7 +110,7 @@ namespace hgl
delete obj;
return List<T *>::DeleteByValue(obj);
return ArrayList<T *>::DeleteByValue(obj);
}
virtual int DeleteByValue(ItemPointer *obj_list,int num) override ///<删除指定的一批数据
@ -119,7 +119,7 @@ namespace hgl
dlm->Clear(obj_list,num);
return List<T *>::DeleteByValue(obj_list,num);
return ArrayList<T *>::DeleteByValue(obj_list,num);
}
virtual T *operator[](int n)const ///<操作符重载取得指定索引处的数据

View File

@ -211,6 +211,6 @@ namespace hgl
virtual ~PoolWithDLM()=default;
};//template<typename T,typename AT,typename IT,typename DLM> class PoolWithDLM:public PoolTemplate<T,AT,IT>
template<typename T> using Pool =PoolWithDLM<T, List<T>, Queue<T>, DataLifecycleManager<T>>; ///<数据池模板
template<typename T> using ObjectPool =PoolWithDLM<T *, List<T *>, ObjectQueue<T>, ObjectLifecycleManager<T>>; ///<对象池
template<typename T> using Pool =PoolWithDLM<T, ArrayList<T>, Queue<T>, DataLifecycleManager<T>>; ///<数据池模板
template<typename T> using ObjectPool =PoolWithDLM<T *, ArrayList<T *>, ObjectQueue<T>, ObjectLifecycleManager<T>>; ///<对象池
}//namespace hgl

View File

@ -276,7 +276,7 @@ namespace hgl
void Insert(int index,const StringClass &str) ///<在指定位置插入一个字符串
{
if(index<Items.GetCount())
Items.List<StringClass *>::Insert(index,new StringClass(str));
Items.ArrayList<StringClass *>::Insert(index,new StringClass(str));
}
/**

View File

@ -10,11 +10,11 @@ namespace hgl
{
protected:
List<FileInfo> *fi_list;
ArrayList<FileInfo> *fi_list;
public:
OnlyFileEnum(List<FileInfo> *lfi)
OnlyFileEnum(ArrayList<FileInfo> *lfi)
{
fi_list=lfi;
}
@ -26,7 +26,7 @@ namespace hgl
};//class OnlyFileEnum:public EnumFile
}//namespace
int GetFileInfoList(List<FileInfo> &fi_list,const OSString &folder_name,bool proc_folder,bool proc_file,bool sub_folder)
int GetFileInfoList(ArrayList<FileInfo> &fi_list,const OSString &folder_name,bool proc_folder,bool proc_file,bool sub_folder)
{
EnumFileConfig efc(folder_name);

View File

@ -9,7 +9,7 @@ namespace hgl
{
namespace logger
{
RWLockObject<List<Logger *>> log_list; //记录器列表
RWLockObject<ArrayList<Logger *>> log_list; //记录器列表
bool AddLogger(Logger *log)
{

View File

@ -17,7 +17,7 @@ namespace hgl
SC id_str[16];
const SC gap_str[4]={SC(' '),SC(':'),SC(' '),0};
const List<ConstStringView<SC>> &csv_list=css->GetConstStringList();
const ArrayList<ConstStringView<SC>> &csv_list=css->GetConstStringList();
for(auto &csv:csv_list)
{