|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2007-12-07 08:24:48
Author: danieljames
Date: 2007-12-07 08:24:47 EST (Fri, 07 Dec 2007)
New Revision: 41826
URL: http://svn.boost.org/trac/boost/changeset/41826
Log:
Make the allocators templated rather than macro based.
Text files modified:
sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table.hpp | 166 ++++++++++++++++++++++++++++++++++++++-
sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table_impl.hpp | 166 ---------------------------------------
2 files changed, 159 insertions(+), 173 deletions(-)
Modified: sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table.hpp
==============================================================================
--- sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table.hpp (original)
+++ sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table.hpp 2007-12-07 08:24:47 EST (Fri, 07 Dec 2007)
@@ -1031,6 +1031,156 @@
}
};
+ // Iterators
+
+ template <typename Alloc, typename Data> class hash_iterator;
+ template <typename Alloc, typename Data> class hash_const_iterator;
+ template <typename Alloc, typename Data> class hash_local_iterator;
+ template <typename Alloc, typename Data> class hash_const_local_iterator;
+ class iterator_access;
+
+ // Local Iterators
+ //
+ // all no throw
+
+ template <typename Alloc, typename Data>
+ class hash_local_iterator
+ : public boost::iterator <
+ std::forward_iterator_tag,
+ BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
+ std::ptrdiff_t,
+ BOOST_DEDUCED_TYPENAME allocator_pointer<Alloc>::type,
+ BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type >
+ {
+ public:
+ typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
+
+ private:
+ typedef BOOST_DEDUCED_TYPENAME Data::local_iterator_base base;
+ typedef hash_const_local_iterator<Alloc, Data> const_local_iterator;
+
+ friend class hash_const_local_iterator<Alloc, Data>;
+ base base_;
+
+ public:
+ hash_local_iterator() : base_() {}
+ explicit hash_local_iterator(base x) : base_(x) {}
+ BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type operator*() const
+ { return *base_; }
+ value_type* operator->() const { return &*base_; }
+ hash_local_iterator& operator++() { base_.increment(); return *this; }
+ hash_local_iterator operator++(int) { hash_local_iterator tmp(base_); base_.increment(); return tmp; }
+ bool operator==(hash_local_iterator x) const { return base_ == x.base_; }
+ bool operator==(const_local_iterator x) const { return base_ == x.base_; }
+ bool operator!=(hash_local_iterator x) const { return base_ != x.base_; }
+ bool operator!=(const_local_iterator x) const { return base_ != x.base_; }
+ };
+
+ template <typename Alloc, typename Data>
+ class hash_const_local_iterator
+ : public boost::iterator <
+ std::forward_iterator_tag,
+ BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
+ std::ptrdiff_t,
+ BOOST_DEDUCED_TYPENAME allocator_const_pointer<Alloc>::type,
+ BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type >
+ {
+ public:
+ typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
+
+ private:
+ typedef BOOST_DEDUCED_TYPENAME Data::local_iterator_base base;
+ typedef hash_local_iterator<Alloc, Data> local_iterator;
+ friend class hash_local_iterator<Alloc, Data>;
+ base base_;
+
+ public:
+ hash_const_local_iterator() : base_() {}
+ explicit hash_const_local_iterator(base x) : base_(x) {}
+ hash_const_local_iterator(local_iterator x) : base_(x.base_) {}
+ BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type
+ operator*() const { return *base_; }
+ value_type const* operator->() const { return &*base_; }
+ hash_const_local_iterator& operator++() { base_.increment(); return *this; }
+ hash_const_local_iterator operator++(int) { hash_const_local_iterator tmp(base_); base_.increment(); return tmp; }
+ bool operator==(local_iterator x) const { return base_ == x.base_; }
+ bool operator==(hash_const_local_iterator x) const { return base_ == x.base_; }
+ bool operator!=(local_iterator x) const { return base_ != x.base_; }
+ bool operator!=(hash_const_local_iterator x) const { return base_ != x.base_; }
+ };
+
+ // iterators
+ //
+ // all no throw
+
+ template <typename Alloc, typename Data>
+ class hash_iterator
+ : public boost::iterator <
+ std::forward_iterator_tag,
+ BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
+ std::ptrdiff_t,
+ BOOST_DEDUCED_TYPENAME allocator_pointer<Alloc>::type,
+ BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type >
+ {
+ public:
+ typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
+
+ private:
+ typedef BOOST_DEDUCED_TYPENAME Data::iterator_base base;
+ typedef hash_const_iterator<Alloc, Data> const_iterator;
+ friend class hash_const_iterator<Alloc, Data>;
+ base base_;
+
+ public:
+
+ hash_iterator() : base_() {}
+ explicit hash_iterator(base const& x) : base_(x) {}
+ BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type
+ operator*() const { return *base_; }
+ value_type* operator->() const { return &*base_; }
+ hash_iterator& operator++() { base_.increment(); return *this; }
+ hash_iterator operator++(int) { hash_iterator tmp(base_); base_.increment(); return tmp; }
+ bool operator==(hash_iterator const& x) const { return base_ == x.base_; }
+ bool operator==(const_iterator const& x) const { return base_ == x.base_; }
+ bool operator!=(hash_iterator const& x) const { return base_ != x.base_; }
+ bool operator!=(const_iterator const& x) const { return base_ != x.base_; }
+ };
+
+ template <typename Alloc, typename Data>
+ class hash_const_iterator
+ : public boost::iterator <
+ std::forward_iterator_tag,
+ BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
+ std::ptrdiff_t,
+ BOOST_DEDUCED_TYPENAME allocator_const_pointer<Alloc>::type,
+ BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type >
+ {
+ public:
+ typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
+
+ private:
+ typedef BOOST_DEDUCED_TYPENAME Data::iterator_base base;
+ typedef hash_iterator<Alloc, Data> iterator;
+ friend class hash_iterator<Alloc, Data>;
+ friend class iterator_access;
+ base base_;
+
+ public:
+
+ hash_const_iterator() : base_() {}
+ explicit hash_const_iterator(base const& x) : base_(x) {}
+ hash_const_iterator(iterator const& x) : base_(x.base_) {}
+ BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type
+ operator*() const { return *base_; }
+ value_type const* operator->() const { return &*base_; }
+ hash_const_iterator& operator++() { base_.increment(); return *this; }
+ hash_const_iterator operator++(int) { hash_const_iterator tmp(base_); base_.increment(); return tmp; }
+ bool operator==(iterator const& x) const { return base_ == x.base_; }
+ bool operator==(hash_const_iterator const& x) const { return base_ == x.base_; }
+ bool operator!=(iterator const& x) const { return base_ != x.base_; }
+ bool operator!=(hash_const_iterator const& x) const { return base_ != x.base_; }
+ };
+
class iterator_access
{
public:
@@ -1054,10 +1204,10 @@
value_allocator, data> hash_table;
typedef BOOST_DEDUCED_TYPENAME data::iterator_base iterator_base;
- typedef hash_const_local_iterator_unique_keys<value_allocator> const_local_iterator;
- typedef hash_local_iterator_unique_keys<value_allocator> local_iterator;
- typedef hash_const_iterator_unique_keys<value_allocator> const_iterator;
- typedef hash_iterator_unique_keys<value_allocator> iterator;
+ typedef hash_const_local_iterator<value_allocator, data> const_local_iterator;
+ typedef hash_local_iterator<value_allocator, data> local_iterator;
+ typedef hash_const_iterator<value_allocator, data> const_iterator;
+ typedef hash_iterator<value_allocator, data> iterator;
typedef BOOST_DEDUCED_TYPENAME data::size_type size_type;
typedef std::ptrdiff_t difference_type;
@@ -1077,10 +1227,10 @@
value_allocator, data> hash_table;
typedef BOOST_DEDUCED_TYPENAME data::iterator_base iterator_base;
- typedef hash_const_local_iterator_equivalent_keys<value_allocator> const_local_iterator;
- typedef hash_local_iterator_equivalent_keys<value_allocator> local_iterator;
- typedef hash_const_iterator_equivalent_keys<value_allocator> const_iterator;
- typedef hash_iterator_equivalent_keys<value_allocator> iterator;
+ typedef hash_const_local_iterator<value_allocator, data> const_local_iterator;
+ typedef hash_local_iterator<value_allocator, data> local_iterator;
+ typedef hash_const_iterator<value_allocator, data> const_iterator;
+ typedef hash_iterator<value_allocator, data> iterator;
typedef BOOST_DEDUCED_TYPENAME data::size_type size_type;
typedef std::ptrdiff_t difference_type;
Modified: sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table_impl.hpp (original)
+++ sandbox-branches/unordered-refactor/boost/unordered/detail/hash_table_impl.hpp 2007-12-07 08:24:47 EST (Fri, 07 Dec 2007)
@@ -6,16 +6,8 @@
#if BOOST_UNORDERED_HASH_EQUIVALENT
#define HASH_TABLE_DATA hash_table_data_equivalent_keys
-#define HASH_ITERATOR hash_iterator_equivalent_keys
-#define HASH_CONST_ITERATOR hash_const_iterator_equivalent_keys
-#define HASH_LOCAL_ITERATOR hash_local_iterator_equivalent_keys
-#define HASH_CONST_LOCAL_ITERATOR hash_const_local_iterator_equivalent_keys
#else
#define HASH_TABLE_DATA hash_table_data_unique_keys
-#define HASH_ITERATOR hash_iterator_unique_keys
-#define HASH_CONST_ITERATOR hash_const_iterator_unique_keys
-#define HASH_LOCAL_ITERATOR hash_local_iterator_unique_keys
-#define HASH_CONST_LOCAL_ITERATOR hash_const_local_iterator_unique_keys
#endif
namespace boost {
@@ -986,163 +978,7 @@
};
#endif
- // Iterators
-
- template <typename Alloc> class HASH_ITERATOR;
- template <typename Alloc> class HASH_CONST_ITERATOR;
- template <typename Alloc> class HASH_LOCAL_ITERATOR;
- template <typename Alloc> class HASH_CONST_LOCAL_ITERATOR;
- class iterator_access;
-
- // Local Iterators
- //
- // all no throw
-
- template <typename Alloc>
- class HASH_LOCAL_ITERATOR
- : public boost::iterator <
- std::forward_iterator_tag,
- BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
- std::ptrdiff_t,
- BOOST_DEDUCED_TYPENAME allocator_pointer<Alloc>::type,
- BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type >
- {
- public:
- typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
-
- private:
- typedef BOOST_DEDUCED_TYPENAME HASH_TABLE_DATA<Alloc>::local_iterator_base base;
- typedef HASH_CONST_LOCAL_ITERATOR<Alloc> const_local_iterator;
-
- friend class HASH_CONST_LOCAL_ITERATOR<Alloc>;
- base base_;
-
- public:
- HASH_LOCAL_ITERATOR() : base_() {}
- explicit HASH_LOCAL_ITERATOR(base x) : base_(x) {}
- BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type operator*() const
- { return *base_; }
- value_type* operator->() const { return &*base_; }
- HASH_LOCAL_ITERATOR& operator++() { base_.increment(); return *this; }
- HASH_LOCAL_ITERATOR operator++(int) { HASH_LOCAL_ITERATOR tmp(base_); base_.increment(); return tmp; }
- bool operator==(HASH_LOCAL_ITERATOR x) const { return base_ == x.base_; }
- bool operator==(const_local_iterator x) const { return base_ == x.base_; }
- bool operator!=(HASH_LOCAL_ITERATOR x) const { return base_ != x.base_; }
- bool operator!=(const_local_iterator x) const { return base_ != x.base_; }
- };
-
- template <typename Alloc>
- class HASH_CONST_LOCAL_ITERATOR
- : public boost::iterator <
- std::forward_iterator_tag,
- BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
- std::ptrdiff_t,
- BOOST_DEDUCED_TYPENAME allocator_const_pointer<Alloc>::type,
- BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type >
- {
- public:
- typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
-
- private:
- typedef BOOST_DEDUCED_TYPENAME HASH_TABLE_DATA<Alloc>::local_iterator_base base;
- typedef HASH_LOCAL_ITERATOR<Alloc> local_iterator;
- friend class HASH_LOCAL_ITERATOR<Alloc>;
- base base_;
-
- public:
- HASH_CONST_LOCAL_ITERATOR() : base_() {}
- explicit HASH_CONST_LOCAL_ITERATOR(base x) : base_(x) {}
- HASH_CONST_LOCAL_ITERATOR(local_iterator x) : base_(x.base_) {}
- BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type
- operator*() const { return *base_; }
- value_type const* operator->() const { return &*base_; }
- HASH_CONST_LOCAL_ITERATOR& operator++() { base_.increment(); return *this; }
- HASH_CONST_LOCAL_ITERATOR operator++(int) { HASH_CONST_LOCAL_ITERATOR tmp(base_); base_.increment(); return tmp; }
- bool operator==(local_iterator x) const { return base_ == x.base_; }
- bool operator==(HASH_CONST_LOCAL_ITERATOR x) const { return base_ == x.base_; }
- bool operator!=(local_iterator x) const { return base_ != x.base_; }
- bool operator!=(HASH_CONST_LOCAL_ITERATOR x) const { return base_ != x.base_; }
- };
-
- // iterators
- //
- // all no throw
-
-
- template <typename Alloc>
- class HASH_ITERATOR
- : public boost::iterator <
- std::forward_iterator_tag,
- BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
- std::ptrdiff_t,
- BOOST_DEDUCED_TYPENAME allocator_pointer<Alloc>::type,
- BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type >
- {
- public:
- typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
-
- private:
- typedef BOOST_DEDUCED_TYPENAME HASH_TABLE_DATA<Alloc>::iterator_base base;
- typedef HASH_CONST_ITERATOR<Alloc> const_iterator;
- friend class HASH_CONST_ITERATOR<Alloc>;
- base base_;
-
- public:
-
- HASH_ITERATOR() : base_() {}
- explicit HASH_ITERATOR(base const& x) : base_(x) {}
- BOOST_DEDUCED_TYPENAME allocator_reference<Alloc>::type
- operator*() const { return *base_; }
- value_type* operator->() const { return &*base_; }
- HASH_ITERATOR& operator++() { base_.increment(); return *this; }
- HASH_ITERATOR operator++(int) { HASH_ITERATOR tmp(base_); base_.increment(); return tmp; }
- bool operator==(HASH_ITERATOR const& x) const { return base_ == x.base_; }
- bool operator==(const_iterator const& x) const { return base_ == x.base_; }
- bool operator!=(HASH_ITERATOR const& x) const { return base_ != x.base_; }
- bool operator!=(const_iterator const& x) const { return base_ != x.base_; }
- };
-
- template <typename Alloc>
- class HASH_CONST_ITERATOR
- : public boost::iterator <
- std::forward_iterator_tag,
- BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type,
- std::ptrdiff_t,
- BOOST_DEDUCED_TYPENAME allocator_const_pointer<Alloc>::type,
- BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type >
- {
- public:
- typedef BOOST_DEDUCED_TYPENAME allocator_value_type<Alloc>::type value_type;
-
- private:
- typedef BOOST_DEDUCED_TYPENAME HASH_TABLE_DATA<Alloc>::iterator_base base;
- typedef HASH_ITERATOR<Alloc> iterator;
- friend class HASH_ITERATOR<Alloc>;
- friend class iterator_access;
- base base_;
-
- public:
-
- HASH_CONST_ITERATOR() : base_() {}
- explicit HASH_CONST_ITERATOR(base const& x) : base_(x) {}
- HASH_CONST_ITERATOR(iterator const& x) : base_(x.base_) {}
- BOOST_DEDUCED_TYPENAME allocator_const_reference<Alloc>::type
- operator*() const { return *base_; }
- value_type const* operator->() const { return &*base_; }
- HASH_CONST_ITERATOR& operator++() { base_.increment(); return *this; }
- HASH_CONST_ITERATOR operator++(int) { HASH_CONST_ITERATOR tmp(base_); base_.increment(); return tmp; }
- bool operator==(iterator const& x) const { return base_ == x.base_; }
- bool operator==(HASH_CONST_ITERATOR const& x) const { return base_ == x.base_; }
- bool operator!=(iterator const& x) const { return base_ != x.base_; }
- bool operator!=(HASH_CONST_ITERATOR const& x) const { return base_ != x.base_; }
- };
}
}
-
-#undef HASH_TABLE_DATA
-#undef HASH_ITERATOR
-#undef HASH_CONST_ITERATOR
-#undef HASH_LOCAL_ITERATOR
-#undef HASH_CONST_LOCAL_ITERATOR
-
+#undef HASH_TABLE_DATA
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk