INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Simple lists: containers with one element entries", "implementing a first-in, first-out policy and", "supporting only restricted traversal in one direction"
project: "Visual Eiffel"
revision: "$Revision: 1.2 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: containers
class SIMPLE_LIST_ [G]
inherit

CONTAINER_ [G]
end

SIMPLE_TRAVERSABLE_
end
creation

make
feature -- Operations

allocate_automatically
-- switches the list to the mode of automatic memory allocation
-- for new slots; it can be necessary only if 'allocate_manually'
-- was called before because, by default, all types of the lists
-- allocate memory automatically

allocate_manually (new_capacity: INTEGER)
-- forbids the list to allocate memory for new slots automatically
-- and sets the total amount of slots allocated in the list to be
-- equal to 'new_capacity' - being negligent after that in manual
-- allocating extra slots for new entries to be put might lead to
-- the exception of type SCIF ("container is full")
--
require
no_obstacle: not is_protected
proper_capacity: new_capacity >= count and then new_capacity > 0

make (is_unique: BOOLEAN)
-- tells the container if its entries must be unigue

merge (other: like Current)
-- puts all entries from 'other' into the list
require
no_obstacle: not is_protected
valid_argument: other /= void
ensure
well_done: count = guide.count

put (x: G)
-- adds the entry into the list
require
valid_argument: x /= void
no_obstacle: not is_protected
uniqueness: unique_items implies not has_item (x)
is_not_full: no_reallocation implies count < capacity
ensure
well_done: not empty and then has_item (x) and then count = guide.count

remove (x: G)
-- deletes the entry from the list
require
no_obstacle: not is_protected
valid_argument: x /= void
valid_target: has_item (x)
ensure
well_done: count = guide.count

remove_all (x: G)
-- deletes the entry from the list together with all its
-- duplicates if more than one copy is currently stored
require
no_obstacle: not is_protected
valid_argument: x /= void
valid_target: has_item (x)
ensure
well_done: not has_item (x) and then count = guide.count

search (x: G)
-- looks for the element: after every successful attempt 'found'
-- is set to true and 'found_item' - to the found element
-- in case of failure 'found' is set to false
require
valid_argument: x /= void

wipe_out
-- remove all entries from the list
require
no_obstacle: not is_protected
ensure
well_done: empty and then count = guide.count
feature -- Queries

count: INTEGER

found: BOOLEAN

found_item: G

unique_items: BOOLEAN

capacity: INTEGER
-- gives the number of all slots allocated in the list (all types
-- of the lists may have not only slots occupied by the entries
-- already put into but unused ones also)

count_of (x: G): INTEGER
-- gives the number of the duplicates of the entry inclusive; if
-- 'unique_items = true' then the number can be only zero or one
require
valid_argument: x /= void
ensure
well_done: Result <= count

cursor_at (x: G): SIMPLE_CURSOR_
-- delivers a new cursor positioned to the entry; if there is no
-- such entry currently stored in the list Void is delivered
require
valid_argument: x /= void
ensure
well_done: Result /= void implies is_protected

has_item (x: G): BOOLEAN
-- is the entry currently stored in the list ?
require
valid_argument: x /= void

item_at (cs: SIMPLE_CURSOR_): G
-- delivers the entry of the list the cursor is positioned to
require
proper_cursor: is_inside (cs)
invariant

nothing_lost: capacity = count + guide.stock
properly_tuned: capacity = guide.capacity
is_ordered: guide /= void and then guide.target = Current
end -- class SIMPLE_LIST_

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES