From d79e3d02193e02c8ce654cd5b41f0bda2ab3f3be Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 9 Oct 2020 21:48:20 +0800 Subject: [PATCH] support for each --- inc/hgl/type/List.h | 3 +++ inc/hgl/type/Map.h | 5 +++++ inc/hgl/type/Queue.h | 3 +++ inc/hgl/type/Sets.h | 3 +++ inc/hgl/type/StringList.h | 3 +++ 5 files changed, 17 insertions(+) diff --git a/inc/hgl/type/List.h b/inc/hgl/type/List.h index 86833ed..f9e512e 100644 --- a/inc/hgl/type/List.h +++ b/inc/hgl/type/List.h @@ -29,6 +29,9 @@ namespace hgl T * GetBegin (){return (items&&count>0)?items:nullptr;} ///<取得第一个数据项指针 T * GetEnd (){return (items&&count>0)?items+count-1:nullptr;} ///<取得最后一个数据项指针 + T * begin()const{return items;} + T * end()const{return items+count;} + public: //方法 List(){}; ///<本类构造函数 diff --git a/inc/hgl/type/Map.h b/inc/hgl/type/Map.h index 2f79cc5..a811f58 100644 --- a/inc/hgl/type/Map.h +++ b/inc/hgl/type/Map.h @@ -22,6 +22,11 @@ namespace hgl DataPairPool data_pool; DataPairList data_list; + public: + + const DataPair *begin()const{return data_list.begin();} + const DataPair *end()const{return data_list.end();} + public: //方法 _Map()=default; diff --git a/inc/hgl/type/Queue.h b/inc/hgl/type/Queue.h index c5fed65..489a0fe 100644 --- a/inc/hgl/type/Queue.h +++ b/inc/hgl/type/Queue.h @@ -30,6 +30,9 @@ namespace hgl int GetMaxCount ()const{return max_count;} ///<取得最大数量 bool SetMaxCount (int); ///<设置最大数量 + const T *begin()const{return items;} + const T *end()const{return items+cur_count;} + public: //方法 Queue(int=0); diff --git a/inc/hgl/type/Sets.h b/inc/hgl/type/Sets.h index 7b16a66..c8570f1 100644 --- a/inc/hgl/type/Sets.h +++ b/inc/hgl/type/Sets.h @@ -22,6 +22,9 @@ namespace hgl T * GetData ()const{return data_list.GetData();} ///<取得数据指针 int GetCount ()const{return data_list.GetCount();} ///<取得数据总量 + T * begin ()const{return data_list.begin();} + T * end ()const{return data_list.end();} + public: Sets()=default; diff --git a/inc/hgl/type/StringList.h b/inc/hgl/type/StringList.h index 9f5be08..f701e0f 100644 --- a/inc/hgl/type/StringList.h +++ b/inc/hgl/type/StringList.h @@ -27,6 +27,9 @@ namespace hgl T **GetDataList()const{return Items.GetData();} ///<取得字符串列表指针数据 const int GetCount()const{return Items.GetCount();} ///<字符串列表行数虚拟变量 + T **begin() const{return Items.GetData();} + T **end() const{return Items.GetData()+Items.GetCount();} + public: //操作符重载 T &operator[](int n)const