From 04726e20678a1dd8269b33a51e3a3a16d38ddb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 10 Dec 2017 12:00:17 +0100 Subject: [PATCH] Hash tables - Accessing values in RW mode --- include/ebcl/HashTables.hh | 12 +++++++----- include/ebcl/inline/HashTables.hh | 22 +++++++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/ebcl/HashTables.hh b/include/ebcl/HashTables.hh index 1a894f5..fd87a86 100644 --- a/include/ebcl/HashTables.hh +++ b/include/ebcl/HashTables.hh @@ -90,9 +90,10 @@ class T_KeyValueTable // --------------------------------------------------------------------- - uint32_t size( ) const; - T_Array< KeyType > const& keys( ) const; - T_Array< ValueType > const& values( ) const; + uint32_t size( ) const noexcept; + T_Array< KeyType > const& keys( ) const noexcept; + T_Array< ValueType > const& values( ) const noexcept; + T_Array< ValueType >& values( ) noexcept; uint32_t indexOf( KeyType const& k ) const; bool contains( KeyType const& k ) const; @@ -182,8 +183,9 @@ class T_ObjectTable uint32_t size( ) const; uint32_t indexOf( KeyType const& k ) const; bool contains( KeyType const& k ) const; - T_Array< KeyType > keys( ) const; - T_Array< ValueType > const& values( ) const; + T_Array< KeyType > keys( ) const noexcept; + T_Array< ValueType > const& values( ) const noexcept; + T_Array< ValueType >& values( ) noexcept; ValueType const * get( KeyType const& k ) const; ValueType * get( KeyType const& k ); diff --git a/include/ebcl/inline/HashTables.hh b/include/ebcl/inline/HashTables.hh index 22dc150..66c00ab 100644 --- a/include/ebcl/inline/HashTables.hh +++ b/include/ebcl/inline/HashTables.hh @@ -131,19 +131,25 @@ inline void T_KeyValueTable< K , V >::free( ) /*----------------------------------------------------------------------------*/ template< typename K , typename V > -inline uint32_t T_KeyValueTable< K , V >::size( ) const +inline uint32_t T_KeyValueTable< K , V >::size( ) const noexcept { return keys_.size( ); } template< typename K , typename V > -T_Array< K > const& T_KeyValueTable< K , V >::keys( ) const +T_Array< K > const& T_KeyValueTable< K , V >::keys( ) const noexcept { return keys_; } template< typename K , typename V > -T_Array< V > const& T_KeyValueTable< K , V >::values( ) const +T_Array< V > const& T_KeyValueTable< K , V >::values( ) const noexcept +{ + return values_; +} + +template< typename K , typename V > +T_Array< V >& T_KeyValueTable< K , V >::values( ) noexcept { return values_; } @@ -364,7 +370,7 @@ inline bool T_ObjectTable< K , V >::contains( K const& k ) const /*----------------------------------------------------------------------------*/ template< typename K , typename V > -inline T_Array< K > T_ObjectTable< K , V >::keys( ) const +inline T_Array< K > T_ObjectTable< K , V >::keys( ) const noexcept { const auto sz( size( ) ); T_Array< K > k( sz ? sz : 1 ); @@ -375,7 +381,13 @@ inline T_Array< K > T_ObjectTable< K , V >::keys( ) const } template< typename K , typename V > -inline T_Array< V > const& T_ObjectTable< K , V >::values( ) const +inline T_Array< V > const& T_ObjectTable< K , V >::values( ) const noexcept +{ + return values_; +} + +template< typename K , typename V > +inline T_Array< V >& T_ObjectTable< K , V >::values( ) noexcept { return values_; }