From: ageay Date: Mon, 20 Feb 2012 16:22:30 +0000 (+0000) Subject: Addition of "empty" method. X-Git-Tag: V6_main_FINAL~837 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79cee2fddcad93067c407da067e63574e49b46b3;p=tools%2Fmedcoupling.git Addition of "empty" method. --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index da0befe97..e9d0a4650 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -331,6 +331,16 @@ void DataArrayDouble::checkAllocated() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayDouble::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); } +/*! + * This method should be called on an allocated DataArrayDouble instance. If not an exception will be throw ! + * This method checks the number of tupes. If it is equal to 0, it returns true, if not false is returned. + */ +bool DataArrayDouble::empty() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + return getNumberOfTuples()==0; +} + DataArrayDouble *DataArrayDouble::deepCpy() const { return new DataArrayDouble(*this); @@ -2379,6 +2389,16 @@ void DataArrayInt::checkAllocated() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayInt::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); } +/*! + * This method should be called on an allocated DataArrayInt instance. If not an exception will be throw ! + * This method checks the number of tupes. If it is equal to 0, it returns true, if not false is returned. + */ +bool DataArrayInt::empty() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + return getNumberOfTuples()==0; +} + DataArrayInt *DataArrayInt::deepCpy() const { return new DataArrayInt(*this); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index f6e7bfcf5..e35a7c3c3 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -136,6 +136,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayDouble *New(); MEDCOUPLING_EXPORT bool isAllocated() const; MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const; MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const; MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception); @@ -305,6 +306,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayInt *New(); MEDCOUPLING_EXPORT bool isAllocated() const; MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const; MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const; MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception);