From 0fcb2d8041856bd77176b1296aca832d086d69d1 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 30 Apr 2006 14:11:47 +0000 Subject: [PATCH] Add cbegin() and cend() from the new draft standard to the unordered containers. The standard doesn't add them for local iterators, but I'm guessing that's an oversight. So for now, I've hidden them behind a preprocessor condition. Which I'll probably remove before review. [SVN r2944] --- include/boost/unordered_map.hpp | 44 +++++++++++++++++++++++++++++++++ include/boost/unordered_set.hpp | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/include/boost/unordered_map.hpp b/include/boost/unordered_map.hpp index 2d26fc63..009e7f9d 100644 --- a/include/boost/unordered_map.hpp +++ b/include/boost/unordered_map.hpp @@ -172,6 +172,16 @@ namespace boost return const_iterator(base.end()); } + const_iterator cbegin() const + { + return const_iterator(base.begin()); + } + + const_iterator cend() const + { + return const_iterator(base.end()); + } + // modifiers std::pair insert(const value_type& obj) @@ -321,6 +331,18 @@ namespace boost return const_local_iterator(base.end(n)); } +#if defined(BOOST_UNORDERED_LOCAL_CBEGIN) + const_local_iterator cbegin(size_type n) const + { + return const_local_iterator(base.begin(n)); + } + + const_local_iterator cend(size_type n) const + { + return const_local_iterator(base.end(n)); + } +#endif + // hash policy float load_factor() const @@ -475,6 +497,16 @@ namespace boost return const_iterator(base.end()); } + const_iterator cbegin() const + { + return const_iterator(base.begin()); + } + + const_iterator cend() const + { + return const_iterator(base.end()); + } + // modifiers iterator insert(const value_type& obj) @@ -618,6 +650,18 @@ namespace boost return const_local_iterator(base.end(n)); } +#if defined(BOOST_UNORDERED_LOCAL_CBEGIN) + const_local_iterator cbegin(size_type n) const + { + return const_local_iterator(base.begin(n)); + } + + const_local_iterator cend(size_type n) const + { + return const_local_iterator(base.end(n)); + } +#endif + // hash policy float load_factor() const diff --git a/include/boost/unordered_set.hpp b/include/boost/unordered_set.hpp index 75d16031..ee5a9b6c 100644 --- a/include/boost/unordered_set.hpp +++ b/include/boost/unordered_set.hpp @@ -144,6 +144,16 @@ namespace boost return const_iterator(base.end()); } + const_iterator cbegin() const + { + return const_iterator(base.begin()); + } + + const_iterator cend() const + { + return const_iterator(base.end()); + } + // modifiers std::pair insert(const value_type& obj) @@ -261,6 +271,17 @@ namespace boost return const_local_iterator(base.end(n)); } +#if defined(BOOST_UNORDERED_LOCAL_CBEGIN) + const_local_iterator cbegin(size_type n) const + { + return const_local_iterator(base.begin(n)); + } + + const_local_iterator cend(size_type n) const + { + return const_local_iterator(base.end(n)); + } +#endif // hash policy @@ -413,6 +434,16 @@ namespace boost return const_iterator(base.end()); } + const_iterator cbegin() const + { + return const_iterator(base.begin()); + } + + const_iterator cend() const + { + return const_iterator(base.end()); + } + // modifiers iterator insert(const value_type& obj) @@ -529,6 +560,18 @@ namespace boost return const_local_iterator(base.end(n)); } +#if defined(BOOST_UNORDERED_LOCAL_CBEGIN) + const_local_iterator cbegin(size_type n) const + { + return const_local_iterator(base.begin(n)); + } + + const_local_iterator cend(size_type n) const + { + return const_local_iterator(base.end(n)); + } +#endif + // hash policy float load_factor() const