From d07f9d0392e7a46229a8c6b72ecec37f8dab52a5 Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Tue, 7 Feb 2023 19:56:48 +0800 Subject: [PATCH] added IsEmpty and AddUnique functions at StringList. --- inc/hgl/type/StringList.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 要增加的字符串列表