Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "Stacks with a bounded physical size, implemented by arrays" status: "See notice at end of class" names: dispenser, array representation: array access: fixed, lifo, membership size: fixed contents: generic date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" class BOUNDED_STACK [G] create make feature -- Initialization make (n: INTEGER) is -- Create a stack for at most n items. require non_negative_argument: n >= 0 do create fl.make (0, n) ensure stack_allocated: capacity = n empty_stack: count = 0 end feature -- Access has (v: G): BOOLEAN is -- Does v appear in stack? -- (Reference or object equality, -- based on object_comparison.) do if object_comparison then fl.compare_objects else fl.compare_references end Result := fl.has (v) ensure -- from CONTAINER not_found_in_empty: Result implies not is_empty end item: G is -- Last item pushed (i.e. top) require -- from ACTIVE readable: readable require else not_empty: count > 0 do Result := fl.item (count) end feature -- Measurement capacity: INTEGER is do Result := fl.count - 1 end count: INTEGER occurrences (v: G): INTEGER is do if object_comparison then fl.compare_objects else fl.compare_references end Result := fl.occurrences (v) ensure -- from BAG non_negative_occurrences: Result >= 0 end feature -- Status report changeable_comparison_criterion: BOOLEAN is -- May object_comparison be changed? -- (Answer: yes by default.) -- (from CONTAINER) do Result := True end empty: BOOLEAN is obsolete "ELKS 2000: Use `is_empty' instead" -- Is there no element? -- (from CONTAINER) do Result := is_empty end extendible: BOOLEAN is do Result := not full ensure then Result = not full end full: BOOLEAN is -- Is structure full? -- (from BOUNDED) do Result := (count = capacity) end is_empty: BOOLEAN is -- Is structure empty? -- (from FINITE) do Result := (count = 0) end is_inserted (v: G): BOOLEAN is -- Has v been inserted by the most recent insertion? -- (By default, the value returned is equivalent to calling -- `has (v)'. However, descendants might be able to provide more -- efficient implementations.) -- (from COLLECTION) do Result := has (v) end object_comparison: BOOLEAN -- Must search operations use equal rather than = -- for comparing references? (Default: no, use =.) -- (from CONTAINER) Prunable: BOOLEAN is True readable: BOOLEAN is -- Is there a current item that may be read? -- (from DISPENSER) do Result := not is_empty end Resizable: BOOLEAN is True writable: BOOLEAN is -- Is there a current item that may be modified? -- (from DISPENSER) do Result := not is_empty end feature -- Status setting compare_objects is -- Ensure that future search operations will use equal -- rather than = for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := True ensure -- from CONTAINER object_comparison end compare_references is -- Ensure that future search operations will use = -- rather than equal for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := False ensure -- from CONTAINER reference_comparison: not object_comparison end feature -- Element change append (s: SEQUENCE [G]) is -- Append a copy of s. -- (Synonym for fill) -- (from DISPENSER) do fill (s) end extend (v: like item) is -- Push v on top. -- Was declared in BOUNDED_STACK as synonym of force and put. require -- from COLLECTION extendible: extendible do count := count + 1 fl.put (v, count) ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from BAG one_more_occurrence: occurrences (v) = old (occurrences (v)) + 1 ensure then -- from STACK item_pushed: item = v end fill (other: LINEAR [G]) is -- Fill with as many items of other as possible. -- Fill items with greatest index from other first. -- Items inserted with lowest index (from other) will -- always be on the top of stack. -- The representations of other and current structure -- need not be the same. -- (from STACK) require -- from COLLECTION other_not_void: other /= void extendible local temp: ARRAYED_STACK [G] do create temp.make (0) from other.start until other.off loop temp.extend (other.item) other.forth end from until temp.is_empty or else not extendible loop extend (temp.item) temp.remove end end force (v: like item) is -- Push v on top. -- Was declared in BOUNDED_STACK as synonym of extend and put. do count := count + 1 fl.put (v, count) ensure then -- from STACK item_pushed: item = v end put (v: like item) is -- Push v on top. -- Was declared in BOUNDED_STACK as synonym of extend and force. require -- from COLLECTION extendible: extendible do count := count + 1 fl.put (v, count) ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from STACK item_pushed: item = v end replace (v: like item) is -- Replace top item by v. require -- from ACTIVE writable: writable do fl.put (v, count) ensure -- from ACTIVE item_replaced: item = v end feature -- Removal remove is -- Remove top item. require -- from ACTIVE prunable: prunable writable: writable require else not_empty: count /= 0 local default_value: like item do fl.put (default_value, count) count := count - 1 end wipe_out is -- Remove all items. require -- from COLLECTION prunable do fl.clear_all count := 0 ensure -- from COLLECTION wiped_out: is_empty end feature {NONE} -- Removal prune_all (v: G) is -- Remove all occurrences of v. -- (Reference or object equality, -- based on object_comparison.) -- (from COLLECTION) require -- from COLLECTION prunable do from until not has (v) loop prune (v) end ensure -- from COLLECTION no_more_occurrences: not has (v) end feature -- Conversion linear_representation: ARRAYED_LIST [G] is -- Representation as a linear structure -- (in the reverse order of original insertion) local i: INTEGER do from create Result.make (count) i := count until i < 0 loop Result.extend (fl.item (i)) i := i - 1 end end feature {NONE} -- Inapplicable prune (v: G) is require -- from COLLECTION prunable: prunable do end feature {STACK} -- Implementation finish is -- Move to last position. -- (No effect if empty) do if not is_empty then index := 1 end end fl: ARRAY [G] -- Storage forth is -- Move to next position. do index := index - 1 end index: INTEGER -- Current place in stack. off: BOOLEAN is -- Is there no current item? do Result := (index < 1) or else (index > count) end start is -- Move to first position. -- (No effect if empty) do if not is_empty then index := count end end invariant count_small_enough: count <= capacity extendible_definition: extendible = not full -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from DISPENSER readable_definition: readable = not is_empty writable_definition: writable = not is_empty -- from ACTIVE writable_constraint: writable implies readable empty_constraint: is_empty implies (not readable) and (not writable) -- from FINITE empty_definition: is_empty = (count = 0) non_negative_count: count >= 0 -- from BOUNDED valid_count: count <= capacity full_definition: full = (count = capacity) indexing library: "[ EiffelBase: Library of reusable components for Eiffel. ]" status: "[ Copyright 1986-2001 Interactive Software Engineering (ISE). For ISE customers the original versions are an ISE product covered by the ISE Eiffel license and support agreements. ]" license: "[ EiffelBase may now be used by anyone as FREE SOFTWARE to develop any product, public-domain or commercial, without payment to ISE, under the terms of the ISE Free Eiffel Library License (IFELL) at http://eiffel.com/products/base/license.html. ]" source: "[ Interactive Software Engineering Inc. ISE Building 360 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Electronic mail <info@eiffel.com> Customer support http://support.eiffel.com ]" info: "[ For latest info see award-winning pages: http://eiffel.com ]" end -- class BOUNDED_STACK
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com