[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [computer-go] space efficiency in C++
> I'm using C++, and I have a class: tree, that contains a member object
> list<tree *> children. I think I do want a list here, because I do a
> lot of deleting individual elements. ...
> the lists of children are typically quite short,
> often one or two elements.
Maybe std::vector<tree*> is going to be better, perhaps with reserve(2)
or reserve(4) on creation. I.e. save memory, pay extra for deletions.
Or you could get fancy and use a fixed size array for the first 2-4
elements, and create a list or vector when more than 4 children. But I
wouldn't begin that unless I had a realistic usage test to do timing
tests with.
Darren
_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://www.computer-go.org/mailman/listinfo/computer-go/