Brian Silverman | fad8f55 | 2018-08-04 23:36:19 -0700 | [diff] [blame^] | 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 | #include <boost/container/detail/config_begin.hpp> |
| 11 | #include <boost/container/detail/workaround.hpp> |
| 12 | //[doc_custom_tree |
| 13 | #include <boost/container/set.hpp> |
| 14 | |
| 15 | //Make sure assertions are active |
| 16 | #ifdef NDEBUG |
| 17 | #undef NDEBUG |
| 18 | #endif |
| 19 | #include <cassert> |
| 20 | |
| 21 | int main () |
| 22 | { |
| 23 | using namespace boost::container; |
| 24 | |
| 25 | //First define several options |
| 26 | // |
| 27 | |
| 28 | //This option specifies an AVL tree based associative container |
| 29 | typedef tree_assoc_options< tree_type<avl_tree> >::type AVLTree; |
| 30 | |
| 31 | //This option specifies an AVL tree based associative container |
| 32 | //disabling node size optimization. |
| 33 | typedef tree_assoc_options< tree_type<avl_tree> |
| 34 | , optimize_size<false> >::type AVLTreeNoSizeOpt; |
| 35 | |
| 36 | //This option specifies an Splay tree based associative container |
| 37 | typedef tree_assoc_options< tree_type<splay_tree> >::type SplayTree; |
| 38 | |
| 39 | //Now define new tree-based associative containers |
| 40 | // |
| 41 | |
| 42 | //AVLTree based set container |
| 43 | typedef set<int, std::less<int>, std::allocator<int>, AVLTree> AvlSet; |
| 44 | |
| 45 | //AVLTree based set container without size optimization |
| 46 | typedef set<int, std::less<int>, std::allocator<int>, AVLTreeNoSizeOpt> AvlSetNoSizeOpt; |
| 47 | |
| 48 | //Splay tree based multiset container |
| 49 | typedef multiset<int, std::less<int>, std::allocator<int>, SplayTree> SplayMultiset; |
| 50 | |
| 51 | //Use them |
| 52 | // |
| 53 | AvlSet avl_set; |
| 54 | avl_set.insert(0); |
| 55 | assert(avl_set.find(0) != avl_set.end()); |
| 56 | |
| 57 | AvlSetNoSizeOpt avl_set_no_szopt; |
| 58 | avl_set_no_szopt.insert(1); |
| 59 | avl_set_no_szopt.insert(1); |
| 60 | assert(avl_set_no_szopt.count(1) == 1); |
| 61 | |
| 62 | SplayMultiset splay_mset; |
| 63 | splay_mset.insert(2); |
| 64 | splay_mset.insert(2); |
| 65 | assert(splay_mset.count(2) == 2); |
| 66 | return 0; |
| 67 | } |
| 68 | //] |
| 69 | #include <boost/container/detail/config_end.hpp> |