Torque and (STL) Container,... classes
by Stefan Beffy Moises · in Torque Game Engine · 07/06/2002 (3:58 am) · 10 replies
I've read that Torque and STL won't work together, so my question is: does Torque have alternative classes, e.g. Map, HashMap/HashTable, Vector, etc.?
If not (and I think it doesn't have them after searching through the Project files), does anybody know an open source, cross platform library providing such base classes, especially a Map/HashMap which could be used with Torque?
thanks! :-)
If not (and I think it doesn't have them after searching through the Project files), does anybody know an open source, cross platform library providing such base classes, especially a Map/HashMap which could be used with Torque?
thanks! :-)
About the author
#2
Should I really have to write all these base classes myself? Or find some free, cross-platform lib somewhere else? I found a free hash_map which seems to work, but now I need a List, too... and I'm sure it won't be the last container I need... :-(
Can anybody think of a way to get Torque running with STL?
07/06/2002 (4:52 am)
Hmmm... how about a List?Should I really have to write all these base classes myself? Or find some free, cross-platform lib somewhere else? I found a free hash_map which seems to work, but now I need a List, too... and I'm sure it won't be the last container I need... :-(
Can anybody think of a way to get Torque running with STL?
#3
Torque does not have a complete suite of STL-style routines but it does have plenty of support for most 'game' cases.
You've got a Linked-List, Dynamic Vector (inc. bit vectors) and various forms of Hash-Tables like the StringTable. These cover most gaming uses I would of thought.
There is also a 'HuffmanProcessor' which is really helpful for many situations where you want to encode data streams into tokens.
As far as I can tell, the routines in Torque seem to have been created due to specific requirements rather than create a suite of routines that may be needed.
Is there a specific requirement you have for your project Stefan?
- Melv.
07/06/2002 (5:33 am)
Stefan,Torque does not have a complete suite of STL-style routines but it does have plenty of support for most 'game' cases.
You've got a Linked-List, Dynamic Vector (inc. bit vectors) and various forms of Hash-Tables like the StringTable. These cover most gaming uses I would of thought.
There is also a 'HuffmanProcessor' which is really helpful for many situations where you want to encode data streams into tokens.
As far as I can tell, the routines in Torque seem to have been created due to specific requirements rather than create a suite of routines that may be needed.
Is there a specific requirement you have for your project Stefan?
- Melv.
#4
Btw. can't wait to get your water stuff, Melv :-))
07/06/2002 (5:45 am)
Hm, well, I wanted to implement the "FuzzyFSM" found in Game Progr. Gems 2 to tune the Torque bots a bit... but it's using STL Maps and Lists, so if I want to get it to compile with Torque, I have to replace those with other (Torque internal or some external) implementations... any idea which Torque classes could serve as such general Map and List replacements? If not, I found some basic code examples which should suit my needs here, and a hash_map here if anyone's interested...Btw. can't wait to get your water stuff, Melv :-))
#5
I spent some time last night working on it and I'm hoping to get it finished on Sunday.
I've not got time today to work on it unfortunately. 8(
- Melv.
07/06/2002 (5:56 am)
Stefan,I spent some time last night working on it and I'm hoping to get it finished on Sunday.
I've not got time today to work on it unfortunately. 8(
- Melv.
#6
It won't be *that* hard to adopt and then you could always write your own or extend those found in Torque to better suit your needs.
07/06/2002 (10:18 am)
Why not just adopt the Torque specific code to the code found in the Gems book, instead of rewritting those support functions in Torque.It won't be *that* hard to adopt and then you could always write your own or extend those found in Torque to better suit your needs.
#7
07/06/2002 (10:35 am)
So do you have any pointer which Torque classes provide List and Map functionality that could suit the standard "container needs"? The only Map type class I found that nearly provides the required functionality was "core/stringTable.cc"...
#8
Im in the same boat as Stefan Beffy Moises. I found a vector class tmeplate here if you need it:
http://www.garagegames.com/docs/tge/engine/classVector.php
I really need a map/hashmap style data structure.
I know there is a way to get stl to work and so you can use the data structures from that but that causes a performance dent.
Can anyone help?
12/17/2005 (7:56 am)
Hi there,Im in the same boat as Stefan Beffy Moises. I found a vector class tmeplate here if you need it:
http://www.garagegames.com/docs/tge/engine/classVector.php
I really need a map/hashmap style data structure.
I know there is a way to get stl to work and so you can use the data structures from that but that causes a performance dent.
Can anyone help?
#9
At design time they are lovely, but in the final optimization they can be a pain.
If you ever plan to work for consoles I'd advise finding alternatives.
12/17/2005 (9:45 am)
Please do realize that STL vectors and maps are relatively evil in game design, as they only guarantuee a certain performance like O(n), but no guarantee whatsoever about O. At design time they are lovely, but in the final optimization they can be a pain.
If you ever plan to work for consoles I'd advise finding alternatives.
#10
12/17/2005 (10:31 am)
See this thread. It's in the T2D private forums, so relevant bits of my posts there quoted below for those that dont have access:Quote:Torque already has vector and list templates. Look in core/tVector.h and core/llist.h. Also, I hacked a simple hash table together just before 1.4 shipped so it was too late to get it into 1.4, but it's in Mantis so will end up in the next version of TGE. If you're impatient you can get it here.
Quote:I havent tested performance either, mainly because i havent needed it for anything all that critical. It's based on some ancient code that has been in TGE for years but wasnt used, so there may be issues yet to be found. I've already fixed a couple of bugs in it, so as long as you're using the tSparseArray.h from the .zip and not the original TGE then there shouldnt be any issues.
Re: collisions question that I forgot to answer: SimpleHashTable just derives from SparseArray and adds the neccessary code to generate the hashes, so SparseArray deals with the collisions. It's called Simple for a reason, unfortunately ;-) I am starting to lose the ability to do without iterators for the hash table so I might add those at some point, but if someone beats me to it then please post the code.
Associate Tim Newell
Max Gaming Technologies
-Tim aka Spock