From 6cd189c9978604755cdb82107fc6741c4d3c1952 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 22 Jun 2009 21:41:16 +0000 Subject: [PATCH] Added BinarySearchIndex(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31186 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/ObjectList.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/headers/private/shared/ObjectList.h b/headers/private/shared/ObjectList.h index 6fc9f16cf3..04a59bf1a3 100644 --- a/headers/private/shared/ObjectList.h +++ b/headers/private/shared/ObjectList.h @@ -203,6 +203,10 @@ public: T *BinarySearchByKey(const Key &key, int (*compare)(const Key *, const T *, void *), void *state) const; + int32 BinarySearchIndex(const T &item, CompareFunction compare) const; + int32 BinarySearchIndex(const T &item, CompareFunctionWithState compare, + void *state) const; + // Binary insertion - list must be sorted with CompareFunction for // these to work @@ -670,6 +674,25 @@ BObjectList::BinarySearchByKey(const Key &key, } +template +int32 +BObjectList::BinarySearchIndex(const T &item, CompareFunction compare) const +{ + return _PointerList_::BinarySearchIndex(&item, + (GenericCompareFunction)compare); +} + + +template +int32 +BObjectList::BinarySearchIndex(const T &item, + CompareFunctionWithState compare, void *state) const +{ + return _PointerList_::BinarySearchIndex(&item, + (GenericCompareFunctionWithState)compare, state); +} + + template bool BObjectList::BinaryInsert(T *item, CompareFunction func)