Mail Archives: djgpp/1994/09/21/02:24:29
I wrote a message to comp.lang.c++ asking a relatively simple question:
How can I dynamically allocate a random number of objects of a particular
class? I received a couple of responses, and parts of one are below. The
|> lines are my inquiry, > is his reply. (To avoid any confusion.)
> |> Maybe a binary tree is what I want, with a few indexing and searching
> |> functions. If I have three types of classes, types A, B, and C, and throw
> |> them in binary trees, I'd need three trees. That's not a problem. Adding
> |> the material one at a time -- if one entry needs to be killed, its marked
> |> as deleted, and the next time I need a place for data it goes there. Is
> |> there a better way?
> |>
>
> In C people used to painfully reconstruct linked-list code for each type
> of things they wanted to keep track of. With C++ and templates we now
> have things called "collection classes" that hold collection of
> objects. These are generally very powerful and flexible containers for
> any type of objects you want to use. Chances are your compiler came
> with a simple set of collection classes or containers that you can use.
Does DJGPP have any prebuilt collection classes? I really have only a
very vague idea what he's talking about, and that isn't enough to build
one of these templates. I suppose I could go the linked-list/binary-tree
route, but now my curiosity has peaked.
Thanks.
- Raw text -