Mixin with preelaborated element 
Author Message
 Mixin with preelaborated element

I run into a problem with my list_mixin.
  ftp://ftp.iks-jena.de/pub/mitarb/lutz/ada/types/list_mixin.ad?

generic
   type Base (<>) is abstract tagged limited private;
   type S    (<>) is abstract new Base with private;
package List_Mixin is
   type T is abstract new S with private;
   type T_Class is access all T'Class;
   type List is limited private;
   -- several lines of code deleted
private
   type T is abstract new S with
      record
         Next : T_Class := null;
         Used : Boolean := False;  -- to detect multiple insertions
      end record;

   type List is limited
      record
         Start : T_Class := null;
      end record;
   -- several lines of code deleted
end List_Mixin;

The current implementation use null at the tail marker. This requires the
flag Used and causes a lot of ineffient code.

So I'd like to introduce a single fixed end node used by all instantiations.
It should contain only the Next element.

How can I achieve it?

Using assembly I added the link in front of the structure and ignored the
varying context following it. Good examples can be found in D.E.Knuth TAoCP.



Sun, 17 Nov 2002 03:00:00 GMT  
 Mixin with preelaborated element
Why don't implement a circular list so that  <last element>.Next accesses to
List.Start.



Quote:
> I run into a problem with my list_mixin.
>   ftp://ftp.iks-jena.de/pub/mitarb/lutz/ada/types/list_mixin.ad?

> generic
>    type Base (<>) is abstract tagged limited private;
>    type S    (<>) is abstract new Base with private;
> package List_Mixin is
>    type T is abstract new S with private;
>    type T_Class is access all T'Class;
>    type List is limited private;
>    -- several lines of code deleted
> private
>    type T is abstract new S with
>       record
>          Next : T_Class := null;
>          Used : Boolean := False;  -- to detect multiple insertions
>       end record;

>    type List is limited
>       record
>          Start : T_Class := null;
>       end record;
>    -- several lines of code deleted
> end List_Mixin;

> The current implementation use null at the tail marker. This requires the
> flag Used and causes a lot of ineffient code.

> So I'd like to introduce a single fixed end node used by all
instantiations.
> It should contain only the Next element.

> How can I achieve it?

> Using assembly I added the link in front of the structure and ignored the
> varying context following it. Good examples can be found in D.E.Knuth

TAoCP.


Sun, 17 Nov 2002 03:00:00 GMT  
 Mixin with preelaborated element

Quote:
>Why don't implement a circular list so that  <last element>.Next accesses to
>List.Start.

I'm looking for a solution, not a workaround. A circular list does indeed
exists in my lib, but it offers an extended interface. I'd like to choose an
implementation based on the needs of the algorithm not based on the
(in)flexibility of the programming language.

BTW: Even a circular list has the same problem: How to provide a base node.



Mon, 18 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. What is pragma preelaborated used for?

2. pragma Pure/Preelaborate - tools, practice?

3. what does preelaborated package mean?

4. Adding an element in an array of cluster of 2 elements

5. Shifting array element & regex on array element

6. element by element comparisons in Numeric

7. Is mixin possible with dynamic require?

8. Mixin class methods

9. Mixin using append_features and class<<self do not work together

10. RUNIT: mixin instead of inheriting?

11. Mixin class methods?

12. Mixin question

 

 
Powered by phpBB® Forum Software