| 1 | #include <memory>
|
|---|
| 2 | #include <boost/intrusive/unordered_set.hpp>
|
|---|
| 3 |
|
|---|
| 4 | namespace bi=boost::intrusive;
|
|---|
| 5 |
|
|---|
| 6 | class Item : public bi::unordered_set_base_hook<bi::link_mode<bi::safe_link>>
|
|---|
| 7 | {
|
|---|
| 8 |
|
|---|
| 9 | public:
|
|---|
| 10 | struct hash
|
|---|
| 11 | {
|
|---|
| 12 | size_t operator()(const Item &s) const
|
|---|
| 13 | {
|
|---|
| 14 | return /* ... */ 0;
|
|---|
| 15 | }
|
|---|
| 16 | };
|
|---|
| 17 | };
|
|---|
| 18 |
|
|---|
| 19 | void main()
|
|---|
| 20 | {
|
|---|
| 21 | typedef bi::unordered_set<
|
|---|
| 22 | Item,
|
|---|
| 23 | bi::constant_time_size<false>,
|
|---|
| 24 | bi::hash<Item::hash>
|
|---|
| 25 | > map_type;
|
|---|
| 26 |
|
|---|
| 27 | std::unique_ptr<map_type::bucket_type[]> buckets;
|
|---|
| 28 | std::unique_ptr<map_type> set;
|
|---|
| 29 | buckets.reset(new map_type::bucket_type[50]);
|
|---|
| 30 | set.reset(new map_type(map_type::bucket_traits(buckets.get(),50)));
|
|---|
| 31 |
|
|---|
| 32 | // ... use the set
|
|---|
| 33 |
|
|---|
| 34 | set->clear_and_dispose([](Item *ptr) { delete ptr; });
|
|---|
| 35 | }
|
|---|