TECH: STL / Heaps, etc. (was: [MUD-Dev] TECH DGN: a few mud server design questions (long))
Caliban Tiresias Darklock
caliban at darklock.com
Mon Aug 6 20:55:46 New Zealand Standard Time 2001
On Sat, 4 Aug 2001 10:19:38 +0100, "Adam Martin" <ya_hoo_com at yahoo.com>
> surely the point is that with all templates and standard libraries
> there is a high barrier to using them the first time, but once you
> are familiar with them (i.e. have used the various bits a few
> times) you can make new programs much faster (to code, and one
> would hope usually to run too, in the case of libraries) than you
> could using your own hacks, otherwise what is the point?
To solve hard problems. If your problem is not hard, the library may
be overkill. A stack of 100 integers, for example, could be
implemented with STL:
using namespace std;
Or with straight C++ types:
Let's look at how these work.
Push something on the stack.
Pop something off the stack.
Is the stack empty?
What's on the top of the stack?
How much stuff is on the stack?
The STL version has some great features, *if* you have a harder
problem. If your stack may contain thousands of objects, or you
need a lot of stacks, or the object on the stack is more complex
than a simple int, STL will make things a lot easier. A stack of
parse trees, for example, would almost certainly be better
implemented with STL. But for this particular problem, STL is just
plain too much -- and the straight C++ version is a great deal
smaller and faster.
MUD-Dev mailing list
MUD-Dev at kanga.nu
More information about the MUD-Dev