vfs: check userland buffers before reading them.
[haiku.git] / headers / os / support / List.h
blobdd38992b1f983f6ac0cc5c58b8cd000e209637f0
1 /*
2 * Copyright 2001-2009 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& other);
16 virtual ~BList();
18 BList& operator=(const BList& other);
19 bool operator==(const BList& other) const;
20 bool operator!=(const BList& other) const;
22 // Adding and removing items
23 bool AddItem(void* item, int32 index);
24 bool AddItem(void* item);
25 bool AddList(const BList* list, int32 index);
26 bool AddList(const BList* list);
28 bool RemoveItem(void* item);
29 void* RemoveItem(int32 index);
30 bool RemoveItems(int32 index, int32 count);
31 bool ReplaceItem(int32 index, void* item);
33 void MakeEmpty();
35 // Reorder items
36 void SortItems(int (*compareFunc)(const void*,
37 const void*));
38 bool SwapItems(int32 indexA, int32 indexB);
39 bool MoveItem(int32 from, int32 to);
41 // Retrieve items
42 void* ItemAt(int32 index) const;
43 void* FirstItem() const;
44 void* ItemAtFast(int32 index) const;
45 // does not check the array bounds!
47 void* LastItem() const;
48 void* Items() const;
50 // Query
51 bool HasItem(void* item) const;
52 bool HasItem(const void* item) const;
53 int32 IndexOf(void* item) const;
54 int32 IndexOf(const void* item) const;
55 int32 CountItems() const;
56 bool IsEmpty() const;
58 // Iteration
59 void DoForEach(bool (*func)(void* item));
60 void DoForEach(bool (*func)(void* item,
61 void* arg2), void* arg2);
63 private:
64 virtual void _ReservedList1();
65 virtual void _ReservedList2();
67 bool _ResizeArray(int32 count);
69 private:
70 void** fObjectList;
71 int32 fPhysicalSize;
72 int32 fItemCount;
73 int32 fBlockSize;
74 int32 fResizeThreshold;
76 uint32 _reserved[1];
80 #endif // _BE_LIST_H