Bit vector  0.9
Fast and space efficient dynamic bit vector library.
Public Member Functions | Protected Attributes | List of all members
bv::malloc_alloc Class Reference

Simple malloc based allocation for internal nodes and leaves. More...

#include <allocator.hpp>

Public Member Functions

template<class node_type >
node_type * allocate_node ()
 Allocate new internal node. More...
 
template<class node_type >
void deallocate_node (node_type *node)
 Deallocate internal node. More...
 
template<class leaf_type >
leaf_type * allocate_leaf (uint64_t size)
 Allocates a new leaf with space for storing size * 64 bits. More...
 
template<class leaf_type >
void deallocate_leaf (leaf_type *leaf)
 Deallocates leaf node. More...
 
template<class leaf_type >
leaf_type * reallocate_leaf (leaf_type *leaf, uint64_t old_size, uint64_t new_size)
 Reallocator for leaf nodes. More...
 
uint64_t live_allocations () const
 Get the number of blocks currenty allocated by this allocator instance. More...
 

Protected Attributes

uint64_t allocations_
 Number of objects currently allocated.
 

Detailed Description

Simple malloc based allocation for internal nodes and leaves.

Malloc and free are directly used to allocate/deallocate internal nodes.

For leaves, a block is (re)allocated for housing both the leaf "struct" and the associated data.

Member Function Documentation

◆ allocate_leaf()

template<class leaf_type >
leaf_type* bv::malloc_alloc::allocate_leaf ( uint64_t  size)
inline

Allocates a new leaf with space for storing size * 64 bits.

Uses malloc to allocate sizeof(leaf_type) + 8 * size bytes, and initializes the first sizeof(leaf_type) bytes of the allocated block using the default constructor of leaf_type.

Template Parameters
leaf_typeBit vector leaf type. Typically some kind of bv::leaf.
Parameters
sizeNumber of 64-bit words to reserve for data storage.

◆ allocate_node()

template<class node_type >
node_type* bv::malloc_alloc::allocate_node ( )
inline

Allocate new internal node.

Simply uses malloc(sizeof(node_type)).

Template Parameters
node_typeInternal node type. Typically some kind of bv::node.

◆ deallocate_leaf()

template<class leaf_type >
void bv::malloc_alloc::deallocate_leaf ( leaf_type *  leaf)
inline

Deallocates leaf node.

Simply calls free(leaf).

Template Parameters
leaf_typeBit vector leaf type. Typically some kind of bv::leaf.

◆ deallocate_node()

template<class node_type >
void bv::malloc_alloc::deallocate_node ( node_type *  node)
inline

Deallocate internal node.

Simply does free(node).

Template Parameters
node_typeInternal node type. Typically some kind of bv::node.
Parameters
nodeInternal node to deallocate.

◆ live_allocations()

uint64_t bv::malloc_alloc::live_allocations ( ) const
inline

Get the number of blocks currenty allocated by this allocator instance.

Returns
Number of blocks currently allocated by this allocator instance.

◆ reallocate_leaf()

template<class leaf_type >
leaf_type* bv::malloc_alloc::reallocate_leaf ( leaf_type *  leaf,
uint64_t  old_size,
uint64_t  new_size 
)
inline

Reallocator for leaf nodes.

Reallocates the block for a leaf and associated data.

Template Parameters
leaf_typeBit vector leaf type. Typically some kind of bv::leaf.
Parameters
leafPointer to leaf_type to reallocate.
old_sizeSize of leaf data block. (in 64 bit words.)
new_sizeNew size for leaf data block. (in 64 bit words.)

The documentation for this class was generated from the following file: