SLAQ - Stack, List, Array, Queue
Sound it out -- C++ Slaq - Slack -- Easy
Unfortunatly the list and queue have not been included, but the abstract SLAQ class has been included with two derives, Stack and Array. The List is a managed list which uses a stack of free_id's to allow very quick insertion, in fact up to the 50,000 index mark it is incredibly fast it is due to this fact I have not included it.
The app_Main.cpp includes a small benchmark which runs a console app, asks the allocation size and does a comparison: Hals Array VS std::vector. It compares the alike push_backs functions and plain assigments.
On my computer the assigment match ties at exactly 20 indices. Anything less than 20 and vector seems to win, anything above 20 and my array seems to make very large jumps. The push_back match acts much the same except they seem to stay pretty close even though mine does jump ahead.
Unfortunetly, a RELEASE mode compile completly changes everything -- the assigment match will almost ALWAYS be won by Hals Dynamic Array, where on the other hand the push_back() match will always been won by vector.
A last note, this is not even close to version 1.0 of this release and it is really meant for games. In fact the managed list, in release mode, can process 50,000 push's faster than anything I've seen, but it is a list method where you do not need to know the precise location of your members (a unit pool for example). The library will eventually be out for full release and I hope to get that release mode push_back to fight harder. Most of this stuff is pretty basic, but it does show a use of complex memory managment combining both some C and C++ functions.
Thanks for downloading, please leave you comments.
If you wish to incorporate any of this code then just allow me the honor of knowing where it is being used and by who otherwise I have no objections.
Halsafar
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Not necessary but it initializes all indices to 0.
If memcpy does it faster then beautiful.
I noticed a big difference from your to mine was the fact I used malloc and realloc. You use new and had to temp the array, create a new array, copy the old, delete the old. This is all elimated with realloc.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
What do you mean constructors/destructors which require new??
I have found that malloc and new --- free and delete are pretty well the exact same and can be used in any situation. It is usually a point of preference -- also if you need to resize a lot without data loss then malloc/realloc is your BEST choice.
Just never mix a malloc allocation with delete
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama