ZGen  0.2.0
a linearization system for natural language.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
span_allocator.h
Go to the documentation of this file.
1 #ifndef __ZGEN_BESTFIRST_SPAN_POOL_H__
2 #define __ZGEN_BESTFIRST_SPAN_POOL_H__
3 
5 
6 namespace ZGen {
7 
8 namespace BestFirst {
9 
28 public:
36  SpanAllocator(int reserved_num_spans= 1,
37  int bucket_size=65535);
38 
44  Span* malloc();
45 
49  void clear();
50 
54  void pruge();
55 
62  friend std::ostream& operator << (std::ostream& os, const SpanAllocator& allocator);
63 private:
64  Span** buckets; /*< The real memory for storing the spans.*/
65 
66  Span* next_valid_span;
67 
68  int bucket_size; /*< The size of buckets */
69  int num_buckets; /*< The number of buckets. */
70  int cap_buckets; /*< The capcity of buckets. */
71  int num_spans_left_in_bucket;
72  int num_spans; /*< The total number of spans in buckets */
73 };
74 
75 }
76 
77 }
78 
79 #endif // end for __ZGEN_BESTFIRST_SPAN_POOL_H__
void pruge()
Definition: span_allocator.cc:73
friend std::ostream & operator<<(std::ostream &os, const SpanAllocator &allocator)
Span * malloc()
Definition: span_allocator.cc:30
Definition: span_allocator.h:27
Definition: span.h:13
void clear()
Definition: span_allocator.cc:59
SpanAllocator(int reserved_num_spans=1, int bucket_size=65535)
Definition: span_allocator.cc:8