comp.lang.ada
 help / color / mirror / Atom feed
* ANNOUNCE: data structures with limited items pattern
@ 1999-03-01  0:00 Matthew Heaney
  0 siblings, 0 replies; only message in thread
From: Matthew Heaney @ 1999-03-01  0:00 UTC (permalink / 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.




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-03-01  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-01  0:00 ANNOUNCE: data structures with limited items pattern Matthew Heaney

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