0032276: Coding Rules - replace IntTools_CArray1OfReal by NCollection_Array1
[occt.git] / src / IntTools / IntTools_CArray1OfInteger.hxx
1 // Created on: 2000-05-18
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _IntTools_CArray1OfInteger_HeaderFile
17 #define _IntTools_CArray1OfInteger_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Standard_Address.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 class Standard_ConstructionError;
27 class Standard_OutOfRange;
28 class Standard_OutOfMemory;
29
30
31
32 class IntTools_CArray1OfInteger 
33 {
34 public:
35
36   DEFINE_STANDARD_ALLOC
37
38   
39
40   //! Creates an array  of given Length.
41   Standard_EXPORT IntTools_CArray1OfInteger(const Standard_Integer Length = 0);
42   
43
44   //! Creates an array sharing datas with an other.
45   //! Example:
46   //! Item tab[100];
47   //! CArray1OfItem thetab (tab[0],100);
48   //!
49   //! CArray1OfItem aArray1(100);
50   //! CArray1OfItem anSharedArray1(aArray1.ChangeValue(0),aArray1.Length());
51   //!
52   //! Warning:
53   //! The validity of length are under the responsibility
54   //! of the user.
55   //! The sahred array must have a valid address during the life of
56   //! the Array1.
57   Standard_EXPORT IntTools_CArray1OfInteger(const Standard_Integer& Item, const Standard_Integer Length);
58   
59
60   //! Initializes the array with a given value.
61   Standard_EXPORT void Init (const Standard_Integer& V);
62   
63
64   //! destroy current content and realloc the new size
65   //! does nothing if Length() == theLength
66   Standard_EXPORT void Resize (const Standard_Integer theNewLength);
67   
68
69   //! Frees the  allocated   area  corresponding  to the
70   //! array.
71   Standard_EXPORT void Destroy();
72 ~IntTools_CArray1OfInteger()
73 {
74   Destroy();
75 }
76   
77
78   //! Returns the number of elements of <me>.
79     Standard_Integer Length() const;
80   
81   Standard_EXPORT void Append (const Standard_Integer& Value);
82   
83
84   //! Sets  the   <Index>th  element  of   the  array to
85   //! <Value>.
86   Standard_EXPORT void SetValue (const Standard_Integer Index, const Standard_Integer& Value);
87   
88
89   //! Returns the value of  the  <Index>th element of the
90   //! array.
91   Standard_EXPORT const Standard_Integer& Value (const Standard_Integer Index) const;
92 const Standard_Integer& operator () (const Standard_Integer Index) const
93 {
94   return Value(Index);
95 }
96   
97
98   //! Returns the value  of the <Index>th element  of the
99   //! array.
100   Standard_EXPORT Standard_Integer& ChangeValue (const Standard_Integer Index);
101 Standard_Integer& operator () (const Standard_Integer Index)
102 {
103   return ChangeValue(Index);
104 }
105   
106
107   //! Applyies the == operator on each array item
108   Standard_EXPORT Standard_Boolean IsEqual (const IntTools_CArray1OfInteger& Other) const;
109 Standard_Boolean operator == (const IntTools_CArray1OfInteger& Other) const
110 {
111   return IsEqual(Other);
112 }
113
114
115
116
117 protected:
118
119
120
121
122
123 private:
124
125   
126
127   //! Prohibits the creator by copy
128   Standard_EXPORT IntTools_CArray1OfInteger(const IntTools_CArray1OfInteger& AnArray);
129
130
131   Standard_Address myStart;
132   Standard_Integer myLength;
133   Standard_Boolean myIsAllocated;
134
135
136 };
137
138 #define Array1Item Standard_Integer
139 #define Array1Item_hxx <Standard_Integer.hxx>
140 #define IntTools_CArray1 IntTools_CArray1OfInteger
141 #define IntTools_CArray1_hxx <IntTools_CArray1OfInteger.hxx>
142
143 #include <IntTools_CArray1.lxx>
144
145 #undef Array1Item
146 #undef Array1Item_hxx
147 #undef IntTools_CArray1
148 #undef IntTools_CArray1_hxx
149
150
151
152
153 #endif // _IntTools_CArray1OfInteger_HeaderFile