/[eiffelstudio]/FreeELKS/trunk/library/structures/cursor_tree/linked_cursor_tree.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/structures/cursor_tree/linked_cursor_tree.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 2 months ago) by manus_eiffel
File size: 3220 byte(s)
Initial revision

1 indexing
2
3 description:
4 "Cursor trees in linked representation"
5
6 status: "See notice at end of class"
7 names: linked_cursor_tree, cursor_tree;
8 access: cursor, membership;
9 representation: recursive, linked;
10 contents: generic;
11 date: "$Date$"
12 revision: "$Revision$"
13
14 class LINKED_CURSOR_TREE [G] inherit
15
16 RECURSIVE_CURSOR_TREE [G]
17 redefine
18 put_right,
19 active, cursor, is_leaf
20 end
21
22 create
23
24 make, make_root
25
26 feature -- Initialization
27
28 make is
29 -- Create an empty tree.
30 local
31 dummy: G
32 do
33 create above_node.make (dummy)
34 active := above_node
35 ensure
36 is_above: above
37 is_empty: is_empty
38 end
39
40 make_root (v: G) is
41 -- Create a tree with `v' as root.
42 do
43 make
44 put_root (v)
45 end
46
47 feature -- Status report
48
49 full: BOOLEAN is False
50 -- Is tree filled to capacity? (Answer: no.)
51
52 prunable: BOOLEAN is True
53
54 is_leaf: BOOLEAN is
55 do
56 if not off then
57 Result := not below and then active.arity = 0
58 end
59 end
60
61 feature -- Access
62
63 cursor: LINKED_CURSOR_TREE_CURSOR [G] is
64 -- Current cursor position
65 do
66 create Result.make (active, active_parent, after, before, below)
67 end
68
69 feature -- Element change
70
71 put_right (v: G) is
72 -- Add `v' to the right of cursor position.
73 do
74 if below then
75 active.child_put_right (v)
76 active.child_forth
77 active_parent := active
78 active := active_parent.child
79 below := False
80 elseif before then
81 active_parent.child_put_left (v)
82 active_parent.child_back
83 active := active_parent.child
84 else
85 active_parent.child_put_right (v)
86 end
87 end
88
89 put_root (v: G) is
90 -- Put `v' as root of an empty tree.
91 require
92 is_empty: is_empty
93 do
94 above_node.child_put_right (v)
95 active_parent := above_node
96 active := active_parent.child
97 ensure
98 is_root: is_root
99 count = 1
100 end
101
102 put_child (v: G) is
103 -- Put `v' as child of a leaf.
104 require
105 is_leaf: is_leaf
106 do
107 down (0)
108 put_right (v)
109 end
110
111 feature {LINKED_CURSOR_TREE} -- Implementation
112
113 new_tree: like Current is
114 -- A newly created instance of the same type.
115 -- This feature may be redefined in descendants so as to
116 -- produce an adequately allocated and initialized object.
117 do
118 create Result.make
119 end
120
121 feature {NONE} -- Implementation
122
123 active: LINKED_TREE [G];
124 -- Current node
125
126 indexing
127
128 library: "[
129 EiffelBase: Library of reusable components for Eiffel.
130 ]"
131
132 status: "[
133 Copyright 1986-2001 Interactive Software Engineering (ISE).
134 For ISE customers the original versions are an ISE product
135 covered by the ISE Eiffel license and support agreements.
136 ]"
137
138 license: "[
139 EiffelBase may now be used by anyone as FREE SOFTWARE to
140 develop any product, public-domain or commercial, without
141 payment to ISE, under the terms of the ISE Free Eiffel Library
142 License (IFELL) at http://eiffel.com/products/base/license.html.
143 ]"
144
145 source: "[
146 Interactive Software Engineering Inc.
147 ISE Building
148 360 Storke Road, Goleta, CA 93117 USA
149 Telephone 805-685-1006, Fax 805-685-6869
150 Electronic mail <info@eiffel.com>
151 Customer support http://support.eiffel.com
152 ]"
153
154 info: "[
155 For latest info see award-winning pages: http://eiffel.com
156 ]"
157
158 end -- class LINKED_CURSOR_TREE
159
160
161

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23