// ---------------------------------------------------------------------- // 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; // }