comp.lang.ada
 help / color / mirror / Atom feed
From: reinert <reinkor@gmail.com>
Subject: Question on speed of set operations
Date: Fri, 29 Mar 2019 15:39:59 -0700 (PDT)
Date: 2019-03-29T15:39:59-07:00	[thread overview]
Message-ID: <b5bbc7b4-f685-4392-b8cd-b3f971c2b564@googlegroups.com> (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


             reply	other threads:[~2019-03-29 22:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 22:39 reinert [this message]
2019-03-29 23:11 ` Question on speed of set operations Simon Wright
2019-04-01 21:43   ` Randy Brukardt
2019-04-02  6:03     ` reinert
replies disabled

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