#include <STK_ArrayHo.h>
Inherits IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >.
Public Types | |
| typedef IArrayBase< TYPE * > | _IArrayBaseType |
| typedef IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > > | _IArrayHoType |
Public Member Functions | |
| ArrayHo (const Inx &I=Inx()) | |
| ArrayHo (const Inx &I, const TYPE &v) | |
| ArrayHo (const ArrayHo &T, bool ref=false) | |
| ArrayHo (const ArrayHo< TYPE > &T, const Inx &I) | |
| ArrayHo (const _IArrayBaseType &T, const Inx &I, Integer row) | |
| virtual | ~ArrayHo () |
| TYPE const & | getElt (const Integer &pos) const |
| TYPE & | getElt (const Integer &pos) |
| ArrayHo | getElt (const Inx &J) const |
| void | clear () |
| void | freeMem () |
| void | initialize (const Inx &I) |
| void | pushBackElts (const Integer &n=1) |
| void | insertElts (const Integer &pos, const Integer &n=1) |
| void | popBackElts (const Integer &n=1) |
| void | eraseElts (Integer pos, Integer n=1) |
| ArrayHo & | operator= (const ArrayHo &T) |
| ArrayHo & | operator= (const TYPE &v) |
| template<class LEAF > | |
| ArrayHo & | operator= (const ITContainer1D< TYPE, LEAF > &T) |
Protected Member Functions | |
| void | initElts (const Inx &J) |
| void | freeElts (const Inx &J) |
| void | initElt (const Integer &pos) |
| void | freeElt (const Integer &pos) |
By default the index of the first element is 1 but this can be modified using the apropriate ctor or using the method shift.
Definition at line 125 of file STK_ArrayHo.h.
| typedef IArrayBase<TYPE*> STK::ArrayHo< TYPE >::_IArrayBaseType |
Type for the Base reference Class.
Reimplemented from STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >.
Definition at line 131 of file STK_ArrayHo.h.
| typedef IArray1DBase<TYPE, TYPE*, ArrayHo<TYPE> > STK::ArrayHo< TYPE >::_IArrayHoType |
Type for the Implementation Class.
Definition at line 134 of file STK_ArrayHo.h.
| STK::ArrayHo< TYPE >::ArrayHo | ( | const Inx & | I = Inx() |
) | [inline] |
Default Ctor : beg_ =1 and end_ =0.
| I | range of the container |
Definition at line 141 of file STK_ArrayHo.h.
References STK::ArrayHo< TYPE >::initElts().
Referenced by STK::ArrayHo< Real >::getElt(), and STK::ArrayHo< TYPE >::getElt().
00142 : _IArrayHoType(I) 00143 { this->initElts(I);}
| STK::ArrayHo< TYPE >::ArrayHo | ( | const Inx & | I, | |
| const TYPE & | v | |||
| ) | [inline] |
Misc Ctor with beg and end, initialization with a constant.
| I | range of the container | |
| v | initial value of the container |
Definition at line 149 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::getElt(), STK::ArrayHo< TYPE >::initElts(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().
00150 : _IArrayHoType(I) 00151 { 00152 this->initElts(I); 00153 // set value v 00154 for (Integer i=this->first(); i<=this->last(); i++) 00155 this->getElt(i) = v; 00156 }
| STK::ArrayHo< TYPE >::ArrayHo | ( | const ArrayHo< TYPE > & | T, | |
| bool | ref = false | |||
| ) | [inline] |
Copy Ctor.
| T | the container to copy | |
| ref | true if this is a wrapper of T |
Definition at line 162 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::IArrayBase< DATA >::getData(), STK::IArrayBase< TYPE * >::getData(), STK::IArray1DBase< TYPE, PTRELT, TArray1D >::getIndex(), STK::ITContainer1D< TYPE, TContainer1D >::getRange(), STK::ArrayHo< TYPE >::initElts(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().
00163 : _IArrayHoType(T, ref) 00164 { 00165 // check if we want just a reference 00166 if (!ref) 00167 { 00168 // if this is not a reference, initialize the container 00169 this->initElts(T.getRange()); 00170 // this and T have the same row : save time 00171 const Integer row(T.getIndex()); 00172 // and copy the datas 00173 for (Integer j=this->first(); j<=this->last(); j++) 00174 this->getData(j)[row] = T.getData(j)[row]; 00175 } 00176 }
| STK::ArrayHo< TYPE >::ArrayHo | ( | const ArrayHo< TYPE > & | T, | |
| const Inx & | I | |||
| ) | [inline] |
Ctor by reference, ref_=1.
| T | the container to wrap | |
| I | the range of the datas to wrap |
Definition at line 182 of file STK_ArrayHo.h.
00183 : _IArrayHoType(T, I) 00184 { ;}
| STK::ArrayHo< TYPE >::ArrayHo | ( | const _IArrayBaseType & | T, | |
| const Inx & | I, | |||
| Integer | row | |||
| ) | [inline] |
Ctor by reference, ref_=1.
| T | the container to wrap | |
| I | the range of the datas to wrap | |
| row | the index of the row to wrap |
Definition at line 191 of file STK_ArrayHo.h.
00192 : _IArrayHoType(T, I, row) 00193 { ;}
| virtual STK::ArrayHo< TYPE >::~ArrayHo | ( | ) | [inline, virtual] |
virtual Dtor.
Definition at line 198 of file STK_ArrayHo.h.
References STK::ArrayHo< TYPE >::freeElts(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::getRange(), and STK::IContainerRef::isRef().
| TYPE const& STK::ArrayHo< TYPE >::getElt | ( | const Integer & | pos | ) | const [inline] |
Get one element const.
| pos | index of the element (const) |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 208 of file STK_ArrayHo.h.
References STK::IArrayBase< TYPE * >::getData(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().
Referenced by STK::ArrayHo< Real >::ArrayHo(), STK::ArrayHo< TYPE >::ArrayHo(), STK::ArrayHo< Real >::operator*=(), STK::ArrayHo< Real >::operator+=(), STK::ArrayHo< Real >::operator-=(), STK::ArrayHo< Real >::operator/=(), STK::ArrayHo< Real >::operator=(), and STK::ArrayHo< TYPE >::operator=().
| TYPE& STK::ArrayHo< TYPE >::getElt | ( | const Integer & | pos | ) | [inline] |
Get one element.
| pos | index of the element |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 214 of file STK_ArrayHo.h.
References STK::IArrayBase< TYPE * >::getData(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().
| ArrayHo STK::ArrayHo< TYPE >::getElt | ( | const Inx & | J | ) | const [inline] |
access to many elements.
| J | Range of the elements |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 220 of file STK_ArrayHo.h.
References STK::ArrayHo< TYPE >::ArrayHo(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().
| void STK::ArrayHo< TYPE >::clear | ( | ) | [inline] |
clear the object.
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 226 of file STK_ArrayHo.h.
References STK::ArrayHo< TYPE >::freeMem(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange().
Referenced by STK::ArrayHo< Real >::initialize(), and STK::ArrayHo< TYPE >::initialize().
00227 { 00228 this->freeMem(); // Free Mem 00229 this->setRange(); // Set dimension to default 00230 }
| void STK::ArrayHo< TYPE >::freeMem | ( | ) | [inline] |
Method for memory desallocation. Memory is liberated but the range of the container is not updated.
Definition at line 235 of file STK_ArrayHo.h.
References STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::free1D(), STK::ArrayHo< TYPE >::freeElts(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::getRange(), and STK::IContainerRef::isRef().
Referenced by STK::ArrayHo< Real >::clear(), STK::ArrayHo< TYPE >::clear(), STK::ArrayHo< Real >::eraseElts(), STK::ArrayHo< TYPE >::eraseElts(), STK::ArrayHo< Real >::popBackElts(), and STK::ArrayHo< TYPE >::popBackElts().
00236 { 00237 if (this->isRef()) return; // Nothing to do for ref 00238 this->freeElts(this->getRange()); // free the ptr of elts 00239 this->free1D(); // free the elts 00240 }
| void STK::ArrayHo< TYPE >::initialize | ( | const Inx & | I | ) | [inline] |
function for memory allocation and initialization. This method will free all allocated memory owned by this container before initialization.
| I | range of the container |
Definition at line 247 of file STK_ArrayHo.h.
References STK::ArrayHo< TYPE >::clear(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::init1D(), STK::ArrayHo< TYPE >::initElts(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange(), and STK::IContainerRef::setRef().
Referenced by STK::ArrayHo< Real >::pushBackElts(), and STK::ArrayHo< TYPE >::pushBackElts().
00248 { 00249 // check if there is memory allocated 00250 this->clear(); 00251 // if we initialize the memory the container is not a reference 00252 this->setRef(false); 00253 // try to allocate memory 00254 this->init1D(I); 00255 // initialize Horizontally the container 00256 this->initElts(I); 00257 // set the range of the container if init1D is successful 00258 this->setRange(I); 00259 }
| void STK::ArrayHo< TYPE >::pushBackElts | ( | const Integer & | n = 1 |
) | [inline] |
Add n Elts to the container.
| n | number of elements to add |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 264 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::empty(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::initialize(), STK::ArrayHo< TYPE >::insertElts(), STK::IContainerRef::isRef(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().
00265 { 00266 // if n<=0 nothing to do 00267 if (n <= 0) return; 00268 // is this structure just a pointer? 00269 if (this->isRef()) 00270 { throw std::runtime_error("ArrayHo::pushBackElts(n) " 00271 "can't operate on references."); 00272 } 00273 // If the container is empty : create it 00274 if (this->empty()) 00275 this->initialize(Inx(this->first(), this->first()+n-1)); 00276 else 00277 this->insertElts(this->last()+1, n); 00278 }
| void STK::ArrayHo< TYPE >::insertElts | ( | const Integer & | pos, | |
| const Integer & | n = 1 | |||
| ) | [inline] |
Insert n elts at the position pos of the container.
| pos | index where to insert elements | |
| n | number of elements to insert (default 1) |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 284 of file STK_ArrayHo.h.
References STK::IContainerBase< ArrayHo< TYPE > >::asLeaf(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getCapacity(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::getRange(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::incLast(), STK::Inx::incLast(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::init1D(), STK::ArrayHo< TYPE >::initElts(), STK::IContainerRef::isRef(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::moveElt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::swap().
Referenced by STK::ArrayHo< Real >::pushBackElts(), and STK::ArrayHo< TYPE >::pushBackElts().
00285 { 00286 // if n<=0 nothing to do 00287 if (n <= 0) return; 00288 // is this structure just a pointer? 00289 if (this->isRef()) 00290 { throw std::runtime_error("ArrayHo::insertElts(pos, n) " 00291 "can't operate on references."); 00292 } 00293 #ifdef STK_BOUNDS_CHECK 00294 // check indices 00295 if (this->first() > pos) 00296 { throw std::out_of_range("ArrayHo::insertElts(pos, n) " 00297 "this->first() > pos"); 00298 } 00299 if (this->last()+1 < pos) 00300 { throw std::out_of_range("ArrayHo::insertElts(pos, n) " 00301 "this->last()+1 < pos"); 00302 } 00303 #endif 00304 // compute new range 00305 // allocate, if necessary, the mem for the elts 00306 if (this->getCapacity() < this->size()+n) 00307 { 00308 // compute range of the container after insertion 00309 Inx range(this->getRange()); 00310 range.incLast(n); 00311 // temporary empty container 00312 ArrayHo Taux; 00313 // save Elts in Taux 00314 this->swap(Taux); 00315 // initialize Elts of the container 00316 try 00317 { 00318 this->init1D(range); 00319 } 00320 catch (std::runtime_error & error) // if an error occur 00321 { 00322 this->swap(Taux); // restore container 00323 throw error; // and send again the exception 00324 } 00325 // set the range of the Cols 00326 this->setRange(range); 00327 // move first Elts from Taux to this 00328 for (Integer k=this->first(); k<pos; k++) 00329 this->moveElt(k, Taux, k); 00330 // translate and copy last Elts from Taux to this 00331 for (Integer k=this->last()-n; k>=pos; k--) 00332 this->moveElt(k+n, Taux, k); 00333 } 00334 else // enough space -> initialize and shift the last elts 00335 { 00336 // update range 00337 this->incLast(n); 00338 // translate datas 00339 for (Integer k=this->last()-n; k>=pos; k--) 00340 this->moveElt(k+n, this->asLeaf(), k); 00341 } 00342 // initialize the Elts in the range pos:pos+n-1 00343 this->initElts(Inx(pos, pos+n-1)); 00344 }
| void STK::ArrayHo< TYPE >::popBackElts | ( | const Integer & | n = 1 |
) | [inline] |
Delete last elts of the container.
| n | number of elts to delete |
Reimplemented from STK::ITContainer1D< TYPE, ArrayHo< TYPE > >.
Definition at line 349 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::decLast(), STK::ArrayHo< TYPE >::freeElts(), STK::ArrayHo< TYPE >::freeMem(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::getSize(), STK::IContainerRef::isRef(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().
00350 { 00351 // if n<=0 nothing to do 00352 if (n <= 0) return; 00353 // is this structure just a pointer? 00354 if (this->isRef()) 00355 { throw std::runtime_error("ArrayHo::popBackElts() " 00356 "can't operate on references."); 00357 } 00358 #ifdef STK_BOUNDS_CHECK 00359 // if there is elts to erase 00360 if (this->getSize()<n) 00361 { throw std::out_of_range("ArrayHo::popBackElts(n) " 00362 "this->getSize() < n"); 00363 } 00364 #endif 00365 // delete each elt 00366 this->freeElts(Inx(this->last()-n+1, this->last())); 00367 // update range 00368 this->decLast(n); 00369 // if there is no more Elts 00370 if (this->getSize() == 0) this->freeMem(); 00371 }
| void STK::ArrayHo< TYPE >::eraseElts | ( | Integer | pos, | |
| Integer | n = 1 | |||
| ) | [inline] |
Delete n elts at the pos index to the container.
| pos | index where to delete elements | |
| n | number of elements to delete (default 1) |
Definition at line 377 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::decLast(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::freeElts(), STK::ArrayHo< TYPE >::freeMem(), STK::IArrayBase< TYPE * >::getData(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::getSize(), STK::IContainerRef::isRef(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), and STK::IArrayBase< TYPE * >::setData().
00378 { 00379 // if n==0 nothing to do 00380 if (n<=0) return; 00381 // is this structure just a pointer? 00382 if (this->isRef()) 00383 { throw std::runtime_error("ArrayHo::eraseElts(pos, n) " 00384 "can't operate on references."); 00385 } 00386 #ifdef STK_BOUNDS_CHECK 00387 // check bounds 00388 if (this->first() > pos) 00389 { throw std::out_of_range("ArrayHo::eraseElts(pos, n) " 00390 "this->first() > pos"); 00391 } 00392 if (this->last() < pos) 00393 { throw std::out_of_range("ArrayHo::eraseElts(pos, n)" 00394 " this->last() < pos"); 00395 } 00396 if (this->last() < pos+n-1) 00397 { throw std::out_of_range("ArrayHo::eraseElts(pos, n)" 00398 " this->last() < pos+n-1"); 00399 } 00400 #endif 00401 // delete each col 00402 this->freeElts(Inx(pos, pos+n-1)); 00403 // update rangeHo_ 00404 this->decLast(n); 00405 // shift Elts 00406 for (Integer k=pos; k<=this->last(); k++) 00407 this->setData(k, this->getData(k+n)); 00408 // if there is no more Elts 00409 if (this->getSize() == 0) this->freeMem(); 00410 }
| ArrayHo& STK::ArrayHo< TYPE >::operator= | ( | const ArrayHo< TYPE > & | T | ) | [inline] |
operator = : overwrite the ArrayHo with the ArrayHo T. We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.
| T | the container to copy |
Definition at line 419 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::getElt(), STK::ITContainer1D< TYPE, TContainer1D >::getRange(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::resize(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().
00420 { // We have to resize if this and T does not have the same size 00421 // but if they have the same size, we don't scale the index 00422 if (this->size()!=T.size()) this->resize(T.getRange()); 00423 00424 /*--------------------------------------------------------------*/ 00425 // copy without ovelapping 00426 if (this->first() < T.first()) 00427 { for (Integer j=this->first(), i=T.first(); i<=T.last(); j++, i++) 00428 getElt(j) = T.getElt(i); 00429 } 00430 else 00431 { for (Integer j=this->last(), i=T.last(); i>=T.first(); j--, i--) 00432 getElt(j) = T.getElt(i); 00433 } 00434 return *this; 00435 }
| ArrayHo& STK::ArrayHo< TYPE >::operator= | ( | const TYPE & | v | ) | [inline] |
operator= : set the container to a constant value.
| v | the value to set |
Definition at line 440 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::getElt(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().
00441 { 00442 for (Integer i=this->first(); i<=this->last(); i++) 00443 this->getElt(i) = v; 00444 return *this; 00445 }
| ArrayHo& STK::ArrayHo< TYPE >::operator= | ( | const ITContainer1D< TYPE, LEAF > & | T | ) | [inline] |
operator = : overwrite the ArrayHo with the container T. We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.
| T | the container to copy |
Definition at line 454 of file STK_ArrayHo.h.
References STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::getElt(), STK::ITContainer1D< TYPE, TContainer1D >::getRange(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::resize(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().
00455 { // We have to resize if this and T does not have the same size 00456 // but if they have the same size, we don't scale the index 00457 if (this->size()!=T.size()) this->resize(T.getRange()); 00458 00459 /*--------------------------------------------------------------*/ 00460 // copy without ovelapping 00461 if (this->first() < T.first()) 00462 { for (Integer j=this->first(), i=T.first(); i<=T.last(); j++, i++) 00463 getElt(j) = T[i]; 00464 } 00465 else 00466 { for (Integer j=this->last(), i=T.last(); i>=T.first(); j--, i--) 00467 getElt(j) = T[i]; 00468 } 00469 return *this; 00470 }
| void STK::ArrayHo< TYPE >::initElts | ( | const Inx & | J | ) | [inline, protected] |
Method for elts memory allocation.
| J | the range of the Elts to initialize |
Definition at line 478 of file STK_ArrayHo.h.
References STK::Inx::first(), STK::ArrayHo< TYPE >::freeElt(), STK::ArrayHo< TYPE >::initElt(), STK::Inx::last(), and STK::IArrayBase< TYPE * >::setData().
Referenced by STK::ArrayHo< Real >::ArrayHo(), STK::ArrayHo< TYPE >::ArrayHo(), STK::ArrayHo< Real >::initialize(), STK::ArrayHo< TYPE >::initialize(), STK::ArrayHo< Real >::insertElts(), and STK::ArrayHo< TYPE >::insertElts().
00479 { 00480 // for each col 00481 for (Integer j=J.first(); j<=J.last(); j++) 00482 { 00483 // try to Allocate mem for the jth elt 00484 try 00485 { 00486 this->initElt(j); 00487 } 00488 catch (std::runtime_error & error) // if an error occur 00489 { 00490 // for each col allocated 00491 for (Integer k=J.first(); k<j; k++) 00492 this->freeElt(k); 00493 // put default parameters for the elts j to end 00494 for (Integer k=j; k<=J.last(); k++) 00495 this->setData(k); 00496 // and throw an exception 00497 throw error; 00498 } 00499 } 00500 }
| void STK::ArrayHo< TYPE >::freeElts | ( | const Inx & | J | ) | [inline, protected] |
Method for Elts memory desallocation.
| J | the range of the Elts to liberate |
Definition at line 505 of file STK_ArrayHo.h.
References STK::Inx::first(), STK::ArrayHo< TYPE >::freeElt(), and STK::Inx::last().
Referenced by STK::ArrayHo< Real >::eraseElts(), STK::ArrayHo< TYPE >::eraseElts(), STK::ArrayHo< Real >::freeMem(), STK::ArrayHo< TYPE >::freeMem(), STK::ArrayHo< Real >::popBackElts(), STK::ArrayHo< TYPE >::popBackElts(), STK::ArrayHo< Real >::~ArrayHo(), and STK::ArrayHo< TYPE >::~ArrayHo().
00506 { 00507 // for all elts 00508 for (Integer j=J.first(); j<=J.last(); j++) 00509 this->freeElt(j); 00510 }
| void STK::ArrayHo< TYPE >::initElt | ( | const Integer & | pos | ) | [inline, protected] |
function for the the allocation of memory of element pos.
| pos | the number of the elt to initialize |
Definition at line 516 of file STK_ArrayHo.h.
References STK::IArrayBase< TYPE * >::getData(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex(), and STK::IArrayBase< TYPE * >::setData().
Referenced by STK::ArrayHo< Real >::initElts(), and STK::ArrayHo< TYPE >::initElts().
00517 { 00518 // try to Allocate mem for each col 00519 try 00520 { 00521 this->setData(pos, new TYPE); 00522 this->getData(pos) -= this->getIndex(); 00523 } 00524 catch (std::bad_alloc & error) // if an alloc error occur 00525 { 00526 // set default 00527 this->setData(pos); 00528 // throw an exception 00529 throw std::runtime_error("ArrayHo::initElt(pos) " 00530 "memory allocation failed."); 00531 } 00532 }
| void STK::ArrayHo< TYPE >::freeElt | ( | const Integer & | pos | ) | [inline, protected] |
protected function for the the desallocation of memory of the element pos.
| pos | the number of the element to liberate |
Definition at line 538 of file STK_ArrayHo.h.
References STK::IArrayBase< TYPE * >::getData(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex(), and STK::IArrayBase< TYPE * >::setData().
Referenced by STK::ArrayHo< Real >::freeElts(), STK::ArrayHo< TYPE >::freeElts(), STK::ArrayHo< Real >::initElts(), and STK::ArrayHo< TYPE >::initElts().
00539 { 00540 if (this->getData(pos)) // if there is an elt 00541 { 00542 this->getData(pos) += this->getIndex(); 00543 delete this->getData(pos); // erase 00544 this->setData(pos); // set default 00545 } 00546 }
1.5.8