xref: /haiku/src/add-ons/kernel/file_systems/bfs/Utility.h (revision 020cbad9d40235a2c50a81a42d69912a5ff8fbc4)
1 /*
2  * Copyright 2001-2008, Axel Dörfler, axeld@pinc-software.de.
3  * This file may be used under the terms of the MIT License.
4  */
5 #ifndef UTILITY_H
6 #define UTILITY_H
7 
8 
9 #include "system_dependencies.h"
10 
11 
12 // Simple array, used for the duplicate handling in the B+Tree
13 // TODO: this is not endian safe!!!
14 
15 struct sorted_array {
16 	public:
17 		off_t	count;
18 		off_t	values[0];
19 
20 		inline int32 Find(off_t value) const;
21 		void Insert(off_t value);
22 		bool Remove(off_t value);
23 
24 	private:
25 		bool _FindInternal(off_t value, int32 &index) const;
26 };
27 
28 
29 inline int32
30 sorted_array::Find(off_t value) const
31 {
32 	int32 i;
33 	return _FindInternal(value, i) ? i : -1;
34 }
35 
36 #endif	/* UTILITY_H */
37