From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_MSGID, PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,12a85170c266992c,start X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: ANNOUNCE: data structures with limited items pattern Date: 1999/03/01 Message-ID: #1/1 X-Deja-AN: 449687963 Sender: matt@mheaney.ni.net NNTP-Posting-Date: Sun, 28 Feb 1999 16:14:35 PDT Newsgroups: comp.lang.ada Date: 1999-03-01T00:00:00+00:00 List-Id: 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. You can subscribe to the patterns list by sending the message (body) subscribe patterns to the ACM mail-list server. 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.