OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
index_allocator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef ctrlplane_index_allocator_h
6 #define ctrlplane_index_allocator_h
7 
8 #include <assert.h>
9 #include <inttypes.h>
10 #include <string>
11 #include <vector>
12 #include <base/bitset.h>
13 
15 public:
16  IndexAllocator(size_t max_index)
17  : max_index_(max_index), last_index_(BitSet::npos) { }
18 
19  size_t AllocIndex();
20  void FreeIndex(size_t index);
21  bool NoneIndexSet();
22  bool AnyIndexSet();
23 
24 private:
26  size_t max_index_;
27  size_t last_index_;
28 };
29 
30 #endif
IndexAllocator(size_t max_index)
size_t AllocIndex()
void FreeIndex(size_t index)
Definition: bitset.h:17