comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: ANNOUNCE: data structures with limited items pattern
Date: 1999/03/01
Date: 1999-03-01T00:00:00+00:00	[thread overview]
Message-ID: <m3aexycbbo.fsf@mheaney.ni.net> (raw)

I have submitted an article to the ACM patterns archive, on how to
implement a collection of items in which the item-type is limited.  A
description appears below.

<http://www.acm.org/archives/patterns.html>

You can subscribe to the patterns list by sending the message (body) 

subscribe patterns <your full name>

to the ACM mail-list server.

<mailto:listserv@acm.org>

You can also subscribe from the web page.



Data Structures Containing Limited Items

In this article I show how to implement a stack whose items are limited.

Most data structures you see are implemented this way:

generic
  type Item_Type is private;
package Stacks is

  type Stack_Type is limited private;

  procedure Push (Item : in     Item_Type;
                  On   : in out Stack_Type);
...
end Stacks;

The generic formal type Item_Type is non-limited, so it comes with
assignment.  This allows you to implement operation Push (for a bounded
stack) like this:

  procedure Push (Item : in     Item_Type;
                  On   : in out Stack_Type) is
  begin
     On.Top := On.Top + 1;
     On.Items (On.Top) := Item;
  end;

But suppose you need a stack of, say, files?  Type File_Type, in
Text_IO, is limited:

  type File_Type is limited private;

so you wouldn't be able to instantiate the stack package above.  But
even if you could, it's not clear how you'd implement Push, which
requires assignment.




                 reply	other threads:[~1999-03-01  0:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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