Bit vector
0.9
Fast and space efficient dynamic bit vector library.
|
1 #ifndef BV_ALLOCATOR_HPP
2 #define BV_ALLOCATOR_HPP
34 template <
class node_type>
37 void* nd = malloc(
sizeof(node_type));
38 return new (nd) node_type();
50 template <
class node_type>
67 template <
class leaf_type>
70 constexpr
size_t leaf_bytes =
sizeof(leaf_type) +
sizeof(leaf_type) % 8;
71 void*
leaf = malloc(leaf_bytes + size *
sizeof(uint64_t));
73 reinterpret_cast<uint8_t*
>(
leaf) + leaf_bytes;
74 memset(data_ptr, 0, size *
sizeof(uint64_t));
76 leaf_type(size,
reinterpret_cast<uint64_t*
>(data_ptr));
86 template <
class leaf_type>
103 template <
class leaf_type>
106 constexpr
size_t leaf_bytes =
sizeof(leaf_type) +
sizeof(leaf_type) % 8;
107 #pragma GCC diagnostic ignored "-Wclass-memaccess"
108 leaf_type* n_leaf =
reinterpret_cast<leaf_type*
>(
109 realloc(
leaf, leaf_bytes + new_size *
sizeof(uint64_t)));
110 #pragma GCC diagnostic pop
112 reinterpret_cast<uint8_t*
>(n_leaf) + leaf_bytes;
113 memset(data_ptr +
sizeof(uint64_t) * old_size, 0,
114 sizeof(uint64_t) * (new_size - old_size));
115 n_leaf->set_data_ptr(
reinterpret_cast<uint64_t*
>(data_ptr));
116 n_leaf->capacity(new_size);
uint64_t allocations_
Number of objects currently allocated.
Definition: allocator.hpp:22
void deallocate_leaf(leaf_type *leaf)
Deallocates leaf node.
Definition: allocator.hpp:87
simple_bv< 8, 16384, 64 > bv
Default dynamic bit vector type.
Definition: bv.hpp:94
Simple flat dynamic bit vector for use as a leaf for a dynamic b-tree bit vector.
Definition: leaf.hpp:47
void deallocate_node(node_type *node)
Deallocate internal node.
Definition: allocator.hpp:51
Simple malloc based allocation for internal nodes and leaves.
Definition: allocator.hpp:20
node_type * allocate_node()
Allocate new internal node.
Definition: allocator.hpp:35
Internal node for use with bit vector b-tree structures.
Definition: node.hpp:65
uint64_t live_allocations() const
Get the number of blocks currenty allocated by this allocator instance.
Definition: allocator.hpp:125
leaf_type * reallocate_leaf(leaf_type *leaf, uint64_t old_size, uint64_t new_size)
Reallocator for leaf nodes.
Definition: allocator.hpp:104
leaf_type * allocate_leaf(uint64_t size)
Allocates a new leaf with space for storing size * 64 bits.
Definition: allocator.hpp:68