Unordered: Get rid of get_start.

[SVN r80561]
This commit is contained in:
Daniel James committed 2012-09-17 18:59:03 +00:00
1 parent 549b93e629
commit 53f278312f
6 files changed
+55 -67

No files matched your search

+12 -21
View File
@@ -222,6 +222,7 @@ namespace boost { namespace unordered { namespace detail {
bucket_pointer get_bucket(std::size_t bucket_index) const
{
BOOST_ASSERT(buckets_);
return buckets_ + static_cast<std::ptrdiff_t>(bucket_index);
}
@@ -235,14 +236,15 @@ namespace boost { namespace unordered { namespace detail {
return get_bucket(bucket_index)->next_;
}
iterator get_start() const
iterator begin() const
{
return iterator(static_cast<node_pointer>(
get_previous_start()->next_));
return size_ ? iterator(static_cast<node_pointer>(
get_previous_start()->next_)) : iterator();
}
iterator get_start(std::size_t bucket_index) const
iterator begin(std::size_t bucket_index) const
{
if (!size_) return iterator();
previous_pointer prev = get_previous_start(bucket_index);
return prev ? iterator(static_cast<node_pointer>(prev->next_)) :
iterator();
@@ -257,8 +259,7 @@ namespace boost { namespace unordered { namespace detail {
std::size_t bucket_size(std::size_t index) const
{
if (!size_) return 0;
iterator it = get_start(index);
iterator it = begin(index);
if (!it.node_) return 0;
std::size_t count = 0;
@@ -384,7 +385,7 @@ namespace boost { namespace unordered { namespace detail {
if (x.size_) {
create_buckets(bucket_count_);
copy_nodes<node_allocator> copy(node_alloc());
table_impl::fill_buckets(x.get_start(), *this, copy);
table_impl::fill_buckets(x.begin(), *this, copy);
}
}
@@ -526,7 +527,7 @@ namespace boost { namespace unordered { namespace detail {
void delete_buckets()
{
if(buckets_) {
delete_nodes(get_start(), iterator());
delete_nodes(begin(), iterator());
if (bucket::extra_node) {
node_pointer n = static_cast<node_pointer>(
@@ -548,7 +549,7 @@ namespace boost { namespace unordered { namespace detail {
{
if(!size_) return;
delete_nodes(get_start(), iterator());
delete_nodes(begin(), iterator());
get_previous_start()->next_ = link_pointer();
clear_buckets();
@@ -651,13 +652,6 @@ namespace boost { namespace unordered { namespace detail {
}
}
////////////////////////////////////////////////////////////////////////
// Iterators
iterator begin() const {
return !buckets_ ? iterator() : get_start();
}
////////////////////////////////////////////////////////////////////////
// Assignment
@@ -694,10 +688,7 @@ namespace boost { namespace unordered { namespace detail {
// assigning to them if possible, and deleting any that are
// left over.
assign_nodes<table> assign(*this);
if (x.size_) {
table_impl::fill_buckets(x.get_start(), *this, assign);
}
table_impl::fill_buckets(x.begin(), *this, assign);
}
void assign(table const& x, true_type)
@@ -725,7 +716,7 @@ namespace boost { namespace unordered { namespace detail {
if (x.size_) {
create_buckets(bucket_count_);
copy_nodes<node_allocator> copy(node_alloc());
table_impl::fill_buckets(x.get_start(), *this, copy);
table_impl::fill_buckets(x.begin(), *this, copy);
}
}
}