comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Adding functions to generic package
Date: Wed, 01 Jun 2005 01:50:02 GMT
Date: 2005-06-01T01:50:02+00:00	[thread overview]
Message-ID: <uhdgilub7.fsf@earthlink.net> (raw)
In-Reply-To: mailman.140.1117492183.24457.comp.lang.ada@ada-france.org

Marius Amado Alves <amado.alves@netcabo.pt> writes:

> > I guess it must be:
> >
> >    procedure Swap (Container : in out Container_Type; L,R :
> > Iterator_Type);
> >
> > as I want the Swap to Swap say element in position 4 with element in
> > postion 2 in the list but by using iterators to point at them.
> 
> No need. Cursors know their containers.

No, this is wrong.

In Charles, iterators do *not* carry a pointer to container (they only
hold a pointer to the node containing the element), and so (in Charles)
you'd need to pass the container too.

But moving a node can change the value of the head and foot pointers,
which are part of the representation of the container type, so you need
to pass the container anyway.  The rule is that whenever an operation
manipulates the container object itself, the container is passed a
parameter.

Mario is probably thinking of the Ada 2005 standard container library.
Cursor types do indeed hold a pointer to the container, in addition to
the node.  However, the rule about manipulation of the container object
still applies (what a coincidence!), so the container is passed as a
parameter too (see the operation named Swap_Links).

-Matt



  reply	other threads:[~2005-06-01  1:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-28 15:44 Adding functions to generic package Preben Randhol
2005-05-28 16:27 ` Matthew Heaney
2005-05-28 18:18   ` Preben Randhol
2005-05-28 18:20     ` Preben Randhol
2005-05-29  0:56     ` Matthew Heaney
2005-05-29  8:41       ` Preben Randhol
2005-05-29 14:37         ` Matthew Heaney
2005-05-29 21:31           ` Preben Randhol
2005-05-29 21:33             ` Preben Randhol
2005-05-29 22:30               ` Matthew Heaney
2005-05-30 20:45                 ` Preben Randhol
2005-05-30 22:28                   ` Marius Amado Alves
2005-06-01  1:50                     ` Matthew Heaney [this message]
2005-06-02 12:49                       ` Marius Amado Alves
2005-06-02 13:11                         ` Matthew Heaney
2005-06-01  1:41                   ` Matthew Heaney
2005-05-29 22:27             ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox