 |
NEURON
|
Go to the documentation of this file.
16 #define declarePool(Pool, T) \
19 Pool(long count, int mkmut = 0); \
45 #define implementPool(Pool, T) \
46 Pool::Pool(long count, int mkmut) { \
48 pool_ = new T[count_]; \
50 items_ = new T*[count_]; \
52 for (long i = 0; i < count_; ++i) \
53 items_[i] = pool_ + i; \
64 assert(get_ == put_); \
65 Pool* p = new Pool(count_); \
68 long newcnt = 2 * count_; \
69 T** itms = new T*[newcnt]; \
73 for (i = 0; i < get_; ++i) { \
74 itms[i] = items_[i]; \
78 for (i = get_, j = 0; j < count_; ++i, ++j) { \
79 itms[i] = p->items_[j]; \
83 for (i = put_, j = get_; j < count_; ++i, ++j) { \
84 itms[i] = items_[j]; \
111 if (nget_ >= count_) { \
115 T* item = items_[get_]; \
116 get_ = (get_ + 1) % count_; \
119 if (nget_ > maxget_) { \
127 void Pool::hpfree(T* item) { \
130 items_[put_] = item; \
131 put_ = (put_ + 1) % count_; \
136 void Pool::free_all() { \
144 for (pp = this; pp; pp = pp->chain_) { \
145 for (i = 0; i < pp->pool_size_; ++i) { \
146 items_[put_++] = pp->pool_ + i; \
147 pp->pool_[i].clear(); \
151 assert(put_ == count_); \