From df37d692f16e10fa405faf0e09a0130142168f6b Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 29 Mar 2016 22:50:22 +0300 Subject: [PATCH] Minor bugfix, docfix --- cds/container/michael_map_nogc.h | 71 +++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/cds/container/michael_map_nogc.h b/cds/container/michael_map_nogc.h index 6fd18f76..61ec5dc9 100644 --- a/cds/container/michael_map_nogc.h +++ b/cds/container/michael_map_nogc.h @@ -93,44 +93,32 @@ namespace cds { namespace container { protected: //@cond /// Calculates hash value of \p key - size_t hash_value( key_type const & key ) const + template + size_t hash_value( K const & key ) const { return m_HashFunctor( key ) & m_nHashBitmask; } /// Returns the bucket (ordered list) for \p key - bucket_type& bucket( key_type const& key ) + template + bucket_type& bucket( K const& key ) { return m_Buckets[ hash_value( key ) ]; } //@endcond protected: - /// Forward iterator - /** - \p IsConst - constness boolean flag - - The forward iterator for Michael's map is based on \p OrderedList forward iterator and has some features: - - it has no post-increment operator, only pre-increment - - it iterates items in unordered fashion - */ + //@cond template class iterator_type: private cds::intrusive::michael_set::details::iterator< bucket_type, IsConst > { - //@cond typedef cds::intrusive::michael_set::details::iterator< bucket_type, IsConst > base_class; friend class MichaelHashMap; - //@endcond protected: - //@cond - //typedef typename base_class::bucket_type bucket_type; typedef typename base_class::bucket_ptr bucket_ptr; typedef typename base_class::list_iterator list_iterator; - //typedef typename bucket_type::key_type key_type; - //@endcond - public: /// Value pointer type (const for const_iterator) typedef typename cds::details::make_const_type::pointer value_ptr; @@ -143,11 +131,9 @@ namespace cds { namespace container { typedef typename cds::details::make_const_type::reference pair_ref; protected: - //@cond iterator_type( list_iterator const& it, bucket_ptr pFirst, bucket_ptr pLast ) : base_class( it, pFirst, pLast ) {} - //@endcond public: /// Default ctor @@ -207,10 +193,45 @@ namespace cds { namespace container { return !( *this == i ); } }; - + //@endcond public: + ///@name Forward iterators + //@{ /// Forward iterator + /** + The forward iterator for Michael's map is based on \p OrderedList forward iterator and has some features: + - it has no post-increment operator + - it iterates items in unordered fashion + + The iterator interface: + \code + class iterator { + public: + // Default constructor + iterator(); + + // Copy construtor + iterator( iterator const& src ); + + // Dereference operator + value_type * operator ->() const; + + // Dereference operator + value_type& operator *() const; + + // Preincrement operator + iterator& operator ++(); + + // Assignment operator + iterator& operator = (iterator const& src); + + // Equality operators + bool operator ==(iterator const& i ) const; + bool operator !=(iterator const& i ) const; + }; + \endcode + */ typedef iterator_type< false > iterator; /// Const forward iterator @@ -237,28 +258,29 @@ namespace cds { namespace container { } /// Returns a forward const iterator addressing the first element in a set - //@{ const_iterator begin() const { return get_const_begin(); } + + /// Returns a forward const iterator addressing the first element in a set const_iterator cbegin() const { return get_const_begin(); } - //@} /// Returns an const iterator that addresses the location succeeding the last element in a set - //@{ const_iterator end() const { return get_const_end(); } + + /// Returns an const iterator that addresses the location succeeding the last element in a set const_iterator cend() const { return get_const_end(); } - //@} + //@} private: //@cond @@ -485,6 +507,7 @@ namespace cds { namespace container { The function is an analog of contains( key ) but \p pred is used for key comparing. \p Less functor has the interface like \p std::less. \p pred must imply the same element order as the comparator used for building the map. + Hash functor specified in \p Traits should accept parameters of type \p K. */ template iterator contains( K const& key, Less pred ) -- 2.34.1