1 // Copyright (c) 1993-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_DimensionMismatch.hxx>
20 #include <Standard_RangeError.hxx>
21 #include <Standard_OutOfMemory.hxx>
22 #include <Standard.hxx>
24 // ###### REFERENCER LE STORAGE MANAGER DES COLLECTIONS ######
26 //=======================================================================
27 //function : TCollection_Array1
29 //=======================================================================
31 TCollection_Array1::TCollection_Array1 (const Standard_Integer Low,
32 const Standard_Integer Up) :
35 isAllocated(Standard_True)
37 Standard_RangeError_Raise_if(Up < Low,"TCollection_Array1::Create");
41 // p = new char [(Up-Low+1)*sizeof (Array1Item)];
42 p = (Array1Item *)Standard::Allocate((Up-Low+1)*sizeof (Array1Item));
44 p = new Array1Item[Up-Low+1];
47 if (!p) Standard_OutOfMemory::Raise("Array1 : Allocation failed");
48 myStart = (void*)(p - myLowerBound);
53 //=======================================================================
56 //=======================================================================
58 void TCollection_Array1::Init (const Array1Item& V) {
59 Array1Item* p = &ChangeValue(myLowerBound);
61 for(i = myLowerBound; i <= myUpperBound; i++) {
66 //=======================================================================
67 //function : TCollection_Array1
68 //purpose : C Array constructor
69 //=======================================================================
71 TCollection_Array1::TCollection_Array1(const Array1Item& AnItem,
72 const Standard_Integer Low,
73 const Standard_Integer Up) :
76 isAllocated(Standard_False)
79 Standard_RangeError_Raise_if(Up < Low,"Array1::CArray");
80 myStart = (void*)( &AnItem - Low );
83 //=======================================================================
86 //=======================================================================
88 void TCollection_Array1::Destroy()
92 Standard_Address it = (Standard_Address)&((Array1Item *)myStart)[myLowerBound];
95 delete [] &ChangeValue(myLowerBound);
100 //=======================================================================
103 //=======================================================================
105 const TCollection_Array1& TCollection_Array1::Assign
106 (const TCollection_Array1& Right)
108 if (&Right != this) {
109 Standard_Integer max = Length() ;
110 Standard_DimensionMismatch_Raise_if(max != Right.Length(),
111 "DimensionMismatch in Array1::Operator=");
113 Array1Item* p = &ChangeValue(myLowerBound);
114 const Array1Item* q = &Right.Value(Right.Lower());
115 for (Standard_Integer i=0; i<max; i++){