summaryrefslogtreecommitdiff
path: root/inc/TCollection_HSequence.gxx
blob: 6e58f7c40bfc1819ff24795236c3063f893edd77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

// ----------------------------------------------------------------------
// Copyright: 	Matra-Datavision 1992
// File:	TCollection_HSequence.gxx
// Created:	Nov, 24 1992
// Author:      Mireille MERCIEN
// ----------------------------------------------------------------------

// ----------------------------------
// Clear : Clear the Current HSequence
// ----------------------------------
void TCollection_HSequence::Clear()
{
   mySequence.Clear();
}

// -------------------------------------------------
// Append : Push an item  at the end of the sequence
// -------------------------------------------------
void TCollection_HSequence::Append(const Item& T)
{
   mySequence.Append(T);   
}

// ---------------------------------------------------
// Append : Push a Sequence at the end of the sequence
// ---------------------------------------------------
void TCollection_HSequence::Append(const Handle(TCollection_HSequence)& S)
{
  Standard_Integer i,l = S->Length();
  for (i = 1; i <= l; i++) mySequence.Append(S->Value(i));
}

// ---------------------------------------------------------
// Prepend : Push an element at the begining of the sequence
// ---------------------------------------------------------
void TCollection_HSequence::Prepend(const Item& T)
{
   mySequence.Prepend(T);   
}

// ---------------------------------------------------------
// Prepend : Push an element at the begining of the sequence
// ---------------------------------------------------------
void TCollection_HSequence::Prepend(const Handle(TCollection_HSequence)& S)
{
  Standard_Integer i,l = S->Length();
  for (i = 0; i < l; i++) mySequence.Prepend(S->Value(S->Length()-i));
}

// ---------------------------------------------------------
// Reverse : Reverse the order of a given sequence
// ---------------------------------------------------------
void TCollection_HSequence::Reverse()
{
   mySequence.Reverse();   
}

// -------------------------------------------------------------------
// InsertBefore : Insert an item before a given index in the sequence
// --------------------------------------------------------------------
void TCollection_HSequence::InsertBefore(const Standard_Integer Index, 
					 const Item& T)
{
   mySequence.InsertBefore(Index,T);   
}

// ----------------------------------------------------------------------
// InsertBefore : Insert a sequence before a specific index in a HSequence
// ----------------------------------------------------------------------
void TCollection_HSequence::InsertBefore(const Standard_Integer Index , 
					 const Handle(TCollection_HSequence)& S)
{   
  Standard_Integer i,l = S->Length();
  for (i = 1; i <= l; i++) mySequence.InsertBefore(Index+i-1,S->Value(i));
}

// -----------------------------------------------------------------
// InsertAfter : Insert an element after a given index in a sequence
// -----------------------------------------------------------------
void TCollection_HSequence::InsertAfter(const Standard_Integer Index, 
					const Item& T)
{
   mySequence.InsertAfter(Index,T);   
}

// -------------------------------------------------------------------
// InsertAfter : Insert a sequence after a given index in the sequence
// -------------------------------------------------------------------
void TCollection_HSequence::InsertAfter(const Standard_Integer Index, 
					const Handle(TCollection_HSequence)& S)
{
  Standard_Integer i,l = S->Length();
  for (i = 1; i <= l; i++) mySequence.InsertAfter(Index+i-1,S->Value(i));
}

// ----------------------------------------
// Exchange : Exchange two elements in the sequence
// ----------------------------------------
void TCollection_HSequence::Exchange(const Standard_Integer I, 
                                   const Standard_Integer J)
{
   mySequence.Exchange(I,J);   
}

// ---------------------------------------------
// Split : Split a sequence in two sub-sequences
// ---------------------------------------------
Handle (TCollection_HSequence) 
            TCollection_HSequence::Split(const Standard_Integer Index)
{
  TheSequence SS;
  mySequence.Split(Index,SS);
  Handle(TCollection_HSequence) NS = new TCollection_HSequence();
  Standard_Integer i,l = SS.Length();
  for (i=1; i<= l; i++) NS->Append(SS(i));
  return NS;
}

// ----------------------------------------------------------
// SetValue : Change the element of a given index in a sequence
// ----------------------------------------------------------
void TCollection_HSequence::SetValue(const Standard_Integer Index, 
                                   const Item& T)
{
  mySequence(Index) = T;   
}

// -----------------------------------------
// Value : Return the value of a given index
// -----------------------------------------
const Item& TCollection_HSequence::Value(const Standard_Integer Index) const
{
   return (mySequence(Index));   
}

// -----------------------------------------
// ChangeValue : Return the value of a given index
// -----------------------------------------
Item& TCollection_HSequence::ChangeValue(const Standard_Integer Index)
{
   return (mySequence(Index));   
}

// -------------------------------------
// Remove : Remove an item in a sequence
// -------------------------------------
void TCollection_HSequence::Remove(const Standard_Integer Index)
{
   mySequence.Remove(Index);
}

// ---------------------
// Remove a set of items
// --------------------- 
void TCollection_HSequence::Remove(const Standard_Integer From,
				   const Standard_Integer To)
{
   mySequence.Remove(From,To);   
}

// ---------------------------------------------------------------------
// ShallowCopy
// ---------------------------------------------------------------------
Handle(TCollection_HSequence) TCollection_HSequence::ShallowCopy() const
{
   Handle (TCollection_HSequence) TheCopy = new TCollection_HSequence();

   Standard_Integer i;
   for (i=1; i <= mySequence.Length(); i++) TheCopy->Append(mySequence(i));
   return TheCopy;
}

// ----------------------------------------------------------------------------
// IsSamestate
// ----------------------------------------------------------------------------
// Standard_Boolean TCollection_HSequence::IsSameState
//   (const Handle(TCollection_HSequence)& other) const
// {
//   Handle(TCollection_HSequence) Seq = 
//     Handle(TCollection_HSequence)::DownCast(other);
//   if (Seq->Length() != Length()) return Standard_False;
//   for (Standard_Integer I = 1; I<= Length(); I++) {
//     if ( !(Value(I) == Seq->Value(I)) ) return Standard_False;
//   }
//   return Standard_True;   
// }