|
-
June 15th, 2008, 10:28 AM
#1
boost::intrusive without using a vector?
Hello,
I am trying to implement the scapegoat tree provided by the boost::intrusive library, and in the example code, it first inserts the object into a vector and then into the scapegoat tree. Specifically, I am looking at the following part (modified some just to show the parts that I would be using):
Code:
typedef sg_set
< MyClass, compare<std::greater<MyClass> >, floating_point<false> > BaseSet;
typedef std::vector<MyClass>::iterator VectIt;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i));
BaseSet baseset;
//Now insert them in the reverse order in the base hook sg_set
for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it){
baseset.insert(*it);
}
In this code, it inserts an iterator in the scapegoat (baseset). What if I don't want to create the vector first? Is it possible to create a one object iterator? I don't want to create the vector first because I already have the object ready to go and be inserted, I figure that it is wasted storage/cpu cycles to first insert into a vector if the only purpose of that vector is then to be inserted into a different list.
Thanks,
Justin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|