Warnings on vc14 were eliminated
[occt.git] / src / TCollection / TCollection_BaseSequence.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _TCollection_BaseSequence_HeaderFile
18#define _TCollection_BaseSequence_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Address.hxx>
25#include <Standard_Integer.hxx>
26#include <Standard_Boolean.hxx>
27class Standard_NoSuchObject;
28class Standard_OutOfRange;
29
30
31//! Definition of a base class for all instanciations
32//! of sequence.
33//!
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.
39class TCollection_BaseSequence
40{
41public:
42
43 DEFINE_STANDARD_ALLOC
44
45
46 //! returns True if the sequence <me> contains no elements.
47 Standard_Boolean IsEmpty() const;
48
49 //! Returns the number of element(s) in the
50 //! sequence. Returns zero if the sequence is empty.
51 Standard_Integer Length() const;
52
53 //! Reverses the order of items on <me>.
54 //! Example:
55 //! before
56 //! me = (A B C)
57 //! after
58 //! me = (C B A)
59 Standard_EXPORT void Reverse();
60
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.
64 //! Example:
65 //! before
66 //! me = (A B C), I = 1, J = 3
67 //! after
68 //! me = (C B A)
69 Standard_EXPORT void Exchange (const Standard_Integer I, const Standard_Integer J);
70
71
72
73
74protected:
75
76
77 //! Creation of an empty sequence.
78 Standard_EXPORT TCollection_BaseSequence();
79
80 Standard_EXPORT void Clear (const Standard_Address DelNode);
81
82 Standard_EXPORT void PAppend (const Standard_Address Node);
83
84 //! Concatenates <S> at the end of <me>.
85 //! <S> is cleared.
86 //! Example:
87 //! before
88 //! me = (A B C)
89 //! S = (D E F)
90 //! after
91 //! me = (A B C D E F)
92 //! S = ()
93 Standard_EXPORT void PAppend (TCollection_BaseSequence& S);
94
95 Standard_EXPORT void PPrepend (const Standard_Address Node);
96
97 //! Concatenates <S> at the beginning of <me>.
98 //! <S> is cleared.
99 //! Example:
100 //! before
101 //! me = (A B C) S = (D E F)
102 //! after me = (D E F A B C)
103 //! S = ()
104 Standard_EXPORT void PPrepend (TCollection_BaseSequence& S);
105
106 Standard_EXPORT void PInsertAfter (const Standard_Integer Index, const Standard_Address Node);
107
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.
111 //! Example:
112 //! before
113 //! me = (A B C), Index = 3, S = (D E F)
114 //! after
115 //! me = (A B C D E F)
116 //! S = ()
117 Standard_EXPORT void PInsertAfter (const Standard_Integer Index, TCollection_BaseSequence& S);
118
119 //! Keeps in <me> the items 1 to <Index>-1 and
120 //! puts in <Sub> the items <Index> to the end.
121 //! Example:
122 //! before
123 //! me = (A B C D) ,Index = 3
124 //! after
125 //! me = (A B)
126 //! Sub = (C D)
127 Standard_EXPORT void PSplit (const Standard_Integer Index, TCollection_BaseSequence& Sub);
128
129 Standard_EXPORT void Remove (const Standard_Integer Index, const Standard_Address DelNode);
130
131 Standard_EXPORT void Remove (const Standard_Integer FromIndex, const Standard_Integer ToIndex, const Standard_Address DelNode);
132
133 //! Returns the node at position <index>.
134 Standard_EXPORT Standard_Address Find (const Standard_Integer Index) const;
135
136
137 Standard_Address FirstItem;
138 Standard_Address LastItem;
139 Standard_Address CurrentItem;
140 Standard_Integer CurrentIndex;
141 Standard_Integer Size;
142
143
144private:
145
146
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);
151
152 //! Clear all fields.
153 Standard_EXPORT void Nullify();
154
155
156
157
158};
159
160
161#include <TCollection_BaseSequence.lxx>
162
163
164
165
166
167#endif // _TCollection_BaseSequence_HeaderFile