component GenericStack ( Stack, Element ); type Stack; Stack (MaxSize = integer) -> Stack; Empty ( Stack ) -> boolean; Full ( Stack ) -> boolean; Push ( Stack, Element) -> nothing; Pull ( Stack ) -> Element; begin Stack(MaxSize) = Stack:[ MaxSize; index:=0; area=array (Element, MaxSize) ]; Empty( stack ) = (stack.index <= 0); Full ( stack ) = (stack.index >= stack.MaxSize); Push ( stack, element ) = [ exception (Full (stack), "Stack Overflow"); stack.index:=stack.index + 1; stack.area[stack.index]:=element ]; Pull ( stack ) = [ exception (Empty (stack), "Stack Underflow"); stack.index:=stack.index - 1; stack.area[stack.index + 1] ]; end component GenericStack;