1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #include <Standard.hxx>
20 #include <Standard_OutOfRange.hxx>
22 #include Array2Item_hxx
24 //=======================================================================
25 //function : TCollection_Array2
27 //=======================================================================
29 inline TCollection_Array2::TCollection_Array2 (const Standard_Integer R1,
30 const Standard_Integer R2,
31 const Standard_Integer C1,
32 const Standard_Integer C2) :
37 myDeletable(Standard_True)
42 //=======================================================================
43 //function : TCollection_Array2
44 //purpose : User allocated data
45 //=======================================================================
47 inline TCollection_Array2::TCollection_Array2 (const Array2Item& Item,
48 const Standard_Integer R1,
49 const Standard_Integer R2,
50 const Standard_Integer C1,
51 const Standard_Integer C2) :
56 myDeletable(Standard_False),
62 //=======================================================================
65 //=======================================================================
67 inline void TCollection_Array2::Init (const Array2Item& V)
69 Standard_Integer Size = RowLength() * ColLength();
70 Array2Item* p = &(ChangeValue(myLowerRow,myLowerColumn));
71 for (Standard_Integer I = 0; I < Size ; I++) p[I] = V;
74 //=======================================================================
77 //=======================================================================
79 inline void TCollection_Array2::Destroy ()
81 Array2Item** anItemPtr = ((Array2Item**)myData + myLowerRow);
86 delete [] &ChangeValue(myLowerRow,myLowerColumn);
88 // delete the indirection table
89 Standard::Free((void*&)anItemPtr);
92 //=======================================================================
93 //function : ColLength
95 //=======================================================================
96 inline Standard_Integer TCollection_Array2::ColLength () const
98 return myUpperRow - myLowerRow + 1 ;
101 //=======================================================================
102 //function : LowerCol
104 //=======================================================================
105 inline Standard_Integer TCollection_Array2::LowerCol () const
107 return myLowerColumn ;
110 //=======================================================================
111 //function : LowerRow
113 //=======================================================================
114 inline Standard_Integer TCollection_Array2::LowerRow () const
119 //=======================================================================
120 //function : RowLength
122 //=======================================================================
123 inline Standard_Integer TCollection_Array2::RowLength () const
125 return myUpperColumn - myLowerColumn + 1 ;
128 //=======================================================================
129 //function : UpperRow
131 //=======================================================================
132 inline Standard_Integer TCollection_Array2::UpperRow () const
137 //=======================================================================
138 //function : UpperCol
140 //=======================================================================
141 inline Standard_Integer TCollection_Array2::UpperCol () const
143 return myUpperColumn ;
146 //=======================================================================
147 //function : SetValue
149 //=======================================================================
151 inline void TCollection_Array2::SetValue ( const Standard_Integer Row,
152 const Standard_Integer Col,
153 const Array2Item& Value )
155 Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
156 Col < myLowerColumn || Col > myUpperColumn),
159 ((Array2Item **)myData)[Row][Col] = Value ;
162 //=======================================================================
165 //=======================================================================
166 inline const Array2Item& TCollection_Array2::Value(const Standard_Integer Row,
167 const Standard_Integer Col) const
169 Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
170 Col < myLowerColumn || Col > myUpperColumn),
173 return ((Array2Item **)myData)[Row][Col];
176 //=======================================================================
177 //function : ChangeValue
179 //=======================================================================
181 inline Array2Item& TCollection_Array2::ChangeValue(const Standard_Integer Row,
182 const Standard_Integer Col)
184 Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
185 Col < myLowerColumn || Col > myUpperColumn),
188 return ((Array2Item **)myData)[Row][Col];