Generalize definition of SumExpr a little...Lets sum all elements of
[repair.git] / Repair / RepairInterpreter / list.cc
1 #include "list.h"
2 //#include "dmalloc.h"
3
4 List::List() {
5   array=new void*[INITIAL_LIST_SIZE];
6   length=0;
7   arraysize=INITIAL_LIST_SIZE;
8 }
9
10 List::~List() {
11   delete[](array);
12 }
13
14 void List::addobject(void *object) {
15   if ((length+1)>arraysize) {
16     void **oldarray=array;
17     int oldarraysize=arraysize;
18     arraysize*=2;
19     array=new void*[arraysize];
20     for(int i=0;i<length;i++)
21       array[i]=oldarray[i];
22     delete[](oldarray);
23   }
24   array[length++]=object;
25 }
26
27 void List::toArray(void **writearray) {
28   for(int i=0;i<length;i++) {
29     writearray[i]=array[i];
30   }
31 }
32
33 unsigned int List::size() {
34   return length;
35 }