1 | #include <boost/intrusive/avl_set.hpp>
|
---|
2 |
|
---|
3 | typedef void *Type;
|
---|
4 |
|
---|
5 | struct EntryType {
|
---|
6 | EntryType(Type id) : id(id) {}
|
---|
7 | Type id;
|
---|
8 | typedef boost::intrusive::avl_set_member_hook <> AvlHook;
|
---|
9 | AvlHook avl_by_id_hook;
|
---|
10 | struct CompareById {
|
---|
11 | bool operator()(const EntryType &a,const EntryType &b) const
|
---|
12 | {return (a.id < b.id);}
|
---|
13 | };
|
---|
14 | struct KeyCompareById {
|
---|
15 | bool operator()(const Type &id,const EntryType &b) const
|
---|
16 | {return (id < b.id);}
|
---|
17 | bool operator()(const EntryType &a,const Type &id) const
|
---|
18 | {return (a.id < id);}
|
---|
19 | };
|
---|
20 | };
|
---|
21 |
|
---|
22 | typedef boost::intrusive::avl_set<
|
---|
23 | EntryType,
|
---|
24 | boost::intrusive::member_hook<
|
---|
25 | EntryType,
|
---|
26 | EntryType::AvlHook,
|
---|
27 | &EntryType::avl_by_id_hook
|
---|
28 | >,
|
---|
29 | boost::intrusive::compare<EntryType::CompareById>
|
---|
30 | > SetById;
|
---|
31 |
|
---|
32 | void foo(SetById &s,const Type &x) {
|
---|
33 | s.find(x,EntryType::KeyCompareById());
|
---|
34 | }
|
---|
35 |
|
---|