X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMemArray.txx;h=90773df2bf988fdc97fb6522ffaf3af13a069222;hb=6bfd8d6afb47fa46fd8fa0bc98d7fe057790460c;hp=1eb130c25fac8f5c50f5c4e3e9818e746c1db249;hpb=d841bf0f548baf1321a64cad715c7dff9110dd3b;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 1eb130c25..90773df2b 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -82,7 +82,7 @@ namespace ParaMEDMEM _ownership=false; _dealloc=CPPDeallocator; } - + template void MemArray::writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers) { @@ -93,7 +93,7 @@ namespace ParaMEDMEM std::copy(others,others+sizeOfOthers,pointer+id+1); _nb_of_elem=std::max(_nb_of_elem,id+sizeOfOthers+1); } - + template template void MemArray::insertAtTheEnd(InputIterator first, InputIterator last) @@ -109,18 +109,18 @@ namespace ParaMEDMEM pointer[_nb_of_elem++]=*first++; } } - + template - void MemArray::pushBack(T elem) throw(INTERP_KERNEL::Exception) + void MemArray::pushBack(T elem) { if(_nb_of_elem>=_nb_of_elem_alloc) reserve(_nb_of_elem_alloc>0?2*_nb_of_elem_alloc:1); T *pt=getPointer(); pt[_nb_of_elem++]=elem; } - + template - T MemArray::popBack() throw(INTERP_KERNEL::Exception) + T MemArray::popBack() { if(_nb_of_elem>0) { @@ -129,12 +129,11 @@ namespace ParaMEDMEM } throw INTERP_KERNEL::Exception("MemArray::popBack : nothing to pop in array !"); } - + template void MemArray::pack() const { - if(_nb_of_elem>=0) - (const_cast * >(this))->reserve(_nb_of_elem); + (const_cast * >(this))->reserve(_nb_of_elem); } template @@ -181,7 +180,7 @@ namespace ParaMEDMEM { if(sl!=0) stream << _nb_of_elem/sl << std::endl << "Internal memory facts : " << _nb_of_elem << "/" << _nb_of_elem_alloc; - else + else stream << "Empty Data"; } else @@ -193,7 +192,7 @@ namespace ParaMEDMEM stream << "No data !\n"; return ret; } - + /*! * \param [in] sl is typically the number of components */ @@ -218,7 +217,7 @@ namespace ParaMEDMEM stream << "Empty Data\n"; } } - + /*! * \param [in] sl is typically the number of components */ @@ -258,14 +257,14 @@ namespace ParaMEDMEM else stream << "No data !\n"; } - + template void MemArray::fillWithValue(const T& val) { T *pt=_pointer.getPointer(); std::fill(pt,pt+_nb_of_elem,val); } - + template T *MemArray::fromNoInterlace(int nbOfComp) const { @@ -280,7 +279,7 @@ namespace ParaMEDMEM *w=pt[j*nbOfTuples+i]; return ret; } - + template T *MemArray::toNoInterlace(int nbOfComp) const { @@ -334,11 +333,9 @@ namespace ParaMEDMEM } template - void MemArray::alloc(std::size_t nbOfElements) throw(INTERP_KERNEL::Exception) + void MemArray::alloc(std::size_t nbOfElements) { destroy(); - if(nbOfElements<0) - throw INTERP_KERNEL::Exception("MemArray::alloc : request for negative length of data !"); _nb_of_elem=nbOfElements; _nb_of_elem_alloc=nbOfElements; _pointer.setInternal((T*)malloc(_nb_of_elem_alloc*sizeof(T))); @@ -356,10 +353,8 @@ namespace ParaMEDMEM * So this method should not be confused with MemArray::reserve that is close to MemArray::reAlloc but not same. */ template - void MemArray::reserve(std::size_t newNbOfElements) throw(INTERP_KERNEL::Exception) + void MemArray::reserve(std::size_t newNbOfElements) { - if(newNbOfElements<0) - throw INTERP_KERNEL::Exception("MemArray::reAlloc : request for negative length of data !"); if(_nb_of_elem_alloc==newNbOfElements) return ; T *pointer=(T*)malloc(newNbOfElements*sizeof(T)); @@ -382,10 +377,8 @@ namespace ParaMEDMEM * So this method should not be confused with MemArray::reserve that is close to MemArray::reAlloc but not same. */ template - void MemArray::reAlloc(std::size_t newNbOfElements) throw(INTERP_KERNEL::Exception) + void MemArray::reAlloc(std::size_t newNbOfElements) { - if(newNbOfElements<0) - throw INTERP_KERNEL::Exception("MemArray::reAlloc : request for negative length of data !"); if(_nb_of_elem==newNbOfElements) return ; T *pointer=(T*)malloc(newNbOfElements*sizeof(T)); @@ -413,17 +406,17 @@ namespace ParaMEDMEM } template - typename MemArray::Deallocator MemArray::BuildFromType(DeallocType type) throw(INTERP_KERNEL::Exception) + typename MemArray::Deallocator MemArray::BuildFromType(DeallocType type) { switch(type) - { + { case CPP_DEALLOC: return CPPDeallocator; case C_DEALLOC: return CDeallocator; default: throw INTERP_KERNEL::Exception("Invalid deallocation requested ! Unrecognized enum DeallocType !"); - } + } } template @@ -445,7 +438,7 @@ namespace ParaMEDMEM _nb_of_elem=0; _nb_of_elem_alloc=0; } - + template MemArray &MemArray::operator=(const MemArray& other) {