Hey
Just starting to look at doing this replacement. And thinking this could
change alot if we move to vector.h
I see in mysys/my_list.h && mysys/list.cc
The List is treated like a stack as:
LIST *list_add(LIST *root, LIST *element)
{
if (root)
{
if (root->prev) /* If add in mid of list */
root->prev->next= element;
element->prev=root->prev;
root->prev=element;
}
else
element->prev=0;
element->next=root;
return(element); /* New root */
}
I see we return element the thing you want to add as the new root of the
LIST and root becomes the next link. So does this mean you treat the
list more like a stack? like stack.push?
So like i started with like to see if i could make a little changes to
the code with:
typedef vector<void*> LIST;
And then just work things around it. But playing around with vector:
vector<const void*> mylist;
//would be like list_add(LIST,item)
mylist.push_back("test");
mylist.push_back("test2");
int i;
for(i=0;i<mylist.size(); ++i)
printf("vector: %i - %s\n",i, (char*)mylist[i])
I dont see a vector.push but just vector.push_back().
So this could mess up everyones code. But if i use stl stack it works
but it isnt so easy to access the members of the vector because you have
to just pop() them and you dont get them back as it doesnt return anything.
stack<const void*> list;
list.push("first");
list.push("second");
list.push("third");
printf("Stack size: %i\n",list.size());
while( !list.empty() ) {
printf("Stack %s\n",(char*) list.top());
list.pop();
}
But i guess if you used vector, but just reversed it each time. It maby
be ok but just could be slower? Hmm i am not 100% sure if i got this all
right. I usualy just make my own structs :) in c so i dont use the
container classes in c++ that often
Just wondering what do you recomend i do?
-Phil
http://redbrain.co.uk
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp