2008-05-01 09:23:22 +00:00
|
|
|
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
// Copyright 2008-2009 Daniel James.
|
2008-05-01 09:23:22 +00:00
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
|
|
// Gratuitous single linked list.
|
|
|
|
|
//
|
|
|
|
|
// Sadly some STL implementations aren't up to scratch and I need a simple
|
|
|
|
|
// cross-platform container. So here it is.
|
|
|
|
|
|
|
|
|
|
#if !defined(UNORDERED_TEST_LIST_HEADER)
|
|
|
|
|
#define UNORDERED_TEST_LIST_HEADER
|
|
|
|
|
|
|
|
|
|
#include <boost/iterator.hpp>
|
|
|
|
|
#include <boost/limits.hpp>
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
namespace test
|
|
|
|
|
{
|
|
|
|
|
template <typename T> class list;
|
|
|
|
|
|
|
|
|
|
namespace test_detail
|
|
|
|
|
{
|
New version of Boost.Unordered
Merged revisions 55470,55877-55878,55901-55902,55921-55922,55990-55992,56009-56010,56329,56346-56349,56362-56363,56374 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r55470 | danieljames | 2009-08-08 19:50:00 +0100 (Sat, 08 Aug 2009) | 1 line
Remove empty svn:mergeinfo properties. This should reduce the amount of differences between trunk and release.
........
r55877 | danieljames | 2009-08-30 17:33:42 +0100 (Sun, 30 Aug 2009) | 1 line
Remove allocator_constructor since it's never used.
........
r55878 | danieljames | 2009-08-30 17:42:28 +0100 (Sun, 30 Aug 2009) | 6 lines
Initial checkin of new version of Boost.Unordered.
- More template use, less preprocessor use.
- Removed some of the Visual C++ 6 workarounds.
- Reduced memory use of the main object.
- Split into smaller headers.
........
r55901 | danieljames | 2009-08-31 11:39:25 +0100 (Mon, 31 Aug 2009) | 1 line
Detab.
........
r55902 | danieljames | 2009-08-31 11:39:40 +0100 (Mon, 31 Aug 2009) | 1 line
Remove unnecessary BOOST_DEDUCED_TYPENAMEs
........
r55921 | danieljames | 2009-08-31 16:33:28 +0100 (Mon, 31 Aug 2009) | 1 line
Remove a few unused parameters.
........
r55922 | danieljames | 2009-08-31 16:33:49 +0100 (Mon, 31 Aug 2009) | 1 line
Remove 'static' from next_node and node_count. Will hopefully make vacpp happy.
........
r55990 | danieljames | 2009-09-03 08:36:21 +0100 (Thu, 03 Sep 2009) | 1 line
Combine hash_structure and hash_table_manager.
........
r55991 | danieljames | 2009-09-03 08:37:14 +0100 (Thu, 03 Sep 2009) | 1 line
Remove some old Visual C++ workarounds.
........
r55992 | danieljames | 2009-09-03 08:37:30 +0100 (Thu, 03 Sep 2009) | 1 line
Add a small test to see if the tested compilers support out of line template methods.
........
r56009 | danieljames | 2009-09-04 08:02:28 +0100 (Fri, 04 Sep 2009) | 1 line
Fix link to n2691.
........
r56010 | danieljames | 2009-09-04 08:03:04 +0100 (Fri, 04 Sep 2009) | 1 line
Move size_ and cached_begin_bucket_ into table, rename hash_table_manager hash_buckets.
........
r56329 | danieljames | 2009-09-20 22:55:15 +0100 (Sun, 20 Sep 2009) | 2 lines
Since all the compilers support out of line template members use them
and lots of other things.
........
r56346 | danieljames | 2009-09-21 22:17:19 +0100 (Mon, 21 Sep 2009) | 1 line
Slightly more consistent variable names. In detail 'n' is now always a node pointer.
........
r56347 | danieljames | 2009-09-21 22:17:40 +0100 (Mon, 21 Sep 2009) | 1 line
Fix bug where container was reducing the number of buckets.
........
r56348 | danieljames | 2009-09-21 22:18:01 +0100 (Mon, 21 Sep 2009) | 1 line
Fix a bug that was causing unnecessary rehahes.
........
r56349 | danieljames | 2009-09-21 22:18:21 +0100 (Mon, 21 Sep 2009) | 1 line
Use std::max.
........
r56362 | danieljames | 2009-09-22 23:39:00 +0100 (Tue, 22 Sep 2009) | 1 line
Another std::max.
........
r56363 | danieljames | 2009-09-22 23:39:17 +0100 (Tue, 22 Sep 2009) | 1 line
Remove the emplace_hint implementation for unique containers as it isn't really used and seems to be causing sun 5.7 problems.
........
r56374 | danieljames | 2009-09-24 21:42:19 +0100 (Thu, 24 Sep 2009) | 1 line
Remove temporary test.
........
[SVN r56375]
2009-09-24 21:12:46 +00:00
|
|
|
template <typename T> class list_node;
|
2008-05-01 09:23:22 +00:00
|
|
|
template <typename T> class list_data;
|
|
|
|
|
template <typename T> class list_iterator;
|
|
|
|
|
template <typename T> class list_const_iterator;
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
New version of Boost.Unordered
Merged revisions 55470,55877-55878,55901-55902,55921-55922,55990-55992,56009-56010,56329,56346-56349,56362-56363,56374 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r55470 | danieljames | 2009-08-08 19:50:00 +0100 (Sat, 08 Aug 2009) | 1 line
Remove empty svn:mergeinfo properties. This should reduce the amount of differences between trunk and release.
........
r55877 | danieljames | 2009-08-30 17:33:42 +0100 (Sun, 30 Aug 2009) | 1 line
Remove allocator_constructor since it's never used.
........
r55878 | danieljames | 2009-08-30 17:42:28 +0100 (Sun, 30 Aug 2009) | 6 lines
Initial checkin of new version of Boost.Unordered.
- More template use, less preprocessor use.
- Removed some of the Visual C++ 6 workarounds.
- Reduced memory use of the main object.
- Split into smaller headers.
........
r55901 | danieljames | 2009-08-31 11:39:25 +0100 (Mon, 31 Aug 2009) | 1 line
Detab.
........
r55902 | danieljames | 2009-08-31 11:39:40 +0100 (Mon, 31 Aug 2009) | 1 line
Remove unnecessary BOOST_DEDUCED_TYPENAMEs
........
r55921 | danieljames | 2009-08-31 16:33:28 +0100 (Mon, 31 Aug 2009) | 1 line
Remove a few unused parameters.
........
r55922 | danieljames | 2009-08-31 16:33:49 +0100 (Mon, 31 Aug 2009) | 1 line
Remove 'static' from next_node and node_count. Will hopefully make vacpp happy.
........
r55990 | danieljames | 2009-09-03 08:36:21 +0100 (Thu, 03 Sep 2009) | 1 line
Combine hash_structure and hash_table_manager.
........
r55991 | danieljames | 2009-09-03 08:37:14 +0100 (Thu, 03 Sep 2009) | 1 line
Remove some old Visual C++ workarounds.
........
r55992 | danieljames | 2009-09-03 08:37:30 +0100 (Thu, 03 Sep 2009) | 1 line
Add a small test to see if the tested compilers support out of line template methods.
........
r56009 | danieljames | 2009-09-04 08:02:28 +0100 (Fri, 04 Sep 2009) | 1 line
Fix link to n2691.
........
r56010 | danieljames | 2009-09-04 08:03:04 +0100 (Fri, 04 Sep 2009) | 1 line
Move size_ and cached_begin_bucket_ into table, rename hash_table_manager hash_buckets.
........
r56329 | danieljames | 2009-09-20 22:55:15 +0100 (Sun, 20 Sep 2009) | 2 lines
Since all the compilers support out of line template members use them
and lots of other things.
........
r56346 | danieljames | 2009-09-21 22:17:19 +0100 (Mon, 21 Sep 2009) | 1 line
Slightly more consistent variable names. In detail 'n' is now always a node pointer.
........
r56347 | danieljames | 2009-09-21 22:17:40 +0100 (Mon, 21 Sep 2009) | 1 line
Fix bug where container was reducing the number of buckets.
........
r56348 | danieljames | 2009-09-21 22:18:01 +0100 (Mon, 21 Sep 2009) | 1 line
Fix a bug that was causing unnecessary rehahes.
........
r56349 | danieljames | 2009-09-21 22:18:21 +0100 (Mon, 21 Sep 2009) | 1 line
Use std::max.
........
r56362 | danieljames | 2009-09-22 23:39:00 +0100 (Tue, 22 Sep 2009) | 1 line
Another std::max.
........
r56363 | danieljames | 2009-09-22 23:39:17 +0100 (Tue, 22 Sep 2009) | 1 line
Remove the emplace_hint implementation for unique containers as it isn't really used and seems to be causing sun 5.7 problems.
........
r56374 | danieljames | 2009-09-24 21:42:19 +0100 (Thu, 24 Sep 2009) | 1 line
Remove temporary test.
........
[SVN r56375]
2009-09-24 21:12:46 +00:00
|
|
|
class list_node
|
2008-05-01 09:23:22 +00:00
|
|
|
{
|
New version of Boost.Unordered
Merged revisions 55470,55877-55878,55901-55902,55921-55922,55990-55992,56009-56010,56329,56346-56349,56362-56363,56374 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r55470 | danieljames | 2009-08-08 19:50:00 +0100 (Sat, 08 Aug 2009) | 1 line
Remove empty svn:mergeinfo properties. This should reduce the amount of differences between trunk and release.
........
r55877 | danieljames | 2009-08-30 17:33:42 +0100 (Sun, 30 Aug 2009) | 1 line
Remove allocator_constructor since it's never used.
........
r55878 | danieljames | 2009-08-30 17:42:28 +0100 (Sun, 30 Aug 2009) | 6 lines
Initial checkin of new version of Boost.Unordered.
- More template use, less preprocessor use.
- Removed some of the Visual C++ 6 workarounds.
- Reduced memory use of the main object.
- Split into smaller headers.
........
r55901 | danieljames | 2009-08-31 11:39:25 +0100 (Mon, 31 Aug 2009) | 1 line
Detab.
........
r55902 | danieljames | 2009-08-31 11:39:40 +0100 (Mon, 31 Aug 2009) | 1 line
Remove unnecessary BOOST_DEDUCED_TYPENAMEs
........
r55921 | danieljames | 2009-08-31 16:33:28 +0100 (Mon, 31 Aug 2009) | 1 line
Remove a few unused parameters.
........
r55922 | danieljames | 2009-08-31 16:33:49 +0100 (Mon, 31 Aug 2009) | 1 line
Remove 'static' from next_node and node_count. Will hopefully make vacpp happy.
........
r55990 | danieljames | 2009-09-03 08:36:21 +0100 (Thu, 03 Sep 2009) | 1 line
Combine hash_structure and hash_table_manager.
........
r55991 | danieljames | 2009-09-03 08:37:14 +0100 (Thu, 03 Sep 2009) | 1 line
Remove some old Visual C++ workarounds.
........
r55992 | danieljames | 2009-09-03 08:37:30 +0100 (Thu, 03 Sep 2009) | 1 line
Add a small test to see if the tested compilers support out of line template methods.
........
r56009 | danieljames | 2009-09-04 08:02:28 +0100 (Fri, 04 Sep 2009) | 1 line
Fix link to n2691.
........
r56010 | danieljames | 2009-09-04 08:03:04 +0100 (Fri, 04 Sep 2009) | 1 line
Move size_ and cached_begin_bucket_ into table, rename hash_table_manager hash_buckets.
........
r56329 | danieljames | 2009-09-20 22:55:15 +0100 (Sun, 20 Sep 2009) | 2 lines
Since all the compilers support out of line template members use them
and lots of other things.
........
r56346 | danieljames | 2009-09-21 22:17:19 +0100 (Mon, 21 Sep 2009) | 1 line
Slightly more consistent variable names. In detail 'n' is now always a node pointer.
........
r56347 | danieljames | 2009-09-21 22:17:40 +0100 (Mon, 21 Sep 2009) | 1 line
Fix bug where container was reducing the number of buckets.
........
r56348 | danieljames | 2009-09-21 22:18:01 +0100 (Mon, 21 Sep 2009) | 1 line
Fix a bug that was causing unnecessary rehahes.
........
r56349 | danieljames | 2009-09-21 22:18:21 +0100 (Mon, 21 Sep 2009) | 1 line
Use std::max.
........
r56362 | danieljames | 2009-09-22 23:39:00 +0100 (Tue, 22 Sep 2009) | 1 line
Another std::max.
........
r56363 | danieljames | 2009-09-22 23:39:17 +0100 (Tue, 22 Sep 2009) | 1 line
Remove the emplace_hint implementation for unique containers as it isn't really used and seems to be causing sun 5.7 problems.
........
r56374 | danieljames | 2009-09-24 21:42:19 +0100 (Thu, 24 Sep 2009) | 1 line
Remove temporary test.
........
[SVN r56375]
2009-09-24 21:12:46 +00:00
|
|
|
list_node(list_node const&);
|
|
|
|
|
list_node& operator=(list_node const&);
|
|
|
|
|
public:
|
2008-05-01 09:23:22 +00:00
|
|
|
T value_;
|
|
|
|
|
list_node* next_;
|
|
|
|
|
|
|
|
|
|
list_node(T const& v) : value_(v), next_(0) {}
|
|
|
|
|
list_node(T const& v, list_node* n) : value_(v), next_(n) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
class list_data
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef list_node<T> node;
|
|
|
|
|
typedef unsigned int size_type;
|
|
|
|
|
|
|
|
|
|
node* first_;
|
|
|
|
|
node** last_ptr_;
|
|
|
|
|
size_type size_;
|
|
|
|
|
|
|
|
|
|
list_data() : first_(0), last_ptr_(&first_), size_(0) {}
|
|
|
|
|
|
|
|
|
|
~list_data() {
|
|
|
|
|
while(first_) {
|
|
|
|
|
node* tmp = first_;
|
|
|
|
|
first_ = first_->next_;
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
list_data(list_data const&);
|
|
|
|
|
list_data& operator=(list_data const&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
class list_iterator
|
|
|
|
|
: public boost::iterator<
|
|
|
|
|
std::forward_iterator_tag, T,
|
|
|
|
|
int, T*, T&>
|
|
|
|
|
{
|
|
|
|
|
friend class list_const_iterator<T>;
|
|
|
|
|
friend class test::list<T>;
|
|
|
|
|
typedef list_node<T> node;
|
|
|
|
|
typedef list_const_iterator<T> const_iterator;
|
|
|
|
|
|
|
|
|
|
node* ptr_;
|
|
|
|
|
public:
|
|
|
|
|
list_iterator() : ptr_(0) {};
|
|
|
|
|
explicit list_iterator(node* x) : ptr_(x) {}
|
|
|
|
|
|
|
|
|
|
T& operator*() const { return ptr_->value_; }
|
|
|
|
|
T* operator->() const { return &ptr_->value_; }
|
|
|
|
|
list_iterator& operator++() {
|
|
|
|
|
ptr_ = ptr_->next_; return *this; }
|
Merge latest changes for unordered. Improved compatability and a few tweaks.
Merged revisions 53127,53253,53256,53311,53314,53316-53318 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r53127 | danieljames | 2009-05-20 07:43:38 +0100 (Wed, 20 May 2009) | 1 line
Better configuration for boost.unordered.
........
r53253 | danieljames | 2009-05-25 20:14:07 +0100 (Mon, 25 May 2009) | 3 lines
Add explicit destructors to the unordered containers. Refs #2908.
Isn't really needed but it doesn't hurt.
........
r53256 | danieljames | 2009-05-25 20:45:23 +0100 (Mon, 25 May 2009) | 1 line
Unordered change log for explicit destructors.
........
r53311 | danieljames | 2009-05-27 18:42:01 +0100 (Wed, 27 May 2009) | 1 line
Missing changelog entry.
........
r53314 | danieljames | 2009-05-27 18:44:09 +0100 (Wed, 27 May 2009) | 1 line
Use lightweight_test for unordered.
........
r53316 | danieljames | 2009-05-27 19:19:32 +0100 (Wed, 27 May 2009) | 1 line
Some workarounds for old versions of Borland.
........
r53317 | danieljames | 2009-05-27 19:32:22 +0100 (Wed, 27 May 2009) | 1 line
Fix a change accidentally included in the last commit.
........
r53318 | danieljames | 2009-05-27 19:32:38 +0100 (Wed, 27 May 2009) | 1 line
Remove an unused function.
........
[SVN r53465]
2009-05-30 17:34:12 +00:00
|
|
|
list_iterator operator++(int) {
|
2008-05-01 09:23:22 +00:00
|
|
|
list_iterator tmp = *this; ptr_ = ptr_->next_; return tmp; }
|
|
|
|
|
bool operator==(const_iterator y) const { return ptr_ == y.ptr_; }
|
|
|
|
|
bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
class list_const_iterator
|
|
|
|
|
: public boost::iterator<
|
|
|
|
|
std::forward_iterator_tag, T,
|
|
|
|
|
int, T const*, T const&>
|
|
|
|
|
{
|
|
|
|
|
friend class list_iterator<T>;
|
|
|
|
|
friend class test::list<T>;
|
|
|
|
|
typedef list_node<T> node;
|
|
|
|
|
typedef list_iterator<T> iterator;
|
|
|
|
|
typedef list_const_iterator<T> const_iterator;
|
|
|
|
|
|
|
|
|
|
node* ptr_;
|
|
|
|
|
public:
|
|
|
|
|
list_const_iterator() : ptr_(0) {}
|
|
|
|
|
list_const_iterator(list_iterator<T> const& x) : ptr_(x.ptr_) {}
|
|
|
|
|
|
|
|
|
|
T const& operator*() const { return ptr_->value_; }
|
|
|
|
|
T const* operator->() const { return &ptr_->value_; }
|
|
|
|
|
list_const_iterator& operator++() {
|
|
|
|
|
ptr_ = ptr_->next_; return *this; }
|
Merge latest changes for unordered. Improved compatability and a few tweaks.
Merged revisions 53127,53253,53256,53311,53314,53316-53318 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r53127 | danieljames | 2009-05-20 07:43:38 +0100 (Wed, 20 May 2009) | 1 line
Better configuration for boost.unordered.
........
r53253 | danieljames | 2009-05-25 20:14:07 +0100 (Mon, 25 May 2009) | 3 lines
Add explicit destructors to the unordered containers. Refs #2908.
Isn't really needed but it doesn't hurt.
........
r53256 | danieljames | 2009-05-25 20:45:23 +0100 (Mon, 25 May 2009) | 1 line
Unordered change log for explicit destructors.
........
r53311 | danieljames | 2009-05-27 18:42:01 +0100 (Wed, 27 May 2009) | 1 line
Missing changelog entry.
........
r53314 | danieljames | 2009-05-27 18:44:09 +0100 (Wed, 27 May 2009) | 1 line
Use lightweight_test for unordered.
........
r53316 | danieljames | 2009-05-27 19:19:32 +0100 (Wed, 27 May 2009) | 1 line
Some workarounds for old versions of Borland.
........
r53317 | danieljames | 2009-05-27 19:32:22 +0100 (Wed, 27 May 2009) | 1 line
Fix a change accidentally included in the last commit.
........
r53318 | danieljames | 2009-05-27 19:32:38 +0100 (Wed, 27 May 2009) | 1 line
Remove an unused function.
........
[SVN r53465]
2009-05-30 17:34:12 +00:00
|
|
|
list_const_iterator operator++(int) {
|
2008-05-01 09:23:22 +00:00
|
|
|
list_const_iterator tmp = *this; ptr_ = ptr_->next_; return tmp; }
|
|
|
|
|
bool operator==(const_iterator y) const { return ptr_ == y.ptr_; }
|
|
|
|
|
bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
class list
|
|
|
|
|
{
|
|
|
|
|
typedef test::test_detail::list_data<T> data;
|
|
|
|
|
typedef test::test_detail::list_node<T> node;
|
|
|
|
|
data data_;
|
|
|
|
|
public:
|
|
|
|
|
typedef T value_type;
|
|
|
|
|
typedef value_type& reference;
|
|
|
|
|
typedef value_type const& const_reference;
|
|
|
|
|
typedef unsigned int size_type;
|
|
|
|
|
|
|
|
|
|
typedef test::test_detail::list_iterator<T> iterator;
|
|
|
|
|
typedef test::test_detail::list_const_iterator<T> const_iterator;
|
|
|
|
|
|
|
|
|
|
list() : data_() {}
|
|
|
|
|
|
|
|
|
|
list(list const& other) : data_() {
|
|
|
|
|
insert(other.begin(), other.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
list(InputIterator i, InputIterator j) : data_() {
|
|
|
|
|
insert(i, j);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list& operator=(list const& other) {
|
|
|
|
|
clear();
|
|
|
|
|
insert(other.begin(), other.end());
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
return *this;
|
2008-05-01 09:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iterator begin() { return iterator(data_.first_); }
|
|
|
|
|
iterator end() { return iterator(); }
|
|
|
|
|
const_iterator begin() const { return iterator(data_.first_); }
|
|
|
|
|
const_iterator end() const { return iterator(); }
|
|
|
|
|
const_iterator cbegin() const { return iterator(data_.first_); }
|
|
|
|
|
const_iterator cend() const { return iterator(); }
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
void insert(InputIterator i, InputIterator j) {
|
|
|
|
|
for(; i != j; ++i)
|
|
|
|
|
push_back(*i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void push_front(value_type const& v) {
|
|
|
|
|
data_.first_ = new node(v, data_.first_);
|
2008-05-10 13:52:14 +00:00
|
|
|
if(!data_.size_) data_.last_ptr_ = &(*data_.last_ptr_)->next_;
|
2008-05-01 09:23:22 +00:00
|
|
|
++data_.size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void push_back(value_type const& v) {
|
|
|
|
|
*data_.last_ptr_ = new node(v);
|
|
|
|
|
data_.last_ptr_ = &(*data_.last_ptr_)->next_;
|
|
|
|
|
++data_.size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
|
while(data_.first_) {
|
|
|
|
|
node* tmp = data_.first_;
|
|
|
|
|
data_.first_ = data_.first_->next_;
|
|
|
|
|
--data_.size_;
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
data_.last_ptr_ = &data_.first_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void erase(const_iterator start, const_iterator end) {
|
|
|
|
|
node** ptr = &data_.first_;
|
|
|
|
|
|
|
|
|
|
while(*ptr != start.ptr_) {
|
|
|
|
|
ptr = &(*ptr)->next_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(*ptr != end.ptr_) {
|
|
|
|
|
node* to_delete = *ptr;
|
|
|
|
|
*ptr = (*ptr)->next_;
|
|
|
|
|
--data_.size_;
|
|
|
|
|
delete to_delete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!*ptr) data_.last_ptr_ = ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool empty() const {
|
|
|
|
|
return !data_.size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_type size() const {
|
|
|
|
|
return data_.size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sort() {
|
|
|
|
|
sort(std::less<T>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename Less>
|
|
|
|
|
void sort(Less less = Less()) {
|
|
|
|
|
if(!empty()) merge_sort(&data_.first_,
|
|
|
|
|
(std::numeric_limits<size_type>::max)(), less);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator==(list const& y) const {
|
|
|
|
|
return size() == y.size() &&
|
|
|
|
|
std::equal(begin(), end(), y.begin());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator!=(list const& y) const {
|
|
|
|
|
return !(*this == y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
template <typename Less>
|
|
|
|
|
node** merge_sort(node** l, size_type recurse_limit, Less less)
|
|
|
|
|
{
|
|
|
|
|
node** ptr = &(*l)->next_;
|
|
|
|
|
for(size_type count = 0; count < recurse_limit && *ptr; ++count)
|
|
|
|
|
{
|
|
|
|
|
ptr = merge_adjacent_ranges(l, ptr,
|
|
|
|
|
merge_sort(ptr, count, less), less);
|
|
|
|
|
}
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename Less>
|
|
|
|
|
node** merge_adjacent_ranges(node** first, node** second,
|
|
|
|
|
node** third, Less less)
|
|
|
|
|
{
|
New version of Boost.Unordered
Merged revisions 55470,55877-55878,55901-55902,55921-55922,55990-55992,56009-56010,56329,56346-56349,56362-56363,56374 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r55470 | danieljames | 2009-08-08 19:50:00 +0100 (Sat, 08 Aug 2009) | 1 line
Remove empty svn:mergeinfo properties. This should reduce the amount of differences between trunk and release.
........
r55877 | danieljames | 2009-08-30 17:33:42 +0100 (Sun, 30 Aug 2009) | 1 line
Remove allocator_constructor since it's never used.
........
r55878 | danieljames | 2009-08-30 17:42:28 +0100 (Sun, 30 Aug 2009) | 6 lines
Initial checkin of new version of Boost.Unordered.
- More template use, less preprocessor use.
- Removed some of the Visual C++ 6 workarounds.
- Reduced memory use of the main object.
- Split into smaller headers.
........
r55901 | danieljames | 2009-08-31 11:39:25 +0100 (Mon, 31 Aug 2009) | 1 line
Detab.
........
r55902 | danieljames | 2009-08-31 11:39:40 +0100 (Mon, 31 Aug 2009) | 1 line
Remove unnecessary BOOST_DEDUCED_TYPENAMEs
........
r55921 | danieljames | 2009-08-31 16:33:28 +0100 (Mon, 31 Aug 2009) | 1 line
Remove a few unused parameters.
........
r55922 | danieljames | 2009-08-31 16:33:49 +0100 (Mon, 31 Aug 2009) | 1 line
Remove 'static' from next_node and node_count. Will hopefully make vacpp happy.
........
r55990 | danieljames | 2009-09-03 08:36:21 +0100 (Thu, 03 Sep 2009) | 1 line
Combine hash_structure and hash_table_manager.
........
r55991 | danieljames | 2009-09-03 08:37:14 +0100 (Thu, 03 Sep 2009) | 1 line
Remove some old Visual C++ workarounds.
........
r55992 | danieljames | 2009-09-03 08:37:30 +0100 (Thu, 03 Sep 2009) | 1 line
Add a small test to see if the tested compilers support out of line template methods.
........
r56009 | danieljames | 2009-09-04 08:02:28 +0100 (Fri, 04 Sep 2009) | 1 line
Fix link to n2691.
........
r56010 | danieljames | 2009-09-04 08:03:04 +0100 (Fri, 04 Sep 2009) | 1 line
Move size_ and cached_begin_bucket_ into table, rename hash_table_manager hash_buckets.
........
r56329 | danieljames | 2009-09-20 22:55:15 +0100 (Sun, 20 Sep 2009) | 2 lines
Since all the compilers support out of line template members use them
and lots of other things.
........
r56346 | danieljames | 2009-09-21 22:17:19 +0100 (Mon, 21 Sep 2009) | 1 line
Slightly more consistent variable names. In detail 'n' is now always a node pointer.
........
r56347 | danieljames | 2009-09-21 22:17:40 +0100 (Mon, 21 Sep 2009) | 1 line
Fix bug where container was reducing the number of buckets.
........
r56348 | danieljames | 2009-09-21 22:18:01 +0100 (Mon, 21 Sep 2009) | 1 line
Fix a bug that was causing unnecessary rehahes.
........
r56349 | danieljames | 2009-09-21 22:18:21 +0100 (Mon, 21 Sep 2009) | 1 line
Use std::max.
........
r56362 | danieljames | 2009-09-22 23:39:00 +0100 (Tue, 22 Sep 2009) | 1 line
Another std::max.
........
r56363 | danieljames | 2009-09-22 23:39:17 +0100 (Tue, 22 Sep 2009) | 1 line
Remove the emplace_hint implementation for unique containers as it isn't really used and seems to be causing sun 5.7 problems.
........
r56374 | danieljames | 2009-09-24 21:42:19 +0100 (Thu, 24 Sep 2009) | 1 line
Remove temporary test.
........
[SVN r56375]
2009-09-24 21:12:46 +00:00
|
|
|
for(;;) {
|
|
|
|
|
for(;;) {
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
if(first == second) return third;
|
|
|
|
|
if(less((*second)->value_, (*first)->value_)) break;
|
|
|
|
|
first = &(*first)->next_;
|
2008-05-01 09:23:22 +00:00
|
|
|
}
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
|
|
|
|
|
swap_adjacent_ranges(first, second, third);
|
|
|
|
|
first = &(*first)->next_;
|
|
|
|
|
|
|
|
|
|
// Since the two ranges we just swapped, the order is now:
|
|
|
|
|
// first...third...second
|
|
|
|
|
|
New version of Boost.Unordered
Merged revisions 55470,55877-55878,55901-55902,55921-55922,55990-55992,56009-56010,56329,56346-56349,56362-56363,56374 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r55470 | danieljames | 2009-08-08 19:50:00 +0100 (Sat, 08 Aug 2009) | 1 line
Remove empty svn:mergeinfo properties. This should reduce the amount of differences between trunk and release.
........
r55877 | danieljames | 2009-08-30 17:33:42 +0100 (Sun, 30 Aug 2009) | 1 line
Remove allocator_constructor since it's never used.
........
r55878 | danieljames | 2009-08-30 17:42:28 +0100 (Sun, 30 Aug 2009) | 6 lines
Initial checkin of new version of Boost.Unordered.
- More template use, less preprocessor use.
- Removed some of the Visual C++ 6 workarounds.
- Reduced memory use of the main object.
- Split into smaller headers.
........
r55901 | danieljames | 2009-08-31 11:39:25 +0100 (Mon, 31 Aug 2009) | 1 line
Detab.
........
r55902 | danieljames | 2009-08-31 11:39:40 +0100 (Mon, 31 Aug 2009) | 1 line
Remove unnecessary BOOST_DEDUCED_TYPENAMEs
........
r55921 | danieljames | 2009-08-31 16:33:28 +0100 (Mon, 31 Aug 2009) | 1 line
Remove a few unused parameters.
........
r55922 | danieljames | 2009-08-31 16:33:49 +0100 (Mon, 31 Aug 2009) | 1 line
Remove 'static' from next_node and node_count. Will hopefully make vacpp happy.
........
r55990 | danieljames | 2009-09-03 08:36:21 +0100 (Thu, 03 Sep 2009) | 1 line
Combine hash_structure and hash_table_manager.
........
r55991 | danieljames | 2009-09-03 08:37:14 +0100 (Thu, 03 Sep 2009) | 1 line
Remove some old Visual C++ workarounds.
........
r55992 | danieljames | 2009-09-03 08:37:30 +0100 (Thu, 03 Sep 2009) | 1 line
Add a small test to see if the tested compilers support out of line template methods.
........
r56009 | danieljames | 2009-09-04 08:02:28 +0100 (Fri, 04 Sep 2009) | 1 line
Fix link to n2691.
........
r56010 | danieljames | 2009-09-04 08:03:04 +0100 (Fri, 04 Sep 2009) | 1 line
Move size_ and cached_begin_bucket_ into table, rename hash_table_manager hash_buckets.
........
r56329 | danieljames | 2009-09-20 22:55:15 +0100 (Sun, 20 Sep 2009) | 2 lines
Since all the compilers support out of line template members use them
and lots of other things.
........
r56346 | danieljames | 2009-09-21 22:17:19 +0100 (Mon, 21 Sep 2009) | 1 line
Slightly more consistent variable names. In detail 'n' is now always a node pointer.
........
r56347 | danieljames | 2009-09-21 22:17:40 +0100 (Mon, 21 Sep 2009) | 1 line
Fix bug where container was reducing the number of buckets.
........
r56348 | danieljames | 2009-09-21 22:18:01 +0100 (Mon, 21 Sep 2009) | 1 line
Fix a bug that was causing unnecessary rehahes.
........
r56349 | danieljames | 2009-09-21 22:18:21 +0100 (Mon, 21 Sep 2009) | 1 line
Use std::max.
........
r56362 | danieljames | 2009-09-22 23:39:00 +0100 (Tue, 22 Sep 2009) | 1 line
Another std::max.
........
r56363 | danieljames | 2009-09-22 23:39:17 +0100 (Tue, 22 Sep 2009) | 1 line
Remove the emplace_hint implementation for unique containers as it isn't really used and seems to be causing sun 5.7 problems.
........
r56374 | danieljames | 2009-09-24 21:42:19 +0100 (Thu, 24 Sep 2009) | 1 line
Remove temporary test.
........
[SVN r56375]
2009-09-24 21:12:46 +00:00
|
|
|
for(;;) {
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
if(first == third) return second;
|
|
|
|
|
if(!less((*first)->value_, (*third)->value_)) break;
|
|
|
|
|
first = &(*first)->next_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swap_adjacent_ranges(first, third, second);
|
2008-05-01 09:23:22 +00:00
|
|
|
first = &(*first)->next_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void swap_adjacent_ranges(node** first, node** second, node** third)
|
|
|
|
|
{
|
|
|
|
|
node* tmp = *first;
|
|
|
|
|
*first = *second;
|
|
|
|
|
*second = *third;
|
|
|
|
|
*third = tmp;
|
|
|
|
|
if(!*second) data_.last_ptr_ = second;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|