RefRows.h

Classes

RefRows -- Class holding the row numbers in a RefTable (full description)
RefRowsSliceIter -- Class to iterate through a RefRows object. (full description)

class RefRows

Interface

Public Members
RefRows (const Vector<uInt>& rowNumbers, Bool isSliced = False, Bool collapse = False)
RefRows (uInt start, uInt end, uInt incr=1)
RefRows (const RefRows& other)
RefRows& operator= (const RefRows& other)
~RefRows()
Bool operator== (const RefRows& other) const
Vector<uInt> convert (const Vector<uInt>& rootRownrs) const
uInt nrows() const
uInt nrow() const
uInt firstRow() const
Bool isSliced() const
const Vector<uInt>& rowVector() const
Private Members
uInt fillNrows() const

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Synopsis

RefRows is used to hold the row numbers forming a view on another table. It contains a vector which can hold the row numbers in 2 ways:
  1. As a normal series of row numbers. This is used by e.g. class RefTable
  2. As a series of Slices. In this case 3 subsequent entries in the vector are used to represent start, end, and increment. This is used by a function like ScalarColumn::getColumnRange.
Class RefRowsSliceIter can be used to iterate through a RefRows object. Each step in the iteration goes to the next a slice. If the RefRows objct contains a simple series of row numbers, each slice contains only one row number. This can degrade performance, so it is possible to use shortcuts by testing if the object contains slices (using isSliced()) and getting the row number vector directly (using rowVector()).

Motivation

RefRows is meant to have one class representing the various ways of picking row numbers. This simplifies the interface of the table and data manager classes dealing with getting/putting the data.

Member Description

RefRows (const Vector<uInt>& rowNumbers, Bool isSliced = False, Bool collapse = False)

Create the object from a Vector containing the row numbers. When isSliced==False, the vector is treated as containing individual row numbers, otherwise as containing slices in the form start,end,incr. When collapse==True, it will try to collapse the individual row numbers to the slice form (to save memory).

RefRows (uInt start, uInt end, uInt incr=1)

Create the object from a single start,end,incr slice.

RefRows (const RefRows& other)

Copy constructor (reference semantics).

RefRows& operator= (const RefRows& other)

Assignment (copy semantics).

~RefRows()

Bool operator== (const RefRows& other) const

Do this and the other object reference the same rows?

Vector<uInt> convert (const Vector<uInt>& rootRownrs) const

Convert this object to a Vector by applying the given row numbers. It is used to convert the RefRows object with row numbers in a RefTable to row numbers in the original root table.

uInt nrows() const
uInt nrow() const

Return the number of rows given by this object. If the object contains slices, it counts the number of rows represented by each slice.

uInt firstRow() const

Return the first row in the object.

Bool isSliced() const

Represents the vector a slice?

const Vector<uInt>& rowVector() const

Get the row vector as is (thus sliced if the object contains slices). It is mainly useful to get all row numbers when the object does not contain slices.

uInt fillNrows() const

Fill the itsNrows variable.

class RefRowsSliceIter

Interface

Public Members
RefRowsSliceIter (const RefRows&)
void reset()
Bool pastEnd() const
void operator++()
void operator++(int)
void next()
uInt sliceStart() const
uInt sliceEnd() const
uInt sliceIncr() const

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:
  • tRefRows.cc

Prerequisite

Synopsis

RefRowsSliceIter is useful to iterate through a RefRows object, especially if the RefRows object contains slices. Each step in the iteration returns a Slice object containing the next slice in the RefRows object.
It is used in Table and data manager classes (e.g. StManColumn).

Example

This example shows how to iterate through a RefRows object (giving a slice) and through each of the slices.
    void somefunc (const RefRows& rownrs)
      // Iterate through all slices.
      RefRowsSliceIter rowiter(rownrs);
      while (! rowiter.pastEnd()) {
        // Get start, end, and increment for this slice.
        uInt rownr = rowiter.sliceStart();
        uInt end = rowiter.sliceEnd();
        uInt incr = rowiter.sliceIncr();
        // Iterate through the row numbers in the slice.
        while (rownr <= end) {
          rownr += incr;
        }
        // Go to next slice.
        rowiter++;
      }
    }
    

Member Description

RefRowsSliceIter (const RefRows&)

Construct the iterator on a RefRows object. It is set to the beginning.

void reset()

Reset the iterator to the beginning.

Bool pastEnd() const

Is the iterator past the end?

void operator++()
void operator++(int)
void next()

Go the next slice.

uInt sliceStart() const
uInt sliceEnd() const
uInt sliceIncr() const

Get the current slice start, end, or increment..