added IsEmpty and AddUnique functions at StringList.

This commit is contained in:
2023-02-07 19:56:48 +08:00
parent 64bb3f224f
commit d07f9d0392

View File

@@ -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 要增加的字符串列表