NXEngine v1.0.0.6
[NXEngine.git] / common / BList.h
bloba043c7ed4bd9da22edd65c9c13e0949b902733ff
1 /*
2 * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _BE_LIST_H
6 #define _BE_LIST_H
9 #include "SupportDefs.h"
12 class BList {
13 public:
14 BList(int32 count = 20);
15 BList(const BList& anotherList);
16 virtual ~BList();
18 virtual BList& operator =(const BList &);
20 /* Adding and removing items. */
21 bool AddItem(const void* item, int32 index);
22 bool AddItem(const void* item);
23 bool AddList(const BList* list, int32 index);
24 bool AddList(const BList* list);
25 bool RemoveItem(void* item);
26 void* RemoveItem(int32 index);
27 bool RemoveItems(int32 index, int32 count);
28 bool ReplaceItem(int32 index, void* newItem);
29 virtual void MakeEmpty();
31 // Reorder items
32 void SortItems(int (*compareFunc)(const void*, const void*));
33 bool SwapItems(int32 indexA, int32 indexB);
34 bool MoveItem(int32 fromIndex, int32 toIndex);
36 // Retrieve items
37 void* ItemAt(int32 index) const;
38 void* FirstItem() const;
39 void* ItemAtFast(int32) const;
40 // does not check the array bounds!
42 void* LastItem() const;
43 void* Items() const;
45 // Query
46 bool HasItem(void* item) const;
47 int32 IndexOf(void* item) const;
48 int32 CountItems() const;
49 bool IsEmpty() const;
51 // Iteration
52 void DoForEach(bool (*func)(void* item));
53 void DoForEach(bool (*func)(void* item, void* arg2), void *arg2);
55 private:
56 bool _ResizeArray(int32 count);
58 void** fObjectList;
59 int32 fPhysicalSize;
60 int32 fItemCount;
61 int32 fBlockSize;
62 int32 fResizeThreshold;
63 uint32 _reserved[1];
66 #endif // _BE_LIST_H