Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > new/delete vs. ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 44720 of 48022
Post > Topic >>

new/delete vs. vector implementing n-ary tree

by nandor.sieben@[EMAIL PROTECTED] Apr 13, 2008 at 04:47 PM

I am using a small set of functions that implements an n-ary tree. The
library is disscusses here:

http://groups.google.com/group/comp.lang.c++/browse_thread/thread/35450795fb41b047/8d274ef3f22fdb90?lnk=gst&q=sieben#8d274ef3f22fdb90

The nodes of the tree are cretaed and erased by new and delete. I just
read in Modern C++ Design that new/delete can be very inefficient. I
am using this library to search in game trees so I do create and erase
a lot of nodes. Would I be better of by creating a large vector
containing nodes and use this vector to store my tree nodes. Instead
of pointers I could use indices. The unused nodes would be linked
together for easy access and used only when a new node is needed. This
would avoid the use of new/delete. The only drawback is that the
memory is allocated even when it's not used, but this is not really an
issue for my application.

Should I expect a significant gain in performance from this?
 




 6 Posts in Topic:
new/delete vs. vector implementing n-ary tree
nandor.sieben@[EMAIL PROT  2008-04-13 16:47:32 
Re: new/delete vs. vector implementing n-ary tree
Kai-Uwe Bux <jkherciue  2008-04-13 20:40:40 
Re: new/delete vs. vector implementing n-ary tree
Razii <DONTwhatevere3e  2008-04-13 19:41:29 
Re: new/delete vs. vector implementing n-ary tree
nandor.sieben@[EMAIL PROT  2008-04-13 17:52:34 
Re: new/delete vs. vector implementing n-ary tree
Ian Collins <ian-news@  2008-04-14 13:00:30 
Re: new/delete vs. vector implementing n-ary tree
"Bo Persson" &l  2008-04-14 17:54:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:43:38 CDT 2008.