فهرست منبع

Refactoring again. COMPILES

Panagiotis Christopoulos Charitos 10 سال پیش
والد
کامیت
ce0c8247ef
1فایلهای تغییر یافته به همراه48 افزوده شده و 0 حذف شده
  1. 48 0
      src/util/StringList.cpp

+ 48 - 0
src/util/StringList.cpp

@@ -0,0 +1,48 @@
+// Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "anki/util/StringList.h"
+
+namespace anki {
+
+//==============================================================================
+void StringList::sortAll(const Sort method)
+{
+	if(method == Sort::ASCENDING)
+	{
+		Base::sort([](const String& a, const String& b)
+		{
+			return a < b;
+		});
+	}
+	else
+	{
+		ANKI_ASSERT(method == Sort::DESCENDING);
+		Base::sort([](const String& a, const String& b)
+		{
+			return a < b;
+		});
+	}
+}
+
+//==============================================================================
+I StringList::getIndexOf(const CString& value) const
+{
+	U pos = 0;
+
+	for(auto it = Base::getBegin(); it != Base::getEnd(); ++it)
+	{
+		if(*it == value)
+		{
+			break;
+		}
+		++ pos;
+	}
+
+	return (pos == Base::getSize()) ? -1 : pos;
+}
+
+} // end namespace anki
+