+
Point of view
All features
deferred class COLLECTION [E_]
Summary
Common abstract definition of a sequenceable collection of objects. Such a collection is traversable using a simple INTEGER index from lower to upper using item. All COLLECTIONs are resizable thanks to add_last / remove_last, add_first / remove_first as well as add / remove .
This abstraction provides feature to view a COLLECTION as a stack (as an example by using add_last, last, and remove_last). One can also use a COLLECTION as a queue (as an example, by using add_last, first and remove_first). See also class QUEUE and STACK.
The Liberty Eiffel standard library provides five implementations of COLLECTION: ARRAY, FAST_ARRAY, RING_ARRAY, LINKED_LIST and TWO_WAY_LINKED_LIST. Except for creations all implementations have exactly the same behavior. Switching from one implementation to another only change the memory used and the execution time (see header comment of ARRAY, FAST_ARRAY, RING_ARRAY, LINKED_LIST and TWO_WAY_LINKED_LIST for more details).
Direct parents
Inherit list: SEARCHABLE, STORABLE, TRAVERSABLE
Known children
Inherit list: ARRAY, ARRAYED_COLLECTION, FAST_ARRAY, LINKED_LIST, MACRO_COMMAND, RING_ARRAY, TWO_WAY_LINKED_LIST
Insert list: LINKED_COLLECTION
Class invariant
Overview
Features
Accessing:
{ANY}
Writing:
{ANY}
Adding:
{ANY}
  • add_first (element: ANY)
    Add a new item in first position : count is increased by one and all other items are shifted right.
  • add_last (element: ANY)
    Add a new item at the end : count is increased by one.
  • add (element: ANY, index: INTEGER_32)
    Add a new element at rank index : count is increased by one and range [index .. upper] is shifted right by one position.
  • append_collection (other: COLLECTION[E_])
    Append other to Current.
  • append_traversable (other: TRAVERSABLE[E_])
    Append other to Current.
Modification:
{ANY}
  • force (element: E_, index: INTEGER_32)
    Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).
  • copy (other: COLLECTION [E_])
    Reinitialize by copying all the items of other.
  • from_collection (model: TRAVERSABLE[ANY])
    Initialize the current object with the contents of model.
