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

Go to the previous, next section.

Link--Abstract Class for LinkedList Links

SYNOPSIS

#include <nihcl/Link.h>

BASE CLASS

Object

DERIVED CLASSES

LinkOb, Process

RELATED CLASSES

LinkedList

DESCRIPTION

Class 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.

ACCESSING LINKS

Link* nextLink() const
Returns a pointer to the Link following this Link.

Link* nextLink(Link* nextlink)
Sets nextlink as the Link following this Link and returns a pointer to nextlink.

SEARCHING

virtual unsigned hash() const = 0
Returns a number suitable for use as a hash table probe.

COMPARING LINKS

virtual int compare(const Object& ob) const = 0
Compares this 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.

TESTING LINKS

bool isListEnd() const
Returns YES if this Link is the last Link on a LinkedList.

virtual bool isEqual(const Object& ob) const = 0
Returns 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().

COPYING LINKS

virtual Object* copy() const
Copies this Link by applying deepCopy(), and returns a pointer to the copy.

virtual void deepenShallowCopy()
This function is a no-op for class Link.

READING AND PRINTING LINKS

virtual void printOn(ostream& strm =cout) const = 0
Prints this Link on the output stream strm.

PROTECTED MEMBERS

Constructors

Link()
Constructs a Link with the pointer to the following Link set to NULL (0).

Link(Link* nextlink)
Constructs a Link with the pointer to the following Link set to nextlink.

Link(const Link&)
Copies the argument Link, setting the pointer to the following Link to NULL (0).

EXCEPTIONS RAISED

NIHCL_DELLNK

Go to the previous, next section.