diff --git a/inc/hgl/type/StringList.h b/inc/hgl/type/StringList.h index ad0dc28..8724b98 100644 --- a/inc/hgl/type/StringList.h +++ b/inc/hgl/type/StringList.h @@ -29,6 +29,8 @@ namespace hgl StringClass ** begin ()const{return Items.GetData();} StringClass ** end ()const{return Items.GetData()+Items.GetCount();} + const bool IsEmpty ()const { return Items.IsEmpty(); } ///<字符串列表是否为空 + public: //操作符重载 StringClass &operator[](int n)const @@ -79,6 +81,19 @@ namespace hgl */ int Add(const StringClass &str){return Items.Add(new StringClass(str));} ///<添加字符串 + /** + * 增加一行字符串到当前列表中,同时做重复判断,重复则不添加 + */ + int AddUnique(const StringClass &str) + { + int pos=Find(str); + + if(pos!=-1) + return pos; + + return Items.Add(new StringClass(str)); + } + /** * 增加一个字符串列表到当前字符串列表中 * @param sl 要增加的字符串列表