Akzeptanz und Vergleichbarkeit

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

SortedBinaryTrees.om
PROCEDURE Acceptable(tree: Tree;
                     object: Objects.Object) : BOOLEAN;
   (* returns TRUE if object may be inserted into tree,
      i.e. if it is comparable to other objects of that tree
      and if there is no object yet in tree that is
      identical to object
   *)
   VAR
      parent, node: Node; (* not used *)
BEGIN
   RETURN tree.comparable(object) &
          ~Find(tree, object, parent, node)
END Acceptable;

PROCEDURE Comparable(tree: Tree;
                     key: Objects.Object) : BOOLEAN;
   (* returns TRUE if key can be compared to
      objects of tree
   *)
BEGIN
   RETURN tree.comparable(key)
END Comparable;

*Dieses Modul besteht darauf, daß jeder Vergleichswert innerhalb eines Baumes eindeutig sein muß.
 
*Das hat den Vorteil, daß Delete und Lookup eindeutig definiert sind.
 

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1999 Andreas Borchert, in HTML konvertiert am 29.06.1999