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 | |
11 | //[doc_extended_allocators |
12 | #include <boost/container/vector.hpp> |
13 | #include <boost/container/flat_set.hpp> |
14 | #include <boost/container/list.hpp> |
15 | #include <boost/container/set.hpp> |
16 | |
17 | //"allocator" is a general purpose allocator that can reallocate |
18 | //memory, something useful for vector and flat associative containers |
19 | #include <boost/container/allocator.hpp> |
20 | |
21 | //"adaptive_pool" is a node allocator, specially suited for |
22 | //node-based containers |
23 | #include <boost/container/adaptive_pool.hpp> |
24 | |
25 | int main () |
26 | { |
27 | using namespace boost::container; |
28 | |
29 | //A vector that can reallocate memory to implement faster insertions |
30 | vector<int, allocator<int> > extended_alloc_vector; |
31 | |
32 | //A flat set that can reallocate memory to implement faster insertions |
33 | flat_set<int, std::less<int>, allocator<int> > extended_alloc_flat_set; |
34 | |
35 | //A list that can manages nodes to implement faster |
36 | //range insertions and deletions |
37 | list<int, adaptive_pool<int> > extended_alloc_list; |
38 | |
39 | //A set that can recycle nodes to implement faster |
40 | //range insertions and deletions |
41 | set<int, std::less<int>, adaptive_pool<int> > extended_alloc_set; |
42 | |
43 | //Now user them as always |
44 | extended_alloc_vector.push_back(x: 0); |
45 | extended_alloc_flat_set.insert(x: 0); |
46 | extended_alloc_list.push_back(x: 0); |
47 | extended_alloc_set.insert(x: 0); |
48 | |
49 | //... |
50 | return 0; |
51 | } |
52 | //] |
53 |