#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; }