--- parser3/src/main/Attic/pa_array.C 2001/01/29 10:15:04 1.6 +++ parser3/src/main/Attic/pa_array.C 2001/01/29 16:37:58 1.8 @@ -1,17 +1,20 @@ /* - $Id: pa_array.C,v 1.6 2001/01/29 10:15:04 paf Exp $ + $Id: pa_array.C,v 1.8 2001/01/29 16:37:58 paf Exp $ */ #include #include "pa_pool.h" +#include "pa_array.h" -void *Array::operator new(size_t size, Pool *apool) { +template +void *Array::operator new(size_t size, Pool *apool) { return apool->malloc(size); } -void Array::construct(Pool *apool, int initial_rows) { - pool=apool; +template +Array::Array(Pool *apool, int initial_rows) : + pool(apool) { head=tail=static_cast( pool->malloc(sizeof(int)+sizeof(Chunk::Row)*initial_rows+sizeof(Chunk *))); head->count=initial_rows; @@ -24,7 +27,8 @@ void Array::construct(Pool *apool, int i cache_chunk=head; } -void Array::expand(int chunk_rows) { +template +void Array::expand(int chunk_rows) { Chunk *chunk=tail=static_cast( pool->malloc(sizeof(int)+sizeof(Chunk::Row)*chunk_rows+sizeof(Chunk *))); chunk->count=chunk_rows; @@ -35,7 +39,8 @@ void Array::expand(int chunk_rows) { } -Array& Array::operator += (Item src) { +template +Array& Array::operator += (Item src) { if(chunk_is_full()) expand(tail->count*CR_GROW_PERCENT/100); @@ -45,7 +50,8 @@ Array& Array::operator += (Item src) { return *this; } -Array::Item& Array::operator [] (int index) { +template +Item& Array::operator [] (int index) { if(!(index>=0 && indexrows[index-cache_chunk_base].item; } -Array& Array::operator += (Array& src) { +template +Array& Array::operator += (Array& src) { int src_used_rows=src.fused_rows; int last_chunk_rows_left=link_row-append_here;