1 -- Created on: 1992-09-11
2 -- Created by: Mireille MERCIEN
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
23 generic class Sequence from TCollection (SeqItem as any)
24 inherits BaseSequence from TCollection
26 ---Purpose: A sequence of items indexed by an integer.
27 -- Sequences have approximately the same goal as
28 -- unidimensional arrays (TCollection_Array1): they are
29 -- commonly used as elementary data structures for more
30 -- complex objects. But a sequence is a structure of
31 -- variable size: sequences avoid the use of large and
32 -- quasi-empty arrays. Exploring a sequence data
33 -- structure is performant when the exploration is done in
34 -- sequence; elsewhere a sequence item is longer to read
35 -- than an array item. Note also that sequences are not
36 -- performant when they have to support numerous
37 -- algorithmic explorations: a map is better for that.
38 -- Sequence is a generic class which depends on Item,
39 -- the type of element in the sequence.
42 NoSuchObject from Standard,
43 OutOfRange from Standard
45 class SequenceNode from TCollection
46 inherits SeqNode from TCollection
47 uses SeqNodePtr from TCollection
49 Create(I : SeqItem; n,p : SeqNodePtr from TCollection) returns SequenceNode from TCollection;
52 Value(me) returns SeqItem;
62 Create returns Sequence;
63 ---Purpose: Constructs an empty sequence.
65 -- - the function Append or Prepend to add an item or
66 -- a collection of items at the end, or at the beginning of the sequence,
67 -- - the function InsertAfter or InsertBefore to add an
68 -- item or a collection of items at any position in the sequence,
69 -- - operator() or the function SetValue to assign a
70 -- new value to an item of the sequence,
71 -- - operator() to read an item of the sequence,
72 -- - the function Remove to remove an item at any
73 -- position in the sequence.
75 -- To copy a sequence, you must explicitly call the
76 -- assignment operator (operator=).
79 Create(Other : Sequence) returns Sequence from TCollection
80 ---Purpose: Creation by copy of existing Sequence.
81 -- Warning: This constructor prints a warning message.
82 -- We recommand to use the operator =.
86 ---Purpose: Removes all element(s) of the sequence <me>
95 Assign(me : in out; Other : Sequence) returns Sequence from TCollection
96 ---Purpose: Copies the contents of the sequence Other into this sequence.
97 -- If this sequence is not empty, it is automatically cleared before the copy.
98 ---C++: alias operator =
99 ---C++: return const &
102 Append(me : in out; T : SeqItem);
104 ---Purpose: Appends <T> at the end of <me>.
111 Append(me : in out; S : in out Sequence)
113 ---Purpose: Concatenates <S> at the end of <me>.
120 -- me = (A B C D E F)
126 Prepend(me : in out; T : SeqItem);
128 ---Purpose: Add <T> at the beginning of <me>.
135 Prepend(me : in out; S : in out Sequence);
137 ---Purpose: Concatenates <S> at the beginning of <me>.
141 -- me = (A B C) S = (D E F)
142 -- after me = (D E F A B C)
147 InsertBefore(me : in out; Index : Integer from Standard; T : SeqItem)
148 raises OutOfRange from Standard;
150 ---Purpose: Inserts <T> in <me> before the position <Index>.
151 -- Raises an exception if the index is out of bounds.
154 -- me = (A B D), Index = 3, T = C
160 InsertBefore(me : in out ; Index : Integer from Standard; S : in out Sequence)
161 raises OutOfRange from Standard;
163 ---Purpose: Inserts the sequence <S> in <me> before
164 -- the position <Index>. <S> is cleared.
165 -- Raises an exception if the index is out of bounds
168 -- me = (A B F), Index = 3, S = (C D E)
170 -- me = (A B C D E F)
175 InsertAfter(me : in out; Index : Integer from Standard; T : SeqItem)
176 raises OutOfRange from Standard;
178 ---Purpose: Inserts <T> in <me> after the position <Index>.
179 -- Raises an exception if the index is out of bound
182 -- me = (A B C), Index = 3, T = D
186 InsertAfter(me : in out; Index : Integer from Standard; S : in out Sequence)
187 raises OutOfRange from Standard;
189 ---Purpose: Inserts the sequence <S> in <me> after the
190 -- position <Index>. <S> is cleared.
191 -- Raises an exception if the index is out of bound.
194 -- me = (A B C), Index = 3, S = (D E F)
196 -- me = (A B C D E F)
201 First(me) returns any SeqItem
202 raises NoSuchObject from Standard
204 ---Purpose: Returns the first element of the sequence <me>
205 -- Raises an exception if the sequence is empty.
212 ---C++: return const &
215 Last(me) returns any SeqItem
216 raises NoSuchObject from Standard
218 ---Purpose: Returns the last element of the sequence <me>
219 -- Raises an exception if the sequence is empty.
226 ---C++: return const &
229 Split(me : in out; Index : Integer from Standard; Sub : in out Sequence)
230 raises OutOfRange from Standard;
232 ---Purpose: Keeps in <me> the items 1 to <Index>-1 and
233 -- puts in <Sub> the items <Index> to the end.
236 -- me = (A B C D) ,Index = 3
243 Value(me; Index : Integer from Standard) returns any SeqItem
244 raises OutOfRange from Standard;
246 ---Purpose: Returns the Item at position <Index> in <me>.
247 -- Raises an exception if the index is out of bound
250 -- me = (A B C), Index = 1
255 ---C++: return const &
256 ---C++: alias operator()
258 SetValue(me : in out; Index : Integer from Standard; I : SeqItem)
259 raises OutOfRange from Standard;
261 ---Purpose: Changes the item at position <Index>
262 -- Raises an exception if the index is out of bound
265 -- me = (A B C), Index = 1, Item = D
270 ChangeValue(me : in out; Index : Integer from Standard) returns any SeqItem
271 raises OutOfRange from Standard;
273 ---Purpose: Returns the Item at position <Index> in
274 -- <me>. This method may be used to modify
275 -- <me> : S.Value(Index) = Item.
276 -- Raises an exception if the index is out of bound
279 -- me = (A B C), Index = 1
285 ---C++: alias operator()
287 Remove(me : in out; Index : Integer from Standard)
288 raises OutOfRange from Standard;
290 ---Purpose: Removes from <me> the item at position <Index>.
291 -- Raises an exception if the index is out of bounds
294 -- me = (A B C), Index = 3
298 Remove(me : in out; FromIndex, ToIndex : Integer from Standard)
299 raises OutOfRange from Standard;
301 ---Purpose: Removes from <me> all the items of
302 -- positions between <FromIndex> and <ToIndex>.
303 -- Raises an exception if the indices are out of bounds.
306 -- me = (A B C D E F), FromIndex = 1 ToIndex = 3