Removing:
{ANY}
Looking and Searching:
{ANY}
Looking and comparison:
{ANY}
Other features:
{ANY}
Implement manifest generic creation:
{}
{ANY}
Other features:
{ANY}
Agent-based features:
{ANY}
Printing:
{ANY}
{ANY}
{}
Counting:
{ANY}
Agent-based features:
{ANY}
{}
Indexing:
{ANY}
Accessing:
{ANY}
Looking and Searching:
{ANY}
infix "@" (i: INTEGER_32): E_
frozen
effective function
{ANY}
The infix notation which is actually just a synonym for item.
put (element: ANY, i: INTEGER_32) assign item
deferred procedure
{ANY}
Make element the item at index i.
swap (i1: INTEGER_32, i2: INTEGER_32)
effective procedure
{ANY}
Swap item at index i1 with item at index i2.
set_all_with (v: ANY)
deferred procedure
{ANY}
Set all items with value v.
set_slice_with (v: ANY, lower_index: INTEGER_32, upper_index: INTEGER_32)
effective procedure
{ANY}
Set all items in range [lower_index .. upper_index] with v.
clear_all
effective procedure
{ANY}
Set every item to its default value.
add_first (element: ANY)
deferred procedure
{ANY}
Add a new item in first position : count is increased by one and all other items are shifted right.
add_last (element: ANY)
deferred procedure
{ANY}
Add a new item at the end : count is increased by one.
add (element: ANY, index: INTEGER_32)
deferred procedure
{ANY}
Add a new element at rank index : count is increased by one and range [index .. upper] is shifted right by one position.
append_collection (other: COLLECTION[E_])
effective procedure
{ANY}
Append other to Current.
append_traversable (other: TRAVERSABLE[E_])
effective procedure
{ANY}
Append other to Current.
force (element: E_, index: INTEGER_32)
deferred procedure
{ANY}
Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).
copy (other: COLLECTION [E_])
deferred procedure
{ANY}
Reinitialize by copying all the items of other.
from_collection (model: TRAVERSABLE[ANY])
deferred procedure
{ANY}
Initialize the current object with the contents of model.
remove_first
deferred procedure
{ANY}
Remove the first element of the collection.
remove_head (n: INTEGER_32)
deferred procedure
{ANY}
Remove the n elements of the collection.
remove (index: INTEGER_32)
deferred procedure
{ANY}
Remove the item at position index.
remove_last
deferred procedure
{ANY}
Remove the last item.
remove_tail (n: INTEGER_32)
deferred procedure
{ANY}
Remove the last n item(s).
clear_count
deferred procedure
{ANY}
Discard all items (is_empty is True after that call).
clear_count_and_capacity
deferred procedure
{ANY}
Discard all items (is_empty is True after that call).
has (x: ANY): BOOLEAN
effective function
{ANY}
Look for x using is_equal for comparison.
fast_has (x: ANY): BOOLEAN
effective function
{ANY}
Look for x using basic = for comparison.
last_index_of (element: ANY): INTEGER_32
effective function
{ANY}
Using is_equal for comparison, gives the index of the last occurrence of element at or before upper.
fast_last_index_of (element: ANY): INTEGER_32
effective function
{ANY}
Using basic = for comparison, gives the index of the last occurrence of element at or before upper.
fast_is_equal (other: COLLECTION [E_]): BOOLEAN
deferred function
{ANY}
Do both collections have the same lower, upper, and items?
is_equal (other: COLLECTION [E_]): BOOLEAN
deferred function
{ANY}
Do both collections have the same lower, upper, and items?
is_equal_map (other: COLLECTION [E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower, upper, and items?
all_default: BOOLEAN
deferred function
{ANY}
Do all items have their type's default value?
same_items (other: COLLECTION[E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same items?
occurrences (element: ANY): INTEGER_32
deferred function
{ANY}
Number of occurrences of element using is_equal for comparison.
fast_occurrences (element: ANY): INTEGER_32
deferred function
{ANY}
Number of occurrences of element using basic = for comparison.
replace_all (old_value: ANY, new_value: ANY)
deferred procedure
{ANY}
Replace all occurrences of the element old_value by new_value using is_equal for comparison.
fast_replace_all (old_value: ANY, new_value: ANY)
deferred procedure
{ANY}
Replace all occurrences of the element old_value by new_value using basic = for comparison.
move (lower_index: INTEGER_32, upper_index: INTEGER_32, distance: INTEGER_32)
effective procedure
{ANY}
Move range lower_index ..
slice (min: INTEGER_32, max: INTEGER_32): COLLECTION [E_]
deferred function
{ANY}
New collection consisting of items at indexes in [min..max].
reverse
deferred procedure
{ANY}
Reverse the order of the elements.
manifest_semicolon_check: BOOLEAN
is False
constant attribute
{}
manifest_put (index: INTEGER_32, element: ANY)
deferred procedure
{}
enumerate: ENUMERATE[E_]
effective function
{ANY}
new_iterator: ITERATOR[E_]
deferred function
{ANY}
get_new_iterator: ITERATOR[E_]
frozen
effective function
{ANY}
for_each (action: PROCEDURE[TUPLE[TUPLE 1[E_]]])
effective procedure
{ANY}
Apply action to every item of Current.
for_all (test: FUNCTION[TUPLE[TUPLE 1[E_]]]): BOOLEAN
effective function
{ANY}
Do all items satisfy test?
exists (test: FUNCTION[TUPLE[TUPLE 1[E_]]]): BOOLEAN
effective function
{ANY}
Does at least one item satisfy test?
aggregate (action: FUNCTION[TUPLE[TUPLE 2[E_, E_], E_]], initial: E_): E_
effective function
{ANY}
Aggregate all the elements starting from the initial value.
out_in_tagged_out_memory
effective procedure
{ANY}
Append terse printable representation of current object in tagged_out_memory.
generation: INTEGER_32
writable attribute
{ANY}
next_generation
effective procedure
{}
count: INTEGER_32
deferred function
{ANY}
Number of available items in the hoard.
is_empty: BOOLEAN
deferred function
{ANY}
Is the hoard empty ?
See also count.
do_all (action: ROUTINE[TUPLE[TUPLE 1[E_]]])
frozen
effective procedure
{ANY}
Apply action to every item of Current.
_inline_agent1 (a: ROUTINE[TUPLE[TUPLE 1[E_]]], e: E_)
frozen
effective procedure
{}
lower: INTEGER_32
deferred function
{ANY}
Minimum index.
upper: INTEGER_32
deferred function
{ANY}
Maximum index.
valid_index (i: INTEGER_32): BOOLEAN
effective function
{ANY}
True when i is valid (i.e., inside actual bounds).
item (i: INTEGER_32): E_
deferred function
{ANY}
Item at the corresponding index i.
first: E_
deferred function
{ANY}
The very first item.
last: E_
deferred function
{ANY}
The last item.
first_index_of (element: ANY): INTEGER_32
deferred function
{ANY}
Give the index of the first occurrence of element using is_equal for comparison.
index_of (element: ANY, start_index: INTEGER_32): INTEGER_32
deferred function
{ANY}
Using is_equal for comparison, gives the index of the first occurrence of element at or after start_index.
reverse_index_of (element: ANY, start_index: INTEGER_32): INTEGER_32
deferred function
{ANY}
Using is_equal for comparison, gives the index of the first occurrence of element at or before start_index.
fast_first_index_of (element: ANY): INTEGER_32
deferred function
{ANY}
Give the index of the first occurrence of element using basic = for comparison.
fast_index_of (element: ANY, start_index: INTEGER_32): INTEGER_32
deferred function
{ANY}
Using basic = for comparison, gives the index of the first occurrence of element at or after start_index.
fast_reverse_index_of (element: ANY, start_index: INTEGER_32): INTEGER_32
deferred function
{ANY}
Using basic = comparison, gives the index of the first occurrence of element at or before start_index.