summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2NameComparator.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2NameComparator.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/T2DLL/T2NameComparator.cpp b/src/T2DLL/T2NameComparator.cpp
new file mode 100644
index 0000000..e2b1a70
--- /dev/null
+++ b/src/T2DLL/T2NameComparator.cpp
@@ -0,0 +1,30 @@
+#include "T2Name.h"
+#include "T2NameComparator.h"
+
+/*virtual*/ int T2NameComparator::Compare(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ T2Name *a = *((T2Name **) inItemOne);
+ T2Name *b = *((T2Name **) inItemTwo);
+
+ if (!b)
+ return -1;
+ else if (!a)
+ return 1;
+
+ return (a->IsFavorite() != b->IsFavorite()) ? (a->IsFavorite() - b->IsFavorite())
+ : (a->GetType() != b->GetType()) ? (a->GetType() - b->GetType())
+ : (a->GetID() - b->GetID());
+}
+
+/*virtual*/ BOOL T2NameComparator::IsEqualTo(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ T2Name *a = *((T2Name **) inItemOne);
+ T2Name *b = *((T2Name **) inItemTwo);
+ return (a->IsFavorite() == b->IsFavorite()) && (a->GetType() == b->GetType()) && (a->GetID() == b->GetID());
+}
+
+/*static*/ T2NameComparator* T2NameComparator::sT2NameComparator;
+
+/*static*/ T2NameComparator* T2NameComparator::GetComparator() {
+ if (!sT2NameComparator)
+ sT2NameComparator = new T2NameComparator;
+ return sT2NameComparator;
+}