1 // Created on: 1992-11-24
2 // Created by: Mireille MERCIEN
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // ----------------------------------------------------------------------
18 // ----------------------------------------------------------------------
20 // ----------------------------------
21 // Clear : Clear the Current HSequence
22 // ----------------------------------
23 void TCollection_HSequence::Clear()
28 // -------------------------------------------------
29 // Append : Push an item at the end of the sequence
30 // -------------------------------------------------
31 void TCollection_HSequence::Append(const Item& T)
36 // ---------------------------------------------------
37 // Append : Push a Sequence at the end of the sequence
38 // ---------------------------------------------------
39 void TCollection_HSequence::Append(const Handle(TCollection_HSequence)& S)
41 Standard_Integer i,l = S->Length();
42 for (i = 1; i <= l; i++) mySequence.Append(S->Value(i));
45 // ---------------------------------------------------------
46 // Prepend : Push an element at the begining of the sequence
47 // ---------------------------------------------------------
48 void TCollection_HSequence::Prepend(const Item& T)
50 mySequence.Prepend(T);
53 // ---------------------------------------------------------
54 // Prepend : Push an element at the begining of the sequence
55 // ---------------------------------------------------------
56 void TCollection_HSequence::Prepend(const Handle(TCollection_HSequence)& S)
58 Standard_Integer i,l = S->Length();
59 for (i = 0; i < l; i++) mySequence.Prepend(S->Value(S->Length()-i));
62 // ---------------------------------------------------------
63 // Reverse : Reverse the order of a given sequence
64 // ---------------------------------------------------------
65 void TCollection_HSequence::Reverse()
70 // -------------------------------------------------------------------
71 // InsertBefore : Insert an item before a given index in the sequence
72 // --------------------------------------------------------------------
73 void TCollection_HSequence::InsertBefore(const Standard_Integer Index,
76 mySequence.InsertBefore(Index,T);
79 // ----------------------------------------------------------------------
80 // InsertBefore : Insert a sequence before a specific index in a HSequence
81 // ----------------------------------------------------------------------
82 void TCollection_HSequence::InsertBefore(const Standard_Integer Index ,
83 const Handle(TCollection_HSequence)& S)
85 Standard_Integer i,l = S->Length();
86 for (i = 1; i <= l; i++) mySequence.InsertBefore(Index+i-1,S->Value(i));
89 // -----------------------------------------------------------------
90 // InsertAfter : Insert an element after a given index in a sequence
91 // -----------------------------------------------------------------
92 void TCollection_HSequence::InsertAfter(const Standard_Integer Index,
95 mySequence.InsertAfter(Index,T);
98 // -------------------------------------------------------------------
99 // InsertAfter : Insert a sequence after a given index in the sequence
100 // -------------------------------------------------------------------
101 void TCollection_HSequence::InsertAfter(const Standard_Integer Index,
102 const Handle(TCollection_HSequence)& S)
104 Standard_Integer i,l = S->Length();
105 for (i = 1; i <= l; i++) mySequence.InsertAfter(Index+i-1,S->Value(i));
108 // ----------------------------------------
109 // Exchange : Exchange two elements in the sequence
110 // ----------------------------------------
111 void TCollection_HSequence::Exchange(const Standard_Integer I,
112 const Standard_Integer J)
114 mySequence.Exchange(I,J);
117 // ---------------------------------------------
118 // Split : Split a sequence in two sub-sequences
119 // ---------------------------------------------
120 Handle (TCollection_HSequence)
121 TCollection_HSequence::Split(const Standard_Integer Index)
124 mySequence.Split(Index,SS);
125 Handle(TCollection_HSequence) NS = new TCollection_HSequence();
126 Standard_Integer i,l = SS.Length();
127 for (i=1; i<= l; i++) NS->Append(SS(i));
131 // ----------------------------------------------------------
132 // SetValue : Change the element of a given index in a sequence
133 // ----------------------------------------------------------
134 void TCollection_HSequence::SetValue(const Standard_Integer Index,
137 mySequence(Index) = T;
140 // -----------------------------------------
141 // Value : Return the value of a given index
142 // -----------------------------------------
143 const Item& TCollection_HSequence::Value(const Standard_Integer Index) const
145 return (mySequence(Index));
148 // -----------------------------------------
149 // ChangeValue : Return the value of a given index
150 // -----------------------------------------
151 Item& TCollection_HSequence::ChangeValue(const Standard_Integer Index)
153 return (mySequence(Index));
156 // -------------------------------------
157 // Remove : Remove an item in a sequence
158 // -------------------------------------
159 void TCollection_HSequence::Remove(const Standard_Integer Index)
161 mySequence.Remove(Index);
164 // ---------------------
165 // Remove a set of items
166 // ---------------------
167 void TCollection_HSequence::Remove(const Standard_Integer From,
168 const Standard_Integer To)
170 mySequence.Remove(From,To);
173 // ----------------------------------------------------------------------------
175 // ----------------------------------------------------------------------------
176 // Standard_Boolean TCollection_HSequence::IsSameState
177 // (const Handle(TCollection_HSequence)& other) const
179 // Handle(TCollection_HSequence) Seq =
180 // Handle(TCollection_HSequence)::DownCast(other);
181 // if (Seq->Length() != Length()) return Standard_False;
182 // for (Standard_Integer I = 1; I<= Length(); I++) {
183 // if ( !(Value(I) == Seq->Value(I)) ) return Standard_False;
185 // return Standard_True;