42cf5bc1 |
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_CArray1OfReal_HeaderFile |
17 | #define _IntTools_CArray1OfReal_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 | #include <Standard_Real.hxx> |
27 | class Standard_ConstructionError; |
28 | class Standard_OutOfRange; |
29 | class Standard_OutOfMemory; |
30 | |
31 | |
32 | |
33 | class IntTools_CArray1OfReal |
34 | { |
35 | public: |
36 | |
37 | DEFINE_STANDARD_ALLOC |
38 | |
39 | |
36b9ff75 |
40 | |
41 | //! Creates an array of given Length. |
42cf5bc1 |
42 | Standard_EXPORT IntTools_CArray1OfReal(const Standard_Integer Length = 0); |
43 | |
36b9ff75 |
44 | |
45 | //! Creates an array sharing datas with an other. |
46 | //! Example: |
47 | //! Item tab[100]; |
48 | //! CArray1OfItem thetab (tab[0],100); |
49 | //! |
50 | //! CArray1OfItem aArray1(100); |
51 | //! CArray1OfItem anSharedArray1(aArray1.ChangeValue(0),aArray1.Length()); |
52 | //! |
53 | //! Warning: |
54 | //! The validity of length are under the responsability |
55 | //! of the user. |
56 | //! The sahred array must have a valid address during the life of |
57 | //! the Array1. |
42cf5bc1 |
58 | Standard_EXPORT IntTools_CArray1OfReal(const Standard_Real& Item, const Standard_Integer Length); |
59 | |
36b9ff75 |
60 | |
61 | //! Initializes the array with a given value. |
42cf5bc1 |
62 | Standard_EXPORT void Init (const Standard_Real& V); |
63 | |
36b9ff75 |
64 | |
65 | //! destroy current content and realloc the new size |
66 | //! does nothing if Length() == theLength |
42cf5bc1 |
67 | Standard_EXPORT void Resize (const Standard_Integer theNewLength); |
68 | |
36b9ff75 |
69 | |
70 | //! Frees the allocated area corresponding to the |
71 | //! array. |
42cf5bc1 |
72 | Standard_EXPORT void Destroy(); |
73 | ~IntTools_CArray1OfReal() |
74 | { |
75 | Destroy(); |
76 | } |
77 | |
36b9ff75 |
78 | |
79 | //! Returns the number of elements of <me>. |
42cf5bc1 |
80 | Standard_Integer Length() const; |
81 | |
82 | Standard_EXPORT void Append (const Standard_Real& Value); |
83 | |
36b9ff75 |
84 | |
85 | //! Sets the <Index>th element of the array to |
86 | //! <Value>. |
42cf5bc1 |
87 | Standard_EXPORT void SetValue (const Standard_Integer Index, const Standard_Real& Value); |
88 | |
36b9ff75 |
89 | |
90 | //! Returns the value of the <Index>th element of the |
91 | //! array. |
42cf5bc1 |
92 | Standard_EXPORT const Standard_Real& Value (const Standard_Integer Index) const; |
93 | const Standard_Real& operator () (const Standard_Integer Index) const |
94 | { |
95 | return Value(Index); |
96 | } |
97 | |
36b9ff75 |
98 | |
99 | //! Returns the value of the <Index>th element of the |
100 | //! array. |
42cf5bc1 |
101 | Standard_EXPORT Standard_Real& ChangeValue (const Standard_Integer Index); |
102 | Standard_Real& operator () (const Standard_Integer Index) |
103 | { |
104 | return ChangeValue(Index); |
105 | } |
106 | |
36b9ff75 |
107 | |
108 | //! Applys the == operator on each array item |
42cf5bc1 |
109 | Standard_EXPORT Standard_Boolean IsEqual (const IntTools_CArray1OfReal& Other) const; |
110 | Standard_Boolean operator == (const IntTools_CArray1OfReal& Other) const |
111 | { |
112 | return IsEqual(Other); |
113 | } |
114 | |
115 | |
116 | |
117 | |
118 | protected: |
119 | |
120 | |
121 | |
122 | |
123 | |
124 | private: |
125 | |
126 | |
36b9ff75 |
127 | |
128 | //! Prohibits the creator by copy |
42cf5bc1 |
129 | Standard_EXPORT IntTools_CArray1OfReal(const IntTools_CArray1OfReal& AnArray); |
130 | |
131 | |
132 | Standard_Address myStart; |
133 | Standard_Integer myLength; |
134 | Standard_Boolean myIsAllocated; |
135 | |
136 | |
137 | }; |
138 | |
139 | #define Array1Item Standard_Real |
140 | #define Array1Item_hxx <Standard_Real.hxx> |
141 | #define IntTools_CArray1 IntTools_CArray1OfReal |
142 | #define IntTools_CArray1_hxx <IntTools_CArray1OfReal.hxx> |
143 | |
144 | #include <IntTools_CArray1.lxx> |
145 | |
146 | #undef Array1Item |
147 | #undef Array1Item_hxx |
148 | #undef IntTools_CArray1 |
149 | #undef IntTools_CArray1_hxx |
150 | |
151 | |
152 | |
153 | |
154 | #endif // _IntTools_CArray1OfReal_HeaderFile |