void table_column_range(Table tab, int *xmin, int *xmax) { Vector rows = tab->rows; int low=0, high=0; int y, ymin, ymax; int first = TRUE; table_row_range(tab, &ymin, &ymax); for(y=ymin; y<=ymax; y++) { TableRow row = getElementVector(rows, toInt(y)); if ( row && notNil(row) ) { int l = valInt(getLowIndexVector((Vector)row)); int h = valInt(getHighIndexVector((Vector)row)); if ( first ) { low = l; high = h; first = FALSE; } else { low = min(low, l); high = max(high, h); } } } *xmin = low; *xmax = high; }
status fillVector(Vector v, Any obj, Int from, Int to) { int f, t; f = (isDefault(from) ? valInt(getLowIndexVector(v)) : valInt(from)); t = (isDefault(to) ? valInt(getHighIndexVector(v)) : valInt(to)); if ( t < f ) fail; if ( v->size == ZERO ) { int size = t-f+1; int n; assign(v, offset, toInt(f - 1)); assign(v, size, toInt(size)); assign(v, allocated, v->size); if ( v->elements ) unalloc(0, v->elements); v->elements = alloc(sizeof(Any) * size); for(n=0; n<size; n++) { v->elements[n] = NIL; if ( notNil(obj) ) assignVector(v, n, obj); } } else { elementVector(v, toInt(f), obj); elementVector(v, toInt(t), obj); while( ++f < t ) elementVector(v, toInt(f), obj); } succeed; }
void table_row_range(Table tab, int *ymin, int *ymax) { Vector rows = tab->rows; *ymin = valInt(getLowIndexVector(rows)); *ymax = valInt(getHighIndexVector(rows)); }
static int get_range(Vector v, Int from, Int to, int *f, int *t) { int low = valInt(getLowIndexVector(v)); int high = valInt(getHighIndexVector(v)); if ( low > high ) fail; /* empty vector */ if ( isDefault(to) ) { if ( isDefault(from) ) { *f = low; *t = high; } else /* from, @default */ { int i = valInt(from); if ( i > high ) fail; if ( i < low ) i = low; *f = i; *t = high; } } else { if ( isDefault(from) ) /* @default, to */ { int i = valInt(to); if ( low > i ) fail; if ( i > high ) i = high; *t = i; *f = low; } else /* from, to */ { int i = valInt(from); BOUNDS(i, low, high); *f = i; i = valInt(to); BOUNDS(i, low, high); *t = i; } } succeed; }