TECH: STL / Heaps, etc. (was: [MUD-Dev] TECH DGN: a few mud server design questions (long))
Caliban Tiresias Darklock
caliban at darklock.com
Thu Aug 2 20:09:03 CEST 2001
On Thu, 2 Aug 2001 10:50:21 -0500, "Eli Stevens"
<listsub at wickedgrey.com> wrote:
> I love the standard template library. Unabashedly. ;) Of course,
> it helps that it is for my language of choice and that I like
> templates just a little too much (when templates are your only
> tool, everything looks like a nail :).
Something I've been breaking myself of for the past few years is
various C habits which perpetuated into my C++ programming -- like
using printf instead of cout, structures instead of classes, global
functions instead of methods. Templates are a reasonably recent
addition to my array of skills, and while they're certainly useful
for data structures of this nature, I don't find them useful for
much else.
It's also much easier for me to write up my own ad hoc
implementation than it is to examine and understand the STL version,
so unless my needs are trivial I tend to avoid it. If I need a
simple binary tree of records for searching, hey, STL is great;
three lines of code, and I'm hooked up. But if I need something a
little more complex, like a binary tree of node *lists* in which the
left child of each node is a list of nodes with no children and the
right child of each node is a list of nodes with children, STL is a
much bigger headache than it is a convenience.
> I think the STL is a Good Thing, but my practical/real world
> experience is limited. Are there problems with the STL lurking
> under the surface? One aspect that concerned me was that while it
> specifies the complexity of a given operation, you don't have any
> control over the coefficients involved. Would it be a bad idea to
> rely on it too much?
I think it's a bad idea to rely on STL for *specific* situations. If
you know that your binary tree is going to require some special
handling that STL is unlikely to provide, it's sometimes easier to
write a fresh binary tree implementation than it is to modify your
class so STL will work. You should use or build the tools that fit
your data, not mangle your data to fit the tools you've got.
Of course, STL is one hell of a tool, and you should at least stick
it in the toolbox. Even if, like me, you virtually never use it.
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list