--- parser3/src/main/Attic/pa_array.C 2001/11/05 11:46:27 1.43 +++ parser3/src/main/Attic/pa_array.C 2002/02/07 11:55:30 1.45 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: pa_array.C,v 1.43 2001/11/05 11:46:27 paf Exp $ + $Id: pa_array.C,v 1.45 2002/02/07 11:55:30 paf Exp $ */ #include "pa_pool.h" @@ -12,10 +12,7 @@ #include "pa_exception.h" #include "pa_common.h" -Array::Array(Pool& apool, int initial_rows) : - Pooled(apool) { - initial_rows=max(initial_rows, CR_INITIAL_ROWS_DEFAULT); - +void Array::construct_new(int initial_rows) { head=tail=static_cast( malloc(sizeof(int)+sizeof(Chunk::Row)*initial_rows+sizeof(Chunk *), 19)); head->count=initial_rows; @@ -25,6 +22,15 @@ Array::Array(Pool& apool, int initial_ro fused_rows=0; } +Array::Array(Pool& apool, int initial_rows) : Pooled(apool) { + construct_new(max(initial_rows, CR_INITIAL_ROWS_DEFAULT)); +} + +Array::Array(const Array& source, int offset) : Pooled(source.pool()) { + construct_new(source.size()); + append_array(source, offset); +} + void Array::expand(int chunk_rows) { Chunk *chunk=tail=static_cast( malloc(sizeof(int)+sizeof(Chunk::Row)*chunk_rows+sizeof(Chunk *), 2)); @@ -152,6 +158,23 @@ void Array::for_each(For_each_func func, } } +/*void Array::for_each(For_each_func_storage func, void *info) { + Chunk *chunk=head; + while(true) { + if(chunk==tail) { // last chunk? + for(Chunk::Row *row=chunk->rows; row!=append_here; row++) + (*func)(&row->item, info); + break; + } else { + int count=chunk->count; + for(int i=0; irows[i].item, info); + chunk=chunk->rows[count].link; + } + } +} +*/ + /*void Array::for_each(For_each_func_const func, const void *info) const { Chunk *chunk=head; while(true) {