From 5ea802e54ecd1d6acd0c83c2dfed7eeb098d8d16 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de> Date: Mon, 23 Nov 2015 15:00:42 +0100 Subject: [PATCH] Rename vec_access() and vec_size() methods This commit renames the `vec_access()` and `vec_size()` methods to match the ones in the `DenseVector` facade class, that is `operator[]()` and `size()`. Closes #3 --- dune/common/densevector.hh | 6 +++--- dune/common/dynvector.hh | 6 +++--- dune/common/fvector.hh | 16 ++++++---------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/dune/common/densevector.hh b/dune/common/densevector.hh index 94ec30c6b..2a4491907 100644 --- a/dune/common/densevector.hh +++ b/dune/common/densevector.hh @@ -284,18 +284,18 @@ namespace Dune { //! random access value_type & operator[] (size_type i) { - return asImp().vec_access(i); + return asImp()[i]; } const value_type & operator[] (size_type i) const { - return asImp().vec_access(i); + return asImp()[i]; } //! size method size_type size() const { - return asImp().vec_size(); + return asImp().size(); } //! Iterator class for sequential access diff --git a/dune/common/dynvector.hh b/dune/common/dynvector.hh index 0319e6d74..e8596c1a0 100644 --- a/dune/common/dynvector.hh +++ b/dune/common/dynvector.hh @@ -137,9 +137,9 @@ namespace Dune { } //==== make this thing a vector - size_type vec_size() const { return _data.size(); } - K & vec_access(size_type i) { return _data[i]; } - const K & vec_access(size_type i) const { return _data[i]; } + size_type size() const { return _data.size(); } + K & operator[](size_type i) { return _data[i]; } + const K & operator[](size_type i) const { return _data[i]; } }; /** \brief Read a DynamicVector from an input stream diff --git a/dune/common/fvector.hh b/dune/common/fvector.hh index 48807360f..27ec2c82f 100644 --- a/dune/common/fvector.hh +++ b/dune/common/fvector.hh @@ -158,12 +158,10 @@ namespace Dune { } using Base::operator=; - DUNE_CONSTEXPR size_type size () const { return vec_size(); } - // make this thing a vector - DUNE_CONSTEXPR size_type vec_size () const { return SIZE; } - K & vec_access(size_type i) { return _data[i]; } - const K & vec_access(size_type i) const { return _data[i]; } + DUNE_CONSTEXPR size_type size () const { return SIZE; } + K & operator[](size_type i) { return _data[i]; } + const K & operator[](size_type i) const { return _data[i]; } private: void fill(const K& t) { @@ -266,17 +264,15 @@ namespace Dune { return *this; } - DUNE_CONSTEXPR size_type size () const { return vec_size(); } - //===== forward methods to container - DUNE_CONSTEXPR size_type vec_size () const { return 1; } - K & vec_access(size_type i) + DUNE_CONSTEXPR size_type size () const { return 1; } + K & operator[](size_type i) { DUNE_UNUSED_PARAMETER(i); assert(i == 0); return _data; } - const K & vec_access(size_type i) const + const K & operator[](size_type i) const { DUNE_UNUSED_PARAMETER(i); assert(i == 0); -- GitLab