diff --git a/CMakeLists.txt b/CMakeLists.txt index 3169cb1..73434d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,3 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index df7dded..c37883a 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -1,14 +1,14 @@ [/ - / Copyright (c) 2007 Ion Gaztanaga + / Copyright (c) 2007-2009 Ion Gaztanaga / / 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) /] [library Boost.Intrusive - [quickbook 1.3] + [quickbook 1.4] [authors [Krzikalla, Olaf], [Gaztanaga, Ion]] - [copyright 2005 Olaf Krzikalla, 2006-2008 Ion Gaztanaga] + [copyright 2005 Olaf Krzikalla, 2006-2009 Ion Gaztanaga] [id intrusive] [dirname intrusive] [purpose Intrusive containers] @@ -2069,13 +2069,38 @@ With multiple ordered and unordered associative containers [classref boost::intrusive::unordered_multiset unordered_multiset]) there is no need for these advanced insertion functions, since insertions are always successful. +[endsect] + +[section:positional_insertions Positional insertions] + +Some ordered associative containers offer low-level functions to bypass ordering +checks and insert nodes directly in desired tree positions. These functions are +provided for performance reasons when values to be inserted in the container are +known to fulfill order (sets and multisets) and uniqueness (sets) invariants. A +typical usage of these functions is when intrusive associative containers are used +to build non-intrusive containers and the programmer wants to speed up assignments +from other associative containers: if the ordering and uniqueness properties are the same, +there is no need to waste time checking the position of each source value, because values +are already ordered: back insertions will be much more efficient. + +[*Note:] These functions [*don't check preconditions] so they must used with care. These +are functions are low-level operations [*will break container invariants if +ordering and uniqueness preconditions are not assured by the caller.] + +Let's see an example: + +[import ../example/doc_positional_insertion.cpp] +[doc_positional_insertion] + + [endsect] For more information about advanced lookup and insertion functions see +associative containers' documentation (e.g. [classref boost::intrusive::set set], [classref boost::intrusive::multiset multiset], [classref boost::intrusive::unordered_set unordered_set] and -[classref boost::intrusive::unordered_multiset unordered_multiset] references. +[classref boost::intrusive::unordered_multiset unordered_multiset] references). [endsect] @@ -2269,7 +2294,7 @@ decide to insert two hooks in the same class. However, there is a more size-efficient alternative in [*Boost.Intrusive]: "any" hooks ([classref boost::intrusive::any_base_hook any_base_hook] and -[classref boost::intrusive::any_member_hook any_member_hook]. +[classref boost::intrusive::any_member_hook any_member_hook]). These hooks can be used to store a type in several containers offered by [*Boost.Intrusive] minimizing the size of the class. @@ -2288,8 +2313,8 @@ These hooks support these options: internally in the hook and propagated to the container. Default: `void_pointer`. -`auto_unlink` can't be supported because the hook does not know in which type of might -be inserted container. Additionally, these hooks don't support `unlink()` and +`auto_unlink` can't be supported because the hook does not know in which type of +container might be currently inserted. Additionally, these hooks don't support `unlink()` and `swap_nodes()` operations for the same reason. Here is an example that creates a class with two any hooks, and uses one to insert the @@ -3157,13 +3182,12 @@ to define the needed value traits classes: Until now all shown custom value traits are stateless, that is, [*the transformation between nodes and values is implemented in terms of static functions]. It's possible to use [*stateful] value traits so that we can separate nodes and values and [*avoid modifying types to insert nodes]. -[*Boost.Intrusive] differentiates between stateful and stateless value traits by checking if the ValueTraits -class is empty: +[*Boost.Intrusive] differentiates between stateful and stateless value traits by checking if all +Node <-> Value transformation functions are static or not: -* If the class is empty, a [*stateless] value traits is assumed. - Node <-> Value transformations must be static functions. -* If the class is not empty, a [*stateful] value traits is assumed. - Node <-> Value transformations must be non-static functions. +* If all Node <-> Value transformation functions are static , a [*stateless] + value traits is assumed. transformations must be static functions. +* Otherwise a [*stateful] value traits is assumed. Using stateful value traits it's possible to create containers of non-copyable/movable objects [*without modifying] the definition of the class to be inserted. This interesting property is achieved without using global variables diff --git a/example/doc_advanced_value_traits.cpp b/example/doc_advanced_value_traits.cpp index dca6585..835f234 100644 --- a/example/doc_advanced_value_traits.cpp +++ b/example/doc_advanced_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_advanced_value_traits2.cpp b/example/doc_advanced_value_traits2.cpp index ec9214e..48193b6 100644 --- a/example/doc_advanced_value_traits2.cpp +++ b/example/doc_advanced_value_traits2.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_assoc_optimized_code.cpp b/example/doc_assoc_optimized_code.cpp index 7b86a70..915f2c2 100644 --- a/example/doc_assoc_optimized_code.cpp +++ b/example/doc_assoc_optimized_code.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_auto_unlink.cpp b/example/doc_auto_unlink.cpp index 208fc6f..28a84ac 100644 --- a/example/doc_auto_unlink.cpp +++ b/example/doc_auto_unlink.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_avl_set.cpp b/example/doc_avl_set.cpp index 985c136..96ef64a 100644 --- a/example/doc_avl_set.cpp +++ b/example/doc_avl_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_avltree_algorithms.cpp b/example/doc_avltree_algorithms.cpp index ee2655c..71b22be 100644 --- a/example/doc_avltree_algorithms.cpp +++ b/example/doc_avltree_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_bucket_traits.cpp b/example/doc_bucket_traits.cpp index 7663bf4..7fe1a89 100644 --- a/example/doc_bucket_traits.cpp +++ b/example/doc_bucket_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_clone_from.cpp b/example/doc_clone_from.cpp index ae3d8c9..f8c5794 100644 --- a/example/doc_clone_from.cpp +++ b/example/doc_clone_from.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_entity.cpp b/example/doc_entity.cpp index 70b109f..efdbc89 100644 --- a/example/doc_entity.cpp +++ b/example/doc_entity.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_erasing_and_disposing.cpp b/example/doc_erasing_and_disposing.cpp index cf0062d..f3bb51a 100644 --- a/example/doc_erasing_and_disposing.cpp +++ b/example/doc_erasing_and_disposing.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_external_value_traits.cpp b/example/doc_external_value_traits.cpp index b53817c..fe78703 100644 --- a/example/doc_external_value_traits.cpp +++ b/example/doc_external_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_how_to_use.cpp b/example/doc_how_to_use.cpp index 2951096..b966fe0 100644 --- a/example/doc_how_to_use.cpp +++ b/example/doc_how_to_use.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_iterator_from_value.cpp b/example/doc_iterator_from_value.cpp index 875db31..652e314 100644 --- a/example/doc_iterator_from_value.cpp +++ b/example/doc_iterator_from_value.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_list.cpp b/example/doc_list.cpp index a4ffcee..0f3818c 100644 --- a/example/doc_list.cpp +++ b/example/doc_list.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_list_algorithms.cpp b/example/doc_list_algorithms.cpp index c5ef4b4..45c1d2e 100644 --- a/example/doc_list_algorithms.cpp +++ b/example/doc_list_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_offset_ptr.cpp b/example/doc_offset_ptr.cpp index 9b88708..064ee6e 100644 --- a/example/doc_offset_ptr.cpp +++ b/example/doc_offset_ptr.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_positional_insertion.cpp b/example/doc_positional_insertion.cpp new file mode 100644 index 0000000..7609bc2 --- /dev/null +++ b/example/doc_positional_insertion.cpp @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2009-2009 +// +// 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) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +//[doc_positional_insertion +#include +#include +#include +#include + +using namespace boost::intrusive; + +//A simple class with a set hook +class MyClass : public set_base_hook<> +{ + public: + int int_; + + MyClass(int i) : int_(i) {} + friend bool operator< (const MyClass &a, const MyClass &b) + { return a.int_ < b.int_; } + friend bool operator> (const MyClass &a, const MyClass &b) + { return a.int_ > b.int_; } +}; + +int main() +{ + //Create some ORDERED elements + std::vector values; + for(int i = 0; i < 100; ++i) values.push_back(MyClass(i)); + + { //Data is naturally ordered in the vector with the same criteria + //as multiset's comparison predicate, so we can just push back + //all elements, which is more efficient than normal insertion + multiset mset; + for(int i = 0; i < 100; ++i) mset.push_back(values[i]); + + //Now check orderd invariant + multiset::const_iterator next(mset.cbegin()), it(next++); + for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it < *next); + } + { //Now the correct order for the set is the reverse order + //so let's push front all elements + multiset > > mset; + for(int i = 0; i < 100; ++i) mset.push_front(values[i]); + + //Now check orderd invariant + multiset > >:: + const_iterator next(mset.cbegin()), it(next++); + for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it > *next); + } + { //Now push the first and the last and insert the rest + //before the last position using "insert_before" + multiset mset; + mset.insert_before(mset.begin(), values[0]); + multiset::const_iterator pos = + mset.insert_before(mset.end(), values[99]); + for(int i = 1; i < 99; ++i) mset.insert_before(pos, values[i]); + + //Now check orderd invariant + multiset::const_iterator next(mset.cbegin()), it(next++); + for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it < *next); + } + + return 0; +} +//] diff --git a/example/doc_rbtree_algorithms.cpp b/example/doc_rbtree_algorithms.cpp index 0843365..d30dce7 100644 --- a/example/doc_rbtree_algorithms.cpp +++ b/example/doc_rbtree_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_set.cpp b/example/doc_set.cpp index 49fbe9c..8dc501f 100644 --- a/example/doc_set.cpp +++ b/example/doc_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_sg_set.cpp b/example/doc_sg_set.cpp index 5885b0e..bf67ba7 100644 --- a/example/doc_sg_set.cpp +++ b/example/doc_sg_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_slist.cpp b/example/doc_slist.cpp index 42220b9..fb8bbeb 100644 --- a/example/doc_slist.cpp +++ b/example/doc_slist.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_slist_algorithms.cpp b/example/doc_slist_algorithms.cpp index 7e7f155..19f1d7b 100644 --- a/example/doc_slist_algorithms.cpp +++ b/example/doc_slist_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_splay_algorithms.cpp b/example/doc_splay_algorithms.cpp index f90a7e2..6b59396 100644 --- a/example/doc_splay_algorithms.cpp +++ b/example/doc_splay_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_splay_set.cpp b/example/doc_splay_set.cpp index 87ed7e0..be8dafa 100644 --- a/example/doc_splay_set.cpp +++ b/example/doc_splay_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_splaytree_algorithms.cpp b/example/doc_splaytree_algorithms.cpp index aeafaae..ed9f943 100644 --- a/example/doc_splaytree_algorithms.cpp +++ b/example/doc_splaytree_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_stateful_value_traits.cpp b/example/doc_stateful_value_traits.cpp index 4712387..696828b 100644 --- a/example/doc_stateful_value_traits.cpp +++ b/example/doc_stateful_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_treap_algorithms.cpp b/example/doc_treap_algorithms.cpp index 773aa69..4379f40 100644 --- a/example/doc_treap_algorithms.cpp +++ b/example/doc_treap_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_treap_set.cpp b/example/doc_treap_set.cpp index 7ae4fec..79fd187 100644 --- a/example/doc_treap_set.cpp +++ b/example/doc_treap_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_unordered_set.cpp b/example/doc_unordered_set.cpp index a007919..fdd0938 100644 --- a/example/doc_unordered_set.cpp +++ b/example/doc_unordered_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_value_traits.cpp b/example/doc_value_traits.cpp index f9bb897..f13e1fe 100644 --- a/example/doc_value_traits.cpp +++ b/example/doc_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_window.cpp b/example/doc_window.cpp index f00f43b..f471c1e 100644 --- a/example/doc_window.cpp +++ b/example/doc_window.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/index.html b/index.html index de9100d..c3f8f9b 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ diff --git a/perf/perf_list.cpp b/perf/perf_list.cpp index ef73947..4f5d86e 100644 --- a/perf/perf_list.cpp +++ b/perf/perf_list.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj index abe74de..8501d3b 100644 --- a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj +++ b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj @@ -243,12 +243,18 @@ + + + + @@ -382,6 +388,9 @@ + + diff --git a/proj/vc7ide/to-do.txt b/proj/vc7ide/to-do.txt index 534314c..6cda9e3 100644 --- a/proj/vc7ide/to-do.txt +++ b/proj/vc7ide/to-do.txt @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -9,20 +9,8 @@ // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// --> Implement C++0x features (variadic templates & rvalue references) +-> Implement C++0x features (rvalue references) -> Offer bidirectional iterator for hashtables -> Non-array buckets -> Document incremental<> option better - --> Revise treap's hooks should be restored if the operation throws --> Revise treap help to add priority changes (throw, new functions, etc.) --> Revise make_functions, and any hook tests to add missing containers --> On exceptions, auto_unlink/safe_link hooks default state should be recovered - (insert_equal, insert_lower_bound, insert_equal_upper_bound) --> insert_unique_check should also compare priorities. --> test insert_unique_check with hint in tests --> revise strong exception safety concepts for treap::erase functions. - What happens with range deletions? -> Assure stable order for optimize_multikey and inverse order otherwise --> linear slist's splice_after(..., slist &x) can be optimized if *this is empty --> optimize slist::merge like list::merge diff --git a/test/any_test.cpp b/test/any_test.cpp index bd2c955..6fc6a4c 100644 --- a/test/any_test.cpp +++ b/test/any_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/avl_multiset_test.cpp b/test/avl_multiset_test.cpp index bc8c7eb..5243ef4 100644 --- a/test/avl_multiset_test.cpp +++ b/test/avl_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,6 +17,26 @@ #include "smart_ptr.hpp" #include "generic_multiset_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +}}} + using namespace boost::intrusive; struct my_tag; diff --git a/test/avl_set_test.cpp b/test/avl_set_test.cpp index 8b4f16e..cd76006 100644 --- a/test/avl_set_test.cpp +++ b/test/avl_set_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,6 +16,27 @@ #include "smart_ptr.hpp" #include "generic_set_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +}}} + + using namespace boost::intrusive; struct my_tag; diff --git a/test/common_functors.hpp b/test/common_functors.hpp index db52197..ebfc846 100644 --- a/test/common_functors.hpp +++ b/test/common_functors.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/custom_bucket_traits_test.cpp b/test/custom_bucket_traits_test.cpp index a74eb0b..c2e1d7c 100644 --- a/test/custom_bucket_traits_test.cpp +++ b/test/custom_bucket_traits_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/default_hook_test.cpp b/test/default_hook_test.cpp index 55c31a2..aef7fa8 100644 --- a/test/default_hook_test.cpp +++ b/test/default_hook_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/external_value_traits_test.cpp b/test/external_value_traits_test.cpp index ec70f13..5016697 100644 --- a/test/external_value_traits_test.cpp +++ b/test/external_value_traits_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/generic_assoc_test.hpp b/test/generic_assoc_test.hpp index 9f39ff7..ea8db49 100644 --- a/test/generic_assoc_test.hpp +++ b/test/generic_assoc_test.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -35,6 +35,12 @@ struct has_rebalance static const bool value = false; }; +template +struct has_insert_before +{ + static const bool value = false; +}; + template class ContainerDefiner> struct test_generic_assoc { @@ -52,6 +58,9 @@ struct test_generic_assoc static void test_rebalance(std::vector& values); static void test_rebalance(std::vector& values, boost::intrusive::detail::true_type); static void test_rebalance(std::vector& values, boost::intrusive::detail::false_type); + static void test_insert_before(std::vector& values); + static void test_insert_before(std::vector& values, boost::intrusive::detail::true_type); + static void test_insert_before(std::vector& values, boost::intrusive::detail::false_type); static void test_container_from_iterator(std::vector& values); }; @@ -149,6 +158,7 @@ void test_generic_assoc::test_all(std::vector::test_rebalance test_rebalance(values, enabler()); } +template class ContainerDefiner> +void test_generic_assoc::test_insert_before +(std::vector& values, boost::intrusive::detail::true_type) +{ + typedef typename ValueTraits::value_type value_type; + typedef typename ContainerDefiner + < value_type + , value_traits + , constant_time_size + >::type assoc_type; + { + assoc_type testset; + typedef typename std::vector::iterator vec_iterator; + for(vec_iterator it(values.begin()), itend(values.end()) + ; it != itend + ; ++it){ + testset.push_back(*it); + } + BOOST_TEST(testset.size() == values.size()); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin()); + } + { + assoc_type testset; + typedef typename std::vector::iterator vec_iterator; + for(vec_iterator it(--values.end()), itend(--values.begin()) + ; it != itend + ; --it){ + testset.push_front(*it); + } + BOOST_TEST(testset.size() == values.size()); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin()); + } + { + assoc_type testset; + typedef typename std::vector::iterator vec_iterator; + typename assoc_type::iterator it_pos = + testset.insert_before(testset.end(), *values.rbegin()); + testset.insert_before(testset.begin(), *values.begin()); + for(vec_iterator it(++values.begin()), itend(--values.end()) + ; it != itend + ; ++it){ + testset.insert_before(it_pos, *it); + } + BOOST_TEST(testset.size() == values.size()); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin()); + } +} + +template class ContainerDefiner> +void test_generic_assoc::test_insert_before +(std::vector&, boost::intrusive::detail::false_type) +{} + +template class ContainerDefiner> +void test_generic_assoc::test_insert_before +(std::vector& values) +{ + typedef typename ContainerDefiner + < value_type + , value_traits + , constant_time_size + >::type assoc_type; + typedef typename detail::remove_const::type Type; + typedef detail::bool_::value> enabler; + test_insert_before(values, enabler()); +} + }}} //namespace boost::intrusive::test #include diff --git a/test/generic_multiset_test.hpp b/test/generic_multiset_test.hpp index 21aeb3c..4cd2e7a 100644 --- a/test/generic_multiset_test.hpp +++ b/test/generic_multiset_test.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/generic_set_test.hpp b/test/generic_set_test.hpp index 5df2489..5edde5f 100644 --- a/test/generic_set_test.hpp +++ b/test/generic_set_test.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,12 @@ namespace boost{ namespace intrusive{ namespace test{ +template +struct is_treap +{ + static const bool value = false; +}; + template class ContainerDefiner> struct test_generic_set { @@ -30,6 +36,9 @@ struct test_generic_set static void test_all(); static void test_sort(std::vector& values); static void test_insert(std::vector& values); + static void test_insert_advanced(std::vector& values, boost::intrusive::detail::true_type); + static void test_insert_advanced(std::vector& values, boost::intrusive::detail::false_type); + static void test_insert_advanced(std::vector& values); static void test_swap(std::vector& values); static void test_find(std::vector& values); static void test_impl(); @@ -65,6 +74,7 @@ void test_generic_set::test_all() } test_sort(values); test_insert(values); + test_insert_advanced(values); test_swap(values); test_find(values); test_impl(); @@ -139,32 +149,94 @@ void test_generic_set::test_insert(std::vector , constant_time_size >::type set_type; - set_type testset; - testset.insert(&values[0] + 2, &values[0] + 5); + { + set_type testset; + testset.insert(&values[0] + 2, &values[0] + 5); - const set_type& const_testset = testset; - { int init_values [] = { 1, 4, 5 }; - TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } + const set_type& const_testset = testset; + { int init_values [] = { 1, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } - typename set_type::iterator i = testset.begin(); - BOOST_TEST (i->value_ == 1); + typename set_type::iterator i = testset.begin(); + BOOST_TEST (i->value_ == 1); - i = testset.insert (i, values[0]); - BOOST_TEST (&*i == &values[0]); + i = testset.insert (i, values[0]); + BOOST_TEST (&*i == &values[0]); - { int init_values [] = { 5, 4, 3, 1 }; - TEST_INTRUSIVE_SEQUENCE( init_values, testset.rbegin() ); } + { int init_values [] = { 5, 4, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.rbegin() ); } - i = testset.iterator_to (values[2]); - BOOST_TEST (&*i == &values[2]); + i = testset.iterator_to (values[2]); + BOOST_TEST (&*i == &values[2]); - i = set_type::s_iterator_to(values[2]); - BOOST_TEST (&*i == &values[2]); + i = set_type::s_iterator_to(values[2]); + BOOST_TEST (&*i == &values[2]); + + testset.erase (i); + { int init_values [] = { 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); } + } +} + +template class ContainerDefiner> +void test_generic_set::test_insert_advanced +(std::vector& values, boost::intrusive::detail::true_type) +{ + typedef typename ValueTraits::value_type value_type; + typedef typename ContainerDefiner + < value_type + , value_traits + , constant_time_size + >::type set_type; + { + set_type testset; + testset.insert(&values[0], &values[0] + values.size()); + value_type v(1); + typename set_type::insert_commit_data data; + BOOST_TEST (!testset.insert_check(v, testset.value_comp(), testset.priority_comp(), data).second); + BOOST_TEST (!testset.insert_check(testset.begin(), v, testset.value_comp(), testset.priority_comp(), data).second); + } +} + + +template class ContainerDefiner> +void test_generic_set::test_insert_advanced +(std::vector& values) +{ + typedef typename ValueTraits::value_type value_type; + typedef typename ContainerDefiner + < value_type + , value_traits + , constant_time_size + >::type set_type; + typedef typename detail::remove_const::type Type; + typedef detail::bool_::value> enabler; + test_insert_advanced(values, enabler()); +} + + +//test: insert, const_iterator, const_reverse_iterator, erase, s_iterator_to: +template class ContainerDefiner> +void test_generic_set::test_insert_advanced + ( std::vector& values + , boost::intrusive::detail::false_type) +{ + typedef typename ValueTraits::value_type value_type; + typedef typename ContainerDefiner + < value_type + , value_traits + , constant_time_size + >::type set_type; + { + set_type testset; + testset.insert(&values[0], &values[0] + values.size()); + value_type v(1); + typename set_type::insert_commit_data data; + BOOST_TEST (!testset.insert_check(v, testset.value_comp(), data).second); + BOOST_TEST (!testset.insert_check(testset.begin(), v, testset.value_comp(), data).second); + } +} - testset.erase (i); - { int init_values [] = { 1, 3, 5 }; - TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); } -} //test: insert (seq-version), swap, erase (seq-version), size: template class ContainerDefiner> diff --git a/test/itestvalue.hpp b/test/itestvalue.hpp index a2885db..e0105f9 100644 --- a/test/itestvalue.hpp +++ b/test/itestvalue.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -115,12 +115,13 @@ std::size_t hash_value(const testvalue &t) } template -bool priority_order(const testvalue &t1, const testvalue &t2) +bool priority_order( const testvalue &t1 + , const testvalue &t2) { std::size_t hash1 = hash_value(t1); - boost::hash_combine(hash1,&t1); + boost::hash_combine(hash1, &t1); std::size_t hash2 = hash_value(t2); - boost::hash_combine(hash2,&t2); + boost::hash_combine(hash2, &t2); return hash1 < hash2; } @@ -150,6 +151,31 @@ struct is_even (const testvalue& v1) const { return (v1.value_ & 1) == 0; } }; +/* +struct int_testvalue_comp +{ + template + bool operator() + (const testvalue& v1, const int &i) const + { return v1.value_ < i; } + template + bool operator() + (const int &i, const testvalue& v1) const + { return i < v1.value_; } +}; + +struct int_testvalue_pcomp +{ + template + bool operator() + (const testvalue& v1, const int &i) const + { return v1.value_ < i; } + template + bool operator() + (const int &i, const testvalue& v1) const + { return i < v1.value_; } +}; +*/ } //namespace boost{ } //namespace intrusive{ diff --git a/test/list_test.cpp b/test/list_test.cpp index 8e67f8b..e9f8b74 100644 --- a/test/list_test.cpp +++ b/test/list_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/make_functions_test.cpp b/test/make_functions_test.cpp index 2f8e1aa..e98b5fc 100644 --- a/test/make_functions_test.cpp +++ b/test/make_functions_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/multiset_test.cpp b/test/multiset_test.cpp index 6bb0b06..6cd3bc2 100644 --- a/test/multiset_test.cpp +++ b/test/multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,6 +16,26 @@ #include "smart_ptr.hpp" #include "generic_multiset_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +}}} + using namespace boost::intrusive; struct my_tag; diff --git a/test/set_test.cpp b/test/set_test.cpp index 6d28424..aa1ca2b 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -11,11 +11,32 @@ // ///////////////////////////////////////////////////////////////////////////// #include + #include #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "generic_set_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +}}} + struct my_tag; using namespace boost::intrusive; @@ -134,4 +155,5 @@ int main( int, char* [] ) test_main_template, true>()(); return boost::report_errors(); } + #include diff --git a/test/sg_multiset_test.cpp b/test/sg_multiset_test.cpp index 327eaf0..ae5eb41 100644 --- a/test/sg_multiset_test.cpp +++ b/test/sg_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -34,6 +34,23 @@ struct has_rebalance +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + }}} using namespace boost::intrusive; diff --git a/test/sg_set_test.cpp b/test/sg_set_test.cpp index 61c19a4..1d49081 100644 --- a/test/sg_set_test.cpp +++ b/test/sg_set_test.cpp @@ -33,6 +33,22 @@ struct has_rebalance +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + }}} diff --git a/test/slist_test.cpp b/test/slist_test.cpp index ff0bd7f..57587c3 100644 --- a/test/slist_test.cpp +++ b/test/slist_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/splay_multiset_test.cpp b/test/splay_multiset_test.cpp index 21bd600..407c86c 100644 --- a/test/splay_multiset_test.cpp +++ b/test/splay_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/stateful_value_traits_test.cpp b/test/stateful_value_traits_test.cpp index ffba752..46867ae 100644 --- a/test/stateful_value_traits_test.cpp +++ b/test/stateful_value_traits_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/test_container.hpp b/test/test_container.hpp index b3124e9..c900a6b 100644 --- a/test/test_container.hpp +++ b/test/test_container.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -20,6 +20,12 @@ namespace boost { namespace intrusive { namespace test { +template +struct is_unordered +{ + static const bool value = false; +}; + template struct has_const_overloads { @@ -78,6 +84,7 @@ void test_sequence_container(Container & c, Data & d) BOOST_TEST( c.size() == 0 ); BOOST_TEST( c.empty() ); + { typename Data::iterator i = d.begin(); c.insert( c.begin(), *i ); @@ -87,7 +94,8 @@ void test_sequence_container(Container & c, Data & d) BOOST_TEST( c.size() == 2 ); BOOST_TEST( !c.empty() ); - c.erase( c.begin() ); + typename Container::iterator i; + i = c.erase( c.begin() ); BOOST_TEST( c.size() == 1 ); @@ -97,7 +105,8 @@ void test_sequence_container(Container & c, Data & d) c.insert( c.begin(), *(i) ); } - c.erase( c.begin(), c.end() ); + i = c.erase( c.begin(), c.end() ); + BOOST_TEST( i == c.end() ); BOOST_TEST( c.empty() ); @@ -107,7 +116,8 @@ void test_sequence_container(Container & c, Data & d) BOOST_TEST( c.begin() != c.end() ); - c.erase( c.begin() ); + i = c.erase_and_dispose( c.begin(), detail::null_disposer() ); + BOOST_TEST( i == c.begin() ); c.assign(d.begin(), d.end()); @@ -119,9 +129,90 @@ void test_sequence_container(Container & c, Data & d) BOOST_TEST( c.empty() ); } +template< class Container, class Data > +void test_common_unordered_and_associative_container(Container & c, Data & d, boost::intrusive::detail::true_ unordered) +{ + (void)unordered; + typedef typename Container::size_type size_type; + + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(), d.end()); + + for( typename Data::const_iterator di = d.begin(), de = d.end(); + di != de; ++di ) + { + BOOST_TEST( c.find(*di) != c.end() ); + } + + typename Data::const_iterator db = d.begin(); + typename Data::const_iterator da = db++; + + size_type old_size = c.size(); + + c.erase(*da, c.hash_function(), c.key_eq()); + BOOST_TEST( c.size() == old_size-1 ); + //This should not eras anyone + size_type second_erase = c.erase_and_dispose + ( *da, c.hash_function(), c.key_eq(), detail::null_disposer() ); + BOOST_TEST( second_erase == 0 ); + + BOOST_TEST( c.count(*da, c.hash_function(), c.key_eq()) == 0 ); + BOOST_TEST( c.count(*db, c.hash_function(), c.key_eq()) != 0 ); + + BOOST_TEST( c.find(*da, c.hash_function(), c.key_eq()) == c.end() ); + BOOST_TEST( c.find(*db, c.hash_function(), c.key_eq()) != c.end() ); + + BOOST_TEST( c.equal_range(*db, c.hash_function(), c.key_eq()).first != c.end() ); + + c.clear(); + + BOOST_TEST( c.equal_range(*da, c.hash_function(), c.key_eq()).first == c.end() ); +} + +template< class Container, class Data > +void test_common_unordered_and_associative_container(Container & c, Data & d, boost::intrusive::detail::false_ unordered) +{ + (void)unordered; + typedef typename Container::size_type size_type; + + assert( d.size() > 2 ); + + c.clear(); + c.insert(d.begin(), d.end()); + + for( typename Data::const_iterator di = d.begin(), de = d.end(); + di != de; ++di ) + { + BOOST_TEST( c.find(*di, c.key_comp()) != c.end() ); + } + + typename Data::const_iterator db = d.begin(); + typename Data::const_iterator da = db++; + + size_type old_size = c.size(); + + c.erase(*da, c.key_comp()); + BOOST_TEST( c.size() == old_size-1 ); + //This should not eras anyone + size_type second_erase = c.erase_and_dispose( *da, c.key_comp(), detail::null_disposer() ); + BOOST_TEST( second_erase == 0 ); + + BOOST_TEST( c.count(*da, c.key_comp()) == 0 ); + BOOST_TEST( c.count(*db, c.key_comp()) != 0 ); + BOOST_TEST( c.find(*da, c.key_comp()) == c.end() ); + BOOST_TEST( c.find(*db, c.key_comp()) != c.end() ); + BOOST_TEST( c.equal_range(*db, c.key_comp()).first != c.end() ); + c.clear(); + BOOST_TEST( c.equal_range(*da, c.key_comp()).first == c.end() ); +} + + template< class Container, class Data > void test_common_unordered_and_associative_container(Container & c, Data & d) { + { typedef typename Container::size_type size_type; assert( d.size() > 2 ); @@ -141,8 +232,10 @@ void test_common_unordered_and_associative_container(Container & c, Data & d) size_type old_size = c.size(); c.erase(*da); - BOOST_TEST( c.size() == old_size-1 ); + //This should not eras anyone + size_type second_erase = c.erase_and_dispose( *da, detail::null_disposer() ); + BOOST_TEST( second_erase == 0 ); BOOST_TEST( c.count(*da) == 0 ); BOOST_TEST( c.count(*db) != 0 ); @@ -155,6 +248,9 @@ void test_common_unordered_and_associative_container(Container & c, Data & d) c.clear(); BOOST_TEST( c.equal_range(*da).first == c.end() ); + } + typedef detail::bool_::value> enabler; + test_common_unordered_and_associative_container(c, d, enabler()); } template< class Container, class Data > diff --git a/test/test_macros.hpp b/test/test_macros.hpp index 0b23322..f5a3b62 100644 --- a/test/test_macros.hpp +++ b/test/test_macros.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008 +// (C) Copyright Ion Gaztanaga 2006-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/treap_multiset_test.cpp b/test/treap_multiset_test.cpp index dbae120..ced326b 100644 --- a/test/treap_multiset_test.cpp +++ b/test/treap_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,6 +17,26 @@ #include "smart_ptr.hpp" #include "generic_multiset_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +}}} + using namespace boost::intrusive; struct my_tag; diff --git a/test/treap_set_test.cpp b/test/treap_set_test.cpp index cbd6471..87d7ae6 100644 --- a/test/treap_set_test.cpp +++ b/test/treap_set_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -15,6 +15,43 @@ #include "smart_ptr.hpp" #include "generic_set_test.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct has_insert_before > +{ + static const bool value = true; +}; + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct is_treap > +{ + static const bool value = true; +}; + +}}} + + using namespace boost::intrusive; struct my_tag; diff --git a/test/unordered_multiset_test.cpp b/test/unordered_multiset_test.cpp index 206605d..7d1e8da 100644 --- a/test/unordered_multiset_test.cpp +++ b/test/unordered_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,26 @@ #include "test_macros.hpp" #include "test_container.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct is_unordered > +{ + static const bool value = true; +}; + +}}} + using namespace boost::intrusive; struct my_tag; diff --git a/test/unordered_set_test.cpp b/test/unordered_set_test.cpp index f6b5e48..ee65896 100644 --- a/test/unordered_set_test.cpp +++ b/test/unordered_set_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2008. +// (C) Copyright Ion Gaztanaga 2006-2009. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -22,6 +22,26 @@ #include "test_macros.hpp" #include "test_container.hpp" +namespace boost { namespace intrusive { namespace test { + +#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES) +template +#else +template +#endif +struct is_unordered > +{ + static const bool value = true; +}; + +}}} + using namespace boost::intrusive; struct my_tag; diff --git a/test/virtual_base_test.cpp b/test/virtual_base_test.cpp index 92a700b..dabef96 100644 --- a/test/virtual_base_test.cpp +++ b/test/virtual_base_test.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2008 +// (C) Copyright Ion Gaztanaga 2007-2009 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at