mirror of
https://github.com/boostorg/intrusive.git
synced 2025-05-09 23:03:56 +00:00
Fixes for 1.41
[SVN r56876]
This commit is contained in:
parent
6f941ef73c
commit
6b67d4eb9d
@ -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
|
||||
|
@ -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<void*>`.
|
||||
|
||||
`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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
74
example/doc_positional_insertion.cpp
Normal file
74
example/doc_positional_insertion.cpp
Normal file
@ -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 <boost/intrusive/set.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
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<MyClass> 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<MyClass> mset;
|
||||
for(int i = 0; i < 100; ++i) mset.push_back(values[i]);
|
||||
|
||||
//Now check orderd invariant
|
||||
multiset<MyClass>::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<MyClass, compare< std::greater<MyClass> > > mset;
|
||||
for(int i = 0; i < 100; ++i) mset.push_front(values[i]);
|
||||
|
||||
//Now check orderd invariant
|
||||
multiset<MyClass, compare< std::greater<MyClass> > >::
|
||||
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<MyClass> mset;
|
||||
mset.insert_before(mset.begin(), values[0]);
|
||||
multiset<MyClass>::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<MyClass>::const_iterator next(mset.cbegin()), it(next++);
|
||||
for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it < *next);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//]
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright 2005-2008 Ion Gaztanaga
|
||||
Copyright 2005-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)
|
||||
-->
|
||||
|
@ -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
|
||||
|
@ -243,12 +243,18 @@
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\ebo_functor_holder.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\function_detector.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\generic_hook.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\hashtable_node.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\is_stateful_value_traits.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\..\boost\intrusive\detail\list_node.hpp">
|
||||
</File>
|
||||
@ -382,6 +388,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\example\doc_offset_ptr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\example\doc_positional_insertion.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\example\doc_rbtree_algorithms.cpp">
|
||||
</File>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::avl_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::avl_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<class T>
|
||||
struct has_insert_before
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
struct test_generic_assoc
|
||||
{
|
||||
@ -52,6 +58,9 @@ struct test_generic_assoc
|
||||
static void test_rebalance(std::vector<value_type>& values);
|
||||
static void test_rebalance(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_rebalance(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_insert_before(std::vector<value_type>& values);
|
||||
static void test_insert_before(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_insert_before(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_container_from_iterator(std::vector<value_type>& values);
|
||||
};
|
||||
|
||||
@ -149,6 +158,7 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(std::vector<typ
|
||||
test_splay_up(values);
|
||||
test_splay_down(values);
|
||||
test_rebalance(values);
|
||||
test_insert_before(values);
|
||||
test_insert_erase_burst();
|
||||
test_container_from_iterator(values);
|
||||
}
|
||||
@ -365,6 +375,73 @@ void test_generic_assoc<ValueTraits, ContainerDefiner>::test_rebalance
|
||||
test_rebalance(values, enabler());
|
||||
}
|
||||
|
||||
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
{
|
||||
assoc_type testset;
|
||||
typedef typename std::vector<value_type>::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<value_type>::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<value_type>::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 ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
(std::vector<typename ValueTraits::value_type>&, boost::intrusive::detail::false_type)
|
||||
{}
|
||||
|
||||
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
|
||||
(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type assoc_type;
|
||||
typedef typename detail::remove_const<assoc_type>::type Type;
|
||||
typedef detail::bool_<has_insert_before<Type>::value> enabler;
|
||||
test_insert_before(values, enabler());
|
||||
}
|
||||
|
||||
}}} //namespace boost::intrusive::test
|
||||
|
||||
#include <boost/intrusive/detail/config_end.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
|
||||
|
@ -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<class T>
|
||||
struct is_treap
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
struct test_generic_set
|
||||
{
|
||||
@ -30,6 +36,9 @@ struct test_generic_set
|
||||
static void test_all();
|
||||
static void test_sort(std::vector<value_type>& values);
|
||||
static void test_insert(std::vector<value_type>& values);
|
||||
static void test_insert_advanced(std::vector<value_type>& values, boost::intrusive::detail::true_type);
|
||||
static void test_insert_advanced(std::vector<value_type>& values, boost::intrusive::detail::false_type);
|
||||
static void test_insert_advanced(std::vector<value_type>& values);
|
||||
static void test_swap(std::vector<value_type>& values);
|
||||
static void test_find(std::vector<value_type>& values);
|
||||
static void test_impl();
|
||||
@ -65,6 +74,7 @@ void test_generic_set<ValueTraits, ContainerDefiner>::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<ValueTraits, ContainerDefiner>::test_insert(std::vector<ty
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::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 ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
(std::vector<typename ValueTraits::value_type>& values, boost::intrusive::detail::true_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::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 ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
(std::vector<typename ValueTraits::value_type>& values)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::constant_time_size>
|
||||
>::type set_type;
|
||||
typedef typename detail::remove_const<set_type>::type Type;
|
||||
typedef detail::bool_<is_treap<Type>::value> enabler;
|
||||
test_insert_advanced(values, enabler());
|
||||
}
|
||||
|
||||
|
||||
//test: insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
|
||||
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
|
||||
( std::vector<typename ValueTraits::value_type>& values
|
||||
, boost::intrusive::detail::false_type)
|
||||
{
|
||||
typedef typename ValueTraits::value_type value_type;
|
||||
typedef typename ContainerDefiner
|
||||
< value_type
|
||||
, value_traits<ValueTraits>
|
||||
, constant_time_size<value_type::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 ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
|
||||
|
@ -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<Hooks, ConstantTimeSize> &t)
|
||||
}
|
||||
|
||||
template<class Hooks, bool ConstantTimeSize>
|
||||
bool priority_order(const testvalue<Hooks, ConstantTimeSize> &t1, const testvalue<Hooks, ConstantTimeSize> &t2)
|
||||
bool priority_order( const testvalue<Hooks, ConstantTimeSize> &t1
|
||||
, const testvalue<Hooks, ConstantTimeSize> &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<Hooks, constant_time_size>& v1) const
|
||||
{ return (v1.value_ & 1) == 0; }
|
||||
};
|
||||
/*
|
||||
struct int_testvalue_comp
|
||||
{
|
||||
template<class Hooks, bool constant_time_size>
|
||||
bool operator()
|
||||
(const testvalue<Hooks, constant_time_size>& v1, const int &i) const
|
||||
{ return v1.value_ < i; }
|
||||
template<class Hooks, bool constant_time_size>
|
||||
bool operator()
|
||||
(const int &i, const testvalue<Hooks, constant_time_size>& v1) const
|
||||
{ return i < v1.value_; }
|
||||
};
|
||||
|
||||
struct int_testvalue_pcomp
|
||||
{
|
||||
template<class Hooks, bool constant_time_size>
|
||||
bool operator()
|
||||
(const testvalue<Hooks, constant_time_size>& v1, const int &i) const
|
||||
{ return v1.value_ < i; }
|
||||
template<class Hooks, bool constant_time_size>
|
||||
bool operator()
|
||||
(const int &i, const testvalue<Hooks, constant_time_size>& v1) const
|
||||
{ return i < v1.value_; }
|
||||
};
|
||||
*/
|
||||
|
||||
} //namespace boost{
|
||||
} //namespace intrusive{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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 <boost/intrusive/detail/config_begin.hpp>
|
||||
|
||||
#include <boost/intrusive/set.hpp>
|
||||
#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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
struct my_tag;
|
||||
|
||||
using namespace boost::intrusive;
|
||||
@ -134,4 +155,5 @@ int main( int, char* [] )
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#include <boost/intrusive/detail/config_end.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
|
||||
@ -34,6 +34,23 @@ struct has_rebalance<boost::intrusive::sg_multiset<T,
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::sg_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
@ -33,6 +33,22 @@ struct has_rebalance<boost::intrusive::sg_set<T,
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::sg_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<class T>
|
||||
struct is_unordered
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
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_<is_unordered<Container>::value> enabler;
|
||||
test_common_unordered_and_associative_container(c, d, enabler());
|
||||
}
|
||||
|
||||
template< class Container, class Data >
|
||||
|
@ -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
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::treap_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct has_insert_before<boost::intrusive::treap_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
template<class T, class O1, class O2, class O3, class O4>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct is_treap<boost::intrusive::treap_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4, class O5, class O6>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct is_unordered<boost::intrusive::unordered_multiset<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4, O5, O6
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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<class T, class O1, class O2, class O3, class O4, class O5, class O6>
|
||||
#else
|
||||
template<class T, class ...Options>
|
||||
#endif
|
||||
struct is_unordered<boost::intrusive::unordered_set<T,
|
||||
#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||
O1, O2, O3, O4, O5, O6
|
||||
#else
|
||||
Options...
|
||||
#endif
|
||||
> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
using namespace boost::intrusive;
|
||||
|
||||
struct my_tag;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user