Class RTS_Head

All Implemented Interfaces:
Runnable

public class RTS_Head extends RTS_Linkage

System class Head.

 linkage class head;
         begin
            ref (link) procedure first; first :- suc;
            ref (link) procedure last;   last :- pred;
            Boolean procedure empty;    empty := SUC == this linkage;

            integer procedure cardinal;
            begin integer i;
               ref (link) ptr;
               ptr :- first;
               while ptr =/= none do begin
                  i   := i+1;
                  ptr :- ptr.suc
               end while;
               cardinal := i
            end cardinal;

            procedure clear;  while first =/= none do first.out;

            SUC :- PRED :- this linkage
         end head;

An object of the class "head", or a subclass of "head" is used to represent a set. "head" objects may not acquire set membership. Thus, a unique "head" is defined for each set.

Link to GitHub: Source File.

Author:
SIMULA Standards Group, Øystein Myhre Andersen
  • Constructor Details

    • RTS_Head

      public RTS_Head(RTS_RTObject SL)

      Construct a new set(Head) with no members.

      The references SUC and PRED initially point to the "head" itself, which thereby represents an empty set.

      Parameters:
      SL - staticLink
  • Method Details

    • _STM

      public RTS_Head _STM()
      Description copied from class: RTS_RTObject
      Method representing the Statements in this Block
      This method is virtual and must be redefined in blocks.
      Overrides:
      _STM in class RTS_Linkage
      Returns:
      a pointer to this _RTObject
    • first

      public RTS_Link first()
      The procedure "first" may be used to obtain a reference to the first member of the set.
      Returns:
      The first member of the set(Head)
    • last

      public RTS_Link last()
      The procedure "last" may be used to obtain a reference to the last member of the set.
      Returns:
      The last member of the set(Head)
    • empty

      public boolean empty()
      The Boolean procedure "empty" gives the value true only if the set has no members.
      Returns:
      true iff no members.
    • cardinal

      public int cardinal()
      The integer procedure "cardinal" counts the number of members in a set.
      Returns:
      the number of members in this set
    • clear

      public void clear()
      The procedure "clear" removes all members from the set.