next up previous
Next: BitFiddleClass Up: simlib Previous: AnyObject

Linkage

     NAME
	  linkage - Simset - classes for double-linked lists.

     DESCRIPTION
	  Simset implements an abstraction of a	double-linked list
	  with a head.	An Empty list is recognized as only containing
	  a Head object, which is different from having	no list	at all
	  (no Head object either).

     AUTHOR
	  Goran	Eriksson, Lund Institute of Technology.

	  This is an alternative implementation	of the functionality
	  provided by the class	Simset included	in the Simula
	  standard.  The difference is in the packaging. Here it has
	  the form of three classes in the same	'module'. It can thus
	  be used much more freely than	the standard package, which
	  must be used as a prefix class (at the outermost
	  superclass).

     DECLARATION AND USE
	  With Standard	Simset:
	   Simset  class  PackageA;  ......   <no  use	of  simset  in
	  PackageA>;
	   PackageA class PackageB;
	   begin
	      Link class myNotice; .....;
	   end - PackageB -;


	  With this implementation
	   class PackageA; .....;
	   PackageA class PackageB;
	   begin
	      external class Linkage; !	This also brings in  Link  and
	  Head ;
	      Link class myNotice; ..... ;
	   end - PackageB -;


	  Compilation: simcomp -L=/usr/local/simulabin -I=simlib
	  Linking: simld ... -lsimlib

     DETAILED INTERFACE
     class LINKAGE
	     external class AnyObject;
	     AnyObject class Linkage;
	  Common abstract super	class for Link	and  Head.  Implements
	  fundamental linking capabilites. Should not be used directly
	  in application programs, neither as objects  nor  as	direct
	  super	class.

	  Supers: AnyObject
	  Kind:	Abstract
	  Init:	none
	  Sequencing: -

     Suc
	     ref(Link) procedure Suc;
	  Return the successor of this element in its list, or none if
	  it is	last in	the list or not	in a list at all.

     Pred
	     ref(Link) procedure Pred;
	  Return the predecessor of this element in its	list, or  none
	  if it	is first in the	list or	not in a list at all.

     Prev
	     ref(Linkage) procedure Prev;
	  Return the predecessor of this element in its	list, seen  as
	  a  cyclic  list. The Head object is returned if this element
	  is first in the list or none is returned if it is not	 in  a
	  list at all.

     class HEAD
	     Linkage class Head;
	  Head objects represents a list  by  itself.  An  empty  list
	  consists  of	just  a	 Head  object. Head objects gives also
	  empty	lists identity.	It  also  makes	 traversals  of	 lists
	  simpler since	the head object	act as end-markers.

	  Subclasses of	Head are used to implement operations that are
	  applicable for entire	lists or 'sets', such as traversals.

	  Supers: Linkage, AnyObject
	  Kind:	Subclassable, Instantiable
	  Init:	none
	  Sequencing: (Suc/Pred/Prev/First/Last/Empty/Cardinal/Clear)*

     First
	     ref(Link) procedure First;
	  Return the first element in the list,	or none	if the list is
	  empty.

     Last
	     ref(Link) procedure Last;
	  Return the last element in the list, or none if the list  is
	  empty.

     Empty
	     boolean procedure Empty;
	  Return true if there are no elements in the list.

     Cardinal
	     integer procedure Cardinal;
	  Return the number of elements	in the list, =0	if it is empty

     Clear
	     procedure Clear;
	  Remove all the elements of this list (it becomes empty).

     class LINK
	     Linkage class Link;
	  Link objects represent individual elements that can be  part
	  of  a	list. A	Link object can	be part	of at most one list at
	  a given time,	but can	be moved between lists.	Subclasses  of
	  Link are used	for operations applicable for single elements,
	  and attributes needed	for each object.

	  Supers: Linkage, AnyObject
	  Kind:	Subclassable, Instantiable
	  Init:	none
	  Sequencing: (Suc/Pred/Prev/Out/Follow/Precede/Into)*

     Out
	     procedure Out;
	  If this element is part of a list, remove it from the	list.

     Follow
	     procedure Follow(ptr); ref(Linkage) ptr;
	  Make this element follow the object 'ptr' in a list. If this
	  element  is  part  of	 a list, it is first removed from that
	  list.	If ptr is none,	or not member of any list, there is no
	  other	 effect	 than  the  possible removal.  Notice: calling
	  Follow on a Head object will	insert	this  element  as  the
	  first	element	of the list.

     Precede
	     procedure Precede(ptr); ref(Linkage) ptr;
	  Make this element precede the	object 'ptr'  in  a  list.  If
	  this	element	 is  part  of a	list, it is first removed from
	  that list. If	ptr is none, or	not member of any list,	 there
	  is  no  other	effect than the	possible removal.  Notice: see
	  Into for inserting an	object last in a list.

     Into
	     procedure Into(H);	ref(Head) H;
	  Make this element the	 last  element	of  a  list.  If  this
	  element  is  part  of	 a list, it is first removed from that
	  list.	If H is	none,  there  is  no  other  effect  than  the
	  possible removal.