summaryrefslogtreecommitdiff
path: root/inc/PCollection_HArray1.gxx
blob: 743a14c180af1e1267f0f2505fc071f29648687c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <Standard_OutOfRange.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_ProgramError.hxx>

// ----------------------------------------------------------------------
// 
// HArray1 implementation:
// 
// Last Revision : Feb,10 1992 J.P Tirault
//                 Implementation of ShallowCopy, ShallowDump
//                 methods.
// ----------------------------------------------------------------------
//                 Constructor
// ----------------------------------------------------------------------

PCollection_HArray1::PCollection_HArray1 
           (const Standard_Integer First, 
            const Standard_Integer Last) : Data (Last-First+1)
{
	Standard_Integer Size = Last-First+1;
	if( Size <= 0 ) Standard_RangeError::Raise();
	LowerBound = First ;
	UpperBound = Last ;
}


// ----------------------------------------------------------------------
//                 datas
// ----------------------------------------------------------------------

Standard_Address PCollection_HArray1::Datas() const
{
  return ((Standard_Address)Data.Lock());
}

// ----------------------------------------------------------------------
//                 Constructor
// ----------------------------------------------------------------------

PCollection_HArray1::PCollection_HArray1 
           (const Standard_Integer First, 
            const Standard_Integer Last, 
            const Item& V) :Data (Last-First+1) {

	Standard_Integer Size = Last-First+1;
	if( Size <= 0 ) Standard_RangeError::Raise();
	LowerBound = First ;
	UpperBound = Last ;
	for(Standard_Integer I = 0 ; I < Size ; I++) Data.SetValue(I, V);
}


// ----------------------------------------------------------------------
//                  Destructor
// ----------------------------------------------------------------------

/*
void PCollection_HArray1::~PCollection_HArray1 () 
{
	delete Data ;
}
*/



// ----------------------------------------------------------------------
//                      ShallowCopy
// ----------------------------------------------------------------------

Handle(Standard_Persistent) PCollection_HArray1::ShallowCopy() const
{
  PCollection_HArray1* TheCopy = new PCollection_HArray1(*this);
//  PCollection_FieldOfHArray1 DataCopy (Data);
//  TheCopy->Data = DataCopy;
  return TheCopy;
}

// ----------------------------------------------------------------------
//                      ShallowDump
// ----------------------------------------------------------------------

void PCollection_HArray1::ShallowDump(Standard_OStream& S) const
{
  ::ShallowDump(Data,S);
}



/* Anciens INLINE */

// ----------------------------------------------------------------------
//                   SetValue
// ----------------------------------------------------------------------
void PCollection_HArray1::SetValue
            ( const Standard_Integer Index, const Item& Value)
{
  Standard_OutOfRange_Raise_if((Index < LowerBound || Index > UpperBound),
        "Index out of range in HArray1::SetValue");
  Data.SetValue(Index-LowerBound, Value) ;
}


// ----------------------------------------------------------------------
//                      Value
// ----------------------------------------------------------------------
Item PCollection_HArray1::Value
            ( const Standard_Integer Index) const
{
  Standard_OutOfRange_Raise_if((Index < LowerBound || Index > UpperBound),
        "Index out of range in HArray1::operator()");

  return Data(Index-LowerBound);

}

// ------------------------------------------------------------------
//
// ------------------------------------------------------------------
PCollection_FieldOfHArray1 PCollection_HArray1::Field () const
{
  return Data ;
}