Quote:Original post by Procyon Lotor
m_TexturesInFile is a LinkedList template that I wrote. I didn't know the Standard Library had a linked list.
Yep. You should use the std::list if that's what you want.
You should not try to use or write an operator[] for any kind of linked list. The std::list deliberately does not provide one, because it is such a bad idea - it creates useless work and makes it easy to write really slow code accidentally when you put it in a loop, because it would have to re-search from the beginning every time.
Instead, use iterators to iterate over standard library containers. This has the advantage that they will work transparently (with just a little bit of typedef work) if you later change your mind about what kind of container to use.
typedef std::list<Texture> texContainer;texContainer textures;// put stuff into it herefor(texContainer::iterator it = textures.begin(); it != textures.end(); // don't use < with iterators; not all provide it ++it) { // preincrement the iterator because the compiler may not be // able to optimize it - the iterator is a class type itself, and this // way is standard idiom // Do stuff with the texture}
Chances are good you want std::vector, unless you're adding or removing things at the beginning or in the middle, or need to keep the items sorted. (Although this point is somewhat controversial too; many argue for std::vector as a "default" and many others for std::deque instead.)
Quote:Does it have hash tables also?
It does not have a hash table per the classic definition, but it does have a tree-based associative container called std::map, which provides the same interface. It is algorithmically slower for lookup, but it also keeps data in sorted order (this in turn requires that the key values can be compared to each other). Both those facts follow from the way it is implemented, as a self-balancing binary search tree.
Quote:Cool, I didn't know you could create a temporary string with string("blah blah blah"), thanks for telling me!
It's amazing how many people don't seem to grasp this, but you can make a temporary like this for any class type, in just the same way that you can make a "temporary integer" in an expression like "3 * 4" without needing variables to hold those numbers (which would be stupid). It's done for symmetry, you know.
Quote:Thanks for the link on naming too, honestly I haven't liked HN very much, but thought it was the industry standard so I was trying to learn it.
"The" industry standard... I must suppress a giggle. :) Seriously, though, it is better to consider these things for yourself, and prefer standards for which you have heard rational arguments that you accept, over standards that "everyone conforms to".
By the way, instead of trying to grab the sName() directly from a Texture, you should probably make that data private, and instead provide a function to return the full concatenated filename. You might even consider making it return the ifstream object (not sure if that works so well with ifstream objects - they don't like to be copied, you know). Although actually, it should probably do all the work that the inner loop will eventually contain, and return some other object constructed from the file data (what are these other files you're opening?)