WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_43.html taken on Sat Jun 10 19:14:00 1995

Go to the previous, next section.

SeqCltn--Abstract Class for Ordered, Indexed Collections

SYNOPSIS

#include <nihcl/SeqCltn.h>

BASE CLASS

Collection

DERIVED CLASSES

Heap, LinkedList, OrderedCltn, Stack

RELATED CLASSES

Iterator

DESCRIPTION

Class SeqCltn (Sequenceable Collection) is an abstract class that defines general functions for derived classes such as LinkedList, OrderedCltn, and Stack, whose elements are ordered and accessible by means of an integer index.

ADDING OBJECTS

virtual void atAllPut(Object& ob) = 0
Replaces all object pointers in this SeqCltn with pointers to the object ob.

@item{virtual void replaceFrom(int start, int stop, const SeqCltn& replacement,} @itemx{int startAt = 0) = 0} Replaces the sequence of object pointers in this SeqCltn beginning at index start through index stop with object pointers from the SeqCltn replacement starting at index startAt.

SEARCHING

virtual unsigned hash() const
Returns a number that classes such as Set can use as a hash table probe. Class SeqCltn implements hash() by exclusive ORing the results of applying hash() to all objects in the SeqCltn.

virtual int indexOf(const Object& ob) const
Returns the index of the pointer to the first object in this SeqCltn that is isEqual() to ob. Returns -1 if no equal object is found.

virtual int indexOfSubCollection(const SeqCltn& cltn, int start = 0) const = 0
Returns the index of the pointer to the first object in this SeqCltn of the sequence of objects that is isEqual to cltn. The search for an equal sequence begins at offset start in this SeqCltn. Returns -1 if no equal sequence of objects is found.

virtual unsigned occurrencesOf(const Object& ob) const
Returns a count of the number of objects in this SeqCltn that are isEqual() to ob.

COMPARING SEQCLTNS

virtual int compare(const Object& a) const
The argument a must be a derived class of SeqCltn; if not, an NIHCL_BADARGCL exception is raised. Does a lexical comparison of this SeqCltn and the argument object a and returns a negative result if this SeqCltn is less than a, zero if they are equal, and a positive result if this SeqCltn is greater than a. The compare() function compares the individual objects in the sequenced collections by applying compare() to them.

TESTING SEQCLTNS

virtual bool isEqual(const Object& ob) const
Returns YES if ob is a kind of SeqCltn that is the same size as this SeqCltn, and all corresponding objects are equal, as determined by application of isEqual().

INDEXING SEQCLTNS

virtual Object* first() const
Returns a pointer to the first object in this SeqCltn, i.e., the object at index 0.

virtual Object* last() const
Returns a pointer to the last object in this SeqCltn, i.e, the object at index size()-1.

SUPPORT FOR ITERATORS

virtual Object* doNext(Iterator& pos) const
Returns a pointer to the next object in this SeqCltn, or 0 if no more objects remain. The Iterator argument pos maintains the state of the iteration for a container so that multiple iterations may be active concurrently for the same container.

SEQCLTN SPECIES

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

PROTECTED MEMBERS

Exception Handling

void indexRangeErr() const
Raises an NIHCL_INDEXRANGE exception.

EXCEPTIONS RAISED

NIHCL_RDABSTCLASS, NIHCL_INDEXRANGE

Go to the previous, next section.