#include "StdAfx.h" #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 theSize = inSizeOne; if (inSizeTwo < inSizeOne) theSize = inSizeTwo; while (theSize > 0) { if (*a != *b) return *a - *b; a++; b++; theSize--; } 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 LComparator; }