1 |
indexing |
2 |
|
3 |
description: |
4 |
"Structures that may be traversed forward and backward"; |
5 |
|
6 |
status: "See notice at end of class"; |
7 |
names: bidirectional, traversing; |
8 |
access: cursor, membership; |
9 |
contents: generic; |
10 |
date: "$Date$"; |
11 |
revision: "$Revision$" |
12 |
|
13 |
deferred class BILINEAR [G] inherit |
14 |
|
15 |
LINEAR [G] |
16 |
rename |
17 |
search as sequential_search |
18 |
export |
19 |
{NONE} |
20 |
sequential_search |
21 |
redefine |
22 |
off |
23 |
end; |
24 |
|
25 |
LINEAR [G] |
26 |
redefine |
27 |
search, off |
28 |
select |
29 |
search |
30 |
end |
31 |
|
32 |
feature -- Access |
33 |
|
34 |
off: BOOLEAN is |
35 |
-- Is there no current item? |
36 |
do |
37 |
Result := before or after |
38 |
end; |
39 |
|
40 |
feature -- Cursor movement |
41 |
|
42 |
before: BOOLEAN is |
43 |
-- Is there no valid position to the left of current one? |
44 |
deferred |
45 |
end; |
46 |
|
47 |
back is |
48 |
-- Move to previous position. |
49 |
require |
50 |
not_before: not before |
51 |
deferred |
52 |
ensure then |
53 |
-- moved_forth_after_start: (not before) implies index = old index - 1 |
54 |
end; |
55 |
|
56 |
search (v: like item) is |
57 |
-- Move to first position (at or after current |
58 |
-- position) where `item' and `v' are equal. |
59 |
-- If structure does not include `v' ensure that |
60 |
-- `exhausted' will be true. |
61 |
-- (Reference or object equality, |
62 |
-- based on `object_comparison'.) |
63 |
do |
64 |
if before and not is_empty then |
65 |
forth |
66 |
end; |
67 |
sequential_search (v) |
68 |
end; |
69 |
|
70 |
invariant |
71 |
|
72 |
not_both: not (after and before) |
73 |
before_constraint: before implies off |
74 |
|
75 |
end -- class BILINEAR |
76 |
|
77 |
|
78 |
--|---------------------------------------------------------------- |
79 |
--| EiffelBase: Library of reusable components for Eiffel. |
80 |
--| Copyright (c) 1993-2006 University of Southern California and contributors. |
81 |
--| For ISE customers the original versions are an ISE product |
82 |
--| covered by the ISE Eiffel license and support agreements. |
83 |
--| EiffelBase may now be used by anyone as FREE SOFTWARE to |
84 |
--| develop any product, public-domain or commercial, without |
85 |
--| payment to ISE, under the terms of the ISE Free Eiffel Library |
86 |
--| License (IFELL) at http://eiffel.com/products/base/license.html. |
87 |
--| |
88 |
--| Interactive Software Engineering Inc. |
89 |
--| ISE Building, 2nd floor |
90 |
--| 270 Storke Road, Goleta, CA 93117 USA |
91 |
--| Telephone 805-685-1006, Fax 805-685-6869 |
92 |
--| Electronic mail <info@eiffel.com> |
93 |
--| Customer support e-mail <support@eiffel.com> |
94 |
--| For latest info see award-winning pages: http://eiffel.com |
95 |
--|---------------------------------------------------------------- |
96 |
|