Go to the previous, next section.
#include <nihcl/Link.h>
Link
is an abstract class that provides the storage for the forward pointer to the next instance on a
LinkedList
; thus, only instances of classes derived from class
Link
can be placed on a
LinkedList
.
Instances of class
Link
may be constructed with the forward pointer initialized with the address of the following
Link
or initialized to
NULL
(0). A
Link
with a non-zero forward pointer is considered to be on a
LinkedList
---destroying a
Link
with a non-zero forward pointer causes an
NIHCL_DELLNK
exception to be raised.
Class
Link
defines a special, static instance of class
Link
called the
nil link. Class
LinkedList
marks the last
Link
on a linked list by setting its forward pointer to the address of the nil link. The member function
Link::isListEnd()
tests the forward pointer of a
Link
to see if it equals the address of the nil link, and hence is the last
Link
on a
LinkedList
.
Link* nextLink() const
Link
following this
Link
.
Link* nextLink(Link*
nextlink)
Link
following this
Link
and returns a pointer to
nextlink.
virtual unsigned hash() const = 0
virtual int compare(const Object&
ob) const = 0
Link
with the argument
Object
ob
and returns a negative result if this
Link
is less than
ob, zero if this
Link
equals
ob, and a positive result if this
Link
is greater than
ob.
bool isListEnd() const
YES
if this
Link
is the last
Link
on a
LinkedList
.
virtual bool isEqual(const Object&
ob) const = 0
YES
if this
Link
and the argument
ob
are comparable and they have equal values. Note that the functions
isEqual()
and
hash()
must be consistently defined; that is, if two objects are
isEqual()
, then they must return the same value for
hash()
.
virtual Object* copy() const
Link
by applying
deepCopy()
, and returns a pointer to the copy.
virtual void deepenShallowCopy()
Link
.
virtual void printOn(ostream&
strm
=cout) const = 0
Link
on the output stream
strm.
Link()
Link
with the pointer to the following
Link
set to
NULL
(0).
Link(Link*
nextlink)
Link
with the pointer to the following
Link
set to
nextlink.
Link(const Link&)
Link
, setting the pointer to the following
Link
to
NULL
(0).
NIHCL_DELLNK
Go to the previous, next section.