I am not too experienced with the standard template library (STL) in C++. I am more experienced with Visual C++ and the Microsoft Foundation Class Library (MFC). I have heard some good things about STL. Is it ture that there is a ready-to-use linked list? Is there also a hash table?
What advantages would there be to writing one from scratch?
If I do go with MFC, what advantages are there?
C++ Linked List or Hash Table
Moderator: MaxCoderz Staff
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Reinventing the wheel is a bad thing. Writing your own containers is fine as an academic exercise, but once done delete the source files and use the standard ones instead. If the STL doesn't offer what you need, turn to another standard-ish library like Boost.
(See here for an example).
(See here for an example).
OK, I am going to use the STL list. I want to have each node have two strings. Here is how far I have gotten:
I would I put nodes into this list?
Code: Select all
#include <list> // list class-template definition
using namespace std;
class Node
{
CString string1;
CString string2;
}
list<Node> MyList;
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
list::push_back will append an item to the end of the list (for example).
Reinventing the wheel is the essence of learning. To use things blindly is probably the stupidest thing you could ever due, and reinventing the wheel generally leads to a better understanding of what is happening.
Maybe reinventing the wheel is a bad thing for linked lists, but sometimes it is needed, and it is better for the community. (Gives more choice.)
For one example you have:
CryEngine2, UE3, Irrlicht, NeoAxis, Ogre, Horde3d, etc.
Maybe reinventing the wheel is a bad thing for linked lists, but sometimes it is needed, and it is better for the community. (Gives more choice.)
For one example you have:
CryEngine2, UE3, Irrlicht, NeoAxis, Ogre, Horde3d, etc.
-
- MCF Legend
- Posts: 1601
- Joined: Mon 20 Dec, 2004 8:45 am
- Location: Budapest, Absurdistan
- Contact:
Reinventing the wheel is wrong if you want to put it on your car. On the other hand, there’s nothing wrong with playing around with new wheel designs as long as they don’t leave your garage before thorough testing.
Studying existing wheels is a very useful way of spending your time, and part of the learning process is indeed creating some of your own. However, there’s no reason to use your own design in production as long as it is inferior to the widespread one. And when you are experimenting with chassis designs, you’ll surely want to take ready-made wheels in order to concentrate your efforts better.
Stupid analogy trip over.
Studying existing wheels is a very useful way of spending your time, and part of the learning process is indeed creating some of your own. However, there’s no reason to use your own design in production as long as it is inferior to the widespread one. And when you are experimenting with chassis designs, you’ll surely want to take ready-made wheels in order to concentrate your efforts better.
Stupid analogy trip over.