Class DS_DISPENSER |
note
description: "Dispenser containers" library: "Gobo Eiffel Structure Library" author: "Eric Bezault <ericb@gobosoft.com>" copyright: "Copyright (c) 1999-2001, Eric Bezault and others" license: "MIT License"
deferred class interface
DS_DISPENSER [G]
inherit
DS_SEARCHABLE [G] DS_CONTAINER [G]
feature {NONE} -- Initialization
make_default -- Create an empty container. -- (From DS_CONTAINER.) deferred ensure empty: is_empty
feature -- Access
item: G -- Item accessible from dispenser require not_empty: not is_empty deferredequality_tester: DS_EQUALITY_TESTER [G] -- Equality tester; -- A void equality tester means that `=' -- will be used as comparison criterion. -- (From DS_SEARCHABLE.)
feature -- Measurement
count: INTEGER -- Number of items in dispenser -- (From DS_CONTAINER.) deferredoccurrences (v: G): INTEGER -- Number of times v appears in dispenser -- (Use equality_tester's comparison criterion -- if not void, use `=' criterion otherwise.) -- (From DS_SEARCHABLE.) deferred ensure positive: Result >= 0 has: has (v) implies Result >= 1
feature -- Status report
has (v: G): BOOLEAN -- Does dispenser include v? -- (Use equality_tester's comparison criterion -- if not void, use `=' criterion otherwise.) -- (From DS_SEARCHABLE.) deferred ensure not_empty: Result implies not is_emptyis_empty: BOOLEAN -- Is dispenser empty? -- (From DS_CONTAINER.)extendible (n: INTEGER): BOOLEAN -- May dispenser be extended with n items? require positive_n: n >= 0 deferredsame_items (v, u: G): BOOLEAN -- Are v and u considered equal? -- (Use equality_tester's comparison criterion -- if not void, use `=' criterion otherwise.) -- (From DS_SEARCHABLE.)same_equality_tester (other: DS_SEARCHABLE [G]): BOOLEAN -- Does container use the same comparison -- criterion as other? -- (From DS_SEARCHABLE.) require other_not_void: other /= Voidequality_tester_settable (a_tester: like equality_tester): BOOLEAN -- Can set_equality_tester be called with a_tester -- as argument in current state of container? -- (Default answer: True.) -- (From DS_SEARCHABLE.)
feature -- Comparison
is_equal (other: like Current): BOOLEAN -- Is current dispenser equal to other? -- (From GENERAL.) require other_not_void: other /= Void deferred ensure consistent: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_equal (Current) same_count: Result implies count = other.count
feature -- Duplication
copy (other: like Current) -- Copy other to current dispenser. -- (From GENERAL.) require other_not_void: other /= Void type_identity: same_type (other) deferred ensure is_equal: is_equal (other)
feature -- Setting
set_equality_tester (a_tester: like equality_tester) -- Set equality_tester to a_tester. -- A void equality tester means that `=' -- will be used as comparison criterion. -- (From DS_SEARCHABLE.) require equality_tester_settable: equality_tester_settable (a_tester) ensure equality_tester_set: equality_tester = a_tester
feature -- Element change
put (v: G) -- Add v to dispenser. require extendible: extendible (1) deferred ensure one_more: count = old count + 1force (v: G) -- Add v to dispenser. deferred ensure one_more: count = old count + 1extend (other: DS_LINEAR [G]) -- Add items of other to dispenser. -- Add other.first first, etc. require other_not_void: other /= Void extendible: extendible (other.count) deferred ensure new_count: count = old count + other.countappend (other: DS_LINEAR [G]) -- Add items of other to dispenser. -- Add other.first first, etc. require other_not_void: other /= Void deferred ensure new_count: count = old count + other.count
feature -- Removal
remove -- Remove item from dispenser. require not_empty: not is_empty deferred ensure one_less: count = old count - 1prune (n: INTEGER) -- Remove n items from dispenser. require valid_n: 0 <= n and n <= count deferred ensure new_count: count = old count - nkeep (n: INTEGER) -- Keep n items in dispenser. require valid_n: 0 <= n and n <= count deferred ensure new_count: count = nwipe_out -- Remove all items from dispenser. -- (From DS_CONTAINER.) deferred ensure wiped_out: is_empty
invariant
positive_count: count >= 0 empty_definition: is_empty = (count = 0) -- (From DS_CONTAINER.)
end -- class DS_DISPENSER
Copyright © 1999-2001, Eric
Bezault mailto:ericb@gobosoft.com http://www.gobosoft.com Last Updated: 31 March 2001 |