 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
DEX Guest
|
Posted: Thu May 13, 2004 3:13 pm Post subject: if( container.have( forward_iterator & reverse_iterator ){ c |
|
|
English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
Example:
1. std::vector have forward, reverse and bidirectional.
2. std::list have forward, reverse and bidirectional.
--
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
llewelly Guest
|
Posted: Fri May 14, 2004 12:07 am Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") writes:
| Quote: | English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
Example:
1. std::vector have forward, reverse and bidirectional.
2. std::list have forward, reverse and bidirectional.
|
Maybe you want 24.4.1/1, which begins:
[snip]
# Bidirectional and random access iterators have corresponding
# reverse iterator adaptors [...]
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
DEX Guest
|
Posted: Fri May 14, 2004 4:46 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
Nope.
Whit other words 24.4.1/1 says:
If container has bi-directional iterator then it must have forward and
reverse.
It is obvious.
My question is in reverse direction.
Mathematicly speaking:
Container have forward and reverse iterator if and only if have
bi-directional iterator.
24.4.1/1 give me proof from rigt to left .
I want left to right.
"llewelly" <llewelly.at (AT) xmission (DOT) dot.com> wrote
| Quote: | I (AT) ddmrm (DOT) com ("DEX") writes:
English version.
If container has forward and reverse iterator does it mean that
container
must have bi-directional iterator.
Example:
1. std::vector have forward, reverse and bidirectional.
2. std::list have forward, reverse and bidirectional.
Maybe you want 24.4.1/1, which begins:
[snip]
# Bidirectional and random access iterators have corresponding
# reverse iterator adaptors [...]
|
| Quote: |
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
James Kuyper Guest
|
Posted: Fri May 14, 2004 8:34 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
| Quote: | English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
|
There's no such requirement.
The converse, on the other hand, is true. If a container has a
bi-directional or random iterator, it's required to provide both a
forward and a reverse iterator (23.1.1p9), and the reverse iterator is
required to be std::reverse_iterator<Container::iterator>.
If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4). However, if Container::iterator is not
bidirectional, then Container::reverse_iterator could still be
defined, and doesn't have to be defined in terms of
std::reverse_iterator,>.
As a practical matter, I can't come up with a good reason why anyone
would implement a container with both forward and reverse iterators,
yet not provide a bidirectional iterator.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
John Potter Guest
|
Posted: Fri May 14, 2004 10:52 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
On Fri, 14 May 2004 16:46:12 +0000 (UTC), [email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote:
| Quote: | Mathematicly speaking:
Container have forward and reverse iterator if and only if have
bi-directional iterator.
24.4.1/1 give me proof from rigt to left .
I want left to right.
|
24.4.1.2/1.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
John Potter Guest
|
Posted: Fri May 14, 2004 10:52 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
On Fri, 14 May 2004 20:34:42 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
| Quote: | I (AT) ddmrm (DOT) com ("DEX") wrote in message news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
There's no such requirement.
|
Did you consider table 66?
| Quote: | If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4).
|
Table 66 gives no choice. If it is a reversible container, that typedef
is required.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
qWake Guest
|
Posted: Sun May 16, 2004 1:31 am Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
"James Kuyper" <kuyper (AT) wizard (DOT) net> wrote in message
| Quote: | As a practical matter, I can't come up with a good reason why anyone
would implement a container with both forward and reverse iterators,
yet not provide a bidirectional iterator.
|
To prevent items from being processed more than once?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
llewelly Guest
|
Posted: Mon May 17, 2004 3:00 am Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]mail (AT) qWake (DOT) com[/email] ("qWake") writes:
| Quote: | "James Kuyper" <kuyper (AT) wizard (DOT) net> wrote in message
As a practical matter, I can't come up with a good reason why anyone
would implement a container with both forward and reverse iterators,
yet not provide a bidirectional iterator.
To prevent items from being processed more than once?
|
The value of a forward iterator can be saved, like a bookmark, and
used to return that spot. So such prevention would have big gaps.
If you *had* a sequence which could be processed in either direction,
but must only be processed once, you'd better provide two kinds
of input iterators.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
James Kuyper Guest
|
Posted: Mon May 17, 2004 5:18 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]jpotter (AT) falcon (DOT) lhup.edu[/email] (John Potter) wrote in message news:<9Japc.5929$zO3.4580 (AT) newsread2 (DOT) news.atl.earthlink.net>...
| Quote: | On Fri, 14 May 2004 20:34:42 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
There's no such requirement.
Did you consider table 66?
|
Yes. It places requirements on reversible containers.
| Quote: | If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4).
Table 66 gives no choice. If it is a reversible container, that typedef
is required.
|
A class with both forward and reverse iterators, but lacking a
bi-directional iterator would fail to meet the requirements for
reversible containers, but he didn't ask about reversible containers.
He asked about containers with both forward and reverse iterators,
which is a broader category.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
John Potter Guest
|
Posted: Mon May 17, 2004 9:21 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
On Mon, 17 May 2004 17:18:13 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
| Quote: | jpotter (AT) falcon (DOT) lhup.edu (John Potter) wrote in message news:<9Japc.5929$zO3.4580 (AT) newsread2 (DOT) news.atl.earthlink.net>...
On Fri, 14 May 2004 20:34:42 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that container
must have bi-directional iterator.
There's no such requirement.
Did you consider table 66?
Yes. It places requirements on reversible containers.
If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4).
Table 66 gives no choice. If it is a reversible container, that typedef
is required.
A class with both forward and reverse iterators, but lacking a
bi-directional iterator would fail to meet the requirements for
reversible containers, but he didn't ask about reversible containers.
He asked about containers with both forward and reverse iterators,
which is a broader category.
|
It seemed to me that the question was about standard containers in
comp.std.c++. There is no container between simple container and
reversible container. If this thing is a container matching standard
requirements, it is either a plain container without reverse_iterator
or a reversible container. We can't talk about requirements for some
fictious broader category here.
I wonder what the real question was and if either of us answered it to
the satisfaction of the poster.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
DEX Guest
|
Posted: Tue May 18, 2004 4:09 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
"James Kuyper" <kuyper (AT) wizard (DOT) net> wrote
| Quote: | I (AT) ddmrm (DOT) com ("DEX") wrote in message
news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that
container
must have bi-directional iterator.
There's no such requirement.
|
I think that there must be another additional condition for container to
have bidirectional iterator
if it has reverse an forward.
Applying that question ( if( container.have ... ) to STL the ansver is YES.
| Quote: |
The converse, on the other hand, is true. If a container has a
bi-directional or random iterator, it's required to provide both a
forward and a reverse iterator (23.1.1p9), and the reverse iterator is
required to be std::reverse_iterator<Container::iterator>.
If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4). However, if Container::iterator is not
bidirectional, then Container::reverse_iterator could still be
defined, and doesn't have to be defined in terms of
std::reverse_iterator,>.
As a practical matter, I can't come up with a good reason why anyone
would implement a container with both forward and reverse iterators,
yet not provide a bidirectional iterator.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
James Kuyper Guest
|
Posted: Tue May 18, 2004 4:57 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]jpotter (AT) falcon (DOT) lhup.edu[/email] (John Potter) wrote in message news:<Xv7qc.12797$zO3.2908 (AT) newsread2 (DOT) news.atl.earthlink.net>...
| Quote: | On Mon, 17 May 2004 17:18:13 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
[email]jpotter (AT) falcon (DOT) lhup.edu[/email] (John Potter) wrote in message news:<9Japc.5929$zO3.4580 (AT) newsread2 (DOT) news.atl.earthlink.net>...
...
Table 66 gives no choice. If it is a reversible container, that typedef
is required.
A class with both forward and reverse iterators, but lacking a
bi-directional iterator would fail to meet the requirements for
reversible containers, but he didn't ask about reversible containers.
He asked about containers with both forward and reverse iterators,
which is a broader category.
It seemed to me that the question was about standard containers in
comp.std.c++. There is no container between simple container and
reversible container. If this thing is a container matching standard
requirements, it is either a plain container without reverse_iterator
or a reversible container. We can't talk about requirements for some
fictious broader category here.
|
I think you mean "defined by", rather than merely "matching". A
container can match all of the requirements of table 65, and have
reverse_iterators, without matching all of the requirements of table
66.
What you're basically saying is that you think he was referring to
some particular named type category (such as container, reversible
container, sequence, or associative container). The problem is, the
only relevant category name he used was "container", which implies
Table 65, but nothing more.
| Quote: | I wonder what the real question was and if either of us answered it to
the satisfaction of the poster.
|
Agreed.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
James Kuyper Guest
|
Posted: Wed May 19, 2004 2:43 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message news:<2gu1j5F6ha6qU1 (AT) uni-berlin (DOT) de>...
| Quote: | "James Kuyper" <kuyper (AT) wizard (DOT) net> wrote in message
news:8b42afac.0405141224.9aed6f7 (AT) posting (DOT) google.com...
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message
news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that
container
must have bi-directional iterator.
There's no such requirement.
I think that there must be another additional condition for container to
have bidirectional iterator
if it has reverse an forward.
|
I can assure you that there is no such additional condition. Perhaps
you mean that there should be such an additional condition?
| Quote: | Applying that question ( if( container.have ... ) to STL the ansver is YES.
|
You mean, that the STL has no such containers, and you're correct.
However, you used "must_have" rather than "does_have". There's no
reason why a container with forward and reverse iterators must have
bidirectional iterators; the STL doesn't contain any examples of that,
but there's no requirement, either from logic or the standard, why it
couldn't.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
DEX Guest
|
Posted: Wed May 19, 2004 2:50 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
"John Potter" <jpotter (AT) falcon (DOT) lhup.edu> wrote
| Quote: | On Mon, 17 May 2004 17:18:13 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
[email]jpotter (AT) falcon (DOT) lhup.edu[/email] (John Potter) wrote in message
news:<9Japc.5929$zO3.4580 (AT) newsread2 (DOT) news.atl.earthlink.net>...
On Fri, 14 May 2004 20:34:42 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
[email]I (AT) ddmrm (DOT) com[/email] ("DEX") wrote in message
news:<2ggunsF2lnpsU1 (AT) uni-berlin (DOT) de>...
English version.
If container has forward and reverse iterator does it mean that
container
must have bi-directional iterator.
There's no such requirement.
Did you consider table 66?
Yes. It places requirements on reversible containers.
If Container::reverse_iterator is typedefd as
std::reverse_iterator<Container::iterator>, then Container::iterator
must be bidirectional (24.1.4).
Table 66 gives no choice. If it is a reversible container, that
typedef
is required.
A class with both forward and reverse iterators, but lacking a
bi-directional iterator would fail to meet the requirements for
reversible containers, but he didn't ask about reversible containers.
He asked about containers with both forward and reverse iterators,
which is a broader category.
It seemed to me that the question was about standard containers in
comp.std.c++.
YES and NO. |
| Quote: | There is no container between simple container and
reversible container.
If this thing is a container matching standard
requirements, it is either a plain container without reverse_iterator
or a reversible container.
|
I think there is a another type of container between simple and
bi-directional.
Acording to ISO-14882 ansver is YES, because says it must be ( without
"mathematical" proof ).
However I think the answr is NO.
This is an example and the answer why I think so:
struct container_simple //!< well known simple container
{
typedef ... iterator_forward, iterator;
};
struct container_forward_reverse //!< mising link
: container_simple
{
typedef ... iterator_reverse;
};
struct container_bidirectional //!< it could look like
: container_forward_reverse
{
struct iterator_forward : iterator_forward
{
// there must to be converters from iterator_forward to
iterator_reverse
iterator_forward( iterator_reverse const& );
operator iterator_reverse()const;
};
struct iterator_reverse : iterator_reverse
{
// there must be converters from iterator_reverse to iterator_forward
iterator_reverse( iterator_forward const& );
operator iterator_forward()const;
};
};
| Quote: | We can't talk about requirements for some
fictious broader category here.
I wonder what the real question was and if either of us answered it to
the satisfaction of the poster.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
John Potter Guest
|
Posted: Wed May 19, 2004 5:15 pm Post subject: Re: if( container.have( forward_iterator & reverse_iterator |
|
|
On Wed, 19 May 2004 14:43:05 +0000 (UTC), [email]kuyper (AT) wizard (DOT) net[/email] (James
Kuyper) wrote:
| Quote: | There's no
reason why a container with forward and reverse iterators must have
bidirectional iterators; the STL doesn't contain any examples of that,
but there's no requirement, either from logic or the standard, why it
couldn't.
|
What is a reverse_iterator? The standard defines it as a bidirecrtional
iterator whose increment and decrement operations are reversed. If a
container has a reverse_iterator, it has a bidirectional_iterator. A
reverse_iterator is a bidirectional_iterator by definition.
If the intent is to talk about an iterator which moves backwards through
a container, then name it something other than reverse_iterator which
has a standard meaning.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|