WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_40.html taken on Sat Jun 10 19:13:57 1995

Go to the previous, next section.

Range--Range of Integers

SYNOPSIS

#include <nihcl/Range.h>

BASE CLASS

Object

DERIVED CLASSES

None

RELATED CLASSES

String, Regex

DESCRIPTION

Instances of class Range represent a range of integers, expressed as the lower bound, or first index, and the length. Ranges are particularly useful for describing substrings.

CONSTRUCTORS

Range()
Constructs a Range with a first index of 0 and a length of -1. This is an invalid Range; that is, the member function valid() will return NO if applied to this Range.

Range(int first, int length)
Constructs a Range with a first index of first and a length of length.

ACCESSING RANGES

int firstIndex() const
int lastIndex() const
int length() const
Returns the first index (lower bound), last index (first+length-1), or length of this Range, respectively.

int firstIndex() const
int lastIndex() const
int length() const
int firstIndex(int first)
int lastIndex(int last)
int length(int len)
Sets the first index (lower bound), last index (first+length-1), or length of this Range, respectively, and returns the new value.

SEARCHING

virtual unsigned hash() const
Returns a number suitable for use as a hash table probe.

RELATIONAL OPERATORS

bool operator==(const Range&) const
bool operator!=(const Range&) const
Returns YES if this Range is equal to (or not equal to) the right operand Range.

TESTING RANGES

virtual bool isEqual(const Object& ob) const
Returns YES if ob is of species Range and equals this Range.

bool valid() const
Returns YES if this Range is valid; that is, the length of this Range is >= 0.

COPYING RANGES

void operator=(const Range&)
Assigns the first index and length of the right operand Range to this Range.

virtual void deepenShallowCopy()
This function is a no-op for class Range.

READING AND PRINTING RANGES

virtual void printOn(ostream& strm =cout) const
Prints this Range on strm in the format first index:length.

RANGE SPECIES

virtual const Class* species() const
Returns a pointer to the class descriptor for class Range.

PROTECTED MEMBERS

Object I/O

virtual void storer(OIOofd& fd) const
virtual void storer(OIOout& strm) const
Stores this Range on fd or strm.

DISABLED MEMBER FUNCTIONS

virtual int compare(const Object&) const
These functions are implemented as shouldNotImplement().

EXCEPTIONS RAISED

None

Go to the previous, next section.