Inherited Packages

1 General Stack Package

Since packages are restricted and enhanced classes they can be inherited and specialized in the same way as classes in general. For example, we can create a package for a double-ended queue, also called dequeue (combines actions of a stack and a queue). For that we need to inherit all stack operations with the data structure declaration Element from GeneralStack. Then we add operations, as in the example DoubleEndedQueue below.

2 DoubleEndedQueue Package

Below is an "instantiation" of the double-ended queue together with a small usage example. Two integers are inserted at the beginning of the queue and one at the end of the queue. Then the end element is accessed and the first element is removed.