1 // Created on: 1992-09-11
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 #ifndef _TCollection_BaseSequence_HeaderFile
18 #define _TCollection_BaseSequence_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Address.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 class Standard_NoSuchObject;
28 class Standard_OutOfRange;
31 //! Definition of a base class for all instanciations
34 //! The methods : Clear, Remove accepts a pointer to a
35 //! function to use to delete the nodes. This allow
36 //! proper call of the destructor on the Items.
37 //! Without adding a virtual function pointer to each
38 //! node or each sequence.
39 class TCollection_BaseSequence
46 //! returns True if the sequence <me> contains no elements.
47 Standard_Boolean IsEmpty() const;
49 //! Returns the number of element(s) in the
50 //! sequence. Returns zero if the sequence is empty.
51 Standard_Integer Length() const;
53 //! Reverses the order of items on <me>.
59 Standard_EXPORT void Reverse();
61 //! Swaps elements which are located at
62 //! positions <I> and <J> in <me>.
63 //! Raises an exception if I or J is out of bound.
66 //! me = (A B C), I = 1, J = 3
69 Standard_EXPORT void Exchange (const Standard_Integer I, const Standard_Integer J);
77 //! Creation of an empty sequence.
78 Standard_EXPORT TCollection_BaseSequence();
80 Standard_EXPORT void Clear (const Standard_Address DelNode);
82 Standard_EXPORT void PAppend (const Standard_Address Node);
84 //! Concatenates <S> at the end of <me>.
91 //! me = (A B C D E F)
93 Standard_EXPORT void PAppend (TCollection_BaseSequence& S);
95 Standard_EXPORT void PPrepend (const Standard_Address Node);
97 //! Concatenates <S> at the beginning of <me>.
101 //! me = (A B C) S = (D E F)
102 //! after me = (D E F A B C)
104 Standard_EXPORT void PPrepend (TCollection_BaseSequence& S);
106 Standard_EXPORT void PInsertAfter (const Standard_Integer Index, const Standard_Address Node);
108 //! Inserts the sequence <S> in <me> after the
109 //! position <Index>. <S> is cleared.
110 //! Raises an exception if the index is out of bound.
113 //! me = (A B C), Index = 3, S = (D E F)
115 //! me = (A B C D E F)
117 Standard_EXPORT void PInsertAfter (const Standard_Integer Index, TCollection_BaseSequence& S);
119 //! Keeps in <me> the items 1 to <Index>-1 and
120 //! puts in <Sub> the items <Index> to the end.
123 //! me = (A B C D) ,Index = 3
127 Standard_EXPORT void PSplit (const Standard_Integer Index, TCollection_BaseSequence& Sub);
129 Standard_EXPORT void Remove (const Standard_Integer Index, const Standard_Address DelNode);
131 Standard_EXPORT void Remove (const Standard_Integer FromIndex, const Standard_Integer ToIndex, const Standard_Address DelNode);
133 //! Returns the node at position <index>.
134 Standard_EXPORT Standard_Address Find (const Standard_Integer Index) const;
137 Standard_Address FirstItem;
138 Standard_Address LastItem;
139 Standard_Address CurrentItem;
140 Standard_Integer CurrentIndex;
141 Standard_Integer Size;
147 //! Creation by copy of existing Sequence.
148 //! Warning: This constructor prints a warning message.
149 //! We recommand to use the operator =.
150 Standard_EXPORT TCollection_BaseSequence(const TCollection_BaseSequence& Other);
152 //! Clear all fields.
153 Standard_EXPORT void Nullify();
161 #include <TCollection_BaseSequence.lxx>
167 #endif // _TCollection_BaseSequence_HeaderFile