/[eiffelstudio]/trunk/eweasel/tests/incr071/sequence.e
ViewVC logotype

Contents of /trunk/eweasel/tests/incr071/sequence.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65297 - (show annotations)
Thu Nov 30 20:22:33 2006 UTC (13 years ago) by manus
File size: 2753 byte(s)
Moved from trunk/Src/eweasel to trunk/eweasel so that a simple checkout of the source code is not penalized by the lenghty process of checking out all the tests of eweasel.
1 indexing
2
3 description:
4 "Finite sequences: structures where existing items are arranged%
5 %and accessed sequentially, and new ones can be added at the end.";
6
7 status: "See notice at end of class";
8 names: sequence;
9 access: cursor, membership;
10 contents: generic;
11 date: "$Date$";
12 revision: "$Revision$"
13
14 deferred class SEQUENCE [G] inherit
15
16 ACTIVE [G]
17 redefine
18 prune_all
19 end;
20
21 BILINEAR [G];
22
23 FINITE [G]
24
25 feature -- Status report
26
27 readable: BOOLEAN is
28 -- Is there a current item that may be read?
29 do
30 Result := not off
31 end;
32
33
34 writable: BOOLEAN is
35 -- Is there a current item that may be modified?
36 do
37 Result := not off
38 end;
39
40 feature -- Element change
41
42 force (v: like item) is
43 -- Add `v' to end.
44 require
45 extendible: extendible
46 do
47 extend (v)
48 ensure then
49 new_count: count = old count + 1;
50 item_inserted: has (v)
51 end;
52
53 append (s: SEQUENCE [G]) is
54 -- Append a copy of `s'.
55 require
56 argument_not_void: s /= Void
57 local
58 l: like s
59 do
60 if s = Current then
61 l := s.deep_twin
62 else
63 l := s
64 end
65 from
66 l.start
67 until
68 l.exhausted
69 loop
70 extend (l.item);
71 l.forth
72 end
73 ensure
74 new_count: count >= old count
75 end;
76
77 put (v: like item) is
78 -- Add `v' to end.
79 do
80 extend (v)
81 ensure then
82 new_count: count = old count + 1;
83 end;
84
85 feature -- Removal
86
87 prune (v: like item) is
88 -- Remove the first occurrence of `v' if any.
89 -- If no such occurrence go `off'.
90 do
91 start;
92 search (v);
93 if not exhausted then
94 remove
95 end
96 end;
97
98 prune_all (v: like item) is
99 -- Remove all occurrences of `v'; go `off'.
100 do
101 from
102 start
103 until
104 exhausted
105 loop
106 search (v);
107 if not exhausted then
108 remove
109 end
110 end
111 end;
112
113 end -- class SEQUENCE
114
115
116 --|----------------------------------------------------------------
117 --| EiffelBase: Library of reusable components for Eiffel.
118 --| Copyright (c) 1993-2006 University of Southern California and contributors.
119 --| For ISE customers the original versions are an ISE product
120 --| covered by the ISE Eiffel license and support agreements.
121 --| EiffelBase may now be used by anyone as FREE SOFTWARE to
122 --| develop any product, public-domain or commercial, without
123 --| payment to ISE, under the terms of the ISE Free Eiffel Library
124 --| License (IFELL) at http://eiffel.com/products/base/license.html.
125 --|
126 --| Interactive Software Engineering Inc.
127 --| ISE Building, 2nd floor
128 --| 270 Storke Road, Goleta, CA 93117 USA
129 --| Telephone 805-685-1006, Fax 805-685-6869
130 --| Electronic mail <info@eiffel.com>
131 --| Customer support e-mail <support@eiffel.com>
132 --| For latest info see award-winning pages: http://eiffel.com
133 --|----------------------------------------------------------------
134

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23