comp.lang.ada
 help / color / mirror / Atom feed
* Question on speed of set operations
@ 2019-03-29 22:39 reinert
  2019-03-29 23:11 ` Simon Wright
  0 siblings, 1 reply; 4+ messages in thread
From: reinert @ 2019-03-29 22:39 UTC (permalink / raw)


Dear all,

I try to make an "Include" procedure similar to

procedure Include(Container: in out Set; New_Item: in Element_Type);

(under Containers.Ordered_sets) and where one includes 
(eventually replaces) elements in a set instead of including 
one element at a time. The intention is to make the user code 
clean/readable and efficient.

So what is the best alternative among the following tree procedures
for the above purpose (in terms of *speed*):

procedure Include(Container: in out Set; New_Items: in Set) is
begin
   for e of New_Items loop
       Container.Include(e);
   end loop;
end include_set;

procedure Include(Container: in out Set; New_Items: in Set) is
begin
   Container.Difference(New_Items);
   Container.Union(New_Items);
end include_set;

procedure Include(Container: in out Set; New_Items: in Set) is
begin
   Container := New_Items or Container
end include_set; 

Could there be other/better alternatives? And/or am I trying
to reinvent the wheel?

reinert


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on speed of set operations
  2019-03-29 22:39 Question on speed of set operations reinert
@ 2019-03-29 23:11 ` Simon Wright
  2019-04-01 21:43   ` Randy Brukardt
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Wright @ 2019-03-29 23:11 UTC (permalink / raw)


reinert <reinkor@gmail.com> writes:

> So what is the best alternative among the following tree procedures
> for the above purpose (in terms of *speed*):

If I were you I would do some benchmarking.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on speed of set operations
  2019-03-29 23:11 ` Simon Wright
@ 2019-04-01 21:43   ` Randy Brukardt
  2019-04-02  6:03     ` reinert
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Brukardt @ 2019-04-01 21:43 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyh8bl2s3u.fsf@pushface.org...
> reinert <reinkor@gmail.com> writes:
>
>> So what is the best alternative among the following tree procedures
>> for the above purpose (in terms of *speed*):
>
> If I were you I would do some benchmarking.

Agreed. I doubt that there is a portable answer; it would depend on the 
internal implementation of the container type (which is purposely left to 
the implementation).

                                         Randy.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on speed of set operations
  2019-04-01 21:43   ` Randy Brukardt
@ 2019-04-02  6:03     ` reinert
  0 siblings, 0 replies; 4+ messages in thread
From: reinert @ 2019-04-02  6:03 UTC (permalink / raw)


> >
> >> So what is the best alternative among the following tree procedures
> >> for the above purpose (in terms of *speed*):
> >
> > If I were you I would do some benchmarking.
> 
> Agreed. I doubt that there is a portable answer; it would depend on the 
> internal implementation of the container type (which is purposely left to 
> the implementation).
> 
>                                          Randy.

And depending on the size of "New_Items" (as compared to the "Container"), I assume? 

Seems like I end up with the first alternative (since, for me, "New_Items" is small. 

reinert


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-02  6:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 22:39 Question on speed of set operations reinert
2019-03-29 23:11 ` Simon Wright
2019-04-01 21:43   ` Randy Brukardt
2019-04-02  6:03     ` reinert

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