From: "Scott Barrish" <tkefufu@icontech.com>
Subject: NEED HELP!!!
Date: 1997/10/03
Date: 1997-10-03T00:00:00+00:00 [thread overview]
Message-ID: <343527ec.0@mail.icontech.com> (raw)
Here is my Stack.ads file:
generic
type Element_Type is private; -- The stack element
package Stack is
-- This package implements a stack, a data structure in which elements are
added
-- and removed from only one end; a "last in, first out" (LIFO) structure.
type Stack_Type (Max_Size : Positive) is limited private; -- The stack
class
UNDERFLOW : exception;
OVERFLOW : exception;
procedure Clear (Stack : in out Stack_Type);
-- Remove all elements from the stack
-- Preconditions: None
-- Postconditions: Stack is empty; it contains no elements
function Empty (Stack : in Stack_Type) return Boolean;
-- Tests whether a stack is empty (contains no elements)
-- Preconditions: None
-- Postconditions: Empty = (stack is empty)
function Full (Stack : in Stack_Type) return Boolean;
-- Tests whether a stack is full (no more elements can be pushed on it)
-- Preconditions: None
-- Postconditions: Full = (stack is full)
procedure Push (Stack : in out Stack_Type;
New_Element : in Element_Type);
-- Adds New_Element to the top of Stack
-- Preconditions: None
-- Postconditions: Stack = original Stack with New_Element added on
top
-- Exceptions: OVERFLOW Raised on attempt to Push a new element
onto a
-- full stack. Stack is unchanged
procedure Pop (Stack : in out Stack_Type;
Popped_Element : out Element_Type);
-- Removes top element from Stack and returns it in Popped_Element
-- Preconditions: None
-- Postconditions: Stack = original Stack with top element
removed
-- Popped_Element = top element of original Stack
-- Exceptions: UNDERFLOW Raised on attempt to Pop an element from
an
-- empty stack. Stack remains empty.
private
type Stack_Array is array (Positive range <>) of Element_Type;
type Stack_Type (Max_Size : Positive) is
record
Top : Natural := 0;
Elements : Stack_Array (1..Max_Size);
end record;
end Stack;
I need to know how to declare a stack of type element and max size.
Sincerely,
Scott Barrish
next reply other threads:[~1997-10-03 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-03 0:00 Scott Barrish [this message]
-- strict thread matches above, loose matches on Subject: below --
1997-02-18 0:00 Need Help!!!! Richard Pearce
1997-02-19 0:00 ` Richard Pearce
1997-02-19 0:00 ` Richard Pearce
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox