comp.lang.ada
 help / color / mirror / Atom feed
* Small ordered set
@ 2017-10-28 16:37 Victor Porton
  2017-11-06 17:32 ` Robert Eachus
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Porton @ 2017-10-28 16:37 UTC (permalink / raw)


I need a "container" which describes an ordered set of two elements maximum 
(Sources, Targets).

All possible examples:

[]
[Sources]
[Targets]
[Sources, Targets]
[Targets, Sources]

What is the best way to implement it in Ada2012?

-- 
Victor Porton - http://portonvictor.org


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

* Re: Small ordered set
  2017-10-28 16:37 Small ordered set Victor Porton
@ 2017-11-06 17:32 ` Robert Eachus
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Eachus @ 2017-11-06 17:32 UTC (permalink / raw)


On Saturday, October 28, 2017 at 12:37:37 PM UTC-4, Victor Porton wrote:
> I need a "container" which describes an ordered set of two elements maximum 
> (Sources, Targets).
> 
> All possible examples:
> 
> []
> [Sources]
> [Targets]
> [Sources, Targets]
> [Targets, Sources]
> 
> What is the best way to implement it in Ada2012?

I think you end up with an enumeration type, and a discriminated type:

type Foo is (None, Sources, Targets, Sources_and_Targets, 
             Targets_and_Sources);

type Bar(F: Foo := None) is record
   case F is..
end record;

Use names more appropriate to the purpose of the objects.  I suspect that Sources and Targets will correspond to heads of linked lists, but a long as they are of limited size no problem.

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

end of thread, other threads:[~2017-11-06 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28 16:37 Small ordered set Victor Porton
2017-11-06 17:32 ` Robert Eachus

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