469,611 Members | 1,933 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

stl-list in 2 dimensions

First off, thanks for the help, this group was a great support
for my efforts of learning c++. However, yet again I plan to
throw away what I programmed and re-use a little more of what
stl has to offer:
I would like to create a list of list-nodes of a smaller list
(preferably slist) so that I could iterate through that smaller
list, and iterate through the big list without omitting any
element of the small list. However, the problem is that the
class-name of a list-node isn't standardized. Am I wrong? What
is the usual way to cope with this portability-problem?
Similarily I would like to alter that container's behaviour
so that new list-elements are initialized right into the
list-node without previous initialization and copy-constructor,
i.e. I want to override node-creation so that an object
can get created by a (child inheriting from) list-class
as a node within the list, and not as a stand-alone object.
Here again portability might become a problem. Do I really
need to copy all the source-code from gcc's stl-implementation
right into my own sourcefiles in order to have a portable
program? Doesn't this defy the very purpose of stl?
Can anyone propose a programming-language or library where
my problems can get solved more elegantly?

--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...

P
Jul 22 '05 #1
4 1553

"Piotr Sawuk" <pi****@unet.univie.ac.at> wrote in message
news:cm*********@gander.coarse.univie.ac.at...
First off, thanks for the help, this group was a great support
for my efforts of learning c++. However, yet again I plan to
throw away what I programmed and re-use a little more of what
stl has to offer:
I would like to create a list of list-nodes of a smaller list
(preferably slist)
slist is non-standard.
so that I could iterate through that smaller
list, and iterate through the big list without omitting any
element of the small list. However, the problem is that the
class-name of a list-node isn't standardized. Am I wrong? What
is the usual way to cope with this portability-problem?
This isn't a portablilty problem, you are trying to pretend that STL lists
have capabilities that they don't.


Similarily I would like to alter that container's behaviour
so that new list-elements are initialized right into the
list-node without previous initialization and copy-constructor,
i.e. I want to override node-creation so that an object
can get created by a (child inheriting from) list-class
as a node within the list, and not as a stand-alone object.
Here again portability might become a problem. Do I really
need to copy all the source-code from gcc's stl-implementation
right into my own sourcefiles in order to have a portable
program? Doesn't this defy the very purpose of stl?

The very purpose is STL is to allow containers of objects of any type in a
non-intrusive way. You seem to want the very opposite. STL is designed to
work with stand alone objects.
Can anyone propose a programming-language or library where
my problems can get solved more elegantly?


The STL is very elegant, you seem to be interested in some very inelegant
micro-optimisations. So I guess the STL isn't for you, but if as you suggest
you already have code that does this, why not stick with that?

john
Jul 22 '05 #2
In article <cm*********@gander.coarse.univie.ac.at>,
pi****@unet.univie.ac.at (Piotr Sawuk) writes:

Can anyone propose a programming-language or library where
my problems can get solved more elegantly?


Meanwhile I have learned that my problem could easily get solved
by a decent templated graph-library, since containers are meant
to be the only owner of their objects. Does anyone know of a
c++ lib where a linked list is implemented with the pointers
between nodes being an array of a size defined through the template,
and iterators being defined through a customizable algorithm
(also part of the template-declaration), preferably open-source?
in other words, does anyone know of a template-library in c++
which implements some more generic and custumizeable list-containers
than the one in the standard-template-library? Or do I need to
write my own "standard" template library?
--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...

P
Jul 22 '05 #3
"Piotr Sawuk" <pi****@unet.univie.ac.at> wrote...
In article <cm*********@gander.coarse.univie.ac.at>,
pi****@unet.univie.ac.at (Piotr Sawuk) writes:

Can anyone propose a programming-language or library where
my problems can get solved more elegantly?


Meanwhile I have learned that my problem could easily get solved
by a decent templated graph-library, since containers are meant
to be the only owner of their objects. Does anyone know of a
c++ lib where a linked list is implemented with the pointers
between nodes being an array of a size defined through the template,
and iterators being defined through a customizable algorithm
(also part of the template-declaration), preferably open-source?


I don't know of such library (doesn't mean there isn't any). What
I fail to understand is why do you need to have such detailed
implementation specification to successfully use the template.
What does it matter how it is implemented? In most cases that's
not what is important. You need to look at the interface, mostly.

If you need both fast insertions and deletions, and random access
to objects, you could keep objects in 'std::list' and also keep
a vector (or a deque) to 'std::list::iterator' objects that point
to elements in the list.
in other words, does anyone know of a template-library in c++
which implements some more generic and custumizeable list-containers
than the one in the standard-template-library? Or do I need to
write my own "standard" template library?


You don't need to write your own "standard" template library, but you
might want to see if you can, and want to, write your own template
library for containers and algorithms that _you_ need.

The Standard library contains the bare minimum of classes, templates
and functions to get by. If it contained every algorithm or class
imaginable, it would barely fit on all developers' computers taken
together. Besides, at that point you wouldn't need a programmer to
use that library, it would already contain all solutions to all
problems in the world.

V
Jul 22 '05 #4
pi****@unet.univie.ac.at (Piotr Sawuk) wrote in message news:<cn*********@gander.coarse.univie.ac.at>...
In article <cm*********@gander.coarse.univie.ac.at>,
pi****@unet.univie.ac.at (Piotr Sawuk) writes:


than the one in the standard-template-library? Or do I need to
write my own "standard" template library?

If std::list does not suit your needs write your own.
If you want to stick with std::list interface, that is not a
problem too, after all list is not library it's just one
class :)

Greetings, Bane.
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

41 posts views Thread by Allan Bruce | last post: by
2 posts views Thread by Jean-Baptiste | last post: by
2 posts views Thread by Steve | last post: by
25 posts views Thread by Norm Matloff | last post: by
11 posts views Thread by RR | last post: by
reply views Thread by rajd99 | last post: by
15 posts views Thread by Herby | last post: by
20 posts views Thread by Andrew Roberts | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.