Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- struct X : public boost::intrusive::set_base_hook<boost::intrusive::store_hash<true> >
- {
- X(T x) : _x{x} { }
- T _x;
- std::ostream& operator<<( std::ostream& os) const
- {
- os << _x;
- return os;
- }
- bool operator<(const X& rhs) const { return _x < rhs._x; }
- bool operator>(const X& rhs) const { return _x > rhs._x; }
- bool operator==(const X& rhs) const { return _x == rhs._x; }
- };
- void __fastcall TTestForm::Button1Click(TObject *Sender)
- {
- std::vector<X<double>> list;
- for(int i=0;i<10000;i++)
- {
- X<double> x(i);
- list.push_back(x);
- }
- boost::intrusive::rbtree< X<double> > tree;
- tree.insert_unique(list.begin(),list.end());
- boost::intrusive::rbtree< X<double> >::iterator loit = tree.lower_bound(X<double>(10));
- boost::intrusive::rbtree< X<double> >::iterator upit = tree.upper_bound(X<double>(13));
- boost::intrusive::rbtree< X<double> >::iterator it;
- for(it = loit;it!=upit;++it)
- {
- Memo1->Lines->Add((*it)._x);
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement