2 -- Copyright (C) 2008-2018 Lorenzo Caminiti
3 -- Distributed under the Boost Software License, Version 1.0 (see accompanying
4 -- file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 -- See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
8 -- Extra spaces, newlines, etc. for visual alignment with this library code.
15 destription: "Dispenser with LIFO access policy and a fixed max capacity."
16 class interface STACK4[G] creation make -- Interface only (no implementation).
25 count_non_negative: count >= 0
26 count_bounded: count <= capacity
27 empty_if_no_elements: empty = (count = 0)
31 feature -- Initialization
33 -- Allocate stack for a maximum of n elements.
36 non_negative_capacity: n >= 0
38 capacity_set: capacity = n
93 -- Max number of stack elements.
100 -- Number of stack elements.
110 not_empty: not empty -- i.e., count > 0
118 feature -- Status report
123 empty_definition: result = (count = 0)
136 full_definition: result = (count = capacity)
146 feature -- Element change
154 added_to_top: item = x
155 one_more_item: count = old count + 1
165 -- Remove top element.
168 not_empty: not empty -- i.e., count > 0
171 one_fewer_item: count = old count - 1
197 end -- class interface STACK4