diff --git a/headers/private/shared/ObjectList.h b/headers/private/shared/ObjectList.h index def0465790..6fc9f16cf3 100644 --- a/headers/private/shared/ObjectList.h +++ b/headers/private/shared/ObjectList.h @@ -192,8 +192,16 @@ public: T *FindIf(const UnaryPredicate &); // list must be sorted with CompareFunction for these to work - const T *BinarySearch(const T &, CompareFunction) const; - const T *BinarySearch(const T &, CompareFunctionWithState, void *state) const; + T *BinarySearch(const T &, CompareFunction) const; + T *BinarySearch(const T &, CompareFunctionWithState, void *state) const; + + template + T *BinarySearchByKey(const Key &key, int (*compare)(const Key *, const T *)) + const; + + template + T *BinarySearchByKey(const Key &key, + int (*compare)(const Key *, const T *, void *), void *state) const; // Binary insertion - list must be sorted with CompareFunction for // these to work @@ -624,21 +632,44 @@ BObjectList::HSortItems(CompareFunctionWithState function, void *state) } template -const T * +T * BObjectList::BinarySearch(const T &key, CompareFunction func) const { - return (const T *)_PointerList_::BinarySearch(&key, + return (T*)_PointerList_::BinarySearch(&key, (GenericCompareFunction)func); } template -const T * +T * BObjectList::BinarySearch(const T &key, CompareFunctionWithState func, void *state) const { - return (const T *)_PointerList_::BinarySearch(&key, + return (T*)_PointerList_::BinarySearch(&key, (GenericCompareFunctionWithState)func, state); } + +template +template +T * +BObjectList::BinarySearchByKey(const Key &key, + int (*compare)(const Key *, const T *)) const +{ + return (T*)_PointerList_::BinarySearch(&key, + (GenericCompareFunction)compare); +} + + +template +template +T * +BObjectList::BinarySearchByKey(const Key &key, + int (*compare)(const Key *, const T *, void *), void *state) const +{ + return (T*)_PointerList_::BinarySearch(&key, + (GenericCompareFunctionWithState)compare, state); +} + + template bool BObjectList::BinaryInsert(T *item, CompareFunction func)