Go to the previous, next section.
#include <nihcl/SortedCltn.h>
A
SortedCltn
is similar to an
OrderedCltn
, except that the objects in the
SortedCltn
are kept in ascending order, as determined by their virtual function
compare()
, rather than by the sequence in which the objects are added.
SortedCltn(unsigned
capacity
=DEFAULT_CAPACITY)
SortedCltn
that can hold up to
capacity
objects. An
NIHCL_ALLOCSIZE
error is raised if
capacity
is not greater than 0. If an attempt is made to add more than
capacity
objects to a
SortedCltn
,
reSize()
is called to increase its capacity.
virtual Object* add(Object&
ob)
SortedCltn
and returns a pointer to
ob. A
SortedCltn
applies the virtual function
compare()
to determine where the object is inserted. Objects that
compare()
the same are kept in the sequence in which they were added.
Object* remove(const Object&
ob)
SortedCltn
that
compare()
s equal to
ob, and returns a pointer to it. Returns
nil
if no equal object is found.
int findIndexOf(const Object&
key) const
SortedCltn
and returns an index to a pointer to an object which
compare()
s equal to the argument
key. However, this is not necessarily the index of the
first
object pointer of a sequence of equal objects. Returns -1 if
key
is less than all other objects in this
SortedCltn
, or if this
SortedCltn
is empty. If no object in this
SortedCltn
is equal to
key, returns the greatest pointer index of an object that is less than
key.
virtual unsigned occurrencesOf(const Object&
ob) const
SortedCltn
that
compare()
equal to
ob.
Range findRangeOf(const Object&
key) const
compare()
equal to
key. If no equal objects are found, returns a zero-length
Range
whose
firstIndex()
is the index at which
key
would be inserted in this
SortedCltn
.
int findIndexOfFirstKey(int
i) const
int findIndexOfLastKey(int
i) const
compare()
equal to the object at index
i.
virtual Object* addAfter(const Object&
ob, Object&
newob)
virtual Object* addAllLast(const OrderedCltn&)
virtual Object* addBefore(const Object&
ob, Object&
newob)
virtual Object* addLast(Object&
ob)
virtual void atAllPut(Object&
ob)
virtual int indexOfSubCollection(const SeqCltn&
cltn, int
start
=0) const
virtual void replaceFrom(int
start, int
stop, const SeqCltn&
replacement, int
startAt
=0)
virtual void sort()
shouldNotImplement()
.
Go to the previous, next section.