bm::mem_alloc< BA, PA > Class Template Reference
[Memory Allocation]

Search Toolkit Book for bm::mem_alloc

#include <bmalloc.h>

Collaboration diagram for bm::mem_alloc< BA, PA >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class BA, class PA>
class bm::mem_alloc< BA, PA >

BM style allocator adapter.

Template takes two parameters BA - allocator object for bit blocks and PA - allocator object for pointer blocks.

Definition at line 139 of file bmalloc.h.

Public Types

typedef BA block_allocator_type
typedef PA ptr_allocator_type

Public Member Functions

 mem_alloc (const BA &block_alloc=BA(), const PA &ptr_alloc=PA())
block_allocator_type get_block_allocator () const
 Returns copy of the block allocator object.
ptr_allocator_type get_ptr_allocator () const
 Returns copy of the ptr allocator object.
bm::word_talloc_bit_block (unsigned alloc_factor=1)
 Allocates and returns bit block.
void free_bit_block (bm::word_t *block, unsigned alloc_factor=1)
 Frees bit block allocated by alloc_bit_block.
bm::gap_word_talloc_gap_block (unsigned level, const gap_word_t *glevel_len)
 Allocates GAP block using bit block allocator (BA).
void free_gap_block (bm::gap_word_t *block, const gap_word_t *glevel_len)
 Frees GAP block using bot block allocator (BA).
void * alloc_ptr (unsigned size=bm::set_array_size)
 Allocates block of pointers.
void free_ptr (void *p, unsigned size=bm::set_array_size)
 Frees block of pointers.

Private Attributes

BA block_alloc_
PA ptr_alloc_


Member Typedef Documentation

template<class BA, class PA>
typedef BA bm::mem_alloc< BA, PA >::block_allocator_type
 

Definition at line 142 of file bmalloc.h.

template<class BA, class PA>
typedef PA bm::mem_alloc< BA, PA >::ptr_allocator_type
 

Definition at line 143 of file bmalloc.h.


Constructor & Destructor Documentation

template<class BA, class PA>
bm::mem_alloc< BA, PA >::mem_alloc const BA &  block_alloc = BA(),
const PA &  ptr_alloc = PA()
[inline]
 

Definition at line 147 of file bmalloc.h.


Member Function Documentation

template<class BA, class PA>
bm::word_t* bm::mem_alloc< BA, PA >::alloc_bit_block unsigned  alloc_factor = 1  )  [inline]
 

Allocates and returns bit block.

Parameters:
alloc_factor indicated how many blocks we want to allocate in chunk total allocation is going to be bm::set_block_size * alloc_factor Default allocation factor is 1

Definition at line 173 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_, and bm::set_block_size.

template<class BA, class PA>
bm::gap_word_t* bm::mem_alloc< BA, PA >::alloc_gap_block unsigned  level,
const gap_word_t glevel_len
[inline]
 

Allocates GAP block using bit block allocator (BA).

GAP blocks in BM library belong to levels. Each level has a correspondent length described in bm::gap_len_table<>.

Parameters:
level GAP block level.

Definition at line 193 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_, BM_ASSERT, bm::gap_levels, and len.

template<class BA, class PA>
void* bm::mem_alloc< BA, PA >::alloc_ptr unsigned  size = bm::set_array_size  )  [inline]
 

Allocates block of pointers.

Definition at line 217 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::ptr_alloc_, and size.

template<class BA, class PA>
void bm::mem_alloc< BA, PA >::free_bit_block bm::word_t block,
unsigned  alloc_factor = 1
[inline]
 

Frees bit block allocated by alloc_bit_block.

Definition at line 180 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_, IS_VALID_ADDR, and bm::set_block_size.

template<class BA, class PA>
void bm::mem_alloc< BA, PA >::free_gap_block bm::gap_word_t block,
const gap_word_t glevel_len
[inline]
 

Frees GAP block using bot block allocator (BA).

Definition at line 205 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_, BM_ASSERT, bm::gap_capacity(), IS_VALID_ADDR, and len.

template<class BA, class PA>
void bm::mem_alloc< BA, PA >::free_ptr void *  p,
unsigned  size = bm::set_array_size
[inline]
 

Frees block of pointers.

Definition at line 224 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::ptr_alloc_, and size.

template<class BA, class PA>
block_allocator_type bm::mem_alloc< BA, PA >::get_block_allocator  )  const [inline]
 

Returns copy of the block allocator object.

Definition at line 154 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_.

template<class BA, class PA>
ptr_allocator_type bm::mem_alloc< BA, PA >::get_ptr_allocator  )  const [inline]
 

Returns copy of the ptr allocator object.

Definition at line 161 of file bmalloc.h.

References bm::mem_alloc< BA, PA >::block_alloc_.


Member Data Documentation

template<class BA, class PA>
BA bm::mem_alloc< BA, PA >::block_alloc_ [private]
 

Definition at line 230 of file bmalloc.h.

Referenced by bm::mem_alloc< BA, PA >::alloc_bit_block(), bm::mem_alloc< BA, PA >::alloc_gap_block(), bm::mem_alloc< BA, PA >::free_bit_block(), bm::mem_alloc< BA, PA >::free_gap_block(), bm::mem_alloc< BA, PA >::get_block_allocator(), and bm::mem_alloc< BA, PA >::get_ptr_allocator().

template<class BA, class PA>
PA bm::mem_alloc< BA, PA >::ptr_alloc_ [private]
 

Definition at line 231 of file bmalloc.h.

Referenced by bm::mem_alloc< BA, PA >::alloc_ptr(), and bm::mem_alloc< BA, PA >::free_ptr().


The documentation for this class was generated from the following file:
Generated on Mon Dec 7 16:06:07 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:24:38 2009 by modify_doxy.py rev. 173732