GetObjectFromList改名为GetObjectFromMap
This commit is contained in:
@@ -205,7 +205,7 @@ namespace hgl
|
|||||||
virtual bool GetLast (T &data)const{return data_array.ReadAt(data,GetCount()-1);} ///<取最后一个数据
|
virtual bool GetLast (T &data)const{return data_array.ReadAt(data,GetCount()-1);} ///<取最后一个数据
|
||||||
};//template <typename T> class ArrayList
|
};//template <typename T> class ArrayList
|
||||||
|
|
||||||
template<typename T> T *GetObjectFromList(const ArrayList<T *> &list,const int index)
|
template<typename T> T *GetObjectFromMap(const ArrayList<T *> &list,const int index)
|
||||||
{
|
{
|
||||||
T *obj;
|
T *obj;
|
||||||
|
|
||||||
|
@@ -192,7 +192,7 @@ namespace hgl
|
|||||||
if(index==-1)
|
if(index==-1)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
KVData *obj=GetObjectFromList(data_list,index);
|
KVData *obj=GetObjectFromMap(data_list,index);
|
||||||
|
|
||||||
if(!obj)return(nullptr);
|
if(!obj)return(nullptr);
|
||||||
return &(obj->value);
|
return &(obj->value);
|
||||||
@@ -209,7 +209,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
int index=Find(flag);
|
int index=Find(flag);
|
||||||
|
|
||||||
KVData *obj=GetObjectFromList(data_list,index);
|
KVData *obj=GetObjectFromMap(data_list,index);
|
||||||
|
|
||||||
if(!obj)
|
if(!obj)
|
||||||
return(-1);
|
return(-1);
|
||||||
@@ -224,7 +224,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
int index=Find(key);
|
int index=Find(key);
|
||||||
|
|
||||||
KVData *obj=GetObjectFromList(data_list,index);
|
KVData *obj=GetObjectFromMap(data_list,index);
|
||||||
|
|
||||||
if(!obj)
|
if(!obj)
|
||||||
return(false);
|
return(false);
|
||||||
@@ -323,7 +323,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
int index=Find(flag);
|
int index=Find(flag);
|
||||||
|
|
||||||
KVData *dp=GetObjectFromList(data_list,index);
|
KVData *dp=GetObjectFromMap(data_list,index);
|
||||||
|
|
||||||
if(!dp)
|
if(!dp)
|
||||||
return(false);
|
return(false);
|
||||||
@@ -394,7 +394,7 @@ namespace hgl
|
|||||||
if(index<0
|
if(index<0
|
||||||
||index>=data_list.GetCount())return(false);
|
||index>=data_list.GetCount())return(false);
|
||||||
|
|
||||||
data_pool.Release(GetObjectFromList(data_list,index));
|
data_pool.Release(GetObjectFromMap(data_list,index));
|
||||||
data_list.DeleteShift(index);
|
data_list.DeleteShift(index);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@@ -433,7 +433,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(FindPos(flag,result))
|
if(FindPos(flag,result))
|
||||||
{
|
{
|
||||||
dp=GetObjectFromList(data_list,result);
|
dp=GetObjectFromMap(data_list,result);
|
||||||
|
|
||||||
if(dp)
|
if(dp)
|
||||||
{
|
{
|
||||||
@@ -469,7 +469,7 @@ namespace hgl
|
|||||||
template<typename K,typename V,typename KVData>
|
template<typename K,typename V,typename KVData>
|
||||||
bool MapTemplate<K,V,KVData>::Change(const K &flag,const V &data)
|
bool MapTemplate<K,V,KVData>::Change(const K &flag,const V &data)
|
||||||
{
|
{
|
||||||
KVData *dp=GetObjectFromList(data_list,Find(flag));
|
KVData *dp=GetObjectFromMap(data_list,Find(flag));
|
||||||
|
|
||||||
if(!dp)
|
if(!dp)
|
||||||
return(false);
|
return(false);
|
||||||
|
@@ -120,7 +120,7 @@ namespace hgl
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
KVData *GetItem(int n){return GetObjectFromList(data_list,n);} ///<取指定序号的数据
|
KVData *GetItem(int n){return GetObjectFromMap(data_list,n);} ///<取指定序号的数据
|
||||||
bool GetBySerial(int,K &,V &) const; ///<取指定序号的数据
|
bool GetBySerial(int,K &,V &) const; ///<取指定序号的数据
|
||||||
bool GetKey(int,K &); ///<取指定序号的索引
|
bool GetKey(int,K &); ///<取指定序号的索引
|
||||||
bool GetValue(int,V &); ///<取指定序号的数据
|
bool GetValue(int,V &); ///<取指定序号的数据
|
||||||
@@ -150,7 +150,7 @@ namespace hgl
|
|||||||
virtual ~Map()=default;
|
virtual ~Map()=default;
|
||||||
};//class Map
|
};//class Map
|
||||||
|
|
||||||
template<typename T_ID,typename T_U> T_U *GetObjectFromList(Map<T_ID,T_U *> &list,const T_ID &id)
|
template<typename T_ID,typename T_U> T_U *GetObjectFromMap(Map<T_ID,T_U *> &list,const T_ID &id)
|
||||||
{
|
{
|
||||||
T_U *result;
|
T_U *result;
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ namespace hgl
|
|||||||
|
|
||||||
void DeleteObject(int index)
|
void DeleteObject(int index)
|
||||||
{
|
{
|
||||||
DeleteObject(GetObjectFromList(this->data_list,index));
|
DeleteObject(GetObjectFromMap(this->data_list,index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -293,7 +293,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
DeleteObject(index);
|
DeleteObject(index);
|
||||||
|
|
||||||
KVData *dp=GetObjectFromList(this->data_list,index);
|
KVData *dp=GetObjectFromMap(this->data_list,index);
|
||||||
|
|
||||||
if(dp)
|
if(dp)
|
||||||
dp->value=data;
|
dp->value=data;
|
||||||
@@ -318,7 +318,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
DeleteObject(index);
|
DeleteObject(index);
|
||||||
|
|
||||||
KVData *dp=GetObjectFromList(this->data_list,index);
|
KVData *dp=GetObjectFromMap(this->data_list,index);
|
||||||
|
|
||||||
if(!dp)
|
if(!dp)
|
||||||
return(false);
|
return(false);
|
||||||
@@ -334,7 +334,7 @@ namespace hgl
|
|||||||
|
|
||||||
V *operator[](const K &index)const
|
V *operator[](const K &index)const
|
||||||
{
|
{
|
||||||
auto *obj=GetObjectFromList(this->data_list,this->Find(index));
|
auto *obj=GetObjectFromMap(this->data_list,this->Find(index));
|
||||||
|
|
||||||
if(obj)
|
if(obj)
|
||||||
return obj->value;
|
return obj->value;
|
||||||
|
Reference in New Issue
Block a user