1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2013-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/container for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 //[doc_custom_tree
11 #include <boost/container/set.hpp>
12
13 //Make sure assertions are active
14 #ifdef NDEBUG
15 #undef NDEBUG
16 #endif
17 #include <cassert>
18
main()19 int main ()
20 {
21 using namespace boost::container;
22
23 //First define several options
24 //
25
26 //This option specifies an AVL tree based associative container
27 typedef tree_assoc_options< tree_type<avl_tree> >::type AVLTree;
28
29 //This option specifies an AVL tree based associative container
30 //disabling node size optimization.
31 typedef tree_assoc_options< tree_type<avl_tree>
32 , optimize_size<false> >::type AVLTreeNoSizeOpt;
33
34 //This option specifies an Splay tree based associative container
35 typedef tree_assoc_options< tree_type<splay_tree> >::type SplayTree;
36
37 //Now define new tree-based associative containers
38 //
39
40 //AVLTree based set container
41 typedef set<int, std::less<int>, new_allocator<int>, AVLTree> AvlSet;
42
43 //AVLTree based set container without size optimization
44 typedef set<int, std::less<int>, new_allocator<int>, AVLTreeNoSizeOpt> AvlSetNoSizeOpt;
45
46 //Splay tree based multiset container
47 typedef multiset<int, std::less<int>, new_allocator<int>, SplayTree> SplayMultiset;
48
49 //Use them
50 //
51 AvlSet avl_set;
52 avl_set.insert(0);
53 assert(avl_set.find(0) != avl_set.end());
54
55 AvlSetNoSizeOpt avl_set_no_szopt;
56 avl_set_no_szopt.insert(1);
57 avl_set_no_szopt.insert(1);
58 assert(avl_set_no_szopt.count(1) == 1);
59
60 SplayMultiset splay_mset;
61 splay_mset.insert(2);
62 splay_mset.insert(2);
63 assert(splay_mset.count(2) == 2);
64 return 0;
65 }
66 //]
67