1 /* Utility - some helper classes 2 * 3 * Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de. 4 * This file may be used under the terms of the MIT License. 5 */ 6 #ifndef UTILITY_H 7 #define UTILITY_H 8 9 10 #include <SupportDefs.h> 11 12 13 // Simple array, used for the duplicate handling in the B+Tree, 14 // and for the log entries. 15 16 struct sorted_array { 17 public: 18 off_t count; 19 off_t values[0]; 20 21 inline int32 Find(off_t value) const; 22 void Insert(off_t value); 23 bool Remove(off_t value); 24 25 private: 26 bool FindInternal(off_t value,int32 &index) const; 27 }; 28 29 30 inline int32 31 sorted_array::Find(off_t value) const 32 { 33 int32 i; 34 return FindInternal(value,i) ? i : -1; 35 } 36 37 #endif /* UTILITY_H */ 38