Re: Pointer To A Vector Elements While Still Adding
From: Ivan Vecerina (INVALID_use_webform_instead_at_vecerina.com)
Date: 03/27/05
- Next message: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Previous message: Thomas Hansen: "Re: Correct C++ tutorial chapter 2.1 "Classes" available (Windows, mingw/msvc/std)"
- In reply to: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Next in thread: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Reply: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 27 Mar 2005 12:20:43 +0200
"Ioannis Vranos" <ivr@remove.this.grad.com> wrote in message
news:1111912117.230641@athnrd02...
> Ivan Vecerina wrote:
>>> pointerClass[i].addPointer(newlist.end()) ;
>>
>> I think this is incorrect: Adam would not want to push end(),
>> but (end()-1)
>
> You are right.
>
>> - which cannot be written as is because list
>> does not provide a random-access iterator.
Why did you 'snip' here these two lines from my previous post?
: The following would compile (for iterators that are not built-in types):
: pointerClass[i].addPointer( --newlist.end() ) ;
> It can be written as:
> pointerClass[i].addIterator(--newlist.end());
We knew ;)
>>>pointerClass[i].addPointer( &newlist.back() );
>>
>> Yep -- and this is not necessarily an inferior solution...
>
> Well if you consider that you can increment the stored iterator to
> access the next element or decrement it to access the previous element,
> while you can't do
> that with the pointers,
If that is the case, the iterator is the obvious choice.
> I can not see any real benefit of using pointers.
Using pointers:
- avoids exposing they type of container used for the storage
of the elements (encapsulation, fewer dependencies)
- allows you to use containers other than std::list
(such as std::deque, which could be preferred)
> [I am using 90 characters word-wrapping - (800/640) *72= 90. If someone
> finds it inconvenient, please let me know].
I don't think it is a good idea, because quotes of most of your
lines will get truncated by other NG engines that wrap at
a shorter line length...
Cheers,
Ivan
-- http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
- Next message: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Previous message: Thomas Hansen: "Re: Correct C++ tutorial chapter 2.1 "Classes" available (Windows, mingw/msvc/std)"
- In reply to: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Next in thread: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Reply: Ioannis Vranos: "Re: Pointer To A Vector Elements While Still Adding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|