home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / exml.lha / exml / examples / ebook / gobo_ext / ds_linked_tree.e < prev    next >
Text File  |  1999-04-13  |  3KB  |  135 lines

  1. indexing
  2.     description:"A linked tree based on the GOBO data structure library"
  3.     status:        "See notice at end of class."
  4.     author:        "Andreas Leitner"
  5.  
  6. class
  7.     DS_LINKED_TREE [G]
  8.  
  9. inherit
  10.     DS_TRAVERSABLE [G]
  11.         redefine
  12.             is_empty
  13.         end
  14.  
  15. creation
  16.     make
  17. feature
  18.     make is
  19.         do
  20.             
  21.         end
  22.  
  23.     new_cursor: DS_LINKED_TREE_CURSOR [G] is
  24.             -- New cursor for traversal
  25.             -- (from DS_BILINEAR)
  26.         do
  27.             !! Result.make (Current)
  28.         end;
  29.  
  30.     item (a_cursor: like new_cursor): G is
  31.         do
  32.             Result := a_cursor.item
  33.         end
  34.  
  35.     put_root (v: G) is
  36.         local
  37.             new_cell: like root_cell
  38.         do
  39.             !! new_cell.make (v)
  40.             root_cell := new_cell
  41.         end
  42.  
  43.  
  44.     root_cell: DS_LINKED_TREE_CELL [G]
  45. feature -- Measurement
  46.  
  47.     count: INTEGER is
  48.             -- Number of items in structure
  49.         local
  50.             cs: DS_LINKED_TREE_CURSOR [G]
  51.         do
  52.             --cs := new_cursor
  53.             if
  54.                 is_empty
  55.             then
  56.                 Result := 0
  57.             else
  58.                 Result := 1
  59.             end
  60.                     
  61.         end
  62.     is_empty: BOOLEAN is
  63.         do
  64.             Result := root_cell = Void
  65.         end
  66.  
  67. feature -- Status report
  68.  
  69. feature -- Comparison
  70.  
  71.     is_equal (other: like Current): BOOLEAN is
  72.             -- Is current structure equal to `other'?
  73.         do
  74.             check False end
  75.         end
  76.  
  77. feature -- Removal
  78.  
  79.     wipe_out is
  80.             -- Remove all items from structure.
  81.         do
  82.             root_cell := Void
  83.         end
  84.  
  85. feature -- Duplication
  86.  
  87.     copy (other: like Current) is
  88.             -- Copy `other' to list.
  89.         do
  90.             check False end
  91.         end;
  92.  
  93.  
  94. feature -- Children
  95.  
  96.     put_first_child (v: G; a_cursor: like new_cursor) is
  97.             -- Add `v' to beginning of list.
  98.         do
  99.             a_cursor.children.put_first (v)
  100.         end
  101.  
  102.     put_last_child (v: G; a_cursor: like new_cursor) is
  103.             -- Add `v' to end of list.
  104.         do
  105.             a_cursor.children.put_last (v)
  106.         end
  107.  
  108.     put_left_child (v: G; a_cursor: like new_cursor) is
  109.             -- Add `v' to left of `a_cursor' position.
  110.         do
  111.             a_cursor.children.put_left (v, a_cursor.children_cursor)
  112.         end
  113.  
  114.     put_right_child (v: G; a_cursor: like new_cursor) is
  115.             -- Add `v' to right of `a_cursor' position.
  116.         do
  117.             a_cursor.children.put_right (v, a_cursor.children_cursor)
  118.         end
  119.  
  120. end -- class DS_LINKED_TREE
  121.  
  122. --|-------------------------------------------------------------------------
  123. --| eXML, Eiffel XML Parser Toolkit
  124. --| Copyright (C) 1999  Andreas Leitner
  125. --| See the file forum.txt included in this package for licensing info.
  126. --|
  127. --| Comments, Questions, Additions to this library? please contact:
  128. --|
  129. --| Andreas Leitner
  130. --| Arndtgasse 1/3/5
  131. --| 8010 Graz
  132. --| Austria
  133. --| email: andreas.leitner@teleweb.at
  134. --| web: http://exml.dhs.org
  135. --|-------------------------------------------------------------------------