/* Dynamic Lists of Numbers; version 1.0 */ /* (c) copyright Ian Hickson 2000, distributed under the GNU GPL */ #include "dynamic-2d-arrays.h" /* array2d stuff */ /* Implements a dynamic list of doubles */ typedef double nlNumber; typedef array2d numberList; numberList* nlAllocList(int entries) { numberList* array; array = allocArray2D(entries, 1, sizeof(nlNumber)); return array; } void nlFreeList(numberList* array) { freeArray2D(array); } void nlSet(numberList* array, int x, nlNumber value) { setArray2D(array, x, 0, &value); } nlNumber nlGet(numberList* array, int x) { nlNumber value; value = *(nlNumber*)getArray2D(array, x, 0); return value; } void nlPrint(numberList* array, int dp) { int x, y; for(x = 0; x < array->width; x++) { printf("%10.*g", dp, nlGet(array, x)); } printf("\n"); } /* end */