unsigned int Range::length(void) { // Total number of values specified by a list unsigned int size = 0; RangeList list = rangeList; while(list) { size += list->n_pts(); list = list->next; } return size; }
int Range::index(int ix) { // Value of ix'th index in list RangeList list = rangeList; int n_pts; int iix = ix; while(list) { n_pts = list->n_pts(); if (iix < n_pts) { return list->start + iix * list->step; } list = list->next; iix -= n_pts; } // fell through! fprintf(stderr, "Error: wanted value %d but list length %d\n", ix, length()); abort(); }