File indexing completed on 2025-01-18 10:04:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef NCollection_SparseArray_HeaderFile
0017 #define NCollection_SparseArray_HeaderFile
0018
0019 #include <NCollection_SparseArrayBase.hxx>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 template <class TheItemType> class NCollection_SparseArray
0047 : public NCollection_SparseArrayBase
0048 {
0049 public:
0050
0051
0052 explicit NCollection_SparseArray (Standard_Size theIncrement)
0053 : NCollection_SparseArrayBase(sizeof(TheItemType),theIncrement)
0054 {
0055 }
0056
0057
0058 NCollection_SparseArray& Assign (const NCollection_SparseArray& theOther)
0059 {
0060 this->assign (theOther);
0061 return *this;
0062 }
0063
0064
0065
0066
0067 void Exchange (NCollection_SparseArray& theOther)
0068 {
0069 this->exchange (theOther);
0070 }
0071
0072
0073 virtual ~NCollection_SparseArray ()
0074 {
0075 Clear();
0076 }
0077
0078 public:
0079
0080
0081
0082
0083 const TheItemType& Value (const Standard_Size theIndex) const
0084 {
0085 return *(const TheItemType*)this->getValue(theIndex);
0086 }
0087
0088
0089 const TheItemType& operator () (const Standard_Size theIndex) const
0090 {
0091 return Value (theIndex);
0092 }
0093
0094
0095 TheItemType& ChangeValue (const Standard_Size theIndex)
0096 {
0097 return *(TheItemType*)(this->getValue (theIndex));
0098 }
0099
0100
0101 TheItemType& operator () (const Standard_Size theIndex)
0102 {
0103 return ChangeValue (theIndex);
0104 }
0105
0106
0107 TheItemType& SetValue (const Standard_Size theIndex,
0108 const TheItemType& theValue)
0109 {
0110 return *(TheItemType*)this->setValue(theIndex, (Standard_Address)&theValue);
0111 }
0112
0113
0114
0115 public:
0116
0117
0118
0119
0120 Standard_Size Extent () const
0121 {
0122 return Size();
0123 }
0124
0125
0126 Standard_Boolean IsEmpty () const
0127 {
0128 return Size() == 0;
0129 }
0130
0131
0132 const TheItemType& Find (const Standard_Size theIndex) const
0133 {
0134 return Value(theIndex);
0135 }
0136
0137
0138 TheItemType& ChangeFind (const Standard_Size theIndex)
0139 {
0140 return ChangeValue(theIndex);
0141 }
0142
0143
0144 TheItemType& Bind (const Standard_Size theIndex,
0145 const TheItemType& theValue)
0146 {
0147 return SetValue(theIndex, theValue);
0148 }
0149
0150
0151 Standard_Boolean IsBound (const Standard_Size theIndex) const
0152 {
0153 return this->HasValue(theIndex);
0154 }
0155
0156
0157 Standard_Boolean UnBind (const Standard_Size theIndex)
0158 {
0159 return this->UnsetValue(theIndex);
0160 }
0161
0162
0163
0164 public:
0165
0166
0167
0168
0169
0170 class ConstIterator : public NCollection_SparseArrayBase::Iterator
0171 {
0172 public:
0173
0174
0175 ConstIterator () {}
0176
0177
0178 ConstIterator (const NCollection_SparseArray& theVector) :
0179 NCollection_SparseArrayBase::Iterator (&theVector) {}
0180
0181
0182 void Init (const NCollection_SparseArray& theVector)
0183 {
0184 this->init (&theVector);
0185 }
0186
0187
0188 const TheItemType& Value (void) const
0189 {
0190 return *(const TheItemType*)this->value();
0191 }
0192
0193
0194 const TheItemType& operator () (void) const
0195 {
0196 return *(const TheItemType*)this->value();
0197 }
0198
0199
0200 Standard_Size Key (void) const { return Index(); }
0201 };
0202
0203
0204
0205
0206 class Iterator : public ConstIterator
0207 {
0208 public:
0209
0210
0211 Iterator () {}
0212
0213
0214 Iterator (NCollection_SparseArray& theVector) :
0215 ConstIterator (theVector) {}
0216
0217
0218 void Init (const NCollection_SparseArray& theVector)
0219 {
0220 this->init (&theVector);
0221 }
0222
0223
0224 TheItemType& ChangeValue (void)
0225 {
0226 return *(TheItemType*)this->value();
0227 }
0228
0229
0230 TheItemType& operator () (void)
0231 {
0232 return *(TheItemType*)this->value();
0233 }
0234
0235
0236 const TheItemType& operator () (void) const
0237 {
0238 return *(const TheItemType*)this->value();
0239 }
0240 };
0241
0242 private:
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253 virtual void createItem (Standard_Address theAddress, Standard_Address theOther)
0254 {
0255 new (theAddress) TheItemType(*(const TheItemType*)theOther);
0256 }
0257
0258
0259 virtual void destroyItem (Standard_Address theAddress)
0260 {
0261 ((TheItemType*)theAddress)->TheItemType::~TheItemType();
0262 }
0263
0264
0265 virtual void copyItem (Standard_Address theAddress, Standard_Address theOther)
0266 {
0267 (*(TheItemType*)theAddress) = *(const TheItemType*)theOther;
0268 }
0269
0270 };
0271
0272 #endif
0273