
Module: ppl/ppl Branch: sparse_matrices Commit: 72882a3727550d333b7faeb80c172a54b88b5ecd URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=72882a3727550...
Author: Marco Poletti poletti.marco@gmail.com Date: Tue Mar 9 13:35:53 2010 +0100
Dense_Row: add find() and find_create() methods, for compatibility with Sparse_Row.
---
src/Dense_Row.defs.hh | 14 ++++++++++++++ src/Dense_Row.inlines.hh | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/Dense_Row.defs.hh b/src/Dense_Row.defs.hh index 44decef..ebb6e68 100644 --- a/src/Dense_Row.defs.hh +++ b/src/Dense_Row.defs.hh @@ -167,6 +167,20 @@ public: void get2(const dimension_type c1,const dimension_type c2, const Coefficient*& p1,const Coefficient*& p2) const;
+ //! Provided for compatibility with Sparse_Row. + iterator find(dimension_type i); + + //! Provided for compatibility with Sparse_Row. + //! itr must point to an element before the searched one. + iterator find(dimension_type i,iterator itr); + + //! Provided for compatibility with Sparse_Row. + iterator find_create(dimension_type i,const Coefficient& x); + + //! Provided for compatibility with Sparse_Row. + //! itr must point to an element before the modified one. + iterator find_create(dimension_type i,const Coefficient& x,iterator itr); + //! \name Subscript operators //@{ //! Returns a reference to the element of the row indexed by \p k. diff --git a/src/Dense_Row.inlines.hh b/src/Dense_Row.inlines.hh index 7e766d7..7232a3c 100644 --- a/src/Dense_Row.inlines.hh +++ b/src/Dense_Row.inlines.hh @@ -161,6 +161,31 @@ Dense_Row::get2(const dimension_type c1,const dimension_type c2, p2 = &(get(c2)); }
+inline Dense_Row::iterator +Dense_Row::find(dimension_type i) { + return iterator(*this,i); +} + +inline Dense_Row::iterator +Dense_Row::find(dimension_type i,iterator itr) { + PPL_ASSERT((*itr).first < i); + return iterator(*this,i); +} + +inline Dense_Row::iterator +Dense_Row::find_create(dimension_type i,const Coefficient& x) { + (*this)[i] = x; + return find(i); +} + +inline Dense_Row::iterator +Dense_Row::find_create(dimension_type i,const Coefficient& x,iterator itr) { + PPL_ASSERT(itr != end()); + PPL_ASSERT((*itr).first < i); + (*this)[i] = x; + return find(i); +} + inline Coefficient& Dense_Row::operator[](const dimension_type k) { return row[k];