ZGen  0.2.0
a linearization system for natural language.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
ZGen::BestFirst::SpanAllocator Class Reference

#include <span_allocator.h>

Public Member Functions

 SpanAllocator (int reserved_num_spans=1, int bucket_size=65535)
 
Spanmalloc ()
 
void clear ()
 
void pruge ()
 

Friends

std::ostream & operator<< (std::ostream &os, const SpanAllocator &allocator)
 

Detailed Description

Span allocator is a stacked-list for allocating memory for spans. The following graph illustrate the general structure for SpanAllocator.

buckets | v [ 0 ] -> [ 1 ] -> [ 2 ] ... [B-1] | v [ B ] -> [B+1] -> [B+2] ... [2*B-1] | v ... Each time there is not enough memory for spans in buckets, the buckets array, which is the header array, is reallocated, but the stacked-list is not reallocated. It guarentee that the allocated span's address is not modified.

Constructor & Destructor Documentation

ZGen::BestFirst::SpanAllocator::SpanAllocator ( int  reserved_num_spans = 1,
int  bucket_size = 65535 
)

Initialize the span allocator with the total number of spans, the size of each buckets.

Parameters
[in]num_spansThe total number of spans in the allocator.
[in]bucket_sizeThe number of elements in each buckets.

Member Function Documentation

void ZGen::BestFirst::SpanAllocator::clear ( )

Batchly clear all the spans in the Pool. The

Span * ZGen::BestFirst::SpanAllocator::malloc ( )

Malloc a Span instance.

Returns
Span* The Span instance.
void ZGen::BestFirst::SpanAllocator::pruge ( )

Clear all the instance in pool.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const SpanAllocator allocator 
)
friend

Print the allocator information onto the stream, [Not Impl].

Parameters
in/out]os
[in]allocator

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