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

Go to the previous, next section.

Arraychar--Byte Array

SYNOPSIS

#include <nihcl/Arraychar.h>

BASE CLASS

Collection

DERIVED CLASSES

None

RELATED CLASSES

None

DESCRIPTION

Class Arraychar provides a basic, one dimensional array of bytes or characters. Bytes are indexed originating at 0, with (optional) index range checking.

Class Arraychar is an example of a parameterized type. Most of the code for this class is generated from the `Array_h.m4' and `Array_c.m4' m4 macro templates. Classes for basic, one dimensional arrays of other fundamental types can be generated from these same macros.

CONSTRUCTORS

Arraychar(unsigned capacity =DEFAULT_CAPACITY)
Constructs an instance of an Arraychar with a capacity of capacity characters and initializes each character to zero. An NIHCL_ALLOCSIZE error is raised if capacity is not greater than 0.

Arraychar(const Arraychar&)
The copy constructor for class Arraychar.

REMOVING OBJECTS

virtual void removeAll()
Clears all characters of this Arraychar to zero.

SEARCHING

virtual unsigned hash() const
Returns a number that classes such as Set can use as a hash table probe.

RELATIONAL OPERATORS

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

COMPARING ARRAYCHARS

virtual int compare(const Object& a) const
Compares this Arraychar with the argument Arraychar a and returns a negative result if this Arraychar is less than a, zero if this Arraychar equals a, and a positive result if this Arraychar is greater than a. This is a lexical comparison--if Arraychars of unequal size are compared, the shorter Arraychar will be considered less than the longer if it matches the first part of the longer Arraychar.

TESTING ARRAYCHARS

virtual bool isEqual(const Object& a) const
Returns YES if this Arraychar and the argument object are comparable, they have the same size, and the corresponding characters they contain are equal. The argument object a is comparable if it returns the address of class Arraychar's class descriptor for its species().

COPYING ARRAYCHARS

void operator=(const Arraychar&)
Replaces the left Arraychar operand with a copy of the right Arraychar operand.

virtual void deepenShallowCopy()
Converts this shallow copy to a deep copy.

INDEXING ARRAYCHARS

char& elem(int i)
const char& elem(int i) const
char& operator[](int i)
const char& operator[](int i) const
Returns a reference to the ith char in this Arraychar. Zero-origin index is used--characters are indexed from 0 to size()-1. The operator[] functions perform a range check on the index i and raise an NIHCL_INDEXRANGE error if i is out of bounds. The elem() functions do not perform a range check.

ARRAYCHAR CAPACITY AND SIZE

virtual unsigned capacity() const
virtual unsigned size() const
Returns the number of characters in this Arraychar.

virtual void reSize(unsigned newSize)
Changes the capacity (size) of this Arraychar to newSize characters, which must be greater than 0. If the capacity is increased the additional characters are uninitialized.

PRINTING ARRAYCHARS

virtual void dumpOn(ostream& strm =cerr) const
Prints the class name of this Arraychar, a left square bracket, calls printOn() to print the contents of this Arraychar, then prints a right square bracket and a newline.

virtual void printOn(ostream& strm =cout) const
Prints the characters in this Arraychar in hexadecimal on strm.

SORTING ARRAYCHARS

virtual void sort()
Sorts the characters in this Arraychar into ascending order.

ARRAYCHAR SPECIES

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

PROTECTED MEMBERS

Object I/O

virtual void storer(OIOofd& fd) const
virtual void storer(OIOout& strm) const
Stores this Arraychar on fd or strm by using OIOofd.put() or OIOout.put().

DISABLED MEMBER FUNCTIONS

virtual Object* add(Object&)
virtual Object*& at(int)
virtual const Object *const& at(int) const
virtual Object* doNext(Iterator&) const
virtual unsigned occurrencesOf(const Object&) const
virtual Object* remove(const Object&)
virtual void removeAll()
These functions are implemented as shouldNotImplement().

EXCEPTIONS RAISED

NIHCL_ALLOCSIZE, NIHCL_INDEXRANGE

Go to the previous, next section.