From 3edae90975a0db4a419126d762a14b9ad3d7a125 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 9 Jul 2009 23:24:55 +0000 Subject: [PATCH] Added BinarySearchIndexByKey(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31491 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/ObjectList.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/headers/private/shared/ObjectList.h b/headers/private/shared/ObjectList.h index 04a59bf1a3..a4655d09cc 100644 --- a/headers/private/shared/ObjectList.h +++ b/headers/private/shared/ObjectList.h @@ -207,6 +207,10 @@ public: int32 BinarySearchIndex(const T &item, CompareFunctionWithState compare, void *state) const; + template + int32 BinarySearchIndexByKey(const Key &key, + int (*compare)(const Key *, const T *)) const; + // Binary insertion - list must be sorted with CompareFunction for // these to work @@ -693,6 +697,17 @@ BObjectList::BinarySearchIndex(const T &item, } +template +template +int32 +BObjectList::BinarySearchIndexByKey(const Key &key, + int (*compare)(const Key *, const T *)) const +{ + return _PointerList_::BinarySearchIndex(&key, + (GenericCompareFunction)compare); +} + + template bool BObjectList::BinaryInsert(T *item, CompareFunction func)