comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: RE: Allocate an array of a record with a discriminant?
Date: Tue, 27 Mar 2001 21:11:56 GMT
Date: 2001-03-27T21:11:56+00:00	[thread overview]
Message-ID: <wm7w6.962$ea6.162289@news1.frmt1.sfba.home.com> (raw)
In-Reply-To: tc1ghv4o7s23e2@corp.supernews.co.uk

Do you want to allocate an array of a record with a discriminant,
or do you want to create and access a list of words?  If the
latter, you might do better to make a package with a spec
along the lines of:

  Overflow : exception;  -- Attempt to Add too many words,
                         -- or too many characters of words.
  Nonesuch : exception;  -- Attempt to Get non-existent ID.

  type Word_Counts is range 0 .. ???
  subtype Word_Indices is Word_Counts range 1 .. Word_Counts'last;

  function Count return Word_Counts;
  -- return number of stored words.

  function Add(S : in Word) return Word_Indices;
  -- Add to store.  Return new index.
  -- Raise Overflow if too many or too long words.

  function Get_Length(Index : in Word_Indices) return Natural;
  -- raise Nonesuch if no such word.

  function Get(Index : in Word_Indices) return Word;
  -- raise Nonesuch if no such word.

  ... anything else that's needed

which can be easily implemented by storing the words as successive
characters in a single big string, and using an array of start
indices to let you quickly get the n-th word.



  parent reply	other threads:[~2001-03-27 21:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-27 15:41 Allocate an array of a record with a discriminant? Joe
2001-03-27 20:22 ` Robert A Duff
2001-03-27 21:11 ` tmoran [this message]
2001-03-30 18:48 ` Mark Lundquist
2001-03-31  4:22   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2001-03-27 19:44 Beard, Frank
replies disabled

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