--- parser3/src/main/Attic/pa_array.C 2001/01/27 15:21:05 1.2 +++ parser3/src/main/Attic/pa_array.C 2003/02/17 13:49:15 1.54.2.3 @@ -1,93 +1,15 @@ -/* - $Id: pa_array.C,v 1.2 2001/01/27 15:21:05 paf Exp $ -*/ - -#include - -#include "pa_pool.h" - -void *Array::operator new(size_t size, Pool *apool) { - return apool->malloc(size); -} - -void Array::construct(Pool *apool, int initial_rows) { - pool=apool; - curr_chunk_rows=initial_rows; - head=static_cast( - pool->malloc(sizeof(int)+sizeof(Chunk::Row)*curr_chunk_rows+sizeof(Chunk *))); - append_here=head->rows; - link_row=&head->rows[curr_chunk_rows]; - link_row->link=0; - fused_rows=0; - - cache_index=0; - cache_row=0; - cache_countdown=curr_chunk_rows; - cache_link_row=link_row; -} - -void Array::expand() { - curr_chunk_rows+=curr_chunk_rows*CR_GROW_PERCENT/100; - Chunk *chunk=static_cast( - pool->malloc(sizeof(int)+sizeof(Chunk::Row)*curr_chunk_rows+sizeof(Chunk *))); - chunk->count=curr_chunk_rows; - link_row->link=chunk; - append_here=chunk->rows; - link_row=&chunk->rows[curr_chunk_rows]; - link_row->link=0; -} - +/** @file + Parser: Array classe impl. -Array& Array::operator += (Item src) { - if(chunk_is_full()) - expand(); - - append_here->item=src; - append_here++; fused_rows++; - - return *this; -} - -/* -char *Array::c_str() { - char *result=static_cast(pool->malloc(size()+1)); - - char *copy_here=result; - Chunk *chunk=&head; - do { - Chunk::Row *row=chunk->rows; - for(int i=0; icount; i++) { - if(row==append_here) - goto break2; - - memcpy(copy_here, row->item.ptr, row->item.size); - copy_here+=row->item.size; - row++; - } - chunk=row->link; - } while(chunk); -break2: - *copy_here=0; - return result; -} -*/ -/* -void Array::put(int index, Item item) { -} - -Array::Item Array::get(int index) { -} + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ -Array::Item& Array::operator [] (int index) { - // we have cached row&index? - if(index>=cache_index && index