summaryrefslogtreecommitdiff
path: root/src/T2DLL/LComparator.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/T2DLL/LComparator.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/T2DLL/LComparator.cpp b/src/T2DLL/LComparator.cpp
new file mode 100644
index 0000000..649075d
--- /dev/null
+++ b/src/T2DLL/LComparator.cpp
@@ -0,0 +1,79 @@
+#include "LComparator.h"
+
+LComparator* LComparator::sComparator;
+
+LComparator::LComparator() {
+ sComparator = NULL;
+}
+
+/*virtual*/ LComparator::~LComparator() {
+}
+
+/*virtual*/ int LComparator::Compare(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ const unsigned char *a = (const unsigned char *) inItemOne;
+ const unsigned char *b = (const unsigned char *) inItemTwo;
+ unsigned int size = inSizeOne;
+ if (inSizeTwo < inSizeOne)
+ size = inSizeTwo;
+
+ while (size > 0) {
+ if (*a != *b)
+ return *a - *b;
+ a++;
+ b++;
+ size--;
+ }
+
+ return inSizeOne - inSizeTwo;
+}
+
+/*virtual*/ BOOL LComparator::IsEqualTo(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ return Compare(inItemOne, inItemTwo, inSizeOne, inSizeTwo) == 0;
+}
+
+/*virtual*/ int LComparator::CompareToKey(const void* inItem, unsigned int inSize, const void* inKey) const {
+#line 86
+ _ASSERT("CompareToKey not implemented");
+ return 1;
+}
+
+/*virtual*/ BOOL LComparator::IsEqualToKey(const void* inItem, unsigned int inSize, const void* inKey) const {
+ return CompareToKey(inItem, inSize, inKey) == 0;
+}
+
+LComparator* LComparator::GetComparator() {
+ if (!sComparator)
+ sComparator = new LComparator;
+ return sComparator;
+}
+
+/*virtual*/ LComparator* LComparator::Clone() {
+ return new LComparator;
+}
+
+LLongComparator* LLongComparator::sLongComparator;
+
+LLongComparator::LLongComparator() {
+ sLongComparator = NULL;
+}
+
+/*virtual*/ LLongComparator::~LLongComparator() {
+}
+
+/*virtual*/ int LLongComparator::Compare(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ return *((const long *) inItemOne) - *((const long *) inItemTwo);
+}
+
+/*virtual*/ BOOL LLongComparator::IsEqualTo(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const {
+ return *((const long *) inItemOne) == *((const long *) inItemTwo);
+}
+
+LLongComparator* LLongComparator::GetComparator() {
+ if (!sLongComparator)
+ sLongComparator = new LLongComparator;
+ return sLongComparator;
+}
+
+/*virtual*/ LComparator* LLongComparator::Clone() {
+ return new LLongComparator;
+}