Go to the previous, next section.
#include <nihcl/Arraychar.h>
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.
Arraychar(unsigned
capacity
=DEFAULT_CAPACITY)
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&)
Arraychar
.
virtual void removeAll()
Arraychar
to zero.
virtual unsigned hash() const
Set
can use as a hash table probe.
bool operator==(const Arraychar&) const
bool operator!=(const Arraychar&) const
YES
if the left
Arraychar
operand is equal to (or not equal to) the right
Arraychar
operand.
virtual int compare(const Object&
a) const
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
Arraychar
s 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
.
virtual bool isEqual(const Object&
a) const
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()
.
void operator=(const Arraychar&)
Arraychar
operand with a copy of the right
Arraychar
operand.
virtual void deepenShallowCopy()
char& elem(int
i)
const char& elem(int
i) const
char& operator[](int
i)
const char& operator[](int
i) const
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.
virtual unsigned capacity() const
virtual unsigned size() const
Arraychar
.
virtual void reSize(unsigned
newSize)
Arraychar
to
newSize
characters, which must be greater than 0. If the capacity is increased the additional characters are uninitialized.
virtual void dumpOn(ostream&
strm
=cerr) const
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
Arraychar
in hexadecimal on
strm.
virtual void sort()
Arraychar
into ascending order.
virtual const Class* species() const
Arraychar
.
virtual void storer(OIOofd&
fd) const
virtual void storer(OIOout&
strm) const
Arraychar
on
fd
or
strm
by using
OIOofd.put()
or
OIOout.put()
.
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()
shouldNotImplement()
.
NIHCL_ALLOCSIZE
,
NIHCL_INDEXRANGE
Go to the previous, next section.