mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-06 14:52:03 +01:00
Author:halw
Date:2008-09-28T19:54:10.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@58 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -16,13 +16,13 @@ The most general class describing sets is [[ref:libraries/base/reference/set_cha
|
||||
The deferred class [[ref:libraries/base/reference/comparable_set_chart|COMPARABLE_SET]] , declared as
|
||||
<code>
|
||||
deferred class
|
||||
[[ref:libraries/base/reference/comparable_set_chart|COMPARABLE_SET]] [G -> [[ref:libraries/base/reference/comparable_chart|COMPARABLE]] ]
|
||||
COMPARABLE_SET [G -> COMPARABLE]
|
||||
|
||||
inherit
|
||||
[[ref:libraries/base/reference/subset_chart|SUBSET]] [G]
|
||||
[[ref:/libraries/base/reference/comparable_struct_chart|COMPARABLE_STRUCT]] [G]
|
||||
SUBSET [G]
|
||||
COMPARABLE_STRUCT [G]
|
||||
...
|
||||
</code>
|
||||
</code>
|
||||
|
||||
describes sets whose items may be compared by a total order relation. The class has the features [[ref:libraries/base/reference/comparable_set_chart|min]] and [[ref:libraries/base/reference/comparable_set_chart|max]] . <br/>
|
||||
Two implementations of [[ref:libraries/base/reference/comparable_set_chart|COMPARABLE_SET]] are provided. One, [[ref:libraries/base/reference/two_way_sorted_set_chart|TWO_WAY_SORTED_SET]] , uses sorted two-way lists. The other, [[ref:libraries/base/reference/binary_search_tree_set_chart|BINARY_SEARCH_TREE_SET]] , uses binary search trees. <br/>
|
||||
|
||||
@@ -80,7 +80,7 @@ Since search operations will follow the same principle (search left if smaller t
|
||||
|
||||
==Cursor Trees==
|
||||
|
||||
Recursive trees, as described so far, are not active data structures: even though each node has its own cursor to traverse the list of its children, there is no global cursor on the tree as a whole. It is not hard to see that the notion of recursive tree is in fact incompatible with the presence of a global cursor. In situations where you need such a cursor, enabling you to move freely from a node to its children, siblings and parents, you may use class [[ref:libraries/base/reference/cursor_tree_chart]] and its descendants.
|
||||
Recursive trees, as described so far, are not active data structures: even though each node has its own cursor to traverse the list of its children, there is no global cursor on the tree as a whole. It is not hard to see that the notion of recursive tree is in fact incompatible with the presence of a global cursor. In situations where you need such a cursor, enabling you to move freely from a node to its children, siblings and parents, you may use class [[ref:libraries/base/reference/cursor_tree_chart|CURSOR_TREE]] and its descendants.
|
||||
|
||||
===The conceptual model===
|
||||
|
||||
@@ -88,7 +88,7 @@ With cursor trees the model is different from what we have seen earlier in this
|
||||
|
||||
===Operations on cursor trees===
|
||||
|
||||
The cursor supported by instances of [[ref:libraries/base/reference/cursor_tree_chart]] has a position referring to a node of the tree, which is then considered to be the active node, or is off the tree. The different off positions are: [[ref:libraries/base/reference/cursor_tree_chart|above]] (above the root), [[ref:libraries/base/reference/cursor_tree_chart|below]] (below a leaf), [[ref:libraries/base/reference/cursor_tree_chart|before]] (before a leftmost sibling), [[ref:libraries/base/reference/cursor_tree_chart|after]] (after a rightmost sibling.) As with linear structures, fictitious sentinel elements are assumed to be present to the left, right, top and bottom. <br/>
|
||||
The cursor supported by instances of [[ref:libraries/base/reference/cursor_tree_chart|CURSOR_TREE]] has a position referring to a node of the tree, which is then considered to be the active node, or is off the tree. The different off positions are: [[ref:libraries/base/reference/cursor_tree_chart|above]] (above the root), [[ref:libraries/base/reference/cursor_tree_chart|below]] (below a leaf), [[ref:libraries/base/reference/cursor_tree_chart|before]] (before a leftmost sibling), [[ref:libraries/base/reference/cursor_tree_chart|after]] (after a rightmost sibling.) As with linear structures, fictitious sentinel elements are assumed to be present to the left, right, top and bottom. <br/>
|
||||
Various procedures are available to move the cursor in all directions:
|
||||
* [[ref:libraries/base/reference/cursor_tree_chart|down (i)]] moves the cursor down to the <code> i </code>-th child of the active node. If <code> i </code> is equal to 0 the cursor ends up before; if <code> i </code> is equal to the arity of the current parent plus 1, the cursor ends up [[ref:libraries/base/reference/cursor_tree_chart|after]] . Calling [[ref:libraries/base/reference/cursor_tree_chart|down (i)]] when the cursor is on a leaf node results in setting [[ref:libraries/base/reference/cursor_tree_chart|below]] and [[ref:libraries/base/reference/cursor_tree_chart|before]] to true if <code> i </code> is equal to 0, or [[ref:libraries/base/reference/cursor_tree_chart|below]] and [[ref:libraries/base/reference/cursor_tree_chart|after]] to true if is equal to arity+1.
|
||||
* [[ref:libraries/base/reference/cursor_tree_chart|forth]] and [[ref:libraries/base/reference/cursor_tree_chart|back]] move the cursor forward and backward between siblings and can cause the cursor to end up [[ref:libraries/base/reference/cursor_tree_chart|after]] or [[ref:libraries/base/reference/cursor_tree_chart|before]] .
|
||||
|
||||
Reference in New Issue
Block a user