Full merge from trunk at revision 41356 of entire boost-root tree.

[SVN r41370]
This commit is contained in:
Beman Dawes
2007-11-25 18:38:02 +00:00
parent ccbfcebe9f
commit cc749e440e
101 changed files with 16039 additions and 0 deletions

55
doc/Jamfile.v2 Normal file
View File

@@ -0,0 +1,55 @@
# Boost.Intrusive library documentation Jamfile
#
# Copyright Ion Gazta<74>aga 2006.
# 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.
import doxygen ;
import quickbook ;
doxygen autodoc
:
[ glob ../../../boost/intrusive/*.hpp ]
:
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>HIDE_UNDOC_CLASSES=YES
<doxygen:param>EXTRACT_PRIVATE=NO
<doxygen:param>ENABLE_PREPROCESSING=YES
<doxygen:param>MACRO_EXPANSION=YES
<doxygen:param>"PREDEFINED=BOOST_INTRUSIVE_DOXYGEN_INVOKED \\
"list_impl=list" \\
"slist_impl=slist" \\
"set_impl=set" \\
"multiset_impl=multiset" \\
"rbtree_impl=rbtree" \\
"unordered_set_impl=unordered_set" \\
"unordered_multiset_impl=unordered_multiset" \\
"hashtable_impl=hashtable" \\
"splay_set_impl=splay_set" \\
"splay_multiset_impl=splay_multiset" \\
"splaytree_impl=splaytree" \\
"sg_set_impl=sg_set" \\
"sg_multiset_impl=sg_multiset" \\
"sgtree_impl=sgtree" \\
"avl_set_impl=avl_set" \\
"avl_multiset_impl=avl_multiset" \\
"avltree_impl=avltree""
;
xml intrusive : intrusive.qbk ;
boostbook standalone
:
intrusive
:
<xsl:param>boost.root=../../../..
<xsl:param>boost.libraries=../../../../libs/libraries.htm
<xsl:param>generate.section.toc.level=3
<xsl:param>chunk.first.sections=1
<dependency>autodoc
;

538
doc/html/boostbook.css Normal file
View File

@@ -0,0 +1,538 @@
/*=============================================================================
Copyright (c) 2004 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to 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)
=============================================================================*/
/*=============================================================================
Body defaults
=============================================================================*/
body
{
margin: 1em;
font-family: sans-serif;
}
/*=============================================================================
Paragraphs
=============================================================================*/
p
{
text-align: left;
font-size: 10pt;
line-height: 1.15;
}
/*=============================================================================
Program listings
=============================================================================*/
/* Code on paragraphs */
p tt.computeroutput
{
font-size: 10pt;
}
pre.synopsis
{
font-size: 10pt;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
.programlisting,
.screen
{
font-size: 10pt;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
/*=============================================================================
Headings
=============================================================================*/
h1, h2, h3, h4, h5, h6
{
text-align: left;
margin: 1em 0em 0.5em 0em;
font-weight: bold;
}
h1 { font: 140% }
h2 { font: bold 140% }
h3 { font: bold 130% }
h4 { font: bold 120% }
h5 { font: italic 110% }
h6 { font: italic 100% }
/* Top page titles */
title,
h1.title,
h2.title
h3.title,
h4.title,
h5.title,
h6.title,
.refentrytitle
{
font-weight: bold;
margin-bottom: 1pc;
}
h1.title { font-size: 140% }
h2.title { font-size: 140% }
h3.title { font-size: 130% }
h4.title { font-size: 120% }
h5.title { font-size: 110% }
h6.title { font-size: 100% }
.section h1
{
margin: 0em 0em 0.5em 0em;
font-size: 140%;
}
.section h2 { font-size: 140% }
.section h3 { font-size: 130% }
.section h4 { font-size: 120% }
.section h5 { font-size: 110% }
.section h6 { font-size: 100% }
/* Code on titles */
h1 tt.computeroutput { font-size: 140% }
h2 tt.computeroutput { font-size: 140% }
h3 tt.computeroutput { font-size: 130% }
h4 tt.computeroutput { font-size: 120% }
h5 tt.computeroutput { font-size: 110% }
h6 tt.computeroutput { font-size: 100% }
/*=============================================================================
Author
=============================================================================*/
h3.author
{
font-size: 100%
}
/*=============================================================================
Lists
=============================================================================*/
li
{
font-size: 10pt;
line-height: 1.3;
}
/* Unordered lists */
ul
{
text-align: left;
}
/* Ordered lists */
ol
{
text-align: left;
}
/*=============================================================================
Links
=============================================================================*/
a
{
text-decoration: none; /* no underline */
}
a:hover
{
text-decoration: underline;
}
/*=============================================================================
Spirit style navigation
=============================================================================*/
.spirit-nav
{
text-align: right;
}
.spirit-nav a
{
color: white;
padding-left: 0.5em;
}
.spirit-nav img
{
border-width: 0px;
}
/*=============================================================================
Table of contents
=============================================================================*/
.toc
{
margin: 1pc 4% 0pc 4%;
padding: 0.1pc 1pc 0.1pc 1pc;
font-size: 10pt;
line-height: 1.15;
}
.toc-main
{
width: 600;
text-align: center;
margin: 1pc 1pc 1pc 10%;
padding: 2pc 1pc 3pc 1pc;
line-height: 0.1;
}
.boost-toc
{
float: right;
padding: 0.5pc;
}
/*=============================================================================
Tables
=============================================================================*/
.table-title,
div.table p.title
{
margin-left: 4%;
padding-right: 0.5em;
padding-left: 0.5em;
}
.informaltable table,
.table table
{
width: 92%;
margin-left: 4%;
margin-right: 4%;
}
div.informaltable table,
div.table table
{
padding: 4px;
}
/* Table Cells */
div.informaltable table tr td,
div.table table tr td
{
padding: 0.5em;
text-align: left;
}
div.informaltable table tr th,
div.table table tr th
{
padding: 0.5em 0.5em 0.5em 0.5em;
border: 1pt solid white;
font-size: 120%;
}
/*=============================================================================
Blurbs
=============================================================================*/
div.note,
div.tip,
div.important,
div.caution,
div.warning,
p.blurb
{
font-size: 10pt;
line-height: 1.2;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
p.blurb img
{
padding: 1pt;
}
/*=============================================================================
Variable Lists
=============================================================================*/
span.term
{
font-weight: bold;
font-size: 10pt;
}
div.variablelist table tbody tr td
{
text-align: left;
vertical-align: top;
padding: 0em 2em 0em 0em;
font-size: 10pt;
}
div.variablelist table tbody tr td p
{
margin: 0em 0em 0.5em 0em;
}
/* Make the terms in definition lists bold */
div.variablelist dl dt
{
font-weight: bold;
font-size: 10pt;
}
div.variablelist dl dd
{
margin: 1em 0em 1em 2em;
font-size: 10pt;
}
/*=============================================================================
Misc
=============================================================================*/
/* Title of books and articles in bibliographies */
span.title
{
font-style: italic;
}
span.underline
{
text-decoration: underline;
}
span.strikethrough
{
text-decoration: line-through;
}
/* Copyright, Legal Notice */
div div.legalnotice p
{
font-size: 8pt;
text-align: left
}
/*=============================================================================
Colors
=============================================================================*/
@media screen
{
/* Links */
a
{
color: #0C7445;
}
a:visited
{
color: #663974;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
{
text-decoration: none; /* no underline */
color: #000000;
}
/* Syntax Highlighting */
.keyword { color: #0000AA; }
.identifier { color: #000000; }
.special { color: #707070; }
.preprocessor { color: #402080; }
.char { color: teal; }
.comment { color: #800000; }
.string { color: teal; }
.number { color: teal; }
.white_bkd { background-color: #E8FBE9; }
.dk_grey_bkd { background-color: #A0DAAC; }
/* Copyright, Legal Notice */
.copyright
{
color: #666666;
font-size: small;
}
div div.legalnotice p
{
color: #666666;
}
/* Program listing */
pre.synopsis
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
.programlisting,
.screen
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
/* Blurbs */
div.note,
div.tip,
div.important,
div.caution,
div.warning,
p.blurb
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
/* Table of contents */
.toc
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
/* Table of contents */
.toc-main
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid #DCDCDC;
background-color: #FAFFFB;
}
div.informaltable table tr th,
div.table table tr th
{
background-color: #E3F9E4;
border: 1px solid #DCDCDC;
}
/* Misc */
span.highlight
{
color: #00A000;
}
}
@media print
{
/* Links */
a
{
color: black;
}
a:visited
{
color: black;
}
.spirit-nav
{
display: none;
}
/* Program listing */
pre.synopsis
{
border: 1px solid gray;
background-color: #FAFFFB;
}
.programlisting,
.screen
{
border: 1px solid gray;
background-color: #FAFFFB;
}
/* Table of contents */
.toc
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
/* Table of contents */
.toc-main
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
background-color: #FAFFFB;
}
.informaltable table,
.table table
{
border: 1px solid #DCDCDC;
border-bottom: 3px solid #9D9D9D;
border-right: 3px solid #9D9D9D;
border-collapse: collapse;
background-color: #FAFFFB;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid #DCDCDC;
background-color: #FAFFFB;
}
div.informaltable table tr th,
div.table table tr th
{
border: 1px solid #DCDCDC;
background-color: #FAFFFB;
}
/* Misc */
span.highlight
{
font-weight: bold;
}
}

BIN
doc/html/images/blank.png Normal file

Binary file not shown.

BIN
doc/html/images/caution.png Normal file

Binary file not shown.

BIN
doc/html/images/draft.png Normal file

Binary file not shown.

BIN
doc/html/images/home.png Normal file

Binary file not shown.

Binary file not shown.

BIN
doc/html/images/next.png Normal file

Binary file not shown.

BIN
doc/html/images/note.png Normal file

Binary file not shown.

BIN
doc/html/images/prev.png Normal file

Binary file not shown.

BIN
doc/html/images/tip.png Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
doc/html/images/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

BIN
doc/html/images/warning.png Normal file

Binary file not shown.

5
doc/html/reference.css Normal file
View File

@@ -0,0 +1,5 @@
PRE.synopsis {
background-color: #e0ffff;
border: thin solid blue;
padding: 1em
}

3418
doc/intrusive.qbk Normal file

File diff suppressed because it is too large Load Diff

34
example/Jamfile.v2 Normal file
View File

@@ -0,0 +1,34 @@
# Boost Intrusive Library Example Jamfile
# (C) Copyright Ion Gazta<74>aga 2006-2007.
# Use, modification and distribution are subject to 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)
# Adapted from John Maddock's TR1 Jamfile.v2
# Copyright John Maddock 2005.
# Use, modification and distribution are subject to 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)
# this rule enumerates through all the sources and invokes
# the run rule for each source, the result is a list of all
# the run rules, which we can pass on to the test_suite rule:
rule test_all
{
local all_rules = ;
for local fileb in [ glob *.cpp ]
{
all_rules += [ run $(fileb) /boost/thread//boost_thread
: # additional args
: # test-files
: # requirements
] ;
}
return $(all_rules) ;
}
test-suite intrusive_example : [ test_all r ] : <threading>multi ;

View File

@@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_advanced_value_traits_code
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/list.hpp>
#include <vector>
//This is the node that will be used with algorithms.
struct simple_node
{
simple_node *prev_;
simple_node *next_;
};
//]
//[doc_advanced_value_traits_value_traits
class base_1{};
class base_2{};
struct value_1 : public base_1, public simple_node
{ int id_; };
struct value_2 : public base_1, public base_2, public simple_node
{ float id_; };
//Define the node traits. A single node_traits will be enough.
struct simple_node_traits
{
typedef simple_node node;
typedef node * node_ptr;
typedef const node * const_node_ptr;
static node *get_next(const node *n) { return n->next_; }
static void set_next(node *n, node *next) { n->next_ = next; }
static node *get_previous(const node *n) { return n->prev_; }
static void set_previous(node *n, node *prev) { n->prev_ = prev; }
};
//A templatized value traits for value_1 and value_2
template<class ValueType>
struct simple_value_traits
{
typedef simple_node_traits node_traits;
typedef node_traits::node_ptr node_ptr;
typedef node_traits::const_node_ptr const_node_ptr;
typedef ValueType value_type;
typedef ValueType * pointer;
typedef const ValueType * const_pointer;
static const boost::intrusive::link_mode_type link_mode = boost::intrusive::normal_link;
static node_ptr to_node_ptr (value_type &value) { return node_ptr(&value); }
static const_node_ptr to_node_ptr (const value_type &value) { return const_node_ptr(&value); }
static pointer to_value_ptr(node_ptr n) { return static_cast<value_type*>(n); }
static const_pointer to_value_ptr(const_node_ptr n) { return static_cast<const value_type*>(n); }
};
//]
//[doc_advanced_value_traits_containers
//Now define two intrusive lists. Both lists will use the same algorithms:
// circular_list_algorithms<simple_node_traits>
using namespace boost::intrusive;
typedef list <value_1, value_traits<simple_value_traits<value_1> > > Value1List;
typedef list <value_2, value_traits<simple_value_traits<value_2> > > Value2List;
//]
//[doc_advanced_value_traits_test
int main()
{
typedef std::vector<value_1> Vect1;
typedef std::vector<value_2> Vect2;
//Create values, with a different internal number
Vect1 values1;
Vect2 values2;
for(int i = 0; i < 100; ++i){
value_1 v1; v1.id_ = i; values1.push_back(v1);
value_2 v2; v2.id_ = (float)i; values2.push_back(v2);
}
//Create the lists with the objects
Value1List list1(values1.begin(), values1.end());
Value2List list2(values2.begin(), values2.end());
//Now test both lists
Value1List::const_iterator bit1(list1.begin()), bitend1(list1.end());
Value2List::const_iterator bit2(list2.begin()), bitend2(list2.end());
Vect1::const_iterator it1(values1.begin()), itend1(values1.end());
Vect2::const_iterator it2(values2.begin()), itend2(values2.end());
//Test the objects inserted in our lists
for(; it1 != itend1; ++it1, ++bit1, ++it2, ++bit2){
if(&*bit1 != &*it1 || &*bit2 != &*it2) return false;
}
return 0;
}
//]

View File

@@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/member_value_traits.hpp>
#include <vector>
struct simple_node
{
simple_node *prev_;
simple_node *next_;
};
//Define the node traits. A single node_traits will be enough.
struct simple_node_traits
{
typedef simple_node node;
typedef node * node_ptr;
typedef const node * const_node_ptr;
static node *get_next(const node *n) { return n->next_; }
static void set_next(node *n, node *next) { n->next_ = next; }
static node *get_previous(const node *n) { return n->prev_; }
static void set_previous(node *n, node *prev) { n->prev_ = prev; }
};
//[doc_advanced_value_traits2_value_traits
class base_1{};
class base_2{};
struct value_1 : public base_1, public simple_node
{
int id_;
simple_node node_;
};
struct value_2 : public base_1, public base_2, public simple_node
{
simple_node node_;
float id_;
};
using namespace boost::intrusive;
typedef member_value_traits
<value_1, simple_node_traits, &value_1::node_, normal_link> ValueTraits1;
typedef member_value_traits
<value_2, simple_node_traits, &value_2::node_, normal_link> ValueTraits2;
//Now define two intrusive lists. Both lists will use the same algorithms:
// circular_list_algorithms<simple_node_traits>
typedef list <value_1, value_traits<ValueTraits1> > Value1List;
typedef list <value_2, value_traits<ValueTraits2> > Value2List;
//]
//[doc_advanced_value_traits2_test
int main()
{
typedef std::vector<value_1> Vect1;
typedef std::vector<value_2> Vect2;
//Create values, with a different internal number
Vect1 values1;
Vect2 values2;
for(int i = 0; i < 100; ++i){
value_1 v1; v1.id_ = i; values1.push_back(v1);
value_2 v2; v2.id_ = (float)i; values2.push_back(v2);
}
//Create the lists with the objects
Value1List list1(values1.begin(), values1.end());
Value2List list2(values2.begin(), values2.end());
//Now test both lists
Value1List::const_iterator bit1(list1.begin()), bitend1(list1.end());
Value2List::const_iterator bit2(list2.begin()), bitend2(list2.end());
Vect1::const_iterator it1(values1.begin()), itend1(values1.end());
Vect2::const_iterator it2(values2.begin()), itend2(values2.end());
//Test the objects inserted in our lists
for(; it1 != itend1; ++it1, ++bit1, ++it2, ++bit2){
if(&*bit1 != &*it1 || &*bit2 != &*it2) return false;
}
return 0;
}
//]

View File

@@ -0,0 +1,260 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_assoc_optimized_code_normal_find
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <cstring>
using namespace boost::intrusive;
// Hash function for strings
struct StrHasher
{
std::size_t operator()(const char *str) const
{
std::size_t seed = 0;
for(; *str; ++str) boost::hash_combine(seed, *str);
return seed;
}
};
class Expensive : public set_base_hook<>, public unordered_set_base_hook<>
{
std::string key_;
// Other members...
public:
Expensive(const char *key)
: key_(key)
{} //other expensive initializations...
const std::string & get_key() const
{ return key_; }
friend bool operator < (const Expensive &a, const Expensive &b)
{ return a.key_ < b.key_; }
friend bool operator == (const Expensive &a, const Expensive &b)
{ return a.key_ == b.key_; }
friend std::size_t hash_value(const Expensive &object)
{ return StrHasher()(object.get_key().c_str()); }
};
// A set and unordered_set that store Expensive objects
typedef set<Expensive> Set;
typedef unordered_set<Expensive> UnorderedSet;
// Search functions
Expensive *get_from_set(const char* key, Set &set_object)
{
Set::iterator it = set_object.find(Expensive(key));
if( it == set_object.end() ) return 0;
return &*it;
}
Expensive *get_from_uset(const char* key, UnorderedSet &uset_object)
{
UnorderedSet::iterator it = uset_object.find(Expensive (key));
if( it == uset_object.end() ) return 0;
return &*it;
}
//]
//[doc_assoc_optimized_code_optimized_find
// These compare Expensive and a c-string
struct StrExpComp
{
bool operator()(const char *str, const Expensive &c) const
{ return std::strcmp(str, c.get_key().c_str()) < 0; }
bool operator()(const Expensive &c, const char *str) const
{ return std::strcmp(c.get_key().c_str(), str) < 0; }
};
struct StrExpEqual
{
bool operator()(const char *str, const Expensive &c) const
{ return std::strcmp(str, c.get_key().c_str()) == 0; }
bool operator()(const Expensive &c, const char *str) const
{ return std::strcmp(c.get_key().c_str(), str) == 0; }
};
// Optimized search functions
Expensive *get_from_set_optimized(const char* key, Set &set_object)
{
Set::iterator it = set_object.find(key, StrExpComp());
if( it == set_object.end() ) return 0;
return &*it;
}
Expensive *get_from_uset_optimized(const char* key, UnorderedSet &uset_object)
{
UnorderedSet::iterator it = uset_object.find(key, StrHasher(), StrExpEqual());
if( it == uset_object.end() ) return 0;
return &*it;
}
//]
//[doc_assoc_optimized_code_normal_insert
// Insertion functions
bool insert_to_set(const char* key, Set &set_object)
{
Expensive *pobject = new Expensive(key);
bool success = set_object.insert(*pobject).second;
if(!success) delete pobject;
return success;
}
bool insert_to_uset(const char* key, UnorderedSet &uset_object)
{
Expensive *pobject = new Expensive(key);
bool success = uset_object.insert(*pobject).second;
if(!success) delete pobject;
return success;
}
//]
//[doc_assoc_optimized_code_optimized_insert
// Optimized insertion functions
bool insert_to_set_optimized(const char* key, Set &set_object)
{
Set::insert_commit_data insert_data;
bool success = set_object.insert_check(key, StrExpComp(), insert_data).second;
if(success) set_object.insert_commit(*new Expensive(key), insert_data);
return success;
}
bool insert_to_uset_optimized(const char* key, UnorderedSet &uset_object)
{
UnorderedSet::insert_commit_data insert_data;
bool success = uset_object.insert_check
(key, StrHasher(), StrExpEqual(), insert_data).second;
if(success) uset_object.insert_commit(*new Expensive(key), insert_data);
return success;
}
//]
int main()
{
Set set;
UnorderedSet::bucket_type buckets[10];
UnorderedSet unordered_set(UnorderedSet::bucket_traits(buckets, 10));
const char * const expensive_key
= "A long string that avoids small string optimization";
Expensive value(expensive_key);
if(get_from_set(expensive_key, set)){
return 1;
}
if(get_from_uset(expensive_key, unordered_set)){
return 1;
}
if(get_from_set_optimized(expensive_key, set)){
return 1;
}
if(get_from_uset_optimized(expensive_key, unordered_set)){
return 1;
}
Set::iterator setit = set.insert(value).first;
UnorderedSet::iterator unordered_setit = unordered_set.insert(value).first;
if(!get_from_set(expensive_key, set)){
return 1;
}
if(!get_from_uset(expensive_key, unordered_set)){
return 1;
}
if(!get_from_set_optimized(expensive_key, set)){
return 1;
}
if(!get_from_uset_optimized(expensive_key, unordered_set)){
return 1;
}
set.erase(setit);
unordered_set.erase(unordered_setit);
if(!insert_to_set(expensive_key, set)){
return 1;
}
if(!insert_to_uset(expensive_key, unordered_set)){
return 1;
}
{
Expensive *ptr = &*set.begin();
set.clear();
delete ptr;
}
{
Expensive *ptr = &*unordered_set.begin();
unordered_set.clear();
delete ptr;
}
if(!insert_to_set_optimized(expensive_key, set)){
return 1;
}
if(!insert_to_uset_optimized(expensive_key, unordered_set)){
return 1;
}
{
Expensive *ptr = &*set.begin();
set.clear();
delete ptr;
}
{
Expensive *ptr = &*unordered_set.begin();
unordered_set.clear();
delete ptr;
}
setit = set.insert(value).first;
unordered_setit = unordered_set.insert(value).first;
if(insert_to_set(expensive_key, set)){
return 1;
}
if(insert_to_uset(expensive_key, unordered_set)){
return 1;
}
if(insert_to_set_optimized(expensive_key, set)){
return 1;
}
if(insert_to_uset_optimized(expensive_key, unordered_set)){
return 1;
}
set.erase(value);
unordered_set.erase(value);
return 0;
}

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_auto_unlink_code
#include <boost/intrusive/list.hpp>
#include <cassert>
using namespace boost::intrusive;
typedef list_base_hook<link_mode<auto_unlink> > auto_unlink_hook;
class MyClass : public auto_unlink_hook
//This hook removes the node in the destructor
{
int int_;
public:
MyClass(int i = 0) : int_(i) {}
void unlink() { auto_unlink_hook::unlink(); }
bool is_linked() { return auto_unlink_hook::is_linked(); }
};
//Define a list that will store values using the base hook
//The list can't have constant-time size!
typedef list< MyClass, constant_time_size<false> > List;
int main()
{
//Create the list
List l;
{
//Create myclass and check it's linked
MyClass myclass;
assert(myclass.is_linked() == false);
//Insert the object
l.push_back(myclass);
//Check that we have inserted the object
assert(l.empty() == false);
assert(&l.front() == &myclass);
assert(myclass.is_linked() == true);
//Now myclass' destructor will unlink it
//automatically
}
//Check auto-unlink has been executed
assert(l.empty() == true);
{
//Now test the unlink() function
//Create myclass and check it's linked
MyClass myclass;
assert(myclass.is_linked() == false);
//Insert the object
l.push_back(myclass);
//Check that we have inserted the object
assert(l.empty() == false);
assert(&l.front() == &myclass);
assert(myclass.is_linked() == true);
//Now unlink the node
myclass.unlink();
//Check auto-unlink has been executed
assert(l.empty() == true);
}
return 0;
}
//]

86
example/doc_avl_set.cpp Normal file
View File

@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_avl_set_code
#include <boost/intrusive/avl_set.hpp>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace boost::intrusive;
//This is a base hook optimized for size
class MyClass : public avl_set_base_hook<optimize_size<true> >
{
int int_;
public:
//This is a member hook
avl_set_member_hook<> member_hook_;
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_; }
friend bool operator== (const MyClass &a, const MyClass &b)
{ return a.int_ < b.int_; }
};
//Define an avl_set using the base hook that will store values in reverse order
typedef avl_set< MyClass, compare<std::greater<MyClass> > > BaseSet;
//Define an multiset using the member hook
typedef member_hook<MyClass, avl_set_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef avl_multiset< MyClass, MemberOption> MemberMultiset;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseSet baseset;
MemberMultiset membermultiset;
//Check that size optimization is activated in the base hook
assert(sizeof(avl_set_base_hook<optimize_size<true> >) == 3*sizeof(void*));
//Check that size optimization is deactivated in the member hook
assert(sizeof(avl_set_member_hook<>) > 3*sizeof(void*));
//Now insert them in the sets
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
baseset.insert(*it);
membermultiset.insert(*it);
}
//Now test avl_sets
{
BaseSet::reverse_iterator rbit(baseset.rbegin()), rbitend(baseset.rend());
MemberMultiset::iterator mit(membermultiset.begin()), mitend(membermultiset.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook avl_set
for(; it != itend; ++it, ++rbit)
if(&*rbit != &*it) return 1;
//Test the objects inserted in the member hook avl_set
for(it = values.begin(); it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_avltree_algorithms_code
#include <boost/intrusive/avltree_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node(int i = 0)
: int_(i)
{}
my_node *parent_, *left_, *right_;
int balance_;
//other members
int int_;
};
//Define our own avltree_node_traits
struct my_avltree_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
typedef int balance;
static node_ptr get_parent(const_node_ptr n) { return n->parent_; }
static void set_parent(node_ptr n, node_ptr parent){ n->parent_ = parent; }
static node_ptr get_left(const_node_ptr n) { return n->left_; }
static void set_left(node_ptr n, node_ptr left) { n->left_ = left; }
static node_ptr get_right(const_node_ptr n) { return n->right_; }
static void set_right(node_ptr n, node_ptr right) { n->right_ = right; }
static balance get_balance(const_node_ptr n) { return n->balance_; }
static void set_balance(node_ptr n, balance b) { n->balance_ = b; }
static balance negative() { return -1; }
static balance zero() { return 0; }
static balance positive() { return 1; }
};
struct node_ptr_compare
{
bool operator()(my_node *a, my_node *b)
{ return a->int_ < b->int_; }
};
int main()
{
typedef boost::intrusive::avltree_algorithms<my_avltree_node_traits> algo;
my_node header, two(2), three(3);
//Create an empty avltree container:
//"header" will be the header node of the tree
algo::init_header(&header);
//Now insert node "two" in the tree using the sorting functor
algo::insert_equal_upper_bound(&header, &two, node_ptr_compare());
//Now insert node "three" in the tree using the sorting functor
algo::insert_equal_lower_bound(&header, &three, node_ptr_compare());
//Now take the first node (the left node of the header)
my_node *n = header.left_;
assert(n == &two);
//Now go to the next node
n = algo::next_node(n);
assert(n == &three);
//Erase a node just using a pointer to it
algo::unlink(&two);
//Erase a node using also the header (faster)
algo::erase(&header, &three);
return 0;
}
//]

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_bucket_traits
#include <boost/intrusive/unordered_set.hpp>
#include <boost/functional/hash.hpp>
#include <vector>
using namespace boost::intrusive;
//A class to be inserted in an unordered_set
class MyClass : public unordered_set_base_hook<>
{
int int_;
public:
MyClass(int i = 0) : int_(i)
{}
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
//Define the base hook option
typedef base_hook< unordered_set_base_hook<> > BaseHookOption;
//Obtain the types of the bucket and the bucket pointer
typedef unordered_bucket<BaseHookOption>::type BucketType;
typedef unordered_bucket_ptr<BaseHookOption>::type BucketPtr;
//The custom bucket traits.
class custom_bucket_traits
{
public:
static const int NumBuckets = 100;
custom_bucket_traits(BucketPtr buckets)
: buckets_(buckets)
{}
//Functions to be implemented by custom bucket traits
BucketPtr bucket_begin() const { return buckets_; }
std::size_t bucket_count() const { return NumBuckets;}
private:
BucketPtr buckets_;
};
//Define the container using the custom bucket traits
typedef unordered_set<MyClass, bucket_traits<custom_bucket_traits> > BucketTraitsUset;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
std::vector<MyClass> values;
//Fill values
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
//Now create the bucket array and the custom bucket traits object
BucketType buckets[custom_bucket_traits::NumBuckets];
custom_bucket_traits btraits(buckets);
//Now create the unordered set
BucketTraitsUset uset(btraits);
//Insert the values in the unordered set
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
uset.insert(*it);
return 0;
}
//]

View File

@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_clone_from
#include <boost/intrusive/list.hpp>
#include <iostream>
#include <vector>
using namespace boost::intrusive;
//A class that can be inserted in an intrusive list
class my_class : public list_base_hook<>
{
public:
friend bool operator==(const my_class &a, const my_class &b)
{ return a.int_ == b.int_; }
int int_;
//...
};
//Definition of the intrusive list
typedef list<my_class> my_class_list;
//Cloner object function
struct new_cloner
{
my_class *operator()(const my_class &clone_this)
{ return new my_class(clone_this); }
};
//The disposer object function
struct delete_disposer
{
void operator()(my_class *delete_this)
{ delete delete_this; }
};
int main()
{
const int MaxElem = 100;
std::vector<my_class> nodes(MaxElem);
//Fill all the nodes and insert them in the list
my_class_list list;
for(int i = 0; i < MaxElem; ++i) nodes[i].int_ = i;
list.insert(list.end(), nodes.begin(), nodes.end());
//Now clone "list" using "new" and "delete" object functions
my_class_list cloned_list;
cloned_list.clone_from(list, new_cloner(), delete_disposer());
//Test that both are equal
if(cloned_list != list)
std::cout << "Both lists are different" << std::endl;
else
std::cout << "Both lists are equal" << std::endl;
//Don't forget to free the memory from the second list
cloned_list.clear_and_dispose(delete_disposer());
return 0;
}
//]

60
example/doc_entity.cpp Normal file
View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_entity_code
#include <boost/intrusive/list.hpp>
using namespace boost::intrusive;
//A class that can be inserted in an intrusive list
class entity : public list_base_hook<>
{
public:
virtual ~entity();
//...
};
//"some_entity" derives from "entity"
class some_entity : public entity
{/**/};
//Definition of the intrusive list
typedef list<entity> entity_list;
//A global list
entity_list global_list;
//The destructor removes itself from the global list
entity::~entity()
{ global_list.erase(entity_list::s_iterator_to(*this)); }
//Function to insert a new "some_entity" in the global list
void insert_some_entity()
{ global_list.push_back (*new some_entity(/*...*/)); }
//Function to clear an entity from the intrusive global list
void clear_list ()
{
// entity's destructor removes itself from the global list implicitly
while (!global_list.empty())
delete &global_list.front();
}
int main()
{
//Insert some new entities
insert_some_entity();
insert_some_entity();
//global_list's destructor will free objects
return 0;
}
//]

View File

@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_erasing_and_disposing
#include <boost/intrusive/list.hpp>
using namespace boost::intrusive;
//A class that can be inserted in an intrusive list
class my_class : public list_base_hook<>
{
public:
my_class(int i)
: int_(i)
{}
int int_;
//...
};
//Definition of the intrusive list
typedef list<my_class> my_class_list;
//The predicate function
struct is_even
{
bool operator()(const my_class &c) const
{ return 0 == (c.int_ % 2); }
};
//The disposer object function
struct delete_disposer
{
void operator()(my_class *delete_this)
{ delete delete_this; }
};
int main()
{
const int MaxElem = 100;
//Fill all the nodes and insert them in the list
my_class_list list;
try{
//Insert new objects in the container
for(int i = 0; i < MaxElem; ++i) list.push_back(*new my_class(i));
//Now use remove_and_dispose_if to erase and delete the objects
list.remove_and_dispose_if(is_even(), delete_disposer());
}
catch(...){
//If something throws, make sure that all the memory is freed
list.clear_and_dispose(delete_disposer());
throw;
}
//Dispose remaining elements
list.erase_and_dispose(list.begin(), list.end(), delete_disposer());
return 0;
}
//]

View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_external_value_traits
#include <boost/intrusive/list.hpp>
#include <vector>
using namespace boost::intrusive;
//This type is not modifiable so we can't store hooks or custom nodes
typedef int identifier_t;
//This value traits will associate elements from an array of identifiers with
//elements of an array of nodes. The element i of the value array will use the
//node i of the node array:
class external_traits
{
//Non-copyable
external_traits(const external_traits &);
external_traits& operator=(const external_traits &);
public:
typedef list_node_traits<void*> node_traits;
typedef node_traits::node node;
typedef node * node_ptr;
typedef const node * const_node_ptr;
typedef identifier_t value_type;
typedef identifier_t * pointer;
typedef const identifier_t * const_pointer;
static const link_mode_type link_mode = normal_link;
external_traits(pointer ids, std::size_t NumElements)
: ids_(ids), nodes_(NumElements)
{}
///Note: non static functions!
node_ptr to_node_ptr (value_type &value)
{ return &this->nodes_[0] + (&value - this->ids_); }
const_node_ptr to_node_ptr (const value_type &value) const
{ return &this->nodes_[0] + (&value - this->ids_); }
pointer to_value_ptr(node_ptr n)
{ return this->ids_ + (n - &this->nodes_[0]); }
const_pointer to_value_ptr(const_node_ptr n) const
{ return this->ids_ + (n - &this->nodes_[0]); }
private:
pointer ids_;
//This is an array of nodes that is necessary to form the linked list
std::vector<list_node_traits<void*>::node> nodes_;
};
//This is the value traits class that will be stored in the container
//and that will lead to the external traits using the address
//of the container.
struct internal_traits
{
static const bool external_value_traits = true;
typedef external_traits value_traits;
template<class Container>
value_traits &get_value_traits(Container &cont);
template<class Container>
const value_traits &get_value_traits(const Container &cont) const;
};
//The intrusive list that will use external value traits
typedef list<identifier_t, value_traits<internal_traits> > List;
class data_holder
: public List
{
public:
data_holder(identifier_t *ids, std::size_t NumElements)
: List()
, external_traits_(ids, NumElements)
{}
external_traits external_traits_;
};
template<class Container>
internal_traits::value_traits &internal_traits::get_value_traits(Container &cont)
{ return static_cast<data_holder&>(cont).external_traits_; }
template<class Container>
const internal_traits::value_traits &internal_traits::get_value_traits(const Container &cont) const
{ return static_cast<const data_holder&>(cont).external_traits_; }
int main()
{
const int NumElements = 100;
//This is an array of ids that we want to "store"
identifier_t ids [NumElements];
//Initialize id objects, each one with a different number
for(int i = 0; i != NumElements; ++i) ids[i] = i;
//The data holding the list and the external traits
data_holder data(ids, NumElements);
//This list will store ids without modifying identifier_t instances
//Stateful value traits must be explicitly passed in the constructor.
List &my_list = data;
//Insert ids in reverse order in the list
for(identifier_t * it(&ids[0]), *itend(&ids[NumElements]); it != itend; ++it)
my_list.push_front(*it);
//Now test lists
List::const_iterator list_it (my_list.cbegin());
identifier_t *it_val(&ids[NumElements]-1), *it_rbeg_val(&ids[0] -1);
//Test the objects inserted in the base hook list
for(; it_val != it_rbeg_val; --it_val, ++list_it){
if(&*list_it != &*it_val) return 1;
}
return 0;
}
//]

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_how_to_use_code
#include <boost/intrusive/list.hpp>
#include <vector>
using namespace boost::intrusive;
class MyClass : public list_base_hook<>
{
int int_;
public:
list_member_hook<> member_hook_;
MyClass(int i) : int_(i) {}
};
//Define a list that will store MyClass using the base hook
typedef list<MyClass> BaseList;
//Define a list that will store MyClass using the member hook
typedef member_hook
< MyClass, list_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef list<MyClass, MemberOption> MemberList;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseList baselist;
MemberList memberlist;
//Now insert them in the reverse order in the base hook list
for(VectIt it(values.begin()), itend(values.end())
; it != itend ; ++it){
baselist.push_front(*it);
}
//Now insert them in the same order as in vector in the member hook list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
memberlist.push_back(*it);
//Now test lists
{
BaseList::reverse_iterator rbit(baselist.rbegin()), rbitend(baselist.rend());
MemberList::iterator mit(memberlist.begin()), mitend(memberlist.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook list
for(; it != itend; ++it, ++rbit)
if(&*rbit != &*it) return 1;
//Test the objects inserted in the member hook list
for(it = values.begin(); it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

View File

@@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_iterator_from_value
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/functional/hash.hpp>
#include <vector>
using namespace boost::intrusive;
class intrusive_data
{
int data_id_;
public:
void set(int id) { data_id_ = id; }
//This class can be inserted in an intrusive list
list_member_hook<> list_hook_;
//This class can be inserted in an intrusive unordered_set
unordered_set_member_hook<> unordered_set_hook_;
//Comparison operators
friend bool operator==(const intrusive_data &a, const intrusive_data &b)
{ return a.data_id_ == b.data_id_; }
friend bool operator!=(const intrusive_data &a, const intrusive_data &b)
{ return a.data_id_ != b.data_id_; }
//The hash function
friend std::size_t hash_value(const intrusive_data &i)
{ return boost::hash<int>()(i.data_id_); }
};
//Definition of the intrusive list that will hold intrusive_data
typedef member_hook<intrusive_data, list_member_hook<>
, &intrusive_data::list_hook_> MemberListOption;
typedef list<intrusive_data, MemberListOption> list_t;
//Definition of the intrusive unordered_set that will hold intrusive_data
typedef member_hook
< intrusive_data, unordered_set_member_hook<>
, &intrusive_data::unordered_set_hook_> MemberUsetOption;
typedef boost::intrusive::unordered_set
< intrusive_data, MemberUsetOption> unordered_set_t;
int main()
{
//Create MaxElem objects
const int MaxElem = 100;
std::vector<intrusive_data> nodes(MaxElem);
//Declare the intrusive containers
list_t list;
unordered_set_t::bucket_type buckets[MaxElem];
unordered_set_t unordered_set
(unordered_set_t::bucket_traits(buckets, MaxElem));
//Initialize all the nodes
for(int i = 0; i < MaxElem; ++i) nodes[i].set(i);
//Now insert them in both intrusive containers
list.insert(list.end(), nodes.begin(), nodes.end());
unordered_set.insert(nodes.begin(), nodes.end());
//Now check the iterator_to function
list_t::iterator list_it(list.begin());
for(int i = 0; i < MaxElem; ++i, ++list_it)
if(list.iterator_to(nodes[i]) != list_it ||
list_t::s_iterator_to(nodes[i]) != list_it)
return 1;
//Now check unordered_set::s_iterator_to (which is a member function)
//and unordered_set::s_local_iterator_to (which is an static member function)
unordered_set_t::iterator unordered_set_it(unordered_set.begin());
for(int i = 0; i < MaxElem; ++i){
unordered_set_it = unordered_set.find(nodes[i]);
if(unordered_set.iterator_to(nodes[i]) != unordered_set_it)
return 1;
if(*unordered_set.local_iterator_to(nodes[i]) != *unordered_set_it ||
*unordered_set_t::s_local_iterator_to(nodes[i]) != *unordered_set_it )
return 1;
}
return 0;
}
//]

76
example/doc_list.cpp Normal file
View File

@@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_list_code
#include <boost/intrusive/list.hpp>
#include <vector>
using namespace boost::intrusive;
class MyClass : public list_base_hook<> //This is a derivation hook
{
int int_;
public:
//This is a member hook
list_member_hook<> member_hook_;
MyClass(int i)
: int_(i)
{}
};
//Define a list that will store MyClass using the public base hook
typedef list<MyClass> BaseList;
//Define a list that will store MyClass using the public member hook
typedef list< MyClass
, member_hook< MyClass, list_member_hook<>, &MyClass::member_hook_>
> MemberList;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseList baselist;
MemberList memberlist;
//Now insert them in the reverse order in the base hook list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
baselist.push_front(*it);
//Now insert them in the same order as in vector in the member hook list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
memberlist.push_back(*it);
//Now test lists
{
BaseList::reverse_iterator rbit(baselist.rbegin()), rbitend(baselist.rend());
MemberList::iterator mit(memberlist.begin()), mitend(memberlist.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook list
for(; it != itend; ++it, ++rbit)
if(&*rbit != &*it) return 1;
//Test the objects inserted in the member hook list
for(it = values.begin(); it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_list_algorithms_code
#include <boost/intrusive/circular_list_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node *next_, *prev_;
//other members...
};
//Define our own list_node_traits
struct my_list_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
static node_ptr get_next(const_node_ptr n) { return n->next_; }
static void set_next(node_ptr n, node_ptr next) { n->next_ = next; }
static node *get_previous(const_node_ptr n) { return n->prev_; }
static void set_previous(node_ptr n, node_ptr prev){ n->prev_ = prev; }
};
int main()
{
typedef boost::intrusive::circular_list_algorithms<my_list_node_traits> algo;
my_node one, two, three;
//Create an empty doubly linked list container:
//"one" will be the first node of the container
algo::init(&one);
assert(algo::count(&one) == 1);
//Now add a new node before "one"
algo::link_before(&one, &two);
assert(algo::count(&one) == 2);
//Now add a new node after "two"
algo::link_after(&two, &three);
assert(algo::count(&one) == 3);
//Now unlink the node after one
algo::unlink(&three);
assert(algo::count(&one) == 2);
//Now unlink two
algo::unlink(&two);
assert(algo::count(&one) == 1);
//Now unlink one
algo::unlink(&one);
assert(algo::count(&one) == 1);
return 0;
}
//]

100
example/doc_offset_ptr.cpp Normal file
View File

@@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
//This is needed to allow concurrent test execution in
//several platforms. The shared memory must be unique
//for each process...
#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <sstream>
const char *get_shared_memory_name()
{
std::stringstream s;
s << "process_" << boost::interprocess::detail::get_current_process_id();
static std::string str = s.str();
return str.c_str();
}
//[doc_offset_ptr_0
#include <boost/intrusive/list.hpp>
#include <boost/interprocess/offset_ptr.hpp>
using namespace boost::intrusive;
namespace ip = boost::interprocess;
class shared_memory_data
//Declare the hook with an offset_ptr from Boost.Interprocess
//to make this class compatible with shared memory
: public list_base_hook< void_pointer< ip::offset_ptr<void> > >
{
int data_id_;
public:
int get() const { return data_id_; }
void set(int id) { data_id_ = id; }
};
//]
//[doc_offset_ptr_1
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/containers/list.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
//Definition of the shared memory friendly intrusive list
typedef ip::list<shared_memory_data> shm_list_t;
int main()
{
//Now create an intrusive list in shared memory:
//nodes and the container itself must be created in shared memory
const int MaxElem = 100;
const int ShmSize = 50000;
const char *ShmName = get_shared_memory_name();
{
//Erase all old shared memory
ip::shared_memory_object::remove(ShmName);
ip::managed_shared_memory shm(ip::create_only, ShmName, ShmSize);
//Create all nodes in shared memory using a shared memory vector
//See Boost.Interprocess documentation for more information on this
typedef ip::allocator
< shared_memory_data, ip::managed_shared_memory::segment_manager>
shm_allocator_t;
typedef ip::vector<shared_memory_data, shm_allocator_t> shm_vector_t;
shm_allocator_t shm_alloc(shm.get_segment_manager());
shm_vector_t *pshm_vect =
shm.construct<shm_vector_t>(ip::anonymous_instance)(shm_alloc);
pshm_vect->resize(MaxElem);
//Initialize all the nodes
for(int i = 0; i < MaxElem; ++i) (*pshm_vect)[i].set(i);
//Now create the shared memory intrusive list
shm_list_t *plist = shm.construct<shm_list_t>(ip::anonymous_instance)();
plist->insert(plist->end(), pshm_vect->begin(), pshm_vect->end());
//Check all the inserted nodes
int checker = 0;
for( shm_list_t::const_iterator it = plist->begin(), itend(plist->end())
; it != itend; ++it, ++checker){
if(it->get() != checker) return false;
}
//Now delete the list and after that, the nodes
shm.destroy_ptr(plist);
shm.destroy_ptr(pshm_vect);
}
ip::shared_memory_object::remove(ShmName);
return 0;
}
//]

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_rbtree_algorithms_code
#include <boost/intrusive/rbtree_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node(int i = 0)
: int_(i)
{}
my_node *parent_, *left_, *right_;
int color_;
//other members
int int_;
};
//Define our own rbtree_node_traits
struct my_rbtree_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
typedef int color;
static node_ptr get_parent(const_node_ptr n) { return n->parent_; }
static void set_parent(node_ptr n, node_ptr parent){ n->parent_ = parent; }
static node_ptr get_left(const_node_ptr n) { return n->left_; }
static void set_left(node_ptr n, node_ptr left) { n->left_ = left; }
static node_ptr get_right(const_node_ptr n) { return n->right_; }
static void set_right(node_ptr n, node_ptr right) { n->right_ = right; }
static color get_color(const_node_ptr n) { return n->color_; }
static void set_color(node_ptr n, color c) { n->color_ = c; }
static color black() { return color(0); }
static color red() { return color(1); }
};
struct node_ptr_compare
{
bool operator()(my_node *a, my_node *b)
{ return a->int_ < b->int_; }
};
int main()
{
typedef boost::intrusive::rbtree_algorithms<my_rbtree_node_traits> algo;
my_node header, two(2), three(3);
//Create an empty rbtree container:
//"header" will be the header node of the tree
algo::init_header(&header);
//Now insert node "two" in the tree using the sorting functor
algo::insert_equal_upper_bound(&header, &two, node_ptr_compare());
//Now insert node "three" in the tree using the sorting functor
algo::insert_equal_lower_bound(&header, &three, node_ptr_compare());
//Now take the first node (the left node of the header)
my_node *n = header.left_;
assert(n == &two);
//Now go to the next node
n = algo::next_node(n);
assert(n == &three);
//Erase a node just using a pointer to it
algo::unlink(&two);
//Erase a node using also the header (faster)
algo::erase(&header, &three);
return 0;
}
//]

86
example/doc_set.cpp Normal file
View File

@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_set_code
#include <boost/intrusive/set.hpp>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace boost::intrusive;
//This is a base hook optimized for size
class MyClass : public set_base_hook<optimize_size<true> >
{
int int_;
public:
//This is a member hook
set_member_hook<> member_hook_;
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_; }
friend bool operator== (const MyClass &a, const MyClass &b)
{ return a.int_ < b.int_; }
};
//Define a set using the base hook that will store values in reverse order
typedef set< MyClass, compare<std::greater<MyClass> > > BaseSet;
//Define an multiset using the member hook
typedef member_hook<MyClass, set_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef multiset< MyClass, MemberOption> MemberMultiset;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseSet baseset;
MemberMultiset membermultiset;
//Check that size optimization is activated in the base hook
assert(sizeof(set_base_hook<optimize_size<true> >) == 3*sizeof(void*));
//Check that size optimization is deactivated in the member hook
assert(sizeof(set_member_hook<>) > 3*sizeof(void*));
//Now insert them in the reverse order in the base hook set
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
baseset.insert(*it);
membermultiset.insert(*it);
}
//Now test sets
{
BaseSet::reverse_iterator rbit(baseset.rbegin()), rbitend(baseset.rend());
MemberMultiset::iterator mit(membermultiset.begin()), mitend(membermultiset.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook set
for(; it != itend; ++it, ++rbit)
if(&*rbit != &*it) return 1;
//Test the objects inserted in the member hook set
for(it = values.begin(); it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

85
example/doc_sg_set.cpp Normal file
View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_sg_set_code
#include <boost/intrusive/sg_set.hpp>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace boost::intrusive;
class MyClass : public bs_set_base_hook<>
{
int int_;
public:
//This is a member hook
bs_set_member_hook<> member_hook_;
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_; }
friend bool operator== (const MyClass &a, const MyClass &b)
{ return a.int_ < b.int_; }
};
//Define an sg_set using the base hook that will store values in reverse order
//and won't execute floating point operations.
typedef sg_set
< MyClass, compare<std::greater<MyClass> >, floating_point<false> > BaseSet;
//Define an multiset using the member hook
typedef member_hook<MyClass, bs_set_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef sg_multiset< MyClass, MemberOption> MemberMultiset;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseSet baseset;
MemberMultiset membermultiset;
//Now insert them in the reverse order in the base hook sg_set
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
baseset.insert(*it);
membermultiset.insert(*it);
}
//Change balance factor
membermultiset.balance_factor(0.9f);
//Now test sg_sets
{
BaseSet::reverse_iterator rbit(baseset.rbegin()), rbitend(baseset.rend());
MemberMultiset::iterator mit(membermultiset.begin()), mitend(membermultiset.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook sg_set
for(; it != itend; ++it, ++rbit)
if(&*rbit != &*it) return 1;
//Test the objects inserted in the member hook sg_set
for(it = values.begin(); it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

79
example/doc_slist.cpp Normal file
View File

@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_slist_code
#include <boost/intrusive/slist.hpp>
#include <vector>
using namespace boost::intrusive;
//This is a base hook
class MyClass : public slist_base_hook<>
{
int int_;
public:
//This is a member hook
slist_member_hook<> member_hook_;
MyClass(int i)
: int_(i)
{}
};
//Define an slist that will store MyClass using the public base hook
typedef slist<MyClass> BaseList;
//Define an slist that will store MyClass using the public member hook
typedef member_hook<MyClass, slist_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef slist<MyClass, MemberOption> MemberList;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseList baselist;
MemberList memberlist;
//Now insert them in the reverse order in the base hook list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
baselist.push_front(*it);
//Now insert them in the same order as in vector in the member hook list
for(BaseList::iterator it(baselist.begin()), itend(baselist.end())
; it != itend; ++it){
memberlist.push_front(*it);
}
//Now test lists
{
BaseList::iterator bit(baselist.begin()), bitend(baselist.end());
MemberList::iterator mit(memberlist.begin()), mitend(memberlist.end());
VectRit rit(values.rbegin()), ritend(values.rend());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook list
for(; rit != ritend; ++rit, ++bit)
if(&*bit != &*rit) return 1;
//Test the objects inserted in the member hook list
for(; it != itend; ++it, ++mit)
if(&*mit != &*it) return 1;
}
return 0;
}
//]

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_slist_algorithms_code
#include <boost/intrusive/circular_slist_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node *next_;
//other members...
};
//Define our own slist_node_traits
struct my_slist_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
static node_ptr get_next(const_node_ptr n) { return n->next_; }
static void set_next(node_ptr n, node_ptr next) { n->next_ = next; }
};
int main()
{
typedef boost::intrusive::circular_slist_algorithms<my_slist_node_traits> algo;
my_node one, two, three;
//Create an empty singly linked list container:
//"one" will be the first node of the container
algo::init(&one);
assert(algo::count(&one) == 1);
//Now add a new node
algo::link_after(&one, &two);
assert(algo::count(&one) == 2);
//Now add a new node after "one"
algo::link_after(&one, &three);
assert(algo::count(&one) == 3);
//Now unlink the node after one
algo::unlink_after(&one);
assert(algo::count(&one) == 2);
//Now unlink two
algo::unlink(&two);
assert(algo::count(&one) == 1);
return 0;
}
//]

View File

@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_splaytree_algorithms_code
#include <boost/intrusive/splaytree_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node(int i = 0)
: int_(i)
{}
my_node *parent_, *left_, *right_;
int color_;
//other members
int int_;
};
//Define our own splaytree_node_traits
struct my_splaytree_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
static node_ptr get_parent(const_node_ptr n) { return n->parent_; }
static void set_parent(node_ptr n, node_ptr parent){ n->parent_ = parent; }
static node_ptr get_left(const_node_ptr n) { return n->left_; }
static void set_left(node_ptr n, node_ptr left) { n->left_ = left; }
static node_ptr get_right(const_node_ptr n) { return n->right_; }
static void set_right(node_ptr n, node_ptr right) { n->right_ = right; }
};
struct node_ptr_compare
{
bool operator()(my_node *a, my_node *b)
{ return a->int_ < b->int_; }
};
int main()
{
typedef boost::intrusive::splaytree_algorithms<my_splaytree_node_traits> algo;
my_node header, two(2), three(3);
//Create an empty splaytree container:
//"header" will be the header node of the tree
algo::init_header(&header);
//Now insert node "two" in the tree using the sorting functor
algo::insert_equal_upper_bound(&header, &two, node_ptr_compare());
//Now insert node "three" in the tree using the sorting functor
algo::insert_equal_lower_bound(&header, &three, node_ptr_compare());
//Now take the first node (the left node of the header)
my_node *n = header.left_;
assert(n == &two);
//Now go to the next node
n = algo::next_node(n);
assert(n == &three);
//Erase a node just using a pointer to it
algo::unlink(&two);
//Erase a node using also the header (faster)
algo::erase(&header, &three);
return 0;
}
//]

93
example/doc_splay_set.cpp Normal file
View File

@@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_splay_set_code
#include <boost/intrusive/splay_set.hpp>
#include <boost/intrusive/bs_set_hook.hpp>
#include <vector>
#include <algorithm>
using namespace boost::intrusive;
class MyClass
: public splay_set_base_hook<> //This is an splay tree base hook
, public bs_set_base_hook<> //This is a binary search tree base hook
{
int int_;
public:
//This is a member hook
splay_set_member_hook<> member_hook_;
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_; }
friend bool operator== (const MyClass &a, const MyClass &b)
{ return a.int_ < b.int_; }
};
//Define a set using the base hook that will store values in reverse order
typedef splay_set< MyClass, compare<std::greater<MyClass> > > BaseSplaySet;
//Define a set using the binary search tree hook
typedef splay_set< MyClass, base_hook<bs_set_base_hook<> > > BaseBsSplaySet;
//Define an multiset using the member hook
typedef member_hook<MyClass, splay_set_member_hook<>, &MyClass::member_hook_> MemberOption;
typedef splay_multiset< MyClass, MemberOption> MemberSplayMultiset;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseSplaySet baseset;
BaseBsSplaySet bsbaseset;
MemberSplayMultiset membermultiset;
//Insert values in the container
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
baseset.insert(*it);
bsbaseset.insert(*it);
membermultiset.insert(*it);
}
//Now test sets
{
BaseSplaySet::reverse_iterator rbit(baseset.rbegin()), rbitend(baseset.rend());
BaseBsSplaySet::iterator bsit(bsbaseset.begin()), bsitend(bsbaseset.end());
MemberSplayMultiset::iterator mit(membermultiset.begin()), mitend(membermultiset.end());
VectIt it(values.begin()), itend(values.end());
//Test the objects inserted in the base hook set
for(; it != itend; ++it, ++rbit){
if(&*rbit != &*it) return 1;
}
//Test the objects inserted in member and binary search hook sets
for(it = values.begin(); it != itend; ++it, ++bsit, ++mit){
if(&*bsit != &*it) return 1;
if(&*mit != &*it) return 1;
}
}
return 0;
}
//]

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_splaytree_algorithms_code
#include <boost/intrusive/splaytree_algorithms.hpp>
#include <cassert>
struct my_node
{
my_node(int i = 0)
: int_(i)
{}
my_node *parent_, *left_, *right_;
//other members
int int_;
};
//Define our own splaytree_node_traits
struct my_splaytree_node_traits
{
typedef my_node node;
typedef my_node * node_ptr;
typedef const my_node * const_node_ptr;
static node_ptr get_parent(const_node_ptr n) { return n->parent_; }
static void set_parent(node_ptr n, node_ptr parent){ n->parent_ = parent; }
static node_ptr get_left(const_node_ptr n) { return n->left_; }
static void set_left(node_ptr n, node_ptr left) { n->left_ = left; }
static node_ptr get_right(const_node_ptr n) { return n->right_; }
static void set_right(node_ptr n, node_ptr right) { n->right_ = right; }
};
struct node_ptr_compare
{
bool operator()(my_node *a, my_node *b)
{ return a->int_ < b->int_; }
};
int main()
{
typedef boost::intrusive::splaytree_algorithms<my_splaytree_node_traits> algo;
my_node header, two(2), three(3);
//Create an empty splaytree container:
//"header" will be the header node of the tree
algo::init_header(&header);
//Now insert node "two" in the tree using the sorting functor
algo::insert_equal_upper_bound(&header, &two, node_ptr_compare());
//Now insert node "three" in the tree using the sorting functor
algo::insert_equal_lower_bound(&header, &three, node_ptr_compare());
//Now take the first node (the left node of the header)
my_node *n = header.left_;
assert(n == &two);
//Now go to the next node
n = algo::next_node(n);
assert(n == &three);
//Erase a node just using a pointer to it
algo::unlink(&two);
//Erase a node using also the header (faster)
algo::erase(&header, &three);
return 0;
}
//]

View File

@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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_stateful_value_traits
#include <boost/intrusive/list.hpp>
using namespace boost::intrusive;
//This type is not modifiable so we can't store hooks or custom nodes
typedef int identifier_t;
//This value traits will associate elements from an array of identifiers with
//elements of an array of nodes. The element i of the value array will use the
//node i of the node array:
struct stateful_value_traits
{
typedef list_node_traits<void*> node_traits;
typedef node_traits::node node;
typedef node * node_ptr;
typedef const node * const_node_ptr;
typedef identifier_t value_type;
typedef identifier_t * pointer;
typedef const identifier_t * const_pointer;
static const link_mode_type link_mode = normal_link;
stateful_value_traits(pointer ids, node_ptr node_array)
: ids_(ids), nodes_(node_array)
{}
///Note: non static functions!
node_ptr to_node_ptr (value_type &value)
{ return this->nodes_ + (&value - this->ids_); }
const_node_ptr to_node_ptr (const value_type &value) const
{ return this->nodes_ + (&value - this->ids_); }
pointer to_value_ptr(node_ptr n)
{ return this->ids_ + (n - this->nodes_); }
const_pointer to_value_ptr(const_node_ptr n) const
{ return this->ids_ + (n - this->nodes_); }
private:
pointer ids_;
node_ptr nodes_;
};
int main()
{
const int NumElements = 100;
//This is an array of ids that we want to "store"
identifier_t ids [NumElements];
//This is an array of nodes that is necessary to form the linked list
list_node_traits<void*>::node nodes [NumElements];
//Initialize id objects, each one with a different number
for(int i = 0; i != NumElements; ++i) ids[i] = i;
//Define a list that will "link" identifiers using external nodes
typedef list<identifier_t, value_traits<stateful_value_traits> > List;
//This list will store ids without modifying identifier_t instances
//Stateful value traits must be explicitly passed in the constructor.
List my_list (stateful_value_traits (ids, nodes));
//Insert ids in reverse order in the list
for(identifier_t * it(&ids[0]), *itend(&ids[NumElements]); it != itend; ++it)
my_list.push_front(*it);
//Now test lists
List::const_iterator list_it (my_list.cbegin());
identifier_t *it_val(&ids[NumElements-1]), *it_rbeg_val(&ids[0]-1);
//Test the objects inserted in the base hook list
for(; it_val != it_rbeg_val; --it_val, ++list_it)
if(&*list_it != &*it_val) return 1;
return 0;
}
//]

View File

@@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_unordered_set_code
#include <boost/intrusive/unordered_set.hpp>
#include <vector>
#include <algorithm>
#include <boost/functional/hash.hpp>
using namespace boost::intrusive;
class MyClass : public unordered_set_base_hook<>
{ //This is a derivation hook
int int_;
public:
unordered_set_member_hook<> member_hook_; //This is a member hook
MyClass(int i)
: int_(i)
{}
friend bool operator== (const MyClass &a, const MyClass &b)
{ return a.int_ == b.int_; }
friend std::size_t hash_value(const MyClass &value)
{ return std::size_t(value.int_); }
};
//Define an unordered_set that will store MyClass objects using the base hook
typedef unordered_set<MyClass> BaseSet;
//Define an unordered_multiset that will store MyClass using the member hook
typedef member_hook<MyClass, unordered_set_member_hook<>, &MyClass::member_hook_>
MemberOption;
typedef unordered_multiset< MyClass, MemberOption> MemberMultiSet;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create a vector with 100 different MyClass objects
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
//Create a copy of the vector
std::vector<MyClass> values2(values);
//Create a bucket array for base_set
BaseSet::bucket_type base_buckets[100];
//Create a bucket array for member_multi_set
MemberMultiSet::bucket_type member_buckets[200];
//Create unordered containers taking buckets as arguments
BaseSet base_set(BaseSet::bucket_traits(base_buckets, 100));
MemberMultiSet member_multi_set
(MemberMultiSet::bucket_traits(member_buckets, 200));
//Now insert values's elements in the unordered_set
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
base_set.insert(*it);
//Now insert values's and values2's elements in the unordered_multiset
for(VectIt it(values.begin()), itend(values.end()),
it2(values2.begin()),itend2(values2.end())
; it != itend; ++it, ++it2){
member_multi_set.insert(*it);
member_multi_set.insert(*it2);
}
//Now find every element
{
VectIt it(values.begin()), itend(values.end());
for(; it != itend; ++it){
//base_set should contain one element for each key
if(base_set.count(*it) != 1) return 1;
//member_multi_set should contain two elements for each key
if(member_multi_set.count(*it) != 2) return 1;
}
}
return 0;
}
//]

View File

@@ -0,0 +1,103 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_value_traits_code_legacy
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <vector>
//This node is the legacy type we can't modify and we want to insert in
//intrusive list and slist containers using only two pointers, since
//we know the object will never be at the same time in both lists.
struct legacy_value
{
legacy_value *prev_;
legacy_value *next_;
int id_;
};
//]
//[doc_value_traits_value_traits
//Define our own NodeTraits that will configure singly and doubly linked
//list algorithms. Note that this node traits is compatible with
//circular_slist_algorithms and circular_list_algorithms.
namespace bi = boost::intrusive;
struct legacy_node_traits
{
typedef legacy_value node;
typedef legacy_value * node_ptr;
typedef const legacy_value * const_node_ptr;
static node *get_next(const node *n) { return n->next_; }
static void set_next(node *n, node *next) { n->next_ = next; }
static node *get_previous(const node *n) { return n->prev_; }
static void set_previous(node *n, node *prev) { n->prev_ = prev; }
};
//This ValueTraits will configure list and slist. In this case,
//legacy_node_traits::node is the same as the
//legacy_value_traits::value_type so to_node_ptr/to_value_ptr
//functions are trivial.
struct legacy_value_traits
{
typedef legacy_node_traits node_traits;
typedef node_traits::node_ptr node_ptr;
typedef node_traits::const_node_ptr const_node_ptr;
typedef legacy_value value_type;
typedef legacy_value * pointer;
typedef const legacy_value * const_pointer;
static const bi::link_mode_type link_mode = bi::normal_link;
static node_ptr to_node_ptr (value_type &value) { return node_ptr(&value); }
static const_node_ptr to_node_ptr (const value_type &value) { return const_node_ptr(&value); }
static pointer to_value_ptr(node_ptr n) { return pointer(n); }
static const_pointer to_value_ptr(const_node_ptr n) { return const_pointer(n); }
};
//]
//[doc_value_traits_test
//Now define an intrusive list and slist that will store legacy_value objects
typedef bi::value_traits<legacy_value_traits> ValueTraitsOption;
typedef bi::list<legacy_value, ValueTraitsOption> LegacyAbiList;
typedef bi::slist<legacy_value, ValueTraitsOption> LegacyAbiSlist;
template<class List>
bool test_list()
{
typedef std::vector<legacy_value> Vect;
//Create legacy_value objects, with a different internal number
Vect legacy_vector;
for(int i = 0; i < 100; ++i){
legacy_value value; value.id_ = i; legacy_vector.push_back(value);
}
//Create the list with the objects
List mylist(legacy_vector.begin(), legacy_vector.end());
//Now test both lists
typename List::const_iterator bit(mylist.begin()), bitend(mylist.end());
typename Vect::const_iterator it(legacy_vector.begin()), itend(legacy_vector.end());
//Test the objects inserted in our list
for(; it != itend; ++it, ++bit)
if(&*bit != &*it) return false;
return true;
}
int main()
{
return test_list<LegacyAbiList>() && test_list<LegacyAbiSlist>() ? 0 : 1;
}
//]

83
example/doc_window.cpp Normal file
View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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_window_code
#include <boost/intrusive/list.hpp>
using namespace boost::intrusive;
//An abstract class that can be inserted in an intrusive list
class Window : public list_base_hook<>
{
public:
//This is a container those value is an abstract class: you can't do this with std::list.
typedef list<Window> win_list;
//An static intrusive list declaration
static win_list all_windows;
//Constructor. Includes this window in the list
Window() { all_windows.push_back(*this); }
//Destructor. Removes this node from the list
virtual ~Window() { all_windows.erase(win_list::s_iterator_to(*this)); }
//Pure virtual function to be implemented by derived classes
virtual void Paint() = 0;
};
//The static intrusive list declaration
Window::win_list Window::all_windows;
//Some Window derived classes
class FrameWindow : public Window
{ void Paint(){/**/} };
class EditWindow : public Window
{ void Paint(){/**/} };
class CanvasWindow : public Window
{ void Paint(){/**/} };
//A function that prints all windows stored in the intrusive list
void paint_all_windows()
{
for(Window::win_list::iterator i(Window::all_windows.begin())
, e(Window::all_windows.end())
; i != e; ++i)
i->Paint();
}
//...
//A class derived from Window
class MainWindow : public Window
{
FrameWindow frame_; //these are derived from Window too
EditWindow edit_;
CanvasWindow canvas_;
public:
void Paint(){/**/}
//...
};
//Main function
int main()
{
//When a Window class is created, is automatically registered in the global list
MainWindow window;
//Paint all the windows, sub-windows and so on
paint_all_windows();
//All the windows are automatically unregistered in their destructors.
return 0;
}
//]

9
index.html Normal file
View File

@@ -0,0 +1,9 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../../doc/html/intrusive.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../../doc/html/intrusive">../../doc/html/intrusive</a>
</body>
</html>

34
perf/Jamfile.v2 Normal file
View File

@@ -0,0 +1,34 @@
# Boost Intrusive Library Performance test Jamfile
# (C) Copyright Ion Gazta<74>aga 2006-2007.
# Use, modification and distribution are subject to 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)
# Adapted from John Maddock's TR1 Jamfile.v2
# Copyright John Maddock 2005.
# Use, modification and distribution are subject to 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)
# this rule enumerates through all the sources and invokes
# the run rule for each source, the result is a list of all
# the run rules, which we can pass on to the test_suite rule:
rule test_all
{
local all_rules = ;
for local fileb in [ glob *.cpp ]
{
all_rules += [ run $(fileb)
: # additional args
: # test-files
: # requirements
] ;
}
return $(all_rules) ;
}
test-suite intrusive_perf : [ test_all r ] ;

547
perf/perf_list.cpp Normal file
View File

@@ -0,0 +1,547 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
//Includes for tests
#include <boost/config.hpp>
#include <list>
#include <functional>
#include <iostream>
#include <boost/intrusive/list.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::posix_time;
//[perf_list_value_type
//Iteration and element count defines
const int NumIter = 100;
const int NumElements = 100000;
using namespace boost::intrusive;
template<bool BigSize> struct filler { int dummy[10]; };
template <> struct filler<false> {};
template<bool BigSize> //The object for non-intrusive containers
struct test_class : private filler<BigSize>
{
int i_;
test_class() {}
test_class(int i) : i_(i) {}
friend bool operator <(const test_class &l, const test_class &r) { return l.i_ < r.i_; }
friend bool operator >(const test_class &l, const test_class &r) { return l.i_ > r.i_; }
};
template <bool BigSize, link_mode_type LinkMode>
struct itest_class //The object for intrusive containers
: public list_base_hook<link_mode<LinkMode> >, public test_class<BigSize>
{
itest_class() {}
itest_class(int i) : test_class<BigSize>(i) {}
};
template<class FuncObj> //Adapts functors taking values to functors taking pointers
struct func_ptr_adaptor : public FuncObj
{
typedef typename FuncObj::first_argument_type* first_argument_type;
typedef typename FuncObj::second_argument_type* second_argument_type;
typedef typename FuncObj::result_type result_type;
result_type operator()(first_argument_type a, second_argument_type b) const
{ return FuncObj::operator()(*a, *b); }
};
//]
template <bool BigSize, link_mode_type LinkMode>
struct get_ilist //Helps to define an intrusive list from a policy
{
typedef list<itest_class<BigSize, LinkMode>, constant_time_size<false> > type;
};
template <bool BigSize> //Helps to define an std list
struct get_list { typedef std::list<test_class<BigSize> > type; };
template <bool BigSize> //Helps to define an std pointer list
struct get_ptrlist { typedef std::list<test_class<BigSize>*> type; };
////////////////////////////////////////////////////////////////////////
//
// PUSH_BACK
//
////////////////////////////////////////////////////////////////////////
template <bool BigSize, link_mode_type LinkMode>
void test_intrusive_list_push_back()
{
typedef typename get_ilist<BigSize, LinkMode>::type ilist;
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
//First create the elements and insert them in the intrusive list
//[perf_list_push_back_intrusive
std::vector<typename ilist::value_type> objects(NumElements);
ilist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(objects[i]);
//Elements are unlinked in ilist's destructor
//Elements are destroyed in vector's destructor
//]
}
ptime tend = microsec_clock::universal_time();
std::cout << "link_mode: " << LinkMode << ", usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_std_list_push_back()
{
typedef typename get_list<BigSize>::type stdlist;
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
//Now create the std list and insert
//[perf_list_push_back_stdlist
stdlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(typename stdlist::value_type(i));
//Elements unlinked and destroyed in stdlist's destructor
//]
}
ptime tend = microsec_clock::universal_time();
std::cout << "std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_compact_std_ptrlist_push_back()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//Now measure insertion time, including element creation
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
//Create elements and insert their pointer in the list
//[perf_list_push_back_stdptrlist
std::vector<typename stdlist::value_type> objects(NumElements);
stdptrlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(&objects[i]);
//Pointers to elements unlinked and destroyed in stdptrlist's destructor
//Elements destroyed in vector's destructor
//]
}
ptime tend = microsec_clock::universal_time();
std::cout << "compact std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_disperse_std_ptrlist_push_back()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//Now measure insertion time, including element creation
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
//Create elements and insert their pointer in the list
//[perf_list_push_back_disperse_stdptrlist
stdlist objects; stdptrlist l;
for(int i = 0; i < NumElements; ++i){
objects.push_back(typename stdlist::value_type(i));
l.push_back(&objects.back());
}
//Pointers to elements unlinked and destroyed in stdptrlist's destructor
//Elements unlinked and destroyed in stdlist's destructor
//]
}
ptime tend = microsec_clock::universal_time();
std::cout << "disperse std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
////////////////////////////////////////////////////////////////////////
//
// REVERSE
//
////////////////////////////////////////////////////////////////////////
//[perf_list_reverse
template <bool BigSize, link_mode_type LinkMode>
void test_intrusive_list_reverse()
{
typedef typename get_ilist<BigSize, LinkMode>::type ilist;
//First create the elements
std::vector<typename ilist::value_type> objects(NumElements);
//Now create the intrusive list and insert data
ilist l(objects.begin(), objects.end());
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
l.reverse();
}
ptime tend = microsec_clock::universal_time();
std::cout << "link_mode: " << LinkMode << ", usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_std_list_reverse()
{
typedef typename get_list<BigSize>::type stdlist;
//Create the list and insert values
stdlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(typename stdlist::value_type());
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
l.reverse();
}
ptime tend = microsec_clock::universal_time();
std::cout << "std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_compact_std_ptrlist_reverse()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements
std::vector<typename stdlist::value_type> objects(NumElements);
//Now create the std list and insert
stdptrlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(&objects[i]);
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
l.reverse();
}
ptime tend = microsec_clock::universal_time();
std::cout << "compact std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_disperse_std_ptrlist_reverse()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements
std::list<typename stdlist::value_type> objects;
//Now create the std list and insert
stdptrlist l;
for(int i = 0; i < NumElements; ++i){
objects.push_back(typename stdlist::value_type());
l.push_back(&objects.back());
}
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
l.reverse();
}
ptime tend = microsec_clock::universal_time();
std::cout << "disperse std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
//]
////////////////////////////////////////////////////////////////////////
//
// SORT
//
////////////////////////////////////////////////////////////////////////
//[perf_list_sort
template <bool BigSize, link_mode_type LinkMode>
void test_intrusive_list_sort()
{
typedef typename get_ilist<BigSize, LinkMode>::type ilist;
//First create the elements
std::vector<typename ilist::value_type> objects(NumElements);
for(int i = 0; i < NumElements; ++i)
objects[i].i_ = i;
//Now create the intrusive list and insert data
ilist l(objects.begin(), objects.end());
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
if(!(i % 2)){
l.sort(std::greater<typename ilist::value_type>());
}
else{
l.sort(std::less<typename ilist::value_type>());
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "link_mode: " << LinkMode << ", usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_std_list_sort()
{
typedef typename get_list<BigSize>::type stdlist;
//Create the list and insert values
stdlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(typename stdlist::value_type(i));
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
if(!(i % 2)){
l.sort(std::greater<typename stdlist::value_type>());
}
else{
l.sort(std::less<typename stdlist::value_type>());
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_compact_std_ptrlist_sort()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements
std::vector<typename stdlist::value_type> objects(NumElements);
for(int i = 0; i < NumElements; ++i)
objects[i].i_ = i;
//Now create the std list and insert
stdptrlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(&objects[i]);
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
if(!(i % 2)){
l.sort(func_ptr_adaptor<std::greater<typename stdlist::value_type> >());
}
else{
l.sort(func_ptr_adaptor<std::less<typename stdlist::value_type> >());
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "compact std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_disperse_std_ptrlist_sort()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements and the list
std::list<typename stdlist::value_type> objects;
stdptrlist l;
for(int i = 0; i < NumElements; ++i){
objects.push_back(typename stdlist::value_type(i));
l.push_back(&objects.back());
}
//Now measure sorting time
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
if(!(i % 2)){
l.sort(func_ptr_adaptor<std::greater<typename stdlist::value_type> >());
}
else{
l.sort(func_ptr_adaptor<std::less<typename stdlist::value_type> >());
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "disperse std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
//]
////////////////////////////////////////////////////////////////////////
//
// WRITE ACCESS
//
////////////////////////////////////////////////////////////////////////
//[perf_list_write_access
template <bool BigSize, link_mode_type LinkMode>
void test_intrusive_list_write_access()
{
typedef typename get_ilist<BigSize, LinkMode>::type ilist;
//First create the elements
std::vector<typename ilist::value_type> objects(NumElements);
for(int i = 0; i < NumElements; ++i){
objects[i].i_ = i;
}
//Now create the intrusive list and insert data
ilist l(objects.begin(), objects.end());
//Now measure access time to the value type
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
typename ilist::iterator it(l.begin()), end(l.end());
for(; it != end; ++it){
++(it->i_);
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "link_mode: " << LinkMode << ", usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_std_list_write_access()
{
typedef typename get_list<BigSize>::type stdlist;
//Create the list and insert values
stdlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(typename stdlist::value_type(i));
//Now measure access time to the value type
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
typename stdlist::iterator it(l.begin()), end(l.end());
for(; it != end; ++it){
++(it->i_);
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_compact_std_ptrlist_write_access()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements
std::vector<typename stdlist::value_type> objects(NumElements);
for(int i = 0; i < NumElements; ++i){
objects[i].i_ = i;
}
//Now create the std list and insert
stdptrlist l;
for(int i = 0; i < NumElements; ++i)
l.push_back(&objects[i]);
//Now measure access time to the value type
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
typename stdptrlist::iterator it(l.begin()), end(l.end());
for(; it != end; ++it){
++((*it)->i_);
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "compact std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
template <bool BigSize>
void test_disperse_std_ptrlist_write_access()
{
typedef typename get_list<BigSize>::type stdlist;
typedef typename get_ptrlist<BigSize>::type stdptrlist;
//First create the elements
std::list<typename stdlist::value_type> objects;
//Now create the std list and insert
stdptrlist l;
for(int i = 0; i < NumElements; ++i){
objects.push_back(typename stdlist::value_type(i));
l.push_back(&objects.back());
}
//Now measure access time to the value type
ptime tini = microsec_clock::universal_time();
for(int i = 0; i < NumIter; ++i){
typename stdptrlist::iterator it(l.begin()), end(l.end());
for(; it != end; ++it){
++((*it)->i_);
}
}
ptime tend = microsec_clock::universal_time();
std::cout << "disperse std::list usecs/iteration: "
<< (tend-tini).total_microseconds()/NumIter << std::endl;
}
//]
////////////////////////////////////////////////////////////////////////
//
// ALL TESTS
//
////////////////////////////////////////////////////////////////////////
template<bool BigSize>
void do_all_tests()
{
std::cout << "\n\nTesting push back() with BigSize:" << BigSize << std::endl;
test_intrusive_list_push_back<BigSize, normal_link>();
test_intrusive_list_push_back<BigSize, safe_link>();
test_intrusive_list_push_back<BigSize, auto_unlink>();
test_std_list_push_back<BigSize> ();
test_compact_std_ptrlist_push_back<BigSize>();
test_disperse_std_ptrlist_push_back<BigSize>();
//reverse
std::cout << "\n\nTesting reverse() with BigSize:" << BigSize << std::endl;
test_intrusive_list_reverse<BigSize, normal_link>();
test_intrusive_list_reverse<BigSize, safe_link>();
test_intrusive_list_reverse<BigSize, auto_unlink>();
test_std_list_reverse<BigSize>();
test_compact_std_ptrlist_reverse<BigSize>();
test_disperse_std_ptrlist_reverse<BigSize>();
//sort
std::cout << "\n\nTesting sort() with BigSize:" << BigSize << std::endl;
test_intrusive_list_sort<BigSize, normal_link>();
test_intrusive_list_sort<BigSize, safe_link>();
test_intrusive_list_sort<BigSize, auto_unlink>();
test_std_list_sort<BigSize>();
test_compact_std_ptrlist_sort<BigSize>();
test_disperse_std_ptrlist_sort<BigSize>();
//write_access
std::cout << "\n\nTesting write_access() with BigSize:" << BigSize << std::endl;
test_intrusive_list_write_access<BigSize, normal_link>();
test_intrusive_list_write_access<BigSize, safe_link>();
test_intrusive_list_write_access<BigSize, auto_unlink>();
test_std_list_write_access<BigSize>();
test_compact_std_ptrlist_write_access<BigSize>();
test_disperse_std_ptrlist_write_access<BigSize>();
}
int main()
{
//First pass the tests with a small size class
do_all_tests<false>();
//Now pass the tests with a big size class
do_all_tests<true>();
return 0;
}

175
proj/vc7ide/Intrusive.sln Normal file
View File

@@ -0,0 +1,175 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "list", "list\list.vcproj", "{977B61B4-9968-497C-9F0B-24A8145473B8}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slist", "slist\slist.vcproj", "{5A02061D-3728-4C49-AFC8-0130C1F161C0}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multiset", "multiset\multiset.vcproj", "{961F0E06-C092-4AF7-ABC5-2A49999F3B79}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_intrusivelib", "_intrusivelib\_intrusivelib.vcproj", "{90F3C5BD-8E6C-4629-BC71-A1009EC88059}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "set", "set\set.vcproj", "{960E01F6-92C1-F74A-BCA5-2A9F3B994979}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unordered_set", "unordered_set\unordered_set.vcproj", "{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unordered_multiset", "unordered_multiset\unordered_multiset.vcproj", "{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_test", "perf_test\perf_test.vcproj", "{910E70E6-2C91-AA67-BF4C-A9C74A309927}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "default_hook", "default_hook\default_hook.vcproj", "{761A79B4-9968-CB81-F02B-2A4497345475}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stateful_value_traits", "stateful_value_traits\stateful_value_traits.vcproj", "{9571A7B4-9968-B9C1-17FB-134547B46975}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "virtual_base", "virtual_base\virtual_base.vcproj", "{3579B1A4-9894-02AB-CB81-297B46154345}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_functions", "make_functions\make_functions.vcproj", "{7679B41B-F2B4-9176-CB81-35449467B435}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "custom_bucket_traits", "custom_bucket_traits\custom_bucket_traits.vcproj", "{31C77B84-0B2C-9481-CB81-27A149F33825}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external_value_traits", "external_value_traits\external_value_traits.vcproj", "{97B69A72-B9D3-7389-17FB-74612F4A9543}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "splay_multiset", "splay_multiset\splay_multiset.vcproj", "{01E70176-B6C5-BF47-2C91-A949077BA323}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "splay_set", "splay_set\splay_set.vcproj", "{1E6909E7-C971-F24A-6C7B-A92094B71B59}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "avl_multiset", "avl_multiset\avl_multiset.vcproj", "{0AE70176-5B8C-4BC7-392C-A4A312B07893}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "avl_set", "avl_set\avl_set.vcproj", "{16909EE7-24AF-97C1-C76B-204B971BA959}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sg_multiset", "sg_multiset\sg_multiset.vcproj", "{07022E76-6CB5-92C1-B47F-A10772A79B43}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sg_set", "sg_set\sg_set.vcproj", "{1690A9E7-DB57-971C-F24A-09B752A942F7}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{977B61B4-9968-497C-9F0B-24A8145473B8}.Debug.ActiveCfg = Debug|Win32
{977B61B4-9968-497C-9F0B-24A8145473B8}.Debug.Build.0 = Debug|Win32
{977B61B4-9968-497C-9F0B-24A8145473B8}.Release.ActiveCfg = Release|Win32
{977B61B4-9968-497C-9F0B-24A8145473B8}.Release.Build.0 = Release|Win32
{5A02061D-3728-4C49-AFC8-0130C1F161C0}.Debug.ActiveCfg = Debug|Win32
{5A02061D-3728-4C49-AFC8-0130C1F161C0}.Debug.Build.0 = Debug|Win32
{5A02061D-3728-4C49-AFC8-0130C1F161C0}.Release.ActiveCfg = Release|Win32
{5A02061D-3728-4C49-AFC8-0130C1F161C0}.Release.Build.0 = Release|Win32
{961F0E06-C092-4AF7-ABC5-2A49999F3B79}.Debug.ActiveCfg = Debug|Win32
{961F0E06-C092-4AF7-ABC5-2A49999F3B79}.Debug.Build.0 = Debug|Win32
{961F0E06-C092-4AF7-ABC5-2A49999F3B79}.Release.ActiveCfg = Release|Win32
{961F0E06-C092-4AF7-ABC5-2A49999F3B79}.Release.Build.0 = Release|Win32
{90F3C5BD-8E6C-4629-BC71-A1009EC88059}.Debug.ActiveCfg = Debug|Win32
{90F3C5BD-8E6C-4629-BC71-A1009EC88059}.Debug.Build.0 = Debug|Win32
{90F3C5BD-8E6C-4629-BC71-A1009EC88059}.Release.ActiveCfg = Release|Win32
{90F3C5BD-8E6C-4629-BC71-A1009EC88059}.Release.Build.0 = Release|Win32
{960E01F6-92C1-F74A-BCA5-2A9F3B994979}.Debug.ActiveCfg = Debug|Win32
{960E01F6-92C1-F74A-BCA5-2A9F3B994979}.Debug.Build.0 = Debug|Win32
{960E01F6-92C1-F74A-BCA5-2A9F3B994979}.Release.ActiveCfg = Release|Win32
{960E01F6-92C1-F74A-BCA5-2A9F3B994979}.Release.Build.0 = Release|Win32
{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}.Debug.ActiveCfg = Debug|Win32
{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}.Debug.Build.0 = Debug|Win32
{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}.Release.ActiveCfg = Release|Win32
{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}.Release.Build.0 = Release|Win32
{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}.Debug.ActiveCfg = Debug|Win32
{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}.Debug.Build.0 = Debug|Win32
{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}.Release.ActiveCfg = Release|Win32
{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}.Release.Build.0 = Release|Win32
{910E70E6-2C91-AA67-BF4C-A9C74A309927}.Debug.ActiveCfg = Debug|Win32
{910E70E6-2C91-AA67-BF4C-A9C74A309927}.Debug.Build.0 = Debug|Win32
{910E70E6-2C91-AA67-BF4C-A9C74A309927}.Release.ActiveCfg = Release|Win32
{910E70E6-2C91-AA67-BF4C-A9C74A309927}.Release.Build.0 = Release|Win32
{761A79B4-9968-CB81-F02B-2A4497345475}.Debug.ActiveCfg = Debug|Win32
{761A79B4-9968-CB81-F02B-2A4497345475}.Debug.Build.0 = Debug|Win32
{761A79B4-9968-CB81-F02B-2A4497345475}.Release.ActiveCfg = Release|Win32
{761A79B4-9968-CB81-F02B-2A4497345475}.Release.Build.0 = Release|Win32
{9571A7B4-9968-B9C1-17FB-134547B46975}.Debug.ActiveCfg = Debug|Win32
{9571A7B4-9968-B9C1-17FB-134547B46975}.Debug.Build.0 = Debug|Win32
{9571A7B4-9968-B9C1-17FB-134547B46975}.Release.ActiveCfg = Release|Win32
{9571A7B4-9968-B9C1-17FB-134547B46975}.Release.Build.0 = Release|Win32
{3579B1A4-9894-02AB-CB81-297B46154345}.Debug.ActiveCfg = Debug|Win32
{3579B1A4-9894-02AB-CB81-297B46154345}.Debug.Build.0 = Debug|Win32
{3579B1A4-9894-02AB-CB81-297B46154345}.Release.ActiveCfg = Release|Win32
{3579B1A4-9894-02AB-CB81-297B46154345}.Release.Build.0 = Release|Win32
{7679B41B-F2B4-9176-CB81-35449467B435}.Debug.ActiveCfg = Debug|Win32
{7679B41B-F2B4-9176-CB81-35449467B435}.Debug.Build.0 = Debug|Win32
{7679B41B-F2B4-9176-CB81-35449467B435}.Release.ActiveCfg = Release|Win32
{7679B41B-F2B4-9176-CB81-35449467B435}.Release.Build.0 = Release|Win32
{31C77B84-0B2C-9481-CB81-27A149F33825}.Debug.ActiveCfg = Debug|Win32
{31C77B84-0B2C-9481-CB81-27A149F33825}.Debug.Build.0 = Debug|Win32
{31C77B84-0B2C-9481-CB81-27A149F33825}.Release.ActiveCfg = Release|Win32
{31C77B84-0B2C-9481-CB81-27A149F33825}.Release.Build.0 = Release|Win32
{97B69A72-B9D3-7389-17FB-74612F4A9543}.Debug.ActiveCfg = Debug|Win32
{97B69A72-B9D3-7389-17FB-74612F4A9543}.Debug.Build.0 = Debug|Win32
{97B69A72-B9D3-7389-17FB-74612F4A9543}.Release.ActiveCfg = Release|Win32
{97B69A72-B9D3-7389-17FB-74612F4A9543}.Release.Build.0 = Release|Win32
{01E70176-B6C5-BF47-2C91-A949077BA323}.Debug.ActiveCfg = Debug|Win32
{01E70176-B6C5-BF47-2C91-A949077BA323}.Debug.Build.0 = Debug|Win32
{01E70176-B6C5-BF47-2C91-A949077BA323}.Release.ActiveCfg = Release|Win32
{01E70176-B6C5-BF47-2C91-A949077BA323}.Release.Build.0 = Release|Win32
{1E6909E7-C971-F24A-6C7B-A92094B71B59}.Debug.ActiveCfg = Debug|Win32
{1E6909E7-C971-F24A-6C7B-A92094B71B59}.Debug.Build.0 = Debug|Win32
{1E6909E7-C971-F24A-6C7B-A92094B71B59}.Release.ActiveCfg = Release|Win32
{1E6909E7-C971-F24A-6C7B-A92094B71B59}.Release.Build.0 = Release|Win32
{0AE70176-5B8C-4BC7-392C-A4A312B07893}.Debug.ActiveCfg = Debug|Win32
{0AE70176-5B8C-4BC7-392C-A4A312B07893}.Debug.Build.0 = Debug|Win32
{0AE70176-5B8C-4BC7-392C-A4A312B07893}.Release.ActiveCfg = Release|Win32
{0AE70176-5B8C-4BC7-392C-A4A312B07893}.Release.Build.0 = Release|Win32
{16909EE7-24AF-97C1-C76B-204B971BA959}.Debug.ActiveCfg = Debug|Win32
{16909EE7-24AF-97C1-C76B-204B971BA959}.Debug.Build.0 = Debug|Win32
{16909EE7-24AF-97C1-C76B-204B971BA959}.Release.ActiveCfg = Release|Win32
{16909EE7-24AF-97C1-C76B-204B971BA959}.Release.Build.0 = Release|Win32
{07022E76-6CB5-92C1-B47F-A10772A79B43}.Debug.ActiveCfg = Debug|Win32
{07022E76-6CB5-92C1-B47F-A10772A79B43}.Debug.Build.0 = Debug|Win32
{07022E76-6CB5-92C1-B47F-A10772A79B43}.Release.ActiveCfg = Release|Win32
{07022E76-6CB5-92C1-B47F-A10772A79B43}.Release.Build.0 = Release|Win32
{1690A9E7-DB57-971C-F24A-09B752A942F7}.Debug.ActiveCfg = Debug|Win32
{1690A9E7-DB57-971C-F24A-09B752A942F7}.Debug.Build.0 = Debug|Win32
{1690A9E7-DB57-971C-F24A-09B752A942F7}.Release.ActiveCfg = Release|Win32
{1690A9E7-DB57-971C-F24A-09B752A942F7}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="list"
ProjectGUID="{B1F70826-C6CF-47EF-B7C9-FC9C8BB63A79}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/Intrusive.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/Intrusive.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/Intrusive.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,423 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="_intrusivelib"
ProjectGUID="{90F3C5BD-8E6C-4629-BC71-A1009EC88059}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/_intrusivelib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/_intrusivelib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Jamfile"
Filter=""
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\..\..\test\Jamfile.v2">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\..\..\..\..\boost\intrusive\avl_set.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\avl_set_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\avltree.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\avltree_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\bs_set_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\circular_list_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\circular_slist_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\derivation_value_traits.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\hashtable.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\intrusive_fwd.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\link_mode.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\list.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\list_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\member_value_traits.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\options.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\pointer_plus_2_bits.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\pointer_plus_bit.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\rbtree.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\rbtree_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\set.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\set_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\sg_set.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\sgtree.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\sgtree_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\slist.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\slist_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\splay_set.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\splay_set_hook.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\splaytree.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\splaytree_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\trivial_value_traits.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\unordered_set.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\unordered_set_hook.hpp">
</File>
<Filter
Name="detail"
Filter="">
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\assert.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\avltree_node.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\config_begin.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\config_end.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\ebo_functor_holder.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\list_node.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\mpl.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\no_exceptions_support.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\parent_from_member.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\pointer_to_other.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\rbtree_node.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\slist_node.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\transform_iterator.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\tree_algorithms.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\tree_node.hpp">
</File>
<File
RelativePath="..\..\..\..\..\boost\intrusive\detail\utilities.hpp">
</File>
</Filter>
</Filter>
<Filter
Name="doc"
Filter="">
<File
RelativePath="..\..\..\doc\intrusive.qbk">
</File>
<File
RelativePath="..\..\..\doc\Jamfile.v2">
</File>
</Filter>
<Filter
Name="Test headers"
Filter="">
<File
RelativePath="..\..\..\test\common_functors.hpp">
</File>
<File
RelativePath="..\..\..\test\generic_assoc_test.hpp">
</File>
<File
RelativePath="..\..\..\test\generic_multiset_test.hpp">
</File>
<File
RelativePath="..\..\..\test\generic_set_test.hpp">
</File>
<File
RelativePath="..\..\..\test\itestvalue.hpp">
</File>
<File
RelativePath="..\..\..\test\smart_ptr.hpp">
</File>
<File
RelativePath="..\..\..\test\stateful_value_traits.hpp">
</File>
<File
RelativePath="..\..\..\test\test_container.hpp">
</File>
<File
RelativePath="..\..\..\test\test_macros.hpp">
</File>
<File
RelativePath="..\..\..\test\test_templates.hpp">
</File>
</Filter>
<Filter
Name="example"
Filter="">
<File
RelativePath="..\..\..\example\doc_advanced_value_traits.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_advanced_value_traits2.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_assoc_optimized_code.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_auto_unlink.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_avl_set.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_avltree_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_bucket_traits.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_clone_from.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_entity.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_erasing_and_disposing.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_external_value_traits.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_how_to_use.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_iterator_from_value.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_list.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_list_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_offset_ptr.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_rbtree_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_set.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_sg_set.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_slist.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_slist_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_splay_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_splay_set.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_splaytree_algorithms.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_stateful_value_traits.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_unordered_set.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_value_traits.cpp">
</File>
<File
RelativePath="..\..\..\example\doc_window.cpp">
</File>
<File
RelativePath="..\..\..\example\Jamfile.v2">
</File>
</Filter>
<Filter
Name="perf"
Filter="">
<File
RelativePath="..\..\..\perf\Jamfile.v2">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\perf\perf_list.cpp">
</File>
</Filter>
<File
RelativePath="..\to-do.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="avl_multiset"
ProjectGUID="{0AE70176-5B8C-4BC7-392C-A4A312B07893}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
GeneratePreprocessedFile="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/avl_multiset.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/avl_multiset.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/avl_multiset.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{F9A837FC-4236-A8D7-745E-2D383A2E13EA}">
<File
RelativePath="..\..\..\test\avl_multiset_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="avl_set"
ProjectGUID="{16909EE7-24AF-97C1-C76B-204B971BA959}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/avl_set.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/avl_set.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/avl_set.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{FC776C11-2A4F-326F-1E35-4C72A23B325A}">
<File
RelativePath="..\..\..\test\avl_set_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="custom_bucket_traits"
ProjectGUID="{31C77B84-0B2C-9481-CB81-27A149F33825}"
RootNamespace="custom_bucket_traits"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/custom_bucket_traits.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/custom_bucket_traits.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/custom_bucket_traits.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{51BA5F47-A612-6376-7AB5-73F17F5C84BC}">
<File
RelativePath="..\..\..\test\custom_bucket_traits_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="default_hook"
ProjectGUID="{761A79B4-9968-CB81-F02B-2A4497345475}"
RootNamespace="default_hook"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/default_hook.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/default_hook.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/default_hook.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4C737FF1-7AB5-3764-A066-252B75A372FF}">
<File
RelativePath="..\..\..\test\default_hook_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="external_value_traits"
ProjectGUID="{97B69A72-B9D3-7389-17FB-74612F4A9543}"
RootNamespace="external_value_traits"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/external_value_traits.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/external_value_traits.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/external_value_traits.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{7FAFEA31-6364-FB35-16A6-77AF315C236A}">
<File
RelativePath="..\..\..\test\external_value_traits_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="list"
ProjectGUID="{977B61B4-9968-497C-9F0B-24A8145473B8}"
RootNamespace="list"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/list.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/list.pdb"
GenerateMapFile="FALSE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/list.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\..\..\test\list_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="make_functions"
ProjectGUID="{7679B41B-F2B4-9176-CB81-35449467B435}"
RootNamespace="make_functions"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/make_functions.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/make_functions.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/make_functions.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4F537F31-AB85-7644-A616-25727F35FA5F}">
<File
RelativePath="..\..\..\test\make_functions_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="multiset"
ProjectGUID="{961F0E06-C092-4AF7-ABC5-2A49999F3B79}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/multiset.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/multiset.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="_WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/multiset.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\..\..\test\multiset_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="perf_test"
ProjectGUID="{910E70E6-2C91-AA67-BF4C-A9C74A309927}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/perf_test.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/perf_test.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/perf_test.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{43C77EF1-B78A-73C5-7346-2D7522AE2C3F}">
<File
RelativePath="..\..\..\perf\perf_list.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{68B017A6-F80D6A2-084c-06A6-8A323C1ABD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

137
proj/vc7ide/set/set.vcproj Normal file
View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="set"
ProjectGUID="{960E01F6-92C1-F74A-BCA5-2A9F3B994979}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/set.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/set.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/set.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4F73C7F1-C745-4726-06A6-2D752AA322FF}">
<File
RelativePath="..\..\..\test\set_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{68007AB6-FDA6800-084c-B78A-8121AA3BBD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="sg_multiset"
ProjectGUID="{07022E76-6CB5-92C1-B47F-A10772A79B43}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
GeneratePreprocessedFile="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/sg_multiset.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/sg_multiset.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/sg_multiset.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{7F97AC3C-5426-8CA7-5D74-2B385DAA232F}">
<File
RelativePath="..\..\..\test\sg_multiset_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="sg_set"
ProjectGUID="{1690A9E7-DB57-971C-F24A-09B752A942F7}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/sg_set.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/sg_set.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/sg_set.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{FC770E61-A263-71E5-72AF-2E7D2C33A42A}">
<File
RelativePath="..\..\..\test\sg_set_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="slist"
ProjectGUID="{5A02061D-3728-4C49-AFC8-0130C1F161C0}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/slist.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/slist.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/slist.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\..\..\test\slist_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="splay_multiset"
ProjectGUID="{01E70176-B6C5-BF47-2C91-A949077BA323}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
GeneratePreprocessedFile="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/splay_multiset.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/splay_multiset.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/splay_multiset.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{C737F9AC-78CA-745E-5426-2DA33852B2FA}">
<File
RelativePath="..\..\..\test\splay_multiset_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="splay_set"
ProjectGUID="{1E6909E7-C971-F24A-6C7B-A92094B71B59}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/splay_set.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/splay_set.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/splay_set.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{FF1C7761-72AF-26A3-71E5-2743AA32D2CA}">
<File
RelativePath="..\..\..\test\splay_set_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="stateful_value_traits"
ProjectGUID="{9571A7B4-9968-B9C1-17FB-134547B46975}"
RootNamespace="stateful_value_traits"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/stateful_value_traits.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/stateful_value_traits.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/stateful_value_traits.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{C7F4F831-AB76-7634-16A6-2A37523FB75A}">
<File
RelativePath="..\..\..\test\stateful_value_traits_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

7
proj/vc7ide/to-do.txt Normal file
View File

@@ -0,0 +1,7 @@
add includes needed for the snippets
add section explaining splice(...,n)
Faltar<EFBFBD>a, en mi opini<6E>n, una gu<67>a de qu<71> headers incluyen a cu<63>les. P.ej.,
los *_hook.hpp t<>picamente est<73>n incluidos por el header del contenedor asociado, etc.
Add resize() to list
Optimize rehash for when shrinking: there is no need to hash the values.
Optimize store_hash<true> to work with the same node and type traits as store_hash<false>

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="unordered_multiset"
ProjectGUID="{9101EE76-BB6C-2C91-F4B7-A9F3B9490279}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
GeneratePreprocessedFile="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/unordered_multiset.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/unordered_multiset.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/unordered_multiset.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4F3C77F1-B78A-C745-4726-2D752AA322FF}">
<File
RelativePath="..\..\..\test\unordered_multiset_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{99954380-9C8D-084c-4b04-62E52E6FBBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{6A181B76-FDA6800-8E8B-0A66-813A3BB1AD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="unordered_set"
ProjectGUID="{90E701E6-2C91-F4A7-BA6C-A9F3B0949279}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/unordered_set.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/unordered_set.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/unordered_set.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4F3C77F1-B78A-C745-4726-2D752AA322FF}">
<File
RelativePath="..\..\..\test\unordered_set_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{68AB0076-FDA6800-084c-06A6-8121AA3BBD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="virtual_base"
ProjectGUID="{3579B1A4-9894-02AB-CB81-297B46154345}"
RootNamespace="virtual_base"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
DisableLanguageExtensions="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/virtual_base.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/virtual_base.pdb"
GenerateMapFile="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../../"
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="4"
DisableLanguageExtensions="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/virtual_base.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{75137BAF-6764-7AB5-3A06-25A73D48B7FC}">
<File
RelativePath="..\..\..\test\virtual_base_test.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

33
test/Jamfile.v2 Normal file
View File

@@ -0,0 +1,33 @@
# Boost Intrusive Library Test Jamfile
# (C) Copyright Ion Gazta<74>aga 2006.
# Use, modification and distribution are subject to 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)
# Adapted from John Maddock's TR1 Jamfile.v2
# Copyright John Maddock 2005.
# Use, modification and distribution are subject to 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)
# this rule enumerates through all the sources and invokes
# the run rule for each source, the result is a list of all
# the run rules, which we can pass on to the test_suite rule:
rule test_all
{
local all_rules = ;
for local fileb in [ glob *.cpp ]
{
all_rules += [ run $(fileb)
: # additional args
: # test-files
: # requirements
] ;
}
return $(all_rules) ;
}
test-suite intrusive_test : [ test_all r ] : <threading>multi ;

118
test/avl_multiset_test.cpp Normal file
View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/avl_set.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_multiset_test.hpp"
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::avl_multiset
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_member_hook_t
, &value_type::avl_set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_member_hook_t
, &value_type::avl_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_auto_member_hook_t
, &value_type::avl_set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

119
test/avl_set_test.cpp Normal file
View File

@@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/avl_set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_set_test.hpp"
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::avl_set
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_member_hook_t
, &value_type::avl_set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_member_hook_t
, &value_type::avl_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::avl_set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::avl_set_auto_member_hook_t
, &value_type::avl_set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

48
test/common_functors.hpp Normal file
View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP
#define BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP
#include<boost/intrusive/detail/utilities.hpp>
#include<boost/intrusive/detail/mpl.hpp>
namespace boost {
namespace intrusive {
namespace test {
template<class T>
class delete_disposer
{
public:
template <class Pointer>
void operator()(Pointer p)
{
typedef typename std::iterator_traits<Pointer>::value_type value_type;
BOOST_INTRUSIVE_INVARIANT_ASSERT(( detail::is_same<T, value_type>::value ));
delete detail::get_pointer(p);
}
};
template<class T>
class new_cloner
{
public:
T *operator()(const T &t)
{ return new T(t); }
};
} //namespace test {
} //namespace intrusive {
} //namespace boost {
#endif

View File

@@ -0,0 +1,127 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/detail/mpl.hpp>
#include <boost/functional/hash.hpp>
#include <vector>
using namespace boost::intrusive;
class MyClass : public unordered_set_base_hook<>
{
int int_;
public:
MyClass(int i = 0) : int_(i)
{}
unordered_set_member_hook<> member_hook_;
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
struct uset_value_traits
{
typedef slist_node_traits<void*> node_traits;
typedef node_traits::node_ptr node_ptr;
typedef node_traits::const_node_ptr const_node_ptr;
typedef MyClass value_type;
typedef MyClass * pointer;
typedef const MyClass * const_pointer;
static const link_mode_type link_mode = normal_link;
static node_ptr to_node_ptr (value_type &value)
{ return node_ptr(&value); }
static const_node_ptr to_node_ptr (const value_type &value)
{ return const_node_ptr(&value); }
static pointer to_value_ptr(node_ptr n)
{ return static_cast<value_type*>(n); }
static const_pointer to_value_ptr(const_node_ptr n)
{ return static_cast<const value_type*>(n); }
};
//Base
typedef base_hook< unordered_set_base_hook<> > BaseHook;
typedef unordered_bucket<BaseHook>::type BaseBucketType;
typedef unordered_set<MyClass, BaseHook> BaseUset;
//Member
typedef member_hook
< MyClass, unordered_set_member_hook<>
, &MyClass::member_hook_ > MemberHook;
typedef unordered_bucket<MemberHook>::type MemberBucketType;
typedef unordered_set<MyClass, MemberHook> MemberUset;
//Explicit
typedef value_traits< uset_value_traits > Traits;
typedef unordered_bucket<Traits>::type TraitsBucketType;
typedef unordered_set<MyClass, Traits> TraitsUset;
struct uset_bucket_traits
{
//Power of two bucket length
static const std::size_t NumBuckets = 128;
uset_bucket_traits(BaseBucketType *buckets)
: buckets_(buckets)
{}
uset_bucket_traits(const uset_bucket_traits &other)
: buckets_(other.buckets_)
{}
BaseBucketType * bucket_begin() const
{ return buckets_; }
std::size_t bucket_count() const
{ return NumBuckets; }
BaseBucketType *buckets_;
};
typedef unordered_set
<MyClass, bucket_traits<uset_bucket_traits>, power_2_buckets<true> >
BucketTraitsUset;
int main()
{
if(!detail::is_same<BaseUset::bucket_type, BaseBucketType>::value)
return 1;
if(!detail::is_same<MemberUset::bucket_type, MemberBucketType>::value)
return 1;
if(!detail::is_same<TraitsUset::bucket_type, TraitsBucketType>::value)
return 1;
if(!detail::is_same<BaseBucketType, MemberBucketType>::value)
return 1;
if(!detail::is_same<BaseBucketType, TraitsBucketType>::value)
return 1;
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseBucketType buckets[uset_bucket_traits::NumBuckets];
uset_bucket_traits btraits(buckets);
BucketTraitsUset uset(btraits);
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
uset.insert(*it);
for( VectRit it(values.rbegin()), itend(values.rend()); it != itend; ++it){
if(uset.find(*it) == uset.cend()) return 1;
}
return 0;
}

View File

@@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include "smart_ptr.hpp"
#include <vector>
using namespace boost::intrusive;
class MyClass
: public list_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
, public slist_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
, public set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
, public unordered_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >
{
int int_;
public:
MyClass(int i)
: int_(i)
{}
friend bool operator<(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
//Define a list that will store MyClass using the public base hook
typedef list<MyClass> List;
typedef slist<MyClass> Slist;
typedef set<MyClass> Set;
typedef unordered_set<MyClass> USet;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
USet::bucket_type buckets[100];
List my_list;
Slist my_slist;
Set my_set;
USet my_uset(USet::bucket_traits(buckets, 100));
//Now insert them in the reverse order
//in the base hook intrusive list
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_set.insert(*it);
my_uset.insert(*it);
}
//Now test lists
{
List::const_iterator list_it(my_list.cbegin());
Slist::const_iterator slist_it(my_slist.cbegin());
Set::const_reverse_iterator set_rit(my_set.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
//Test the objects inserted in the base hook list
for(; vect_it != vect_itend; ++vect_it, ++list_it, ++slist_it, ++set_rit){
if(&*list_it != &*vect_it) return 1;
if(&*slist_it != &*vect_it) return 1;
if(&*set_rit != &*vect_it) return 1;
if(my_uset.find(*set_rit) == my_uset.cend()) return 1;
}
}
return 0;
}

View File

@@ -0,0 +1,239 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/rbtree.hpp>
#include <boost/intrusive/hashtable.hpp>
#include <boost/pointer_to_other.hpp>
#include <functional>
#include <vector>
using namespace boost::intrusive;
class MyClass
{
public:
int int_;
MyClass(int i = 0)
: int_(i)
{}
friend bool operator > (const MyClass &l, const MyClass &r)
{ return l.int_ > r.int_; }
friend bool operator == (const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
const int NumElements = 100;
template<class NodeTraits>
struct external_traits
{
typedef NodeTraits node_traits;
typedef typename node_traits::node node;
typedef typename node_traits::node_ptr node_ptr;
typedef typename node_traits::const_node_ptr const_node_ptr;
typedef MyClass value_type;
typedef typename boost::pointer_to_other
<node_ptr, MyClass>::type pointer;
typedef typename boost::pointer_to_other
<node_ptr, const MyClass>::type const_pointer;
static const link_mode_type link_mode = normal_link;
external_traits(pointer values, std::size_t NumElem)
: values_(values), node_array_(NumElem)
{}
node_ptr to_node_ptr (value_type &value)
{ return (&node_array_[0]) + (&value - values_); }
const_node_ptr to_node_ptr (const value_type &value) const
{ return &node_array_[0] + (&value - values_); }
pointer to_value_ptr(node_ptr n)
{ return values_ + (n - &node_array_[0]); }
const_pointer to_value_ptr(const_node_ptr n) const
{ return values_ + (n - &node_array_[0]); }
pointer values_;
std::vector<node> node_array_;
};
template<class NodeTraits>
struct value_traits_proxy;
template<class T>
struct traits_holder
: public T
{};
typedef value_traits_proxy<list_node_traits<void*> > list_value_traits_proxy;
typedef value_traits_proxy<slist_node_traits<void*> > slist_value_traits_proxy;
typedef value_traits_proxy<rbtree_node_traits<void*> > rbtree_value_traits_proxy;
typedef value_traits_proxy<traits_holder<slist_node_traits<void*> > > hash_value_traits_proxy;
struct uset_bucket_traits
{
private:
typedef unordered_bucket<value_traits<external_traits
<traits_holder<slist_node_traits<void*> > > > >::type bucket_type;
//Non-copyable
uset_bucket_traits(const uset_bucket_traits &other);
uset_bucket_traits & operator=(const uset_bucket_traits &other);
public:
static const std::size_t NumBuckets = 100;
uset_bucket_traits(){}
bucket_type * bucket_begin() const
{ return buckets_; }
std::size_t bucket_count() const
{ return NumBuckets; }
mutable bucket_type buckets_[NumBuckets];
};
struct bucket_traits_proxy
{
static const bool external_bucket_traits = true;
typedef uset_bucket_traits bucket_traits;
template<class Container>
bucket_traits &get_bucket_traits(Container &cont);
template<class Container>
const bucket_traits &get_bucket_traits(const Container &cont) const;
};
//Define a list that will store MyClass using the external hook
typedef list<MyClass, value_traits<list_value_traits_proxy> > List;
//Define a slist that will store MyClass using the external hook
typedef slist<MyClass, value_traits<slist_value_traits_proxy> > Slist;
//Define a rbtree that will store MyClass using the external hook
typedef rbtree< MyClass
, value_traits<rbtree_value_traits_proxy>
, compare<std::greater<MyClass> > > Rbtree;
//Define a hashtable that will store MyClass using the external hook
typedef hashtable< MyClass
, value_traits<hash_value_traits_proxy>
, bucket_traits<bucket_traits_proxy>
> Hash;
template<class NodeTraits>
struct value_traits_proxy
{
static const bool external_value_traits = true;
typedef external_traits<NodeTraits> value_traits;
template<class Container>
const value_traits &get_value_traits(const Container &cont) const;
template<class Container>
value_traits &get_value_traits(Container &cont);
};
struct ContainerHolder
: public uset_bucket_traits
, public List
, public external_traits<list_node_traits<void*> >
, public Slist
, public external_traits<slist_node_traits<void*> >
, public Rbtree
, public external_traits<rbtree_node_traits<void*> >
, public Hash
, public external_traits<traits_holder<slist_node_traits<void*> > >
{
static const std::size_t NumBucket = 100;
ContainerHolder(MyClass *values, std::size_t num_elem)
: uset_bucket_traits()
, List()
, external_traits<list_node_traits<void*> >(values, num_elem)
, Slist()
, external_traits<slist_node_traits<void*> >(values, num_elem)
, Rbtree()
, external_traits<rbtree_node_traits<void*> >(values, num_elem)
, Hash(Hash::bucket_traits())
, external_traits<traits_holder<slist_node_traits<void*> > >(values, num_elem)
{}
};
template<class NodeTraits>
template<class Container>
typename value_traits_proxy<NodeTraits>::value_traits &
value_traits_proxy<NodeTraits>::get_value_traits(Container &cont)
{ return static_cast<value_traits&>(static_cast<ContainerHolder&>(cont)); }
template<class NodeTraits>
template<class Container>
const typename value_traits_proxy<NodeTraits>::value_traits &
value_traits_proxy<NodeTraits>::get_value_traits(const Container &cont) const
{ return static_cast<const value_traits&>(static_cast<const ContainerHolder&>(cont)); }
template<class Container>
typename bucket_traits_proxy::bucket_traits &
bucket_traits_proxy::get_bucket_traits(Container &cont)
{ return static_cast<bucket_traits&>(static_cast<ContainerHolder&>(cont)); }
template<class Container>
const typename bucket_traits_proxy::bucket_traits &
bucket_traits_proxy::get_bucket_traits(const Container &cont) const
{ return static_cast<const bucket_traits&>(static_cast<const ContainerHolder&>(cont)); }
int main()
{
MyClass values [NumElements];
//Create several MyClass objects, each one with a different value
for(int i = 0; i < NumElements; ++i)
values[i].int_ = i;
ContainerHolder cont_holder(values, NumElements);
List &my_list = static_cast<List &> (cont_holder);
Slist &my_slist = static_cast<Slist &> (cont_holder);
Rbtree &my_rbtree = static_cast<Rbtree &> (cont_holder);
Hash &my_hash = static_cast<Hash &> (cont_holder);
//Now insert them in containers
for(MyClass * it(&values[0]), *itend(&values[NumElements])
; it != itend; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_rbtree.insert_unique(*it);
my_hash.insert_unique(*it);
}
//Now test containers
{
List::const_iterator list_it (my_list.cbegin());
Slist::const_iterator slist_it (my_slist.cbegin());
Rbtree::const_iterator rbtree_it (my_rbtree.cbegin());
Hash::const_iterator hash_it (my_hash.cbegin());
MyClass *it_val(&values[NumElements] - 1), *it_rbeg_val(&values[0]-1);
//Test inserted objects
for(; it_val != it_rbeg_val; --it_val, ++list_it, ++slist_it, ++rbtree_it){
if(&*list_it != &*it_val) return 1;
if(&*slist_it != &*it_val) return 1;
if(&*rbtree_it != &*it_val) return 1;
hash_it = my_hash.find(*it_val);
if(hash_it == my_hash.cend() || &*hash_it != &*it_val)
return 1;
}
}
return 0;
}

328
test/generic_assoc_test.hpp Normal file
View File

@@ -0,0 +1,328 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <vector> //vector
#include <algorithm> //sort, random_shuffle
#include <boost/intrusive/detail/config_begin.hpp>
#include "common_functors.hpp"
#include <boost/intrusive/options.hpp>
#include <boost/detail/lightweight_test.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
namespace boost{
namespace intrusive{
namespace test{
template<class T>
struct has_splay
{
static const bool value = false;
};
template<class T>
struct has_rebalance
{
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
{
typedef typename ValueTraits::value_type value_type;
static void test_all(std::vector<value_type>& values);
static void test_clone(std::vector<value_type>& values);
static void test_insert_erase_burst();
static void test_container_from_end(std::vector<value_type>& values);
static void test_splay_up(std::vector<value_type>& values);
static void test_splay_up(std::vector<value_type>& values, boost::intrusive::detail::true_type);
static void test_splay_up(std::vector<value_type>& values, boost::intrusive::detail::false_type);
static void test_splay_down(std::vector<value_type>& values);
static void test_splay_down(std::vector<value_type>& values, boost::intrusive::detail::true_type);
static void test_splay_down(std::vector<value_type>& values, boost::intrusive::detail::false_type);
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);
};
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_erase_burst()
{
typedef typename ValueTraits::value_type value_type;
std::vector<value_type> values;
const int MaxValues = 100;
for(int i = 0; i != MaxValues; ++i){
values.push_back(value_type(i));
}
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type assoc_type;
typedef typename assoc_type::iterator iterator;
//First ordered insertions
assoc_type testset (&values[0], &values[0] + values.size());
TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
//Ordered erasure
iterator it(testset.begin()), itend(testset.end());
for(int i = 0; it != itend; ++i){
BOOST_TEST(&*it == &values[i]);
it = testset.erase(it);
}
BOOST_TEST(testset.empty());
//Now random insertions
std::random_shuffle(values.begin(), values.end());
testset.insert(&values[0], &values[0] + values.size());
std::sort(values.begin(), values.end());
TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
//Random erasure
std::random_shuffle(values.begin(), values.end());
for(int i = 0; i != MaxValues; ++i){
it = testset.erase(testset.iterator_to(values[i]));
}
BOOST_TEST(testset.empty());
}
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_all(std::vector<typename ValueTraits::value_type>& values)
{
test_clone(values);
test_container_from_end(values);
test_splay_up(values);
test_splay_down(values);
test_rebalance(values);
test_insert_erase_burst();
}
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_clone(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 assoc_type;
assoc_type testset1 (&values[0], &values[0] + values.size());
assoc_type testset2;
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
BOOST_TEST (testset2 == testset1);
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
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_container_from_end(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 assoc_type;
assoc_type testset (&values[0], &values[0] + values.size());
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.end()));
BOOST_TEST (testset == assoc_type::container_from_end_iterator(testset.cend()));
}
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_splay_up
(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;
typedef typename assoc_type::iterator iterator;
typedef std::vector<value_type> orig_set_t;
std::size_t num_values;
orig_set_t original_testset;
{
assoc_type testset (values.begin(), values.end());
num_values = testset.size();
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
}
for(std::size_t i = 0; i != num_values; ++i){
assoc_type testset (values.begin(), values.end());
{
iterator it = testset.begin();
for(std::size_t j = 0; j != i; ++j, ++it){}
testset.splay_up(it);
}
BOOST_TEST (testset.size() == num_values);
iterator it = testset.begin();
for( typename orig_set_t::const_iterator origit = original_testset.begin()
, origitend = original_testset.end()
; origit != origitend
; ++origit, ++it){
BOOST_TEST(*origit == *it);
}
}
}
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_splay_up
(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_splay_up
(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_splay<Type>::value> enabler;
test_splay_up(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_splay_down
(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;
typedef typename assoc_type::iterator iterator;
typedef std::vector<value_type> orig_set_t;
std::size_t num_values;
orig_set_t original_testset;
{
assoc_type testset (values.begin(), values.end());
num_values = testset.size();
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
}
for(std::size_t i = 0; i != num_values; ++i){
assoc_type testset (values.begin(), values.end());
BOOST_TEST(testset.size() == num_values);
{
iterator it = testset.begin();
for(std::size_t j = 0; j != i; ++j, ++it){}
BOOST_TEST(*it == *testset.splay_down(*it));
}
BOOST_TEST (testset.size() == num_values);
iterator it = testset.begin();
for( typename orig_set_t::const_iterator origit = original_testset.begin()
, origitend = original_testset.end()
; origit != origitend
; ++origit, ++it){
BOOST_TEST(*origit == *it);
}
}
}
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_splay_down
(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_splay_down
(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_splay<Type>::value> enabler;
test_splay_down(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_rebalance
(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;
typedef std::vector<value_type> orig_set_t;
typedef typename orig_set_t::iterator iterator_t;
std::size_t num_values;
orig_set_t original_testset;
{
assoc_type testset (values.begin(), values.end());
num_values = testset.size();
original_testset.insert(original_testset.end(), testset.begin(), testset.end());
}
{
assoc_type testset(values.begin(), values.end());
testset.rebalance();
iterator_t it = original_testset.begin();
TEST_INTRUSIVE_SEQUENCE_EXPECTED(original_testset, testset.begin());
}
{
std::size_t numdata;
{
assoc_type testset(values.begin(), values.end());
numdata = testset.size();
}
for(int i = 0; i != (int)numdata; ++i){
assoc_type testset(values.begin(), values.end());
typename assoc_type::iterator it = testset.begin();
for(int j = 0; j != i; ++j) ++it;
testset.rebalance_subtree(it);
TEST_INTRUSIVE_SEQUENCE_EXPECTED(original_testset, 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_rebalance
(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_rebalance
(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_rebalance<Type>::value> enabler;
test_rebalance(values, enabler());
}
}}} //namespace boost::intrusive::test
#include <boost/intrusive/detail/config_end.hpp>

View File

@@ -0,0 +1,227 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <boost/intrusive/detail/config_begin.hpp>
#include "common_functors.hpp"
#include <boost/detail/lightweight_test.hpp>
#include <boost/intrusive/options.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
#include "generic_assoc_test.hpp"
namespace boost{
namespace intrusive{
namespace test{
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_multiset
{
typedef typename ValueTraits::value_type value_type;
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_swap(std::vector<value_type>& values);
static void test_find(std::vector<value_type>& values);
static void test_impl();
};
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_multiset<ValueTraits, ContainerDefiner>::test_all ()
{
typedef typename ValueTraits::value_type value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<value_type> values (6);
for (int i = 0; i < 6; ++i)
values[i].value_ = random_init[i];
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
{
multiset_type testset(values.begin(), values.end());
test::test_container(testset);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_common_unordered_and_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_non_unique_container(testset, values);
}
test_sort(values);
test_insert(values);
test_swap(values);
test_find(values);
test_impl();
test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(values);
}
//test case due to an error in tree implementation:
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_multiset<ValueTraits, ContainerDefiner>::test_impl()
{
typedef typename ValueTraits::value_type value_type;
std::vector<value_type> values (5);
for (int i = 0; i < 5; ++i)
values[i].value_ = i;
typedef typename ValueTraits::value_type value_type;
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
multiset_type testset;
for (int i = 0; i < 5; ++i)
testset.insert (values[i]);
testset.erase (testset.iterator_to (values[0]));
testset.erase (testset.iterator_to (values[1]));
testset.insert (values[1]);
testset.erase (testset.iterator_to (values[2]));
testset.erase (testset.iterator_to (values[3]));
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
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_multiset<ValueTraits, ContainerDefiner>::test_sort(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 multiset_type;
multiset_type testset1 (values.begin(), values.end());
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.clear();
BOOST_TEST (testset1.empty());
typedef typename ContainerDefiner
<value_type
, compare<even_odd>
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type2;
multiset_type2 testset2 (&values[0], &values[0] + 6);
{ int init_values [] = { 5, 3, 1, 4, 2, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); }
BOOST_TEST (testset2.begin()->value_ == 2);
BOOST_TEST (testset2.rbegin()->value_ == 5);
}
//test: insert, const_iterator, const_reverse_iterator, erase, 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_multiset<ValueTraits, ContainerDefiner>::test_insert(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
multiset_type testset;
testset.insert(&values[0] + 2, &values[0] + 5);
{ int init_values [] = { 1, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); }
typename multiset_type::iterator i = testset.begin();
BOOST_TEST (i->value_ == 1);
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() ); }
i = testset.iterator_to (values[2]);
BOOST_TEST (&*i == &values[2]);
i = multiset_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() ); }
}
//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>
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_swap(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
multiset_type testset1 (&values[0], &values[0] + 2);
multiset_type testset2;
testset2.insert (&values[0] + 2, &values[0] + 6);
testset1.swap (testset2);
{ int init_values [] = { 1, 2, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
{ int init_values [] = { 2, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
BOOST_TEST (testset1.size() == 1);
BOOST_TEST (&*testset1.begin() == &values[3]);
}
//test: find, equal_range (lower_bound, upper_bound):
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_multiset<ValueTraits, ContainerDefiner>::test_find(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
multiset_type testset (values.begin(), values.end());
typedef typename multiset_type::iterator iterator;
value_type cmp_val;
cmp_val.value_ = 2;
iterator i = testset.find (cmp_val);
BOOST_TEST (i->value_ == 2);
BOOST_TEST ((++i)->value_ == 2);
std::pair<iterator,iterator> range = testset.equal_range (cmp_val);
BOOST_TEST (range.first->value_ == 2);
BOOST_TEST (range.second->value_ == 3);
BOOST_TEST (std::distance (range.first, range.second) == 2);
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
}}} //namespace boost::intrusive::test
#include <boost/intrusive/detail/config_end.hpp>

225
test/generic_set_test.hpp Normal file
View File

@@ -0,0 +1,225 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <boost/intrusive/detail/config_begin.hpp>
#include "common_functors.hpp"
#include <boost/detail/lightweight_test.hpp>
#include <boost/intrusive/options.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
#include "generic_assoc_test.hpp"
namespace boost{
namespace intrusive{
namespace test{
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
{
typedef typename ValueTraits::value_type value_type;
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_swap(std::vector<value_type>& values);
static void test_find(std::vector<value_type>& values);
static void test_impl();
};
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_all()
{
typedef typename ValueTraits::value_type value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<value_type> values (6);
for (int i = 0; i < 6; ++i)
values[i].value_ = random_init[i];
typedef typename ContainerDefiner
< value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type set_type;
{
set_type testset(values.begin(), values.end());
test::test_container(testset);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_common_unordered_and_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_unique_container(testset, values);
}
test_sort(values);
test_insert(values);
test_swap(values);
test_find(values);
test_impl();
test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(values);
}
//test case due to an error in tree implementation:
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_impl()
{
typedef typename ValueTraits::value_type value_type;
std::vector<value_type> values (5);
for (int i = 0; i < 5; ++i)
values[i].value_ = i;
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;
for (int i = 0; i < 5; ++i)
testset.insert (values[i]);
testset.erase (testset.iterator_to (values[0]));
testset.erase (testset.iterator_to (values[1]));
testset.insert (values[1]);
testset.erase (testset.iterator_to (values[2]));
testset.erase (testset.iterator_to (values[3]));
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
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_sort(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;
set_type testset1 (values.begin(), values.end());
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.clear();
BOOST_TEST (testset1.empty());
typedef typename ValueTraits::value_type value_type;
typedef typename ContainerDefiner
< value_type
, compare<even_odd>
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
>::type set_type2;
set_type2 testset2 (&values[0], &values[0] + 6);
{ int init_values [] = { 5, 3, 1, 4, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); }
BOOST_TEST (testset2.begin()->value_ == 2);
BOOST_TEST (testset2.rbegin()->value_ == 5);
}
//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(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;
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() ); }
typename set_type::iterator i = testset.begin();
BOOST_TEST (i->value_ == 1);
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() ); }
i = testset.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() ); }
}
//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>
void test_generic_set<ValueTraits, ContainerDefiner>::test_swap(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;
set_type testset1 (&values[0], &values[0] + 2);
set_type testset2;
testset2.insert (&values[0] + 2, &values[0] + 6);
testset1.swap (testset2);
{ int init_values [] = { 1, 2, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
{ int init_values [] = { 2, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
BOOST_TEST (testset1.size() == 1);
// BOOST_TEST (&testset1.front() == &values[3]);
BOOST_TEST (&*testset1.begin() == &values[3]);
}
//test: find, equal_range (lower_bound, upper_bound):
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_find(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;
set_type testset (values.begin(), values.end());
typedef typename set_type::iterator iterator;
value_type cmp_val;
cmp_val.value_ = 2;
iterator i = testset.find (cmp_val);
BOOST_TEST (i->value_ == 2);
BOOST_TEST ((++i)->value_ != 2);
std::pair<iterator,iterator> range = testset.equal_range (cmp_val);
BOOST_TEST (range.first->value_ == 2);
BOOST_TEST (range.second->value_ == 3);
BOOST_TEST (std::distance (range.first, range.second) == 1);
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
}}} //namespace boost::intrusive::test
#include <boost/intrusive/detail/config_end.hpp>

372
test/itestvalue.hpp Normal file
View File

@@ -0,0 +1,372 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_DETAIL_ITESTVALUE_HPP
#define BOOST_INTRUSIVE_DETAIL_ITESTVALUE_HPP
#include <iostream>
#include <boost/intrusive/set_hook.hpp>
#include <boost/intrusive/list_hook.hpp>
#include <boost/intrusive/slist_hook.hpp>
#include <boost/intrusive/unordered_set_hook.hpp>
#include <boost/intrusive/splay_set_hook.hpp>
#include <boost/intrusive/avl_set_hook.hpp>
#include <boost/intrusive/bs_set_hook.hpp>
#include <boost/intrusive/options.hpp>
#include <boost/functional/hash.hpp>
#include "smart_ptr.hpp"
namespace boost{
namespace intrusive{
struct my_tag;
template<class VoidPointer>
struct set_base_hook_type
{ typedef set_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct set_auto_base_hook_type
{ typedef set_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag>, optimize_size<true> > type; };
template<class VoidPointer>
struct set_member_hook_type
{ typedef set_member_hook<void_pointer<VoidPointer>, optimize_size<true> > type; };
template<class VoidPointer>
struct set_auto_member_hook_type
{ typedef set_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct splay_set_base_hook_type
{ typedef splay_set_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct splay_set_auto_base_hook_type
{ typedef splay_set_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
template<class VoidPointer>
struct splay_set_member_hook_type
{ typedef splay_set_member_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct splay_set_auto_member_hook_type
{ typedef splay_set_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct bs_set_base_hook_type
{ typedef bs_set_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct bs_set_member_hook_type
{ typedef bs_set_member_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct avl_set_base_hook_type
{ typedef avl_set_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct avl_set_auto_base_hook_type
{ typedef avl_set_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag>, optimize_size<true> > type; };
template<class VoidPointer>
struct avl_set_member_hook_type
{ typedef avl_set_member_hook<void_pointer<VoidPointer>, optimize_size<true> > type; };
template<class VoidPointer>
struct avl_set_auto_member_hook_type
{ typedef avl_set_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct list_base_hook_type
{ typedef list_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct list_auto_base_hook_type
{ typedef list_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
template<class VoidPointer>
struct list_member_hook_type
{ typedef list_member_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct list_auto_member_hook_type
{ typedef list_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct slist_base_hook_type
{ typedef slist_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct slist_auto_base_hook_type
{ typedef slist_base_hook<link_mode<auto_unlink>, void_pointer<VoidPointer>, tag<my_tag> > type; };
template<class VoidPointer>
struct slist_member_hook_type
{ typedef slist_member_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct slist_auto_member_hook_type
{ typedef slist_member_hook<link_mode<auto_unlink>, void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct uset_base_hook_type
{ typedef unordered_set_base_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct uset_auto_base_hook_type
{
typedef unordered_set_base_hook
< link_mode<auto_unlink>, void_pointer<VoidPointer>
, tag<my_tag>, store_hash<true> > type;
};
template<class VoidPointer>
struct uset_member_hook_type
{ typedef unordered_set_member_hook<void_pointer<VoidPointer> > type; };
template<class VoidPointer>
struct uset_auto_member_hook_type
{
typedef unordered_set_member_hook
< link_mode<auto_unlink>, void_pointer<VoidPointer>
, store_hash<true> > type;
};
template<class VoidPointer, bool ConstantTimeSize>
struct testvalue
: set_base_hook_type<VoidPointer>::type
, set_auto_base_hook_type<VoidPointer>::type
, splay_set_base_hook_type<VoidPointer>::type
, splay_set_auto_base_hook_type<VoidPointer>::type
, bs_set_base_hook_type<VoidPointer>::type
, avl_set_base_hook_type<VoidPointer>::type
, avl_set_auto_base_hook_type<VoidPointer>::type
, list_base_hook_type<VoidPointer>::type
, list_auto_base_hook_type<VoidPointer>::type
, slist_base_hook_type<VoidPointer>::type
, slist_auto_base_hook_type<VoidPointer>::type
, uset_base_hook_type<VoidPointer>::type
, uset_auto_base_hook_type<VoidPointer>::type
{
typedef typename set_auto_base_hook_type<VoidPointer>::type set_auto_base_hook_t;
typedef typename set_base_hook_type<VoidPointer>::type set_base_hook_t;
typedef typename set_auto_member_hook_type<VoidPointer>::type set_auto_member_hook_t;
typedef typename set_member_hook_type<VoidPointer>::type set_member_hook_t;
typedef typename splay_set_auto_base_hook_type<VoidPointer>::type splay_set_auto_base_hook_t;
typedef typename splay_set_base_hook_type<VoidPointer>::type splay_set_base_hook_t;
typedef typename splay_set_auto_member_hook_type<VoidPointer>::type splay_set_auto_member_hook_t;
typedef typename splay_set_member_hook_type<VoidPointer>::type splay_set_member_hook_t;
typedef typename bs_set_base_hook_type<VoidPointer>::type bs_set_base_hook_t;
typedef typename bs_set_member_hook_type<VoidPointer>::type bs_set_member_hook_t;
typedef typename avl_set_auto_base_hook_type<VoidPointer>::type avl_set_auto_base_hook_t;
typedef typename avl_set_base_hook_type<VoidPointer>::type avl_set_base_hook_t;
typedef typename avl_set_auto_member_hook_type<VoidPointer>::type avl_set_auto_member_hook_t;
typedef typename avl_set_member_hook_type<VoidPointer>::type avl_set_member_hook_t;
typedef typename uset_auto_base_hook_type<VoidPointer>::type unordered_set_auto_base_hook_t;
typedef typename uset_base_hook_type<VoidPointer>::type unordered_set_base_hook_t;
typedef typename uset_auto_member_hook_type<VoidPointer>::type unordered_set_auto_member_hook_t;
typedef typename uset_member_hook_type<VoidPointer>::type unordered_set_member_hook_t;
typedef typename list_auto_base_hook_type<VoidPointer>::type list_auto_base_hook_t;
typedef typename list_base_hook_type<VoidPointer>::type list_base_hook_t;
typedef typename list_auto_member_hook_type<VoidPointer>::type list_auto_member_hook_t;
typedef typename list_member_hook_type<VoidPointer>::type list_member_hook_t;
typedef typename slist_auto_base_hook_type<VoidPointer>::type slist_auto_base_hook_t;
typedef typename slist_base_hook_type<VoidPointer>::type slist_base_hook_t;
typedef typename slist_auto_member_hook_type<VoidPointer>::type slist_auto_member_hook_t;
typedef typename slist_member_hook_type<VoidPointer>::type slist_member_hook_t;
//Set members
set_member_hook_t set_node_;
set_auto_member_hook_t set_auto_node_;
//SplaySet members
splay_set_member_hook_t splay_set_node_;
splay_set_auto_member_hook_t splay_set_auto_node_;
//ScapegoatSet members
bs_set_member_hook_t sg_set_node_;
//AvlSet members
avl_set_member_hook_t avl_set_node_;
avl_set_auto_member_hook_t avl_set_auto_node_;
//Unordered set members
unordered_set_member_hook_t unordered_set_node_;
unordered_set_auto_member_hook_t unordered_set_auto_node_;
//List members
list_member_hook_t list_node_;
list_auto_member_hook_t list_auto_node_;
//Slist members
slist_member_hook_t slist_node_;
slist_auto_member_hook_t slist_auto_node_;
int value_;
static const bool constant_time_size = ConstantTimeSize;
testvalue()
{}
testvalue(int i)
: value_(i)
{}
testvalue (const testvalue& src)
: value_ (src.value_)
{}
// testvalue is used in std::vector and thus prev and next
// have to be handled appropriately when copied:
testvalue & operator= (const testvalue& src)
{
set_base_hook_t::operator=(src);
set_auto_base_hook_t::operator=(src);
this->set_node_ = src.set_node_;
this->set_auto_node_ = src.set_auto_node_;
splay_set_base_hook_t::operator=(src);
splay_set_auto_base_hook_t::operator=(src);
this->splay_set_node_ = src.splay_set_node_;
this->splay_set_auto_node_ = src.splay_set_auto_node_;
bs_set_base_hook_t::operator=(src);
this->sg_set_node_ = src.sg_set_node_;
avl_set_base_hook_t::operator=(src);
avl_set_auto_base_hook_t::operator=(src);
this->avl_set_node_ = src.avl_set_node_;
this->avl_set_auto_node_ = src.avl_set_auto_node_;
unordered_set_base_hook_t::operator=(src);
unordered_set_auto_base_hook_t::operator=(src);
this->unordered_set_node_ = src.unordered_set_node_;
this->unordered_set_auto_node_ = src.unordered_set_auto_node_;
list_base_hook_t::operator=(src);
list_auto_base_hook_t::operator=(src);
this->list_node_ = src.list_node_;
this->list_auto_node_ = src.list_auto_node_;
slist_base_hook_t::operator=(src);
slist_auto_base_hook_t::operator=(src);
this->slist_node_ = src.slist_node_;
this->slist_auto_node_ = src.slist_auto_node_;
value_ = src.value_;
return *this;
}
void swap_nodes(testvalue &other)
{
//Set
set_base_hook_t::swap_nodes(other);
set_auto_base_hook_t::swap_nodes(other);
set_node_.swap_nodes(other.set_node_);
set_auto_node_.swap_nodes(other.set_auto_node_);
//SplaySet
splay_set_base_hook_t::swap_nodes(other);
splay_set_auto_base_hook_t::swap_nodes(other);
splay_set_node_.swap_nodes(other.splay_set_node_);
splay_set_auto_node_.swap_nodes(other.splay_set_auto_node_);
//ScapeoatSet
bs_set_base_hook_t::swap_nodes(other);
sg_set_node_.swap_nodes(other.sg_set_node_);
//AvlSet
avl_set_base_hook_t::swap_nodes(other);
avl_set_auto_base_hook_t::swap_nodes(other);
avl_set_node_.swap_nodes(other.avl_set_node_);
avl_set_auto_node_.swap_nodes(other.avl_set_auto_node_);
//Unordered set
unordered_set_base_hook_t::swap_nodes(other);
unordered_set_auto_base_hook_t::swap_nodes(other);
unordered_set_node_.swap_nodes(other.unordered_set_node_);
unordered_set_auto_node_.swap_nodes(other.unordered_set_auto_node_);
//List
list_base_hook_t::swap_nodes(other);
list_auto_base_hook_t::swap_nodes(other);
list_node_.swap_nodes(other.list_node_);
list_auto_node_.swap_nodes(other.list_auto_node_);
//Slist
slist_base_hook_t::swap_nodes(other);
slist_auto_base_hook_t::swap_nodes(other);
slist_node_.swap_nodes(other.slist_node_);
slist_auto_node_.swap_nodes(other.slist_auto_node_);
}
~testvalue()
{}
bool operator< (const testvalue &other) const
{ return value_ < other.value_; }
bool operator==(const testvalue &other) const
{ return value_ == other.value_; }
friend bool operator< (int other1, const testvalue &other2)
{ return other1 < other2.value_; }
friend bool operator< (const testvalue &other1, int other2)
{ return other1.value_ < other2; }
friend bool operator== (int other1, const testvalue &other2)
{ return other1 == other2.value_; }
friend bool operator== (const testvalue &other1, int other2)
{ return other1.value_ == other2; }
};
template<class VoidPointer, bool ConstantTimeSize>
std::size_t hash_value(const testvalue<VoidPointer, ConstantTimeSize> &t)
{
boost::hash<int> hasher;
return hasher(t.value_);
}
template<class VoidPointer, bool constant_time_size>
std::ostream& operator<<
(std::ostream& s, const testvalue<VoidPointer, constant_time_size>& t)
{ return s << t.value_; }
struct even_odd
{
template<class VoidPointer, bool constant_time_size>
bool operator()
(const testvalue<VoidPointer, constant_time_size>& v1
,const testvalue<VoidPointer, constant_time_size>& v2) const
{
if ((v1.value_ & 1) == (v2.value_ & 1))
return v1.value_ < v2.value_;
else
return v2.value_ & 1;
}
};
} //namespace boost{
} //namespace intrusive{
#endif

414
test/list_test.cpp Normal file
View File

@@ -0,0 +1,414 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "common_functors.hpp"
#include <vector>
#include <boost/detail/lightweight_test.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
using namespace boost::intrusive;
template<class ValueTraits>
struct test_list
{
typedef typename ValueTraits::value_type value_type;
static void test_all(std::vector<value_type>& values);
static void test_front_back(std::vector<value_type>& values);
static void test_sort(std::vector<value_type>& values);
static void test_insert(std::vector<value_type>& values);
static void test_shift(std::vector<value_type>& values);
static void test_swap(std::vector<value_type>& values);
static void test_clone(std::vector<value_type>& values);
static void test_container_from_end(std::vector<value_type>& values);
};
template<class ValueTraits>
void test_list<ValueTraits>::test_all(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
{
list_type list(values.begin(), values.end());
test::test_container(list);
list.clear();
list.insert(list.end(), values.begin(), values.end());
test::test_sequence_container(list, values);
}
test_front_back(values);
test_sort(values);
test_insert(values);
test_shift(values);
test_swap(values);
test_clone(values);
test_container_from_end(values);
/*
const char *list_name = typeid(list_type).name();
std::cout << list_name << std::endl << strlen(list_name) << std::endl;
const char *value_t = typeid(typename list_type::value_traits).name();
std::cout << value_t << std::endl << strlen(value_t) << std::endl;
const char *list_it_name = typeid(typename list_type::iterator).name();
std::cout << list_it_name << std::endl << strlen(list_it_name ) << std::endl;
*/
}
//test: push_front, pop_front, push_back, pop_back, front, back, size, empty:
template<class ValueTraits>
void test_list<ValueTraits>
::test_front_back(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
BOOST_TEST (testlist.empty());
testlist.push_back (values[0]);
BOOST_TEST (testlist.size() == 1);
BOOST_TEST (&testlist.front() == &values[0]);
BOOST_TEST (&testlist.back() == &values[0]);
testlist.push_front (values[1]);
BOOST_TEST (testlist.size() == 2);
BOOST_TEST (&testlist.front() == &values[1]);
BOOST_TEST (&testlist.back() == &values[0]);
testlist.pop_back();
BOOST_TEST (testlist.size() == 1);
const list_type &const_testlist = testlist;
BOOST_TEST (&const_testlist.front() == &values[1]);
BOOST_TEST (&const_testlist.back() == &values[1]);
testlist.pop_front();
BOOST_TEST (testlist.empty());
}
//test: constructor, iterator, reverse_iterator, sort, reverse:
template<class ValueTraits>
void test_list<ValueTraits>
::test_sort(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist(values.begin(), values.end());
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); }
testlist.sort (even_odd());
{ int init_values [] = { 5, 3, 1, 4, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.rbegin() ); }
testlist.reverse();
{ int init_values [] = { 5, 3, 1, 4, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); }
}
//test: assign, insert, const_iterator, const_reverse_iterator, erase, s_iterator_to:
template<class ValueTraits>
void test_list<ValueTraits>
::test_insert(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
testlist.assign (&values[0] + 2, &values[0] + 5);
const list_type& const_testlist = testlist;
{ int init_values [] = { 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
typename list_type::iterator i = ++testlist.begin();
BOOST_TEST (i->value_ == 4);
{
typename list_type::const_iterator ci = typename list_type::iterator();
//typename list_type::iterator i = typename list_type::const_iterator();
}
testlist.insert (i, values[0]);
{ int init_values [] = { 5, 4, 1, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.rbegin() ); }
i = testlist.iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = list_type::s_iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = testlist.erase (i);
BOOST_TEST (i == testlist.end());
{ int init_values [] = { 3, 1, 4 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
}
template<class ValueTraits>
void test_list<ValueTraits>
::test_shift(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
const int num_values = (int)values.size();
std::vector<int> expected_values(num_values);
//Shift forward all possible positions 3 times
for(int i = 0; i < num_values*3; ++i){
testlist.assign(values.begin(), values.end());
testlist.shift_forward(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + num_values - i%num_values) % num_values] = (j + 1);
}
TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin());
testlist.clear();
}
//Shift backwards all possible positions
for(int i = 0; i < num_values*3; ++i){
testlist.assign(values.begin(), values.end());
testlist.shift_backwards(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + i) % num_values] = (j + 1);
}
TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin());
testlist.clear();
}
}
//test: insert (seq-version), swap, splice, erase (seq-version):
template<class ValueTraits>
void test_list<ValueTraits>
::test_swap(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
{
list_type testlist1 (&values[0], &values[0] + 2);
list_type testlist2;
testlist2.insert (testlist2.end(), &values[0] + 2, &values[0] + 5);
testlist1.swap (testlist2);
{ int init_values [] = { 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 1, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
testlist2.splice (++testlist2.begin(), testlist1);
{ int init_values [] = { 1, 3, 4, 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
BOOST_TEST (testlist1.empty());
testlist1.splice (testlist1.end(), testlist2, ++(++testlist2.begin()));
{ int init_values [] = { 4 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 1, 3, 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
testlist1.splice (testlist1.end(), testlist2,
testlist2.begin(), ----testlist2.end());
{ int init_values [] = { 4, 1, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
testlist1.erase (testlist1.iterator_to(values[0]), testlist1.end());
BOOST_TEST (testlist1.size() == 1);
BOOST_TEST (&testlist1.front() == &values[3]);
}
{
list_type testlist1 (&values[0], &values[0] + 2);
list_type testlist2 (&values[0] + 3, &values[0] + 5);
values[0].swap_nodes(values[2]);
{ int init_values [] = { 3, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
values[2].swap_nodes(values[4]);
{ int init_values [] = { 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 4, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
}
}
template<class ValueTraits>
void test_list<ValueTraits>
::test_container_from_end(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist1 (&values[0], &values[0] + values.size());
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
}
template<class ValueTraits>
void test_list<ValueTraits>
::test_clone(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef list
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist1 (&values[0], &values[0] + values.size());
list_type testlist2;
testlist2.clone_from(testlist1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
BOOST_TEST (testlist2 == testlist1);
testlist2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testlist2.empty());
}
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
typedef testvalue<VoidPointer, constant_time_size> value_type;
std::vector<value_type> data (5);
for (int i = 0; i < 5; ++i)
data[i].value_ = i + 1;
test_list < typename detail::get_base_value_traits
< value_type
, typename value_type::list_base_hook_t
>::type
>::test_all(data);
test_list < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::list_member_hook_t
, &value_type::list_node_
>
>::type
>::test_all(data);
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
typedef testvalue<VoidPointer, false> value_type;
std::vector<value_type> data (5);
for (int i = 0; i < 5; ++i)
data[i].value_ = i + 1;
test_list < typename detail::get_base_value_traits
< value_type
, typename value_type::list_base_hook_t
>::type
>::test_all(data);
test_list < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::list_member_hook_t
, &value_type::list_node_
>
>::type
>::test_all(data);
/*
test_list<stateful_value_traits
< value_type
, list_node_traits<VoidPointer>
, safe_link>
>::test_all(data);
*/
test_list < typename detail::get_base_value_traits
< value_type
, typename value_type::list_auto_base_hook_t
>::type
>::test_all(data);
test_list < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::list_auto_member_hook_t
, &value_type::list_auto_node_
>
>::type
>::test_all(data);
/*
test_list<stateful_value_traits
< value_type
, list_node_traits<VoidPointer>
, auto_unlink>
>::test_all(data);
*/
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

View File

@@ -0,0 +1,147 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/detail/mpl.hpp>
#include "smart_ptr.hpp"
#include <vector>
using namespace boost::intrusive;
class MyClass
: public make_list_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_slist_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
, public make_unordered_set_base_hook
< void_pointer<smart_ptr<void> >, link_mode<normal_link> >::type
{
int int_;
public:
MyClass(int i)
: int_(i)
{}
friend bool operator<(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
//Define a list that will store MyClass using the public base hook
typedef make_list<MyClass>::type List;
typedef make_slist<MyClass>::type Slist;
typedef make_set<MyClass>::type Set;
typedef make_unordered_set<MyClass>::type USet;
int main()
{
typedef std::vector<MyClass>::iterator VectIt;
typedef std::vector<MyClass>::reverse_iterator VectRit;
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
USet::bucket_type buckets[100];
List my_list;
Slist my_slist;
Set my_set;
USet my_uset(USet::bucket_traits(buckets, 100));
//Now insert them in containers
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_set.insert(*it);
my_uset.insert(*it);
}
//Now test lists
{
List::const_iterator list_it(my_list.cbegin());
Slist::const_iterator slist_it(my_slist.cbegin());
Set::const_reverse_iterator set_rit(my_set.crbegin());
VectRit vect_it(values.rbegin()), vect_itend(values.rend());
//Test the objects inserted in the base hook list
for(; vect_it != vect_itend; ++vect_it, ++list_it, ++slist_it, ++set_rit){
if(&*list_it != &*vect_it) return 1;
if(&*slist_it != &*vect_it) return 1;
if(&*set_rit != &*vect_it) return 1;
if(my_uset.find(*set_rit) == my_uset.cend()) return 1;
}
}
//Check defined types and implicitly defined types are equal
if(detail::is_same<make_list_base_hook<void_pointer<void*>, link_mode<safe_link> >::type
,make_list_base_hook<>::type
>::value == false){
return 1;
}
if(detail::is_same<make_slist_base_hook<void_pointer<void*>, link_mode<safe_link> >::type
,make_slist_base_hook<>::type
>::value == false){
return 1;
}
if(detail::is_same<make_set_base_hook<void_pointer<void*>, link_mode<safe_link> >::type
,make_set_base_hook<>::type
>::value == false){
return 1;
}
if(detail::is_same<make_unordered_set_base_hook<void_pointer<void*>, link_mode<safe_link> >::type
,make_unordered_set_base_hook<>::type
>::value == false){
return 1;
}
//Check defined types and implicitly defined types are unequal
if(detail::is_same<make_list_base_hook<void_pointer<void*>, link_mode<normal_link> >::type
,make_list_base_hook<>::type
>::value == true){
return 1;
}
if(detail::is_same<make_slist_base_hook<void_pointer<void*>, link_mode<normal_link> >::type
,make_slist_base_hook<>::type
>::value == true){
return 1;
}
if(detail::is_same<make_set_base_hook<void_pointer<void*>, link_mode<normal_link> >::type
,make_set_base_hook<>::type
>::value == true){
return 1;
}
if(detail::is_same<make_unordered_set_base_hook<void_pointer<void*>, link_mode<normal_link> >::type
,make_unordered_set_base_hook<>::type
>::value == true){
return 1;
}
return 0;
}

117
test/multiset_test.cpp Normal file
View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_multiset_test.hpp"
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::multiset
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_member_hook_t
, &value_type::set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_member_hook_t
, &value_type::set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_auto_member_hook_t
, &value_type::set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

118
test/set_test.cpp Normal file
View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_set_test.hpp"
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::set
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_member_hook_t
, &value_type::set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_member_hook_t
, &value_type::set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::set_auto_member_hook_t
, &value_type::set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

108
test/sg_multiset_test.cpp Normal file
View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/sg_set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_multiset_test.hpp"
namespace boost { namespace intrusive { namespace test {
template<class T, class O1, class O2, class O3, class O4>
struct has_rebalance<boost::intrusive::sg_multiset<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
}}}
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::sg_multiset
< ValueType
, Option1
, Option2
, Option3
> type;
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainerFixedAlpha
{
typedef boost::intrusive::sg_multiset
< ValueType
, Option1
, Option2
, Option3
, boost::intrusive::floating_point<false>
> type;
};
template<class VoidPointer>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, true> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::bs_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::bs_set_member_hook_t
, &value_type::sg_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::bs_set_base_hook_t
>::type
, GetContainerFixedAlpha
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::bs_set_member_hook_t
, &value_type::sg_set_node_
>
>::type
, GetContainerFixedAlpha
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*>()();
test_main_template<boost::intrusive::smart_ptr<void> >()();
return boost::report_errors();
}

109
test/sg_set_test.cpp Normal file
View File

@@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/sg_set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_set_test.hpp"
namespace boost { namespace intrusive { namespace test {
template<class T, class O1, class O2, class O3, class O4>
struct has_rebalance<boost::intrusive::sg_set<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
}}}
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::sg_set
< ValueType
, Option1
, Option2
, Option3
> type;
};
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainerFixedAlpha
{
typedef boost::intrusive::sg_set
< ValueType
, Option1
, Option2
, Option3
, boost::intrusive::floating_point<false>
> type;
};
template<class VoidPointer>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, true> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::bs_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::bs_set_member_hook_t
, &value_type::sg_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::bs_set_base_hook_t
>::type
, GetContainerFixedAlpha
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::bs_set_member_hook_t
, &value_type::sg_set_node_
>
>::type
, GetContainerFixedAlpha
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*>()();
test_main_template<boost::intrusive::smart_ptr<void> >()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

449
test/slist_test.cpp Normal file
View File

@@ -0,0 +1,449 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "common_functors.hpp"
#include <vector>
#include <boost/detail/lightweight_test.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
using namespace boost::intrusive;
template<class ValueTraits>
struct test_slist
{
typedef typename ValueTraits::value_type value_type;
static void test_all (std::vector<value_type>& values);
static void test_front_back (std::vector<value_type>& values);
static void test_sort(std::vector<value_type>& values);
static void test_merge (std::vector<value_type>& values);
static void test_insert(std::vector<value_type>& values);
static void test_shift(std::vector<value_type>& values);
static void test_swap(std::vector<value_type>& values);
static void test_slow_insert (std::vector<value_type>& values);
static void test_clone (std::vector<value_type>& values);
static void test_container_from_end(std::vector<value_type> &values);
};
template<class ValueTraits>
void test_slist<ValueTraits>
::test_all (std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
{
list_type list(values.begin(), values.end());
test::test_container(list);
list.clear();
list.insert(list.end(), values.begin(), values.end());
test::test_sequence_container(list, values);
}
test_front_back (values);
test_sort(values);
test_merge (values);
test_insert(values);
test_shift(values);
test_slow_insert (values);
test_swap(values);
test_clone(values);
test_container_from_end(values);
}
//test: push_front, pop_front, front, size, empty:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_front_back (std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
BOOST_TEST (testlist.empty());
testlist.push_front (values[0]);
BOOST_TEST (testlist.size() == 1);
BOOST_TEST (&testlist.front() == &values[0]);
testlist.push_front (values[1]);
BOOST_TEST (testlist.size() == 2);
BOOST_TEST (&testlist.front() == &values[1]);
testlist.pop_front();
BOOST_TEST (testlist.size() == 1);
BOOST_TEST (&testlist.front() == &values[0]);
testlist.pop_front();
BOOST_TEST (testlist.empty());
}
//test: merge due to error in merge implementation:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_merge (std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist1, testlist2;
testlist1.push_front (values[0]);
testlist2.push_front (values[4]);
testlist2.push_front (values[3]);
testlist2.push_front (values[2]);
testlist1.merge (testlist2);
int init_values [] = { 1, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() );
}
//test: constructor, iterator, sort, reverse:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_sort(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist (values.begin(), values.end());
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); }
testlist.sort (even_odd());
{ int init_values [] = { 2, 4, 1, 3, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); }
testlist.reverse();
{ int init_values [] = { 5, 3, 1, 4, 2, };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); }
}
//test: assign, insert_after, const_iterator, erase_after, s_iterator_to, previous:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_insert(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
testlist.assign (&values[0] + 2, &values[0] + 5);
const list_type& const_testlist = testlist;
{ int init_values [] = { 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
typename list_type::iterator i = ++testlist.begin();
BOOST_TEST (i->value_ == 4);
testlist.insert_after (i, values[0]);
{ int init_values [] = { 3, 4, 1, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
i = testlist.iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = list_type::s_iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = testlist.previous (i);
BOOST_TEST (&*i == &values[0]);
testlist.erase_after (i);
BOOST_TEST (&*i == &values[0]);
{ int init_values [] = { 3, 4, 1 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
}
//test: insert, const_iterator, erase, siterator_to:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_slow_insert (std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
testlist.push_front (values[4]);
testlist.insert (testlist.begin(), &values[0] + 2, &values[0] + 4);
const list_type& const_testlist = testlist;
{ int init_values [] = { 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
typename list_type::iterator i = ++testlist.begin();
BOOST_TEST (i->value_ == 4);
testlist.insert (i, values[0]);
{ int init_values [] = { 3, 1, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
i = testlist.iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = list_type::s_iterator_to (values[4]);
BOOST_TEST (&*i == &values[4]);
i = testlist.erase (i);
BOOST_TEST (i == testlist.end());
{ int init_values [] = { 3, 1, 4 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); }
testlist.erase (++testlist.begin(), testlist.end());
BOOST_TEST (testlist.size() == 1);
BOOST_TEST (testlist.front().value_ == 3);
}
template<class ValueTraits>
void test_slist<ValueTraits>
::test_shift(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist;
const int num_values = (int)values.size();
std::vector<int> expected_values(num_values);
//Shift forward all possible positions 3 times
for(int i = 0; i < num_values*3; ++i){
testlist.assign(values.begin(), values.end());
testlist.shift_forward(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + num_values - i%num_values) % num_values] = (j + 1);
}
TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin())
testlist.clear();
}
//Shift backwards all possible positions
for(int i = 0; i < num_values*3; ++i){
testlist.assign(values.begin(), values.end());
testlist.shift_backwards(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + i) % num_values] = (j + 1);
}
TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin())
testlist.clear();
}
}
//test: insert_after (seq-version), swap, splice_after:
template<class ValueTraits>
void test_slist<ValueTraits>
::test_swap(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
{
list_type testlist1 (&values[0], &values[0] + 2);
list_type testlist2;
testlist2.insert_after (testlist2.end(), &values[0] + 2, &values[0] + 5);
testlist1.swap(testlist2);
{ int init_values [] = { 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 1, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
testlist2.splice_after (testlist2.begin(), testlist1);
{ int init_values [] = { 1, 3, 4, 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
BOOST_TEST (testlist1.empty());
testlist1.splice_after (testlist1.end(), testlist2, ++testlist2.begin());
{ int init_values [] = { 4 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 1, 3, 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
testlist1.splice_after (testlist1.begin(), testlist2,
testlist2.end(), ++++testlist2.begin());
{ int init_values [] = { 4, 1, 3, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
}
{
list_type testlist1 (&values[0], &values[0] + 2);
list_type testlist2 (&values[0] + 3, &values[0] + 5);
values[0].swap_nodes(values[2]);
{ int init_values [] = { 3, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
values[2].swap_nodes(values[4]);
{ int init_values [] = { 5, 2 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
{ int init_values [] = { 4, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
}
}
template<class ValueTraits>
void test_slist<ValueTraits>
::test_clone(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist1 (&values[0], &values[0] + values.size());
list_type testlist2;
testlist2.clone_from(testlist1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
BOOST_TEST (testlist2 == testlist1);
testlist2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testlist2.empty());
}
template<class ValueTraits>
void test_slist<ValueTraits>
::test_container_from_end(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef slist
< value_type
, value_traits<ValueTraits>
, size_type<std::size_t>
, constant_time_size<value_type::constant_time_size>
> list_type;
list_type testlist1 (&values[0], &values[0] + values.size());
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end()));
BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend()));
}
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
typedef testvalue<VoidPointer, constant_time_size> value_type;
std::vector<value_type> data (5);
for (int i = 0; i < 5; ++i)
data[i].value_ = i + 1;
test_slist < typename detail::get_base_value_traits
< value_type
, typename value_type::slist_base_hook_t
>::type
>::test_all(data);
test_slist < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::slist_member_hook_t
, &value_type::slist_node_
>
>::type
>::test_all(data);
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
typedef testvalue<VoidPointer, false> value_type;
std::vector<value_type> data (5);
for (int i = 0; i < 5; ++i)
data[i].value_ = i + 1;
test_slist < typename detail::get_base_value_traits
< value_type
, typename value_type::slist_base_hook_t
>::type
>::test_all(data);
test_slist < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::slist_member_hook_t
, &value_type::slist_node_
>
>::type
>::test_all(data);
test_slist < typename detail::get_base_value_traits
< value_type
, typename value_type::slist_auto_base_hook_t
>::type
>::test_all(data);
test_slist < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::slist_auto_member_hook_t
, &value_type::slist_auto_node_
>
>::type
>::test_all(data);
return 0;
}
};
int main(int, char* [])
{
test_main_template<void*, false>()();
test_main_template<smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

422
test/smart_ptr.hpp Normal file
View File

@@ -0,0 +1,422 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006. 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.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_SMART_PTR_HPP
#define BOOST_INTRUSIVE_SMART_PTR_HPP
#include <boost/iterator.hpp>
#include <boost/intrusive/pointer_plus_bit.hpp>
#include <boost/intrusive/pointer_plus_2_bits.hpp>
#if (defined _MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
namespace boost{
namespace intrusive{
namespace detail {
struct static_cast_tag {};
struct const_cast_tag {};
struct dynamic_cast_tag {};
struct reinterpret_cast_tag {};
} //namespace detail {
//Empty class
struct empty_type{};
template<class T>
struct random_it
: public boost::iterator<std::random_access_iterator_tag,
T, std::ptrdiff_t, T*, T&>
{
typedef const T* const_pointer;
typedef const T& const_reference;
};
template<> struct random_it<void>
{
typedef const void * const_pointer;
typedef empty_type& reference;
typedef const empty_type& const_reference;
typedef empty_type difference_type;
typedef empty_type iterator_category;
};
template<> struct random_it<const void>
{
typedef const void * const_pointer;
typedef const empty_type & reference;
typedef const empty_type & const_reference;
typedef empty_type difference_type;
typedef empty_type iterator_category;
};
template<> struct random_it<volatile void>
{
typedef const volatile void * const_pointer;
typedef empty_type& reference;
typedef const empty_type& const_reference;
typedef empty_type difference_type;
typedef empty_type iterator_category;
};
template<> struct random_it<const volatile void>
{
typedef const volatile void * const_pointer;
typedef const empty_type & reference;
typedef const empty_type & const_reference;
typedef empty_type difference_type;
typedef empty_type iterator_category;
};
} //namespace intrusive {
} //namespace boost {
namespace boost {
namespace intrusive {
template <class PointedType>
class smart_ptr
{
typedef random_it<PointedType> random_it_t;
typedef smart_ptr<PointedType> self_t;
typedef typename random_it_t::const_pointer const_pointer_t;
typedef typename random_it_t::const_reference const_reference_t;
void unspecified_bool_type_func() const {}
typedef void (self_t::*unspecified_bool_type)() const;
public:
typedef PointedType * pointer;
typedef typename random_it_t::reference reference;
typedef PointedType value_type;
typedef typename random_it_t::difference_type difference_type;
typedef typename random_it_t::iterator_category iterator_category;
PointedType *m_ptr;
public: //Public Functions
//!Constructor from raw pointer (allows "0" pointer conversion). Never throws.
smart_ptr(pointer ptr = 0)
: m_ptr(ptr)
{}
//!Constructor from other pointer. Never throws.
template <class T>
smart_ptr(T *ptr)
: m_ptr(ptr)
{}
//!Constructor from other smart_ptr
smart_ptr(const smart_ptr& ptr)
: m_ptr(ptr.m_ptr)
{}
//!Constructor from other smart_ptr. If pointers of pointee types are
//!convertible, offset_ptrs will be convertibles. Never throws.
template<class T2>
smart_ptr(const smart_ptr<T2> &ptr)
: m_ptr(ptr.m_ptr)
{}
//!Emulates static_cast operator. Never throws.
template<class Y>
smart_ptr(const smart_ptr<Y> & r, detail::static_cast_tag)
: m_ptr(static_cast<PointedType*>(r.get()))
{}
//!Emulates const_cast operator. Never throws.
template<class Y>
smart_ptr(const smart_ptr<Y> & r, detail::const_cast_tag)
: m_ptr(const_cast<PointedType*>(r.get()))
{}
//!Emulates dynamic_cast operator. Never throws.
template<class Y>
smart_ptr(const smart_ptr<Y> & r, detail::dynamic_cast_tag)
: m_ptr(dynamic_cast<PointedType*>(r.get()))
{}
//!Emulates reinterpret_cast operator. Never throws.
template<class Y>
smart_ptr(const smart_ptr<Y> & r, detail::reinterpret_cast_tag)
: m_ptr(reinterpret_cast<PointedType*>(r.get()))
{}
//!Obtains raw pointer from offset. Never throws.
pointer get() const
{ return m_ptr; }
//!Pointer-like -> operator. It can return 0 pointer. Never throws.
pointer operator->() const
{ return this->get(); }
//!Dereferencing operator, if it is a null smart_ptr behavior
//! is undefined. Never throws.
reference operator* () const
{ return *(this->get()); }
//!Indexing operator. Never throws.
reference operator[](std::ptrdiff_t idx) const
{ return this->get()[idx]; }
//!Assignment from pointer (saves extra conversion). Never throws.
smart_ptr& operator= (pointer from)
{ m_ptr = from; return *this; }
//!Assignment from other smart_ptr. Never throws.
smart_ptr& operator= (const smart_ptr & pt)
{ m_ptr = pt.m_ptr; return *this; }
//!Assignment from related smart_ptr. If pointers of pointee types
//! are assignable, offset_ptrs will be assignable. Never throws.
template <class T2>
smart_ptr& operator= (const smart_ptr<T2> & pt)
{ m_ptr = pt.m_ptr; return *this; }
//!smart_ptr + std::ptrdiff_t. Never throws.
smart_ptr operator+ (std::ptrdiff_t offset) const
{ return smart_ptr(this->get()+offset); }
//!smart_ptr - std::ptrdiff_t. Never throws.
smart_ptr operator- (std::ptrdiff_t offset) const
{ return smart_ptr(this->get()-offset); }
//!smart_ptr += std::ptrdiff_t. Never throws.
smart_ptr &operator+= (std::ptrdiff_t offset)
{ m_ptr += offset; return *this; }
//!smart_ptr -= std::ptrdiff_t. Never throws.
smart_ptr &operator-= (std::ptrdiff_t offset)
{ m_ptr -= offset; return *this; }
//!++smart_ptr. Never throws.
smart_ptr& operator++ (void)
{ ++m_ptr; return *this; }
//!smart_ptr++. Never throws.
smart_ptr operator++ (int)
{ smart_ptr temp(*this); ++*this; return temp; }
//!--smart_ptr. Never throws.
smart_ptr& operator-- (void)
{ --m_ptr; return *this; }
//!smart_ptr--. Never throws.
smart_ptr operator-- (int)
{ smart_ptr temp(*this); --*this; return temp; }
//!safe bool conversion operator. Never throws.
operator unspecified_bool_type() const
{ return this->get()? &self_t::unspecified_bool_type_func : 0; }
//!Not operator. Not needed in theory, but improves portability.
//!Never throws.
bool operator! () const
{ return this->get() == 0; }
/*
friend void swap (smart_ptr &pt, smart_ptr &pt2)
{
value_type *ptr = pt.get();
pt = pt2;
pt2 = ptr;
}
*/
};
//!smart_ptr<T1> == smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator== (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() == pt2.get(); }
//!smart_ptr<T1> != smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator!= (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() != pt2.get(); }
//!smart_ptr<T1> < smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator< (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() < pt2.get(); }
//!smart_ptr<T1> <= smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator<= (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() <= pt2.get(); }
//!smart_ptr<T1> > smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator> (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() > pt2.get(); }
//!smart_ptr<T1> >= smart_ptr<T2>. Never throws.
template<class T1, class T2>
inline bool operator>= (const smart_ptr<T1> &pt1,
const smart_ptr<T2> &pt2)
{ return pt1.get() >= pt2.get(); }
//!operator<<
template<class E, class T, class Y>
inline std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, smart_ptr<Y> const & p)
{ return os << p.get(); }
//!operator>>
template<class E, class T, class Y>
inline std::basic_istream<E, T> & operator>>
(std::basic_istream<E, T> & os, smart_ptr<Y> & p)
{ Y * tmp; return os >> tmp; p = tmp; }
//!std::ptrdiff_t + smart_ptr
template<class T>
inline smart_ptr<T> operator+(std::ptrdiff_t diff, const smart_ptr<T>& right)
{ return right + diff; }
//!smart_ptr - smart_ptr
template<class T, class T2>
inline std::ptrdiff_t operator- (const smart_ptr<T> &pt, const smart_ptr<T2> &pt2)
{ return pt.get()- pt2.get(); }
//!swap specialization
template<class T>
inline void swap (smart_ptr<T> &pt,
smart_ptr<T> &pt2)
{
typename smart_ptr<T>::value_type *ptr = pt.get();
pt = pt2;
pt2 = ptr;
}
//!detail::get_pointer() enables boost::mem_fn to recognize smart_ptr.
//!Never throws.
template<class T>
inline T* get_pointer(const smart_ptr<T> & p)
{ return p.get(); }
//!Simulation of static_cast between pointers. Never throws.
template<class T, class U>
inline smart_ptr<T>
static_pointer_cast(smart_ptr<U> const & r)
{
return smart_ptr<T>(r, detail::static_cast_tag());
}
//!Simulation of const_cast between pointers. Never throws.
template<class T, class U>
inline smart_ptr<T>const_pointer_cast(smart_ptr<U> const & r)
{
return smart_ptr<T>(r, detail::const_cast_tag());
}
//!Simulation of dynamic_cast between pointers. Never throws.
template<class T, class U>
inline smart_ptr<T>
dynamic_pointer_cast(smart_ptr<U> const & r)
{
return smart_ptr<T>
(r, detail::dynamic_cast_tag());
}
//!Simulation of reinterpret_cast between pointers. Never throws.
template<class T, class U>
inline smart_ptr<T>
reinterpret_pointer_cast(smart_ptr<U> const & r)
{
return smart_ptr<T>(r, detail::reinterpret_cast_tag());
}
} //namespace intrusive {
} //namespace boost {
namespace boost{
//This is to support embedding a bit in the pointer
//for intrusive containers, saving space
namespace intrusive {
template<std::size_t N>
struct has_pointer_plus_bit<smart_ptr<void>, N>
{
static const bool value = has_pointer_plus_bit<void*, N>::value;
};
//Specialization
template<class T>
struct pointer_plus_bit<smart_ptr<T> >
{
typedef smart_ptr<T> pointer;
static pointer get_pointer(const pointer &n)
{ return pointer_plus_bit<T*>::get_pointer(n.get()); }
static void set_pointer(pointer &n, pointer p)
{
T *raw_n = n.get();
pointer_plus_bit<T*>::set_pointer(raw_n, p.get());
n = raw_n;
}
static bool get_bit(const pointer &n)
{ return pointer_plus_bit<T*>::get_bit(n.get()); }
static void set_bit(pointer &n, bool c)
{
T *raw_n = n.get();
pointer_plus_bit<T*>::set_bit(raw_n, c);
n = raw_n;
}
};
template<std::size_t N>
struct has_pointer_plus_2_bits<smart_ptr<void>, N>
{
static const bool value = has_pointer_plus_2_bits<void*, N>::value;
};
template<class T>
struct pointer_plus_2_bits<smart_ptr<T> >
{
typedef smart_ptr<T> pointer;
static pointer get_pointer(const pointer &n)
{ return pointer_plus_2_bits<T*>::get_pointer(n.get()); }
static void set_pointer(pointer &n, pointer p)
{
T *raw_n = n.get();
pointer_plus_2_bits<T*>::set_pointer(raw_n, p.get());
n = raw_n;
}
static std::size_t get_bits(const pointer &n)
{ return pointer_plus_2_bits<T*>::get_bits(n.get()); }
static void set_bits(pointer &n, std::size_t c)
{
T *raw_n = n.get();
pointer_plus_2_bits<T*>::set_bits(raw_n, c);
n = raw_n;
}
};
} //namespace intrusive
} //namespace boost{
#endif //#ifndef BOOST_INTRUSIVE_SMART_PTR_HPP

View File

@@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/splay_set.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_multiset_test.hpp"
namespace boost { namespace intrusive { namespace test {
template<class T, class O1, class O2, class O3, class O4>
struct has_const_overloads<boost::intrusive::splay_multiset<T, O1, O2, O3, O4> >
{
static const bool value = false;
};
template<class T, class O1, class O2, class O3, class O4>
struct has_splay<boost::intrusive::splay_multiset<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
template<class T, class O1, class O2, class O3, class O4>
struct has_rebalance<boost::intrusive::splay_multiset<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
}}}
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::splay_multiset
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_member_hook_t
, &value_type::splay_set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_member_hook_t
, &value_type::splay_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_auto_member_hook_t
, &value_type::splay_set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}

138
test/splay_set_test.cpp Normal file
View File

@@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/splay_set.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "generic_set_test.hpp"
namespace boost { namespace intrusive { namespace test {
template<class T, class O1, class O2, class O3, class O4>
struct has_const_overloads<boost::intrusive::splay_set<T, O1, O2, O3, O4> >
{
static const bool value = false;
};
template<class T, class O1, class O2, class O3, class O4>
struct has_splay<boost::intrusive::splay_set<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
template<class T, class O1, class O2, class O3, class O4>
struct has_rebalance<boost::intrusive::splay_set<T, O1, O2, O3, O4> >
{
static const bool value = true;
};
}}}
template< class ValueType
, class Option1 = boost::intrusive::none
, class Option2 = boost::intrusive::none
, class Option3 = boost::intrusive::none
>
struct GetContainer
{
typedef boost::intrusive::splay_set
< ValueType
, Option1
, Option2
, Option3
> type;
};
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, constant_time_size> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_member_hook_t
, &value_type::splay_set_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
using namespace boost::intrusive;
typedef testvalue<VoidPointer, false> value_type;
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_member_hook_t
, &value_type::splay_set_node_
>
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_base_value_traits
< value_type
, typename value_type::splay_set_auto_base_hook_t
>::type
, GetContainer
>::test_all();
test::test_generic_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::splay_set_auto_member_hook_t
, &value_type::splay_set_auto_node_
>
>::type
, GetContainer
>::test_all();
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<boost::intrusive::smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<boost::intrusive::smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

View File

@@ -0,0 +1,147 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/functional/hash.hpp>
#include <boost/pointer_to_other.hpp>
#include <vector>
using namespace boost::intrusive;
class MyClass
{
public:
int int_;
MyClass(int i = 0)
: int_(i)
{}
friend bool operator<(const MyClass &l, const MyClass &r)
{ return l.int_ < r.int_; }
friend bool operator==(const MyClass &l, const MyClass &r)
{ return l.int_ == r.int_; }
friend std::size_t hash_value(const MyClass &v)
{ return boost::hash_value(v.int_); }
};
template<class T, class NodeTraits>
struct stateful_value_traits
{
typedef NodeTraits node_traits;
typedef typename node_traits::node node;
typedef typename node_traits::node_ptr node_ptr;
typedef typename node_traits::const_node_ptr const_node_ptr;
typedef T value_type;
typedef typename boost::pointer_to_other
<node_ptr, T>::type pointer;
typedef typename boost::pointer_to_other
<node_ptr, const T>::type const_pointer;
static const link_mode_type link_mode = normal_link;
stateful_value_traits(pointer values, node_ptr node_array)
: values_(values), node_array_(node_array)
{}
node_ptr to_node_ptr (value_type &value)
{ return node_array_ + (&value - values_); }
const_node_ptr to_node_ptr (const value_type &value) const
{ return node_array_ + (&value - values_); }
pointer to_value_ptr(node_ptr n)
{ return values_ + (n - node_array_); }
const_pointer to_value_ptr(const_node_ptr n) const
{ return values_ + (n - node_array_); }
pointer values_;
node_ptr node_array_;
};
//Define a list that will store MyClass using the external hook
typedef stateful_value_traits< MyClass, list_node_traits<void*> > list_traits;
typedef list<MyClass, value_traits<list_traits> > List;
//Define a slist that will store MyClass using the external hook
typedef stateful_value_traits< MyClass, slist_node_traits<void*> > slist_traits;
typedef slist<MyClass, value_traits<slist_traits> > Slist;
//Define a set that will store MyClass using the external hook
typedef stateful_value_traits< MyClass, rbtree_node_traits<void*> > rbtree_traits;
typedef set<MyClass, value_traits<rbtree_traits> > Set;
//uset uses the same traits as slist
typedef unordered_set<MyClass, value_traits<slist_traits> > Uset;
typedef list_traits::node list_node_t;
typedef slist_traits::node slist_node_t;
typedef rbtree_traits::node rbtree_node_t;
const int NumElements = 100;
MyClass values [NumElements];
list_node_t list_hook_array [NumElements];
slist_node_t slist_hook_array [NumElements];
rbtree_node_t rbtree_hook_array [NumElements];
slist_node_t uset_hook_array [NumElements];
int main()
{
//Create several MyClass objects, each one with a different value
for(int i = 0; i < NumElements; ++i)
values[i].int_ = i;
Uset::bucket_type buckets[NumElements];
List my_list (list_traits (values, list_hook_array));
Slist my_slist(slist_traits(values, slist_hook_array));
Set my_set (std::less<MyClass>(), rbtree_traits(values, rbtree_hook_array));
Uset my_uset ( Uset::bucket_traits(buckets, NumElements)
, boost::hash<MyClass>()
, std::equal_to<MyClass>()
, slist_traits(values, uset_hook_array)
);
//Now insert them in containers
for(MyClass * it(&values[0]), *itend(&values[NumElements])
; it != itend
; ++it){
my_list.push_front(*it);
my_slist.push_front(*it);
my_set.insert(*it);
my_uset.insert(*it);
}
//Now test lists
{
List::const_iterator list_it (my_list.cbegin());
Slist::const_iterator slist_it(my_slist.cbegin());
Set::const_reverse_iterator set_rit(my_set.crbegin());
MyClass *it_val(&values[NumElements-1]), *it_rbeg_val(&values[0]-1);
//Test the objects inserted in the base hook list
for(; it_val != it_rbeg_val; --it_val, ++list_it, ++slist_it, ++set_rit){
if(&*list_it != &*it_val) return 1;
if(&*slist_it != &*it_val) return 1;
if(&*set_rit != &*it_val) return 1;
if(my_uset.find(*it_val) == my_uset.cend()) return 1;
}
}
return 0;
}

301
test/test_container.hpp Normal file
View File

@@ -0,0 +1,301 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_TEST_CONTAINER_HPP
#define BOOST_INTRUSIVE_TEST_CONTAINER_HPP
#include <boost/detail/lightweight_test.hpp>
#include <boost/intrusive/detail/mpl.hpp>
namespace boost {
namespace intrusive {
namespace test {
template<class T>
struct has_const_overloads
{
static const bool value = true;
};
template< class Container >
void test_container( Container & c )
{
typedef typename Container::value_type value_type;
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
typedef typename Container::pointer pointer;
typedef typename Container::const_pointer const_pointer;
typedef typename Container::difference_type difference_type;
typedef typename Container::size_type size_type;
typedef typename Container::difference_type difference_type;
typedef typename Container::size_type size_type;
typedef typename Container::value_traits value_traits;
const size_type num_elem = c.size();
BOOST_TEST( c.empty() == (num_elem == 0) );
{
iterator it(c.begin()), itend(c.end());
size_type i;
for(i = 0; i < num_elem; ++i){
++it;
}
BOOST_TEST( it == c.end() );
BOOST_TEST( c.size() == i );
}
//Check iterator conversion
BOOST_TEST( const_iterator(c.begin()) == c.cbegin() );
{
const_iterator it(c.cbegin()), itend(c.cend());
size_type i;
for(i = 0; i < num_elem; ++i){
++it;
}
BOOST_TEST( it == c.cend() );
BOOST_TEST( c.size() == i );
}
}
template< class Container, class Data >
void test_sequence_container(Container & c, Data & d)
{
assert( d.size() > 2 );
c.clear();
BOOST_TEST( c.size() == 0 );
BOOST_TEST( c.empty() );
{
typename Data::iterator i = d.begin();
c.insert( c.begin(), *i );
c.insert( c.end(), *(++i) );
}
BOOST_TEST( c.size() == 2 );
BOOST_TEST( !c.empty() );
c.erase( c.begin() );
BOOST_TEST( c.size() == 1 );
{
typename Data::iterator i = d.begin();
++++i;
c.insert( c.begin(), *(i) );
}
c.erase( c.begin(), c.end() );
BOOST_TEST( c.empty() );
c.insert( c.begin(), *d.begin() );
BOOST_TEST( c.size() == 1 );
BOOST_TEST( c.begin() != c.end() );
c.erase( c.begin() );
c.assign(d.begin(), d.end());
BOOST_TEST( c.size() == d.size() );
c.clear();
BOOST_TEST( c.size() == 0 );
BOOST_TEST( c.empty() );
}
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 );
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);
BOOST_TEST( c.size() == old_size-1 );
BOOST_TEST( c.count(*da) == 0 );
BOOST_TEST( c.count(*db) != 0 );
BOOST_TEST( c.find(*da) == c.end() );
BOOST_TEST( c.find(*db) != c.end() );
BOOST_TEST( c.equal_range(*db).first != c.end() );
c.clear();
BOOST_TEST( c.equal_range(*da).first == c.end() );
}
template< class Container, class Data >
void test_associative_container_invariants(Container & c, Data & d, boost::intrusive::detail::true_type)
{
typedef typename Container::const_iterator const_iterator;
for( typename Data::const_iterator di = d.begin(), de = d.end();
di != de; ++di)
{
const_iterator ci = c.find(*di);
BOOST_TEST( ci != c.end() );
BOOST_TEST( ! c.value_comp()(*ci, *di) );
const_iterator cil = c.lower_bound(*di);
const_iterator ciu = c.upper_bound(*di);
std::pair<const_iterator, const_iterator> er = c.equal_range(*di);
BOOST_TEST( cil == er.first );
BOOST_TEST( ciu == er.second );
if(ciu != c.end()){
BOOST_TEST( c.value_comp()(*cil, *ciu) );
}
if(c.count(*di) > 1){
const_iterator ci_next = cil; ++ci_next;
for( ; ci_next != ciu; ++cil, ++ci_next){
BOOST_TEST( !c.value_comp()(*ci_next, *cil) );
}
}
}
}
template< class Container, class Data >
void test_associative_container_invariants(Container &, Data &, boost::intrusive::detail::false_type)
{}
template< class Container, class Data >
void test_associative_container_invariants(Container & c, Data & d)
{
using namespace boost::intrusive;
typedef typename detail::remove_const<Container>::type Type;
typedef detail::bool_<has_const_overloads<Type>::value> enabler;
test_associative_container_invariants(c, d, enabler());
}
template< class Container, class Data >
void test_associative_container(Container & c, Data & d)
{
typedef typename Container::const_iterator const_iterator;
assert( d.size() > 2 );
c.clear();
c.insert(d.begin(),d.end());
test_associative_container_invariants(c, d);
const Container & cr = c;
test_associative_container_invariants(cr, d);
}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container & c, Data & d, boost::intrusive::detail::true_type)
{
typedef typename Container::size_type size_type;
typedef typename Container::const_iterator const_iterator;
for( typename Data::const_iterator di = d.begin(), de = d.end() ;
di != de ; ++di ){
const_iterator i = c.find(*di);
size_type nb = c.bucket(*i);
size_type bucket_elem = std::distance(c.begin(nb), c.end(nb));
BOOST_TEST( bucket_elem == c.bucket_size(nb) );
BOOST_TEST( &*c.local_iterator_to(*c.find(*di)) == &*i );
std::pair<const_iterator, const_iterator> er = c.equal_range(*di);
size_type cnt = std::distance(er.first, er.second);
BOOST_TEST( cnt == c.count(*di));
if(cnt > 1)
for(const_iterator n = er.first, i = n++, e = er.second; n != e; ++i, ++n){
BOOST_TEST( c.key_eq()(*i, *n) );
BOOST_TEST( c.hash_function()(*i) == c.hash_function()(*n) );
}
}
size_type blen = c.bucket_count();
size_type total_objects = 0;
for(size_type i = 0; i < blen; ++i){
total_objects += c.bucket_size(i);
}
BOOST_TEST( total_objects == c.size() );
}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container &, Data &, boost::intrusive::detail::false_type)
{}
template< class Container, class Data >
void test_unordered_associative_container_invariants(Container & c, Data & d)
{
using namespace boost::intrusive;
typedef typename detail::remove_const<Container>::type Type;
typedef detail::bool_<has_const_overloads<Type>::value> enabler;
test_unordered_associative_container_invariants(c, d, enabler());
}
template< class Container, class Data >
void test_unordered_associative_container(Container & c, Data & d)
{
c.clear();
c.insert( d.begin(), d.end() );
test_unordered_associative_container_invariants(c, d);
const Container & cr = c;
test_unordered_associative_container_invariants(cr, d);
}
template< class Container, class Data >
void test_unique_container(Container & c, Data & d)
{
typedef typename Container::value_type value_type;
c.clear();
c.insert(d.begin(),d.end());
typename Container::size_type old_size = c.size();
value_type v(*d.begin());
c.insert(v);
BOOST_TEST( c.size() == old_size );
c.clear();
}
template< class Container, class Data >
void test_non_unique_container(Container & c, Data & d)
{
typedef typename Container::value_type value_type;
c.clear();
c.insert(d.begin(),d.end());
typename Container::size_type old_size = c.size();
value_type v(*d.begin());
c.insert(v);
BOOST_TEST( c.size() == (old_size+1) );
c.clear();
}
}}}
#endif //#ifndef BOOST_INTRUSIVE_TEST_CONTAINER_HPP

29
test/test_macros.hpp Normal file
View File

@@ -0,0 +1,29 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2007
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
#define BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP
#define TEST_INTRUSIVE_SEQUENCE( INTVALUES, ITERATOR )\
{ \
const int init_values_size = sizeof(INTVALUES)/sizeof(INTVALUES[0]); \
std::vector<int> expected; \
expected.assign(&INTVALUES[0], &INTVALUES[0] + init_values_size); \
BOOST_TEST (std::equal(expected.begin(), expected.end(), ITERATOR) ); \
}
#define TEST_INTRUSIVE_SEQUENCE_EXPECTED( EXPECTEDVECTOR, ITERATOR )\
{ \
BOOST_TEST (std::equal(EXPECTEDVECTOR.begin(), EXPECTEDVECTOR.end(), ITERATOR) ); \
}
#endif

65
test/test_templates.hpp Normal file
View File

@@ -0,0 +1,65 @@
#ifndef BOOST_INTRUSIVE_TEST_TEST_TEMPLATES_HPP
#define BOOST_INTRUSIVE_TEST_TEST_TEMPLATES_HPP
#include <vector>
namespace boost {
namespace intrusive {
namespace test {
template<class Container>
void test_shift()
{
typedef typename ValueTraits::value_type testvalue_t;
boost::test_tools::output_test_stream test_seq;
Container test_cont;
const int NumElem = 6;
std::vector<typename Container::value_type> values(NumElem);
for(int i = 0; i < NumElem; ++i){
values[i] = i+1;
}
const int num_values = (int)values.size();
std::vector<int> expected_values(num_values);
//Shift forward all possible positions 3 times
for(int i = 0; i < num_values*3; ++i){
test_cont.assign(values.begin(), values.end());
test_cont.shift_forward(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + num_values - i%num_values) % num_values] = (j + 1);
}
std::copy (test_cont.begin(), test_cont.end(),
std::ostream_iterator<testvalue_t> (test_seq));
std::stringstream stream;
std::copy (expected_values.begin(), expected_values.end(),
std::ostream_iterator<testvalue_t> (stream));
stream << std::ends;
BOOST_CHECK (test_seq.is_equal (stream.str().c_str()));
test_cont.clear();
}
//Shift backwards all possible positions
for(int i = 0; i < num_values*2; ++i){
test_cont.assign(values.begin(), values.end());
test_cont.shift_backwards(i);
for(int j = 0; j < num_values; ++j){
expected_values[(j + i) % num_values] = (j + 1);
}
std::copy (test_cont.begin(), test_cont.end(),
std::ostream_iterator<testvalue_t> (test_seq));
std::stringstream stream;
std::copy (expected_values.begin(), expected_values.end(),
std::ostream_iterator<testvalue_t> (stream));
stream << std::ends;
BOOST_CHECK (test_seq.is_equal (stream.str().c_str()));
test_cont.clear();
}
}
} //namespace test {
} //namespace intrusive {
} //namespace boost {
#endif //#ifndef BOOST_INTRUSIVE_TEST_TEST_TEMPLATES_HPP

View File

@@ -0,0 +1,445 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "common_functors.hpp"
#include <vector>
#include <set>
#include <boost/detail/lightweight_test.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
using namespace boost::intrusive;
static const std::size_t BucketSize = 11;
template<class ValueTraits>
struct test_unordered_multiset
{
typedef typename ValueTraits::value_type value_type;
static void test_all (std::vector<value_type>& values);
static void test_sort(std::vector<value_type>& values);
static void test_insert(std::vector<value_type>& values);
static void test_swap(std::vector<value_type>& values);
static void test_rehash(std::vector<value_type>& values);
static void test_find(std::vector<value_type>& values);
static void test_impl();
static void test_clone(std::vector<value_type>& values);
};
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_all (std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
{
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets [BucketSize];
unordered_multiset_type testset(bucket_traits(buckets, BucketSize));
testset.insert(values.begin(), values.end());
test::test_container(testset);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_common_unordered_and_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_unordered_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_non_unique_container(testset, values);
}
test_sort(values);
test_insert(values);
test_swap(values);
test_rehash(values);
test_find(values);
test_impl();
test_clone(values);
}
//test case due to an error in tree implementation:
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_impl()
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
std::vector<value_type> values (5);
for (int i = 0; i < 5; ++i)
values[i].value_ = i;
typename unordered_multiset_type::bucket_type buckets [BucketSize];
unordered_multiset_type testset(bucket_traits(buckets, BucketSize));
for (int i = 0; i < 5; ++i)
testset.insert (values[i]);
testset.erase (testset.iterator_to (values[0]));
testset.erase (testset.iterator_to (values[1]));
testset.insert (values[1]);
testset.erase (testset.iterator_to (values[2]));
testset.erase (testset.iterator_to (values[3]));
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_sort(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets [BucketSize];
unordered_multiset_type testset1(values.begin(), values.end(), bucket_traits(buckets, BucketSize));
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.clear();
BOOST_TEST (testset1.empty());
}
//test: insert, const_iterator, const_reverse_iterator, erase, iterator_to:
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_insert(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets [BucketSize];
unordered_multiset_type testset(bucket_traits(buckets, BucketSize));
testset.insert(&values[0] + 2, &values[0] + 5);
const unordered_multiset_type& const_testset = testset;
{ int init_values [] = { 1, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
typename unordered_multiset_type::iterator i = testset.begin();
BOOST_TEST (i->value_ == 1);
i = testset.insert (values[0]);
BOOST_TEST (&*i == &values[0]);
i = testset.iterator_to (values[2]);
BOOST_TEST (&*i == &values[2]);
testset.erase(i);
{ int init_values [] = { 1, 3, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
testset.clear();
testset.insert(&values[0], &values[0] + values.size());
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
BOOST_TEST (testset.erase(1) == 1);
BOOST_TEST (testset.erase(2) == 2);
BOOST_TEST (testset.erase(3) == 1);
BOOST_TEST (testset.erase(4) == 1);
BOOST_TEST (testset.erase(5) == 1);
BOOST_TEST (testset.empty() == true);
//Now with a single bucket
typename unordered_multiset_type::bucket_type single_bucket[1];
unordered_multiset_type testset2(bucket_traits(single_bucket, 1));
testset2.insert(&values[0], &values[0] + values.size());
BOOST_TEST (testset2.erase(5) == 1);
BOOST_TEST (testset2.erase(2) == 2);
BOOST_TEST (testset2.erase(1) == 1);
BOOST_TEST (testset2.erase(4) == 1);
BOOST_TEST (testset2.erase(3) == 1);
BOOST_TEST (testset2.empty() == true);
}
//test: insert (seq-version), swap, erase (seq-version), size:
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_swap(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets [BucketSize];
typename unordered_multiset_type::bucket_type buckets2 [BucketSize];
unordered_multiset_type testset1(&values[0], &values[0] + 2, bucket_traits(buckets, BucketSize));
unordered_multiset_type testset2(bucket_traits(buckets2, BucketSize));
testset2.insert (&values[0] + 2, &values[0] + 6);
testset1.swap (testset2);
{ int init_values [] = { 1, 2, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
{ int init_values [] = { 2, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
BOOST_TEST (testset1.size() == 1);
// BOOST_TEST (&testset1.front() == &values[3]);
BOOST_TEST (&*testset1.begin() == &values[3]);
}
//test: rehash:
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_rehash(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets1 [BucketSize];
typename unordered_multiset_type::bucket_type buckets2 [2];
typename unordered_multiset_type::bucket_type buckets3 [BucketSize*2];
unordered_multiset_type testset1(&values[0], &values[0] + 6, bucket_traits(buckets1, BucketSize));
BOOST_TEST (testset1.size() == 6);
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.rehash(bucket_traits(buckets2, 2));
BOOST_TEST (testset1.size() == 6);
{ int init_values [] = { 4, 2, 2, 5, 3, 1 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
BOOST_TEST (testset1.size() == 6);
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
//Now rehash reducing the buckets
testset1.rehash(bucket_traits(buckets3, 2));
BOOST_TEST (testset1.size() == 6);
{ int init_values [] = { 4, 2, 2, 5, 3, 1 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
//Now rehash increasing the buckets
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
BOOST_TEST (testset1.size() == 6);
{ int init_values [] = { 1, 2, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
}
//test: find, equal_range (lower_bound, upper_bound):
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>::test_find(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
typename unordered_multiset_type::bucket_type buckets[BucketSize];
unordered_multiset_type testset(values.begin(), values.end(), bucket_traits(buckets, BucketSize));
typedef typename unordered_multiset_type::iterator iterator;
value_type cmp_val;
cmp_val.value_ = 2;
iterator i = testset.find (cmp_val);
BOOST_TEST (i->value_ == 2);
BOOST_TEST ((++i)->value_ == 2);
std::pair<iterator,iterator> range = testset.equal_range (cmp_val);
BOOST_TEST (range.first->value_ == 2);
BOOST_TEST (range.second->value_ == 3);
BOOST_TEST (std::distance (range.first, range.second) == 2);
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
template<class ValueTraits>
void test_unordered_multiset<ValueTraits>
::test_clone(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_multiset
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_multiset_type;
typedef typename unordered_multiset_type::bucket_traits bucket_traits;
{
//Test with equal bucket arrays
typename unordered_multiset_type::bucket_type buckets1 [BucketSize];
typename unordered_multiset_type::bucket_type buckets2 [BucketSize];
unordered_multiset_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize));
unordered_multiset_type testset2 (bucket_traits(buckets2, BucketSize));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::multiset<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::multiset<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
{
//Test with bigger source bucket arrays
typename unordered_multiset_type::bucket_type buckets1 [BucketSize*2];
typename unordered_multiset_type::bucket_type buckets2 [BucketSize];
unordered_multiset_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize*2));
unordered_multiset_type testset2 (bucket_traits(buckets2, BucketSize));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::multiset<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::multiset<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
{
//Test with smaller source bucket arrays
typename unordered_multiset_type::bucket_type buckets1 [BucketSize];
typename unordered_multiset_type::bucket_type buckets2 [BucketSize*2];
unordered_multiset_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize));
unordered_multiset_type testset2 (bucket_traits(buckets2, BucketSize*2));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::multiset<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::multiset<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
}
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
typedef testvalue<VoidPointer, constant_time_size> value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<testvalue<VoidPointer, constant_time_size> > data (6);
for (int i = 0; i < 6; ++i)
data[i].value_ = random_init[i];
test_unordered_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_base_hook_t
>::type
>::test_all(data);
test_unordered_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_member_hook_t
, &value_type::unordered_set_node_
>
>::type
>::test_all(data);
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
typedef testvalue<VoidPointer, false> value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<testvalue<VoidPointer, false> > data (6);
for (int i = 0; i < 6; ++i)
data[i].value_ = random_init[i];
test_unordered_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_base_hook_t
>::type
>::test_all(data);
test_unordered_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_member_hook_t
, &value_type::unordered_set_node_
>
>::type
>::test_all(data);
test_unordered_multiset < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_auto_base_hook_t
>::type
>::test_all(data);
test_unordered_multiset < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_auto_member_hook_t
, &value_type::unordered_set_auto_node_
>
>::type
>::test_all(data);
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

417
test/unordered_set_test.cpp Normal file
View File

@@ -0,0 +1,417 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Olaf Krzikalla 2004-2006.
// (C) Copyright Ion Gaztanaga 2006-2007.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include "itestvalue.hpp"
#include "smart_ptr.hpp"
#include "common_functors.hpp"
#include <vector>
#include <set>
#include <boost/detail/lightweight_test.hpp>
#include "test_macros.hpp"
#include "test_container.hpp"
using namespace boost::intrusive;
static const std::size_t BucketSize = 11;
template<class ValueTraits>
struct test_unordered_set
{
typedef typename ValueTraits::value_type value_type;
static void test_all(std::vector<value_type>& values);
static void test_sort(std::vector<value_type>& values);
static void test_insert(std::vector<value_type>& values);
static void test_swap(std::vector<value_type>& values);
static void test_rehash(std::vector<value_type>& values);
static void test_find(std::vector<value_type>& values);
static void test_impl();
static void test_clone(std::vector<value_type>& values);
};
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_all(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
{
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset(bucket_traits(buckets, BucketSize));
testset.insert(values.begin(), values.end());
test::test_container(testset);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_common_unordered_and_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_unordered_associative_container(testset, values);
testset.clear();
testset.insert(values.begin(), values.end());
test::test_unique_container(testset, values);
}
test_sort(values);
test_insert(values);
test_swap(values);
test_rehash(values);
test_find(values);
test_impl();
test_clone(values);
}
//test case due to an error in tree implementation:
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_impl()
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
std::vector<value_type> values (5);
for (int i = 0; i < 5; ++i)
values[i].value_ = i;
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset(bucket_traits(buckets, BucketSize));
for (int i = 0; i < 5; ++i)
testset.insert (values[i]);
testset.erase (testset.iterator_to (values[0]));
testset.erase (testset.iterator_to (values[1]));
testset.insert (values[1]);
testset.erase (testset.iterator_to (values[2]));
testset.erase (testset.iterator_to (values[3]));
}
//test: constructor, iterator, clear, reverse_iterator, front, back, size:
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_sort(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset1(values.begin(), values.end(), bucket_traits(buckets, BucketSize));
BOOST_TEST (5 == std::distance(testset1.begin(), testset1.end()));
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.clear();
BOOST_TEST (testset1.empty());
}
//test: insert, const_iterator, const_reverse_iterator, erase, iterator_to:
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_insert(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset(bucket_traits(buckets, BucketSize));
testset.insert(&values[0] + 2, &values[0] + 5);
const unordered_set_type& const_testset = testset;
{ int init_values [] = { 1, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
typename unordered_set_type::iterator i = testset.begin();
BOOST_TEST (i->value_ == 1);
i = testset.insert(values[0]).first;
BOOST_TEST (&*i == &values[0]);
i = testset.iterator_to (values[2]);
BOOST_TEST (&*i == &values[2]);
testset.erase (i);
{ int init_values [] = { 1, 3, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); }
}
//test: insert (seq-version), swap, erase (seq-version), size:
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_swap(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typename unordered_set_type::bucket_type buckets1 [BucketSize];
typename unordered_set_type::bucket_type buckets2 [BucketSize];
unordered_set_type testset1(&values[0], &values[0] + 2, bucket_traits(buckets1, BucketSize));
unordered_set_type testset2(bucket_traits(buckets2, BucketSize));
testset2.insert (&values[0] + 2, &values[0] + 6);
testset1.swap (testset2);
{ int init_values [] = { 1, 2, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
{ int init_values [] = { 2, 3 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); }
testset1.erase (testset1.iterator_to(values[5]), testset1.end());
BOOST_TEST (testset1.size() == 1);
// BOOST_TEST (&testset1.front() == &values[3]);
BOOST_TEST (&*testset1.begin() == &values[3]);
}
//test: rehash:
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_rehash(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typename unordered_set_type::bucket_type buckets1 [BucketSize];
typename unordered_set_type::bucket_type buckets2 [2];
typename unordered_set_type::bucket_type buckets3 [BucketSize*2];
unordered_set_type testset1(&values[0], &values[0] + 6, bucket_traits(buckets1, BucketSize));
BOOST_TEST (testset1.size() == 5);
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.rehash(bucket_traits(buckets2, 2));
BOOST_TEST (testset1.size() == 5);
{ int init_values [] = { 4, 2, 5, 3, 1 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
BOOST_TEST (testset1.size() == 5);
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
//Now rehash reducing the buckets
testset1.rehash(bucket_traits(buckets3, 2));
BOOST_TEST (testset1.size() == 5);
{ int init_values [] = { 4, 2, 5, 3, 1 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
//Now rehash increasing the buckets
testset1.rehash(bucket_traits(buckets3, BucketSize*2));
BOOST_TEST (testset1.size() == 5);
{ int init_values [] = { 1, 2, 3, 4, 5 };
TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); }
}
//test: find, equal_range (lower_bound, upper_bound):
template<class ValueTraits>
void test_unordered_set<ValueTraits>::test_find(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset (values.begin(), values.end(), bucket_traits(buckets, BucketSize));
typedef typename unordered_set_type::iterator iterator;
value_type cmp_val;
cmp_val.value_ = 2;
iterator i = testset.find (cmp_val);
BOOST_TEST (i->value_ == 2);
BOOST_TEST ((++i)->value_ != 2);
std::pair<iterator,iterator> range = testset.equal_range (cmp_val);
BOOST_TEST (range.first->value_ == 2);
BOOST_TEST (range.second->value_ == 3);
BOOST_TEST (std::distance (range.first, range.second) == 1);
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
template<class ValueTraits>
void test_unordered_set<ValueTraits>
::test_clone(std::vector<typename ValueTraits::value_type>& values)
{
typedef typename ValueTraits::value_type value_type;
typedef unordered_set
<value_type
, value_traits<ValueTraits>
, constant_time_size<value_type::constant_time_size>
> unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
{
//Test with equal bucket arrays
typename unordered_set_type::bucket_type buckets1 [BucketSize];
typename unordered_set_type::bucket_type buckets2 [BucketSize];
unordered_set_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize));
unordered_set_type testset2 (bucket_traits(buckets2, BucketSize));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::set<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::set<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
{
//Test with bigger source bucket arrays
typename unordered_set_type::bucket_type buckets1 [BucketSize*2];
typename unordered_set_type::bucket_type buckets2 [BucketSize];
unordered_set_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize*2));
unordered_set_type testset2 (bucket_traits(buckets2, BucketSize));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::set<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::set<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
{
//Test with smaller source bucket arrays
typename unordered_set_type::bucket_type buckets1 [BucketSize];
typename unordered_set_type::bucket_type buckets2 [BucketSize*2];
unordered_set_type testset1 (values.begin(), values.end(), bucket_traits(buckets1, BucketSize));
unordered_set_type testset2 (bucket_traits(buckets2, BucketSize*2));
testset2.clone_from(testset1, test::new_cloner<value_type>(), test::delete_disposer<value_type>());
//Ordering is not guarantee in the cloning so insert data in a set and test
std::set<typename ValueTraits::value_type>
src(testset1.begin(), testset1.end());
std::set<typename ValueTraits::value_type>
dst(testset2.begin(), testset2.end());
BOOST_TEST (src.size() == dst.size() && std::equal(src.begin(), src.end(), dst.begin()));
testset2.clear_and_dispose(test::delete_disposer<value_type>());
BOOST_TEST (testset2.empty());
}
}
template<class VoidPointer, bool constant_time_size>
class test_main_template
{
public:
int operator()()
{
typedef testvalue<VoidPointer, constant_time_size> value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<testvalue<VoidPointer, constant_time_size> > data (6);
for (int i = 0; i < 6; ++i)
data[i].value_ = random_init[i];
test_unordered_set < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_base_hook_t
>::type
>::test_all(data);
test_unordered_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_member_hook_t
, &value_type::unordered_set_node_
>
>::type
>::test_all(data);
return 0;
}
};
template<class VoidPointer>
class test_main_template<VoidPointer, false>
{
public:
int operator()()
{
typedef testvalue<VoidPointer, false> value_type;
static const int random_init[6] = { 3, 2, 4, 1, 5, 2 };
std::vector<testvalue<VoidPointer, false> > data (6);
for (int i = 0; i < 6; ++i)
data[i].value_ = random_init[i];
test_unordered_set < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_base_hook_t
>::type
>::test_all(data);
test_unordered_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_member_hook_t
, &value_type::unordered_set_node_
>
>::type
>::test_all(data);
test_unordered_set < typename detail::get_base_value_traits
< value_type
, typename value_type::unordered_set_auto_base_hook_t
>::type
>::test_all(data);
test_unordered_set < typename detail::get_member_value_traits
< value_type
, member_hook< value_type
, typename value_type::unordered_set_auto_member_hook_t
, &value_type::unordered_set_auto_node_
>
>::type
>::test_all(data);
return 0;
}
};
int main( int, char* [] )
{
test_main_template<void*, false>()();
test_main_template<smart_ptr<void>, false>()();
test_main_template<void*, true>()();
test_main_template<smart_ptr<void>, true>()();
return boost::report_errors();
}
#include <boost/intrusive/detail/config_end.hpp>

Some files were not shown because too many files have changed in this diff Show More