Re: limited types (Was: Records that could be arrays)




Dmitry A. Kazakov wrote:
On 28 Feb 2006 09:24:35 -0800, Matthew Heaney wrote:

I still don't see CS.

I wrote the declaration wrong; it should have been:

generic
type ET is private; --or: type ET (<>) is limited private;
type CT is private; --cursor type
with function E (C : CT) return ET is <>;
procedure Generic_Algorithm (C1, C2 : CT);

The cursor pair [C1, C2) describes a range of elements. It might be
the entire range of elements in the container, or just a subrange. The
algorithm doesn't care.


BTW, if I had CS, would need not to instantiate Generic_Algorithm once
more.

(I assume "CS" means "container of element type S, and S derives from
type T.")

As far as generic algorithms are concerned, it doesn't matter that type
S derives from type T. That's what "generic algorithm" means.

And yes, you have to instantiate the algorithm twice, since the cursor
types come from different instantiations of some generic container
package.

Of course, if you instantiate the indefinite container package on
generic actual type T'Class, then you'd only have to instantate generic
algorithm once (assuming generic formal type ET is declared
appropriately, as I show above in the comment).

.



Relevant Pages

  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... To impose an order on them standard needs to put a restriction on implementarion algorithms. ... There is no need for cursors during iterations. ... has exactly the same semantics for _any_ container type. ... This could be done using a generic algorithm which is similar ...
    (comp.lang.ada)
  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... had one after the other through iteration using cursors. ... This could be done using a generic algorithm which is similar ... When I'm can use any container, ... Imagine programming without indirection, whatever the indirection mechanism looks like. ...
    (comp.lang.ada)
  • Re: Ada.Containers.Vectors - querying multiple elements
    ... > When you have a container that is an extensible array, ... The problem you're having is that you have an algorithm written in terms ... procedure Swap is ...
    (comp.lang.ada)
  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... >> works for any container. ... since the algorithm itself doesn't depend on a specific ... all of the containers have some internal order; ... from what the generic formal region requires from its elements. ...
    (comp.lang.ada)
  • Iterator Operations
    ... I have implemented the following insertion sort algorithm which is ... requires knowledge of the container to insert before/after an iterator, ... template<typename BiIter> ...
    (comp.lang.cpp)