2010-05-07 04:47:10 -05:00
|
|
|
/*
|
|
|
|
Open Tracker License
|
|
|
|
|
|
|
|
Terms and Conditions
|
|
|
|
|
|
|
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
of the Software, and to permit persons to whom the Software is furnished to do
|
|
|
|
so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice applies to all licensees
|
|
|
|
and shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
|
|
|
this Software without prior written authorization from Be Incorporated.
|
|
|
|
|
|
|
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
|
|
|
of Be Incorporated in the United States and other countries. Other brand product
|
|
|
|
names are registered trademarks or trademarks of their respective holders.
|
|
|
|
All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
|
|
|
** **
|
|
|
|
** DANGER, WILL ROBINSON! **
|
|
|
|
** **
|
|
|
|
** The interfaces contained here are part of BeOS's **
|
|
|
|
** **
|
|
|
|
** >> PRIVATE NOT FOR PUBLIC USE << **
|
|
|
|
** **
|
|
|
|
** implementation. **
|
|
|
|
** **
|
|
|
|
** These interfaces WILL CHANGE in future releases. **
|
|
|
|
** If you use them, your app WILL BREAK at some future time. **
|
|
|
|
** **
|
|
|
|
** (And yes, this does mean that binaries built from OpenTracker will not **
|
|
|
|
** be compatible with some future releases of the OS. When that happens, **
|
|
|
|
** we will provide an updated version of this file to keep compatibility.) **
|
|
|
|
** **
|
|
|
|
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
//
|
|
|
|
// ObjectList is a wrapper around BList that adds type safety,
|
|
|
|
// optional object ownership, search, insert operations, etc.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef __OBJECT_LIST__
|
|
|
|
#define __OBJECT_LIST__
|
|
|
|
|
|
|
|
#ifndef _BE_H
|
|
|
|
#include <List.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
template<class T> class BObjectList;
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
struct UnaryPredicate {
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
virtual int operator()(const T*) const
|
|
|
|
// virtual could be avoided here if FindBinaryInsertionIndex,
|
|
|
|
// etc. were member template functions
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
private:
|
2010-07-10 08:58:15 -05:00
|
|
|
static int _unary_predicate_glue(const void* item, void* context);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
friend class BObjectList<T>;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int
|
2010-07-10 08:58:15 -05:00
|
|
|
UnaryPredicate<T>::_unary_predicate_glue(const void* item, void* context)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return ((UnaryPredicate<T> *)context)->operator()((const T*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
class _PointerList_ : public BList
|
|
|
|
{
|
2010-05-07 04:47:10 -05:00
|
|
|
public:
|
|
|
|
_PointerList_(const _PointerList_ &list);
|
|
|
|
_PointerList_(int32 itemsPerBlock = 20, bool owning = false);
|
|
|
|
~_PointerList_();
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
typedef void *(* GenericEachFunction)(void*, void*);
|
|
|
|
typedef int (* GenericCompareFunction)(const void*, const void*);
|
|
|
|
typedef int (* GenericCompareFunctionWithState)(const void*, const void*,
|
|
|
|
void*);
|
|
|
|
typedef int (* UnaryPredicateGlue)(const void*, void*);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
void* EachElement(GenericEachFunction, void*);
|
2010-05-07 04:47:10 -05:00
|
|
|
void SortItems(GenericCompareFunction);
|
2010-07-10 08:58:15 -05:00
|
|
|
void SortItems(GenericCompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
void HSortItems(GenericCompareFunction);
|
2010-07-10 08:58:15 -05:00
|
|
|
void HSortItems(GenericCompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
void* BinarySearch(const void*, GenericCompareFunction) const;
|
|
|
|
void* BinarySearch(const void*, GenericCompareFunctionWithState, void* state) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
int32 BinarySearchIndex(const void*, GenericCompareFunction) const;
|
|
|
|
int32 BinarySearchIndex(const void*, GenericCompareFunctionWithState, void* state) const;
|
|
|
|
int32 BinarySearchIndexByPredicate(const void*, UnaryPredicateGlue) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
bool Owning() const;
|
2010-07-10 08:58:15 -05:00
|
|
|
bool ReplaceItem(int32, void*);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool owning;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T>
|
2010-07-10 08:58:15 -05:00
|
|
|
class BObjectList : private _PointerList_
|
|
|
|
{
|
2010-05-07 04:47:10 -05:00
|
|
|
public:
|
|
|
|
|
|
|
|
// iteration and sorting
|
2010-07-10 08:58:15 -05:00
|
|
|
typedef T *(* EachFunction)(T*, void*);
|
|
|
|
typedef const T *(* ConstEachFunction)(const T*, void*);
|
|
|
|
typedef int (* CompareFunction)(const T*, const T*);
|
|
|
|
typedef int (* CompareFunctionWithState)(const T*, const T*, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
BObjectList(int32 itemsPerBlock = 20, bool owning = false);
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList(const BObjectList& list);
|
|
|
|
// clones list; if list is owning, makes copies of all
|
|
|
|
// the items
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
virtual ~BObjectList();
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList& operator=(const BObjectList& list);
|
|
|
|
// clones list; if list is owning, makes copies of all
|
|
|
|
// the items
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// adding and removing
|
|
|
|
// ToDo:
|
|
|
|
// change Add calls to return const item
|
2010-07-10 08:58:15 -05:00
|
|
|
bool AddItem(T*);
|
|
|
|
bool AddItem(T*, int32);
|
|
|
|
bool AddList(BObjectList*);
|
|
|
|
bool AddList(BObjectList*, int32);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
bool RemoveItem(T*, bool deleteIfOwning = true);
|
|
|
|
// if owning, deletes the removed item
|
|
|
|
T* RemoveItemAt(int32);
|
|
|
|
// returns the removed item
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
// item access
|
2010-07-10 08:58:15 -05:00
|
|
|
T* ItemAt(int32) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
bool ReplaceItem(int32 index, T*);
|
|
|
|
// if list is owning, deletes the item at <index> first
|
|
|
|
T* SwapWithItem(int32 index, T* newItem);
|
|
|
|
// same as ReplaceItem, except does not delete old item at <index>,
|
|
|
|
// returns it instead
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
T* FirstItem() const;
|
|
|
|
T* LastItem() const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// misc. getters
|
2010-07-10 08:58:15 -05:00
|
|
|
int32 IndexOf(const T*) const;
|
|
|
|
bool HasItem(const T*) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
bool IsEmpty() const;
|
|
|
|
int32 CountItems() const;
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
T* EachElement(EachFunction, void*);
|
|
|
|
const T* EachElement(ConstEachFunction, void*) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
void SortItems(CompareFunction);
|
2010-07-10 08:58:15 -05:00
|
|
|
void SortItems(CompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
void HSortItems(CompareFunction);
|
2010-07-10 08:58:15 -05:00
|
|
|
void HSortItems(CompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// linear search, returns first item that matches predicate
|
2010-07-10 08:58:15 -05:00
|
|
|
const T* FindIf(const UnaryPredicate<T> &) const;
|
|
|
|
T* FindIf(const UnaryPredicate<T> &);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// list must be sorted with CompareFunction for these to work
|
2010-07-10 08:58:15 -05:00
|
|
|
T* BinarySearch(const T&, CompareFunction) const;
|
|
|
|
T* BinarySearch(const T&, CompareFunctionWithState, void* state) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
template<typename Key>
|
2010-07-10 08:58:15 -05:00
|
|
|
T* BinarySearchByKey(const Key& key, int (*compare)(const Key*, const T*))
|
|
|
|
const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
template<typename Key>
|
2010-07-10 08:58:15 -05:00
|
|
|
T* BinarySearchByKey(const Key& key,
|
|
|
|
int (*compare)(const Key*, const T*, void*), void* state) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
int32 BinarySearchIndex(const T& item, CompareFunction compare) const;
|
|
|
|
int32 BinarySearchIndex(const T& item, CompareFunctionWithState compare,
|
|
|
|
void* state) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
template<typename Key>
|
2010-07-10 08:58:15 -05:00
|
|
|
int32 BinarySearchIndexByKey(const Key& key,
|
|
|
|
int (*compare)(const Key*, const T*)) const;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// Binary insertion - list must be sorted with CompareFunction for
|
|
|
|
// these to work
|
|
|
|
|
|
|
|
// simple insert
|
2010-07-10 08:58:15 -05:00
|
|
|
bool BinaryInsert(T*, CompareFunction);
|
|
|
|
bool BinaryInsert(T*, CompareFunctionWithState, void* state);
|
|
|
|
bool BinaryInsert(T*, const UnaryPredicate<T> &);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// unique insert, returns false if item already in list
|
2010-07-10 08:58:15 -05:00
|
|
|
bool BinaryInsertUnique(T*, CompareFunction);
|
|
|
|
bool BinaryInsertUnique(T*, CompareFunctionWithState, void* state);
|
|
|
|
bool BinaryInsertUnique(T*, const UnaryPredicate<T> &);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// insert a copy of the item, returns new inserted item
|
2010-07-10 08:58:15 -05:00
|
|
|
T* BinaryInsertCopy(const T& copyThis, CompareFunction);
|
|
|
|
T* BinaryInsertCopy(const T& copyThis, CompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// insert a copy of the item if not in list already
|
|
|
|
// returns new inserted item or existing item in case of a conflict
|
2010-07-10 08:58:15 -05:00
|
|
|
T* BinaryInsertCopyUnique(const T& copyThis, CompareFunction);
|
|
|
|
T* BinaryInsertCopyUnique(const T& copyThis, CompareFunctionWithState, void* state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
int32 FindBinaryInsertionIndex(const UnaryPredicate<T> &, bool* alreadyInList = 0) const;
|
|
|
|
// returns either the index into which a new item should be inserted
|
|
|
|
// or index of an existing item that matches the predicate
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
// deprecated API, will go away
|
2010-07-10 08:58:15 -05:00
|
|
|
BList* AsBList() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
const BList* AsBList() const {
|
|
|
|
return this;
|
|
|
|
}
|
2010-05-07 04:47:10 -05:00
|
|
|
private:
|
2010-07-10 08:58:15 -05:00
|
|
|
void SetItem(int32, T*);
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class Item, class Result, class Param1>
|
|
|
|
Result
|
|
|
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1 p1)
|
|
|
|
{
|
|
|
|
Result result = 0;
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if ((result = (list->ItemAt(index)->*func)(p1)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Result, class Param1>
|
|
|
|
Result
|
2010-07-10 08:58:15 -05:00
|
|
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1), Param1 p1)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
Result result = 0;
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if ((result = (*func)(list->ItemAt(index), p1)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Result, class Param1, class Param2>
|
|
|
|
Result
|
|
|
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
|
2010-07-10 08:58:15 -05:00
|
|
|
Param1 p1, Param2 p2)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
Result result = 0;
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if ((result = (list->ItemAt(index)->*func)(p1, p2)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Result, class Param1, class Param2>
|
|
|
|
Result
|
2010-07-10 08:58:15 -05:00
|
|
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1, Param2),
|
|
|
|
Param1 p1, Param2 p2)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
Result result = 0;
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if ((result = (*func)(list->ItemAt(index), p1, p2)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Result, class Param1, class Param2, class Param3, class Param4>
|
|
|
|
Result
|
2010-07-10 08:58:15 -05:00
|
|
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1, Param2,
|
|
|
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
Result result = 0;
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if ((result = (*func)(list->ItemAt(index), p1, p2, p3, p4)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Result>
|
|
|
|
void
|
|
|
|
EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
|
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(list->ItemAt(index)->*func)();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Param1>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1), Param1 p1)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(func)(list->ItemAt(index), p1);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Param1, class Param2>
|
|
|
|
void
|
|
|
|
EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
|
2010-07-10 08:58:15 -05:00
|
|
|
Param1 p1, Param2 p2)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(list->ItemAt(index)->*func)(p1, p2);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Param1, class Param2>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2),
|
|
|
|
Param1 p1, Param2 p2)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(func)(list->ItemAt(index), p1, p2);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Item, class Param1, class Param2, class Param3>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2,
|
|
|
|
Param3), Param1 p1, Param2 p2, Param3 p3)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(func)(list->ItemAt(index), p1, p2, p3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Item, class Param1, class Param2, class Param3, class Param4>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2,
|
|
|
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 count = list->CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
(func)(list->ItemAt(index), p1, p2, p3, p4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// inline code
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
_PointerList_::Owning() const
|
|
|
|
{
|
|
|
|
return owning;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
BObjectList<T>::BObjectList(int32 itemsPerBlock, bool owning)
|
|
|
|
: _PointerList_(itemsPerBlock, owning)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
BObjectList<T>::BObjectList(const BObjectList<T> &list)
|
|
|
|
: _PointerList_(list)
|
|
|
|
{
|
|
|
|
owning = list.owning;
|
|
|
|
if (owning) {
|
|
|
|
// make our own copies in an owning list
|
|
|
|
int32 count = list.CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++) {
|
2010-07-10 08:58:15 -05:00
|
|
|
T* item = list.ItemAt(index);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (item)
|
|
|
|
item = new T(*item);
|
|
|
|
SetItem(index, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
BObjectList<T>::~BObjectList()
|
|
|
|
{
|
|
|
|
if (Owning())
|
|
|
|
// have to nuke elements first
|
|
|
|
MakeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
BObjectList<T> &
|
|
|
|
BObjectList<T>::operator=(const BObjectList<T> &list)
|
|
|
|
{
|
|
|
|
owning = list.owning;
|
|
|
|
BObjectList<T> &result = (BObjectList<T> &)_PointerList_::operator=(list);
|
|
|
|
if (owning) {
|
|
|
|
// make our own copies in an owning list
|
|
|
|
int32 count = list.CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++) {
|
2010-07-10 08:58:15 -05:00
|
|
|
T* item = list.ItemAt(index);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (item)
|
|
|
|
item = new T(*item);
|
|
|
|
SetItem(index, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::AddItem(T* item)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
// need to cast to void * to make T work for const pointers
|
2010-07-10 08:58:15 -05:00
|
|
|
return _PointerList_::AddItem((void*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::AddItem(T* item, int32 atIndex)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return _PointerList_::AddItem((void*)item, atIndex);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
|
|
|
BObjectList<T>::AddList(BObjectList<T> *newItems)
|
|
|
|
{
|
|
|
|
return _PointerList_::AddList(newItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
|
|
|
BObjectList<T>::AddList(BObjectList<T> *newItems, int32 atIndex)
|
|
|
|
{
|
|
|
|
return _PointerList_::AddList(newItems, atIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::RemoveItem(T* item, bool deleteIfOwning)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
bool result = _PointerList_::RemoveItem((void*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
if (result && Owning() && deleteIfOwning)
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
|
|
|
BObjectList<T>::RemoveItemAt(int32 index)
|
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (T*)_PointerList_::RemoveItem(index);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
inline T *
|
|
|
|
BObjectList<T>::ItemAt(int32 index) const
|
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (T*)_PointerList_::ItemAt(index);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::ReplaceItem(int32 index, T* item)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
if (owning)
|
|
|
|
delete ItemAt(index);
|
2010-07-10 08:58:15 -05:00
|
|
|
return _PointerList_::ReplaceItem(index, (void*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::SwapWithItem(int32 index, T* newItem)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
T* result = ItemAt(index);
|
|
|
|
_PointerList_::ReplaceItem(index, (void*)newItem);
|
2010-05-07 04:47:10 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::SetItem(int32 index, T* newItem)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
_PointerList_::ReplaceItem(index, (void*)newItem);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int32
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::IndexOf(const T* item) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return _PointerList_::IndexOf((void*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
|
|
|
BObjectList<T>::FirstItem() const
|
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (T*)_PointerList_::FirstItem();
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
|
|
|
BObjectList<T>::LastItem() const
|
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (T*)_PointerList_::LastItem();
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::HasItem(const T* item) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return _PointerList_::HasItem((void*)item);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
|
|
|
BObjectList<T>::IsEmpty() const
|
|
|
|
{
|
|
|
|
return _PointerList_::IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int32
|
|
|
|
BObjectList<T>::CountItems() const
|
|
|
|
{
|
|
|
|
return _PointerList_::CountItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
|
|
|
BObjectList<T>::MakeEmpty()
|
|
|
|
{
|
|
|
|
if (owning) {
|
|
|
|
int32 count = CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
delete ItemAt(index);
|
|
|
|
}
|
|
|
|
_PointerList_::MakeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::EachElement(EachFunction func, void* params)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (T*)_PointerList_::EachElement((GenericEachFunction)func, params);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
const T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::EachElement(ConstEachFunction func, void* params) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2010-07-10 08:58:15 -05:00
|
|
|
return (const T*)
|
|
|
|
const_cast<BObjectList<T> *>(this)->_PointerList_::EachElement(
|
|
|
|
(GenericEachFunction)func, params);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
const T *
|
|
|
|
BObjectList<T>::FindIf(const UnaryPredicate<T> &predicate) const
|
|
|
|
{
|
|
|
|
int32 count = CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if (predicate.operator()(ItemAt(index)) == 0)
|
|
|
|
return ItemAt(index);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
|
|
|
BObjectList<T>::FindIf(const UnaryPredicate<T> &predicate)
|
|
|
|
{
|
|
|
|
int32 count = CountItems();
|
|
|
|
for (int32 index = 0; index < count; index++)
|
|
|
|
if (predicate.operator()(ItemAt(index)) == 0)
|
|
|
|
return ItemAt(index);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
|
|
|
BObjectList<T>::SortItems(CompareFunction function)
|
|
|
|
{
|
|
|
|
_PointerList_::SortItems((GenericCompareFunction)function);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::SortItems(CompareFunctionWithState function, void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
_PointerList_::SortItems((GenericCompareFunctionWithState)function, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
|
|
|
BObjectList<T>::HSortItems(CompareFunction function)
|
|
|
|
{
|
|
|
|
_PointerList_::HSortItems((GenericCompareFunction)function);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::HSortItems(CompareFunctionWithState function, void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
_PointerList_::HSortItems((GenericCompareFunctionWithState)function, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearch(const T& key, CompareFunction func) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return (T*)_PointerList_::BinarySearch(&key,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)func);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearch(const T& key, CompareFunctionWithState func, void* state) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return (T*)_PointerList_::BinarySearch(&key,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)func, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<typename Key>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearchByKey(const Key& key,
|
|
|
|
int (*compare)(const Key*, const T*)) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return (T*)_PointerList_::BinarySearch(&key,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)compare);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<typename Key>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearchByKey(const Key& key,
|
|
|
|
int (*compare)(const Key*, const T*, void*), void* state) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return (T*)_PointerList_::BinarySearch(&key,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)compare, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int32
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearchIndex(const T& item, CompareFunction compare) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return _PointerList_::BinarySearchIndex(&item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)compare);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int32
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearchIndex(const T& item,
|
|
|
|
CompareFunctionWithState compare, void* state) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return _PointerList_::BinarySearchIndex(&item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)compare, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<typename Key>
|
|
|
|
int32
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinarySearchIndexByKey(const Key& key,
|
|
|
|
int (*compare)(const Key*, const T*)) const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return _PointerList_::BinarySearchIndex(&key,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)compare);
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsert(T* item, CompareFunction func)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)func);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0) {
|
|
|
|
// already in list, add after existing
|
|
|
|
return AddItem(item, index + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return AddItem(item, -index - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsert(T* item, CompareFunctionWithState func, void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)func, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0) {
|
|
|
|
// already in list, add after existing
|
|
|
|
return AddItem(item, index + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return AddItem(item, -index - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertUnique(T* item, CompareFunction func)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)func);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return AddItem(item, -index - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertUnique(T* item, CompareFunctionWithState func, void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)func, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return AddItem(item, -index - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertCopy(const T& copyThis, CompareFunction func)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)func);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
if (index >= 0)
|
|
|
|
index++;
|
|
|
|
else
|
|
|
|
index = -index - 1;
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
T* newItem = new T(copyThis);
|
2010-05-07 04:47:10 -05:00
|
|
|
AddItem(newItem, index);
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertCopy(const T& copyThis, CompareFunctionWithState func, void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)func, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
if (index >= 0)
|
|
|
|
index++;
|
|
|
|
else
|
|
|
|
index = -index - 1;
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
T* newItem = new T(copyThis);
|
2010-05-07 04:47:10 -05:00
|
|
|
AddItem(newItem, index);
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertCopyUnique(const T& copyThis, CompareFunction func)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunction)func);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0)
|
|
|
|
return ItemAt(index);
|
|
|
|
|
|
|
|
index = -index - 1;
|
2010-07-10 08:58:15 -05:00
|
|
|
T* newItem = new T(copyThis);
|
2010-05-07 04:47:10 -05:00
|
|
|
AddItem(newItem, index);
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T *
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertCopyUnique(const T& copyThis, CompareFunctionWithState func,
|
|
|
|
void* state)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
2010-07-10 08:58:15 -05:00
|
|
|
(GenericCompareFunctionWithState)func, state);
|
2010-05-07 04:47:10 -05:00
|
|
|
if (index >= 0)
|
|
|
|
return ItemAt(index);
|
|
|
|
|
|
|
|
index = -index - 1;
|
2010-07-10 08:58:15 -05:00
|
|
|
T* newItem = new T(copyThis);
|
2010-05-07 04:47:10 -05:00
|
|
|
AddItem(newItem, index);
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
int32
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool* alreadyInList)
|
|
|
|
const
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred,
|
2010-07-10 08:58:15 -05:00
|
|
|
(UnaryPredicateGlue)&UnaryPredicate<T>::_unary_predicate_glue);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
if (alreadyInList)
|
|
|
|
*alreadyInList = index >= 0;
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
index = -index - 1;
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsert(T* item, const UnaryPredicate<T> &pred)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
return AddItem(item, FindBinaryInsertionIndex(pred));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool
|
2010-07-10 08:58:15 -05:00
|
|
|
BObjectList<T>::BinaryInsertUnique(T* item, const UnaryPredicate<T> &pred)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
bool alreadyInList;
|
|
|
|
int32 index = FindBinaryInsertionIndex(pred, &alreadyInList);
|
|
|
|
if (alreadyInList)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
AddItem(item, index);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __OBJECT_LIST__ */
|