work in progress | array |
|
|
|
|
|
|
||||
Yes | Yes | make
(minindex, maxindex: INTEGER)
-- Allocate array; set index interval to -- `minindex' .. `maxindex'; set all values to default. -- (Make array empty if `minindex' = `maxindex' + 1) |
make(minindex,
maxindex: INTEGER)
-- Make array with range [`minindex' .. `maxindex']. -- When `maxindex' = `minindex' - 1, the array is empty. |
make(
minindex, maxindex : INTEGER )
-- Allocate array; set index interval to 'minindex' .. 'maxindex'; -- set all values to default. -- (Make array empty if 'minindex' > 'maxindex') |
Yes | Yes | make_from_array
(a: ARRAY [G])
-- Initialize from the items of `a'. -- (Useful in proper descendants of class `ARRAY', -- to initialize an array-like object from a manifest array.) |
make_from_array(
arr : ARRAY[G] )
-- Initialize from the items of 'arr'. -- (Useful in proper descendants of class ARRAY, -- to initialize an array-like object from a manifest array) |
|
setup
(other: like Current)
-- Perform actions on a freshly created object so that -- the contents of `other' can be safely copied onto it. |
||||
with_capacity(needed_capacity,
low: INTEGER)
-- Create an empty array with `capacity' initialized -- at least to `needed_capacity' and `lower' set to `low'. |
||||
from_collection(model: COLLECTION[like item]) | ||||
|
||||
Yes
entry removed |
Yes | frozen
item,
frozen infix "@", entry (i: INTEGER): G
-- Entry at index `i', if in index interval |
item, infix "@" (index: INTEGER): E | frozen
infix "@", item( i : INTEGER ) : G
-- Entry at index 'i', if in index interval |
entry(
i : INTEGER ) : G
-- Entry at index 'i', if in index interval. -- (Redefinable synonym for 'item' and 'infix "@"') |
||||
Yes | has
(v: G): BOOLEAN
-- Does `v' appear in array? -- (Reference or object equality, -- based on `object_comparison'.) |
|||
object_comparison:
BOOLEAN;
-- Must search operations use `equal' rather than `=' -- for comparing references? (Default: no, use `='.) |
||||
changeable_comparison_criterion:
BOOLEAN
-- May `object_comparison' be changed? -- (Answer: yes by default.) |
||||
fast_has(x:
like item): BOOLEAN
-- Look for `x' using basic `=' for comparison. -- Also consider `has' to choose the most appropriate. |
||||
Yes | index_of(element:
like item): INTEGER
-- Give the index of the first occurrence of `element' using -- `is_equal' for comparison. -- Answer `upper + 1' when `element' is not inside. -- Also consider `fast_index_of' to choose the most appropriate. |
|||
fast_index_of(element:
like item): INTEGER
-- Give the index of the first occurrence of `element' using -- basic `=' for comparison. -- Answer `upper + 1' when `element' is not inside. -- Also consider `index_of' to choose the most appropriate. |
||||
Yes | first:
like item
-- The very `first' item. |
|||
Yes | last:
like item
-- The `last' item. |
|||
reverse_index_of (v: like item) | ||||
|
||||
Yes | Yes | lower:
INTEGER;
-- Minimum index |
lower:
INTEGER;
-- Lower index bound. |
frozen lower : INTEGER |
Yes | Yes | upper:
INTEGER;
-- Maximum index |
upper:
INTEGER;
-- Upper index bound. |
upper
: INTEGER
-- Maximum index |
Yes | Yes | count,
capacity:
INTEGER
-- Number of available indices |
count:
INTEGER
-- Number of elements actually stored in the collection. |
frozen count : INTEGER |
Yes | capacity:
INTEGER;
-- Internal storage capacity in number of item. |
|||
Yes | occurrences
(v: G): INTEGER
-- Number of times `v' appears in structure |
|||
nb_occurrences(element:
like item): INTEGER
-- Number of occurrences of `element' using `equal' for comparison. -- Also consider `fast_nb_occurences' to choose the most appropriate. |
||||
fast_nb_occurrences(element:
like item): INTEGER
-- Number of occurrences of `element' using basic `=' for comparison. -- Also consider `nb_occurences' to choose the most appropriate. |
||||
size
: INTEGER
obsolete "Eiffel/S 1.3 compatibility" |
||||
|
||||
Yes | Yes | is_equal
(other: like Current): BOOLEAN
-- Is array made of the same items as `other'? |
is_equal(other: like Current): BOOLEAN | is_equal(
other : like Current ) : BOOLEAN
-- Is array made of the same items as 'other' ? -- (Redefined from GENERAL) |
|
||||
compare_objects
-- Ensure that future search operations will use `equal' -- rather than `=' for comparing references. |
||||
compare_references
-- Ensure that future search operations will use `=' -- rather than `equal' for comparing references. |
||||
is_empty: BOOLEAN | empty:
BOOLEAN
-- Is collection empty? |
empty
: BOOLEAN
obsolete "Eiffel/S 1.3 compatibility" |
||
consistent
(other: like Current): BOOLEAN
-- Is object in a consistent state so that `other' -- may be copied onto it? (Default answer: yes). |
||||
full:
BOOLEAN
-- Is structure filled to capacity? (Answer: yes) |
||||
all_cleared:
BOOLEAN
-- Are all items set to default values? |
all_cleared:
BOOLEAN
-- Are all items set to the default value ? |
all_cleared
: BOOLEAN
obsolete "Eiffel/S 1.3 compatibility" |
||
Yes | Yes | valid_index
(i: INTEGER): BOOLEAN
-- Is `i' within the bounds of the array? |
frozen
valid_index(index:
INTEGER): BOOLEAN
-- True when `index' is valid (ie. inside actual -- bounds of the collection). |
valid_index(
i : INTEGER ) : BOOLEAN
-- Is 'i' within the bounds of the array ? |
valid_key
(k: H): BOOLEAN is
-- Is `k' a valid key? |
||||
extendible:
BOOLEAN
-- May items be added? -- (Answer: no, although array may be resized.) |
||||
prunable:
BOOLEAN
-- May items be removed? (Answer: no.) |
||||
resizable:
BOOLEAN
-- May `capacity' be changed? |
||||
|
||||
Yes
enter removed |
Yes | frozen
put,
enter (v: like item; i: INTEGER)
-- Replace `i'-th entry, if in index interval, by `v'. |
put (element: like item; index: INTEGER) | frozen
put(
v : G; i : INTEGER )
-- Replace 'i-th' entry, if in index interval, by 'v' |
enter removed | Yes | enter(
v : G; i : INTEGER )
-- Replace 'i-th' entry, if in index interval, by 'v'. -- (Redefinable synonym for 'put') |
||
Yes | Yes | force
(v: like item; i: INTEGER)
-- Assign item `v' to `i'-th entry. -- Always applicable: resize the array if `i' falls out of -- currently defined bounds; preserve existing items. |
force(element:
like item; index: INTEGER)
-- Put `element' at position `index'. Current is -- resized if `index' is not inside current bounds. -- New bounds are initialized with default values. |
force(
v : G; i : INTEGER )
-- Assign item 'v' to 'i-th' entry. -- Always applicable: resize the array if 'i' falls out of -- currently defined bounds; preserve existing items |
subcopy
(other: like Current; start_pos, end_pos, index_pos: INTEGER)
-- Copy items of `other' within bounds `start_pos' and `end_pos' -- to current array starting at index `index_pos'. |
||||
set_all_with(v: like item) | ||||
fill
(other: CONTAINER [G])
-- Fill with as many items of `other' as possible. -- The representations of `other' and current structure -- need not be the same. |
||||
Yes | add_first(element:
like item)
-- Add a new item in first position : `count' is increased by -- one and all other items are shifted right. |
|||
Yes | add_last(element:
like item)
-- Add a new item at the end : `count' is increased by one. |
|||
Yes | add(element:
like item; index: INTEGER) is
-- Add a new `element' at rank `index' : `count' is increased -- by one and range [`index' .. `upper'] is shifted right -- by one position. |
|||
insert(
element : G; index : INTEGER )
obsolete "Eiffel/S 1.3 compatibility" |
||||
swap(i1,
i2: INTEGER)
-- Swap item at index `i1' with item at index `i2'. |
||||
set_slice_with(v:
like item; lower_index, upper_index: INTEGER) is
-- Set all items in range [`lower_index' .. `upper_index'] with `v'. |
||||
replace_all(old_value,
new_value: like item) is
-- Replace all occurences of the element `old_value' by `new_value' -- using `equal' for comparison. -- See also `fast_replace_all' to choose the apropriate one. |
||||
fast_replace_all(old_value,
new_value: like item) is
-- Replace all occurences of the element `old_value' by `new_value' -- using operator `=' for comparison. -- See also `replace_all' to choose the apropriate one. |
||||
|
||||
Yes | wipe_out
-- Make array empty. |
wipe_out
obsolete "Eiffel/S 1.3 compatibility" |
||
clear_all
-- Reset all items to default values. |
clear_all
-- Set all items to default values. -- The `count' is not affected (see also `clear'). |
clear_all
obsolete "Eiffel/S 1.3 compatibility" |
||
prune_all
(v: G)
-- Remove all occurrences of `v'. -- (Reference or object equality, -- based on `object_comparison'.) --|Default implementation, usually inefficient. |
||||
Yes | remove_first
-- Remove the `first' element of the collection. |
|||
Yes | remove_last
-- Remove the `last' item. |
|||
Yes | remove(index:
INTEGER)
-- Remove the item at position `index'. Followings items -- are shifted left by one position. |
remove(
index : INTEGER )
obsolete "Eiffel/S 1.3 compatibility" |
||
clear
-- Discard all items in order to make it `empty'. -- See also `clear_all'. |
||||
|
||||
grow
(i: INTEGER)
-- Change the capacity to at least `i'. |
||||
Growth_percentage:
INTEGER is 50;
-- Percentage by which structure will grow automatically |
||||
Minimal_increase:
INTEGER is 5;
-- Minimal number of additional items |
||||
additional_space:
INTEGER
-- Proposed number of additional items --| Result is a reasonable value, resulting from a space-time tradeoff. |
||||
automatic_grow
-- Change the capacity to accommodate at least -- `Growth_percentage' more items. --| Trades space for time: --| allocates fairly large chunks of memory but not very often. |
||||
Yes | Yes | resize
(minindex, maxindex: INTEGER)
-- Rearrange array so that it can accommodate -- indices down to `minindex' and up to `maxindex'. -- Do not lose any previously entered item. |
resize(minindex,
maxindex: INTEGER)
-- Resize the array. No elements will be lost in the -- intersection of [old `lower' .. old `upper'] and -- [`minindex' .. `maxindex']. -- New positions are initialized with appropriate -- default values. |
resize(
minindex, maxindex : INTEGER )
-- Rearrange array so that it can accommodate -- indices down to 'minindex' and up to 'maxindex'. -- Do not lose any previously entered item |
Yes | reindex(
new_lower : INTEGER )
obsolete "Eiffel/S 1.3 compatibility" |
|||
move(lower_index,
upper_index, distance: INTEGER) is
-- Move range `lower_index' .. `upper_index' by `distance' -- positions. Negative distance moves towards lower indices. -- Free places get default values. |
move(
lower_index, upper_index, distance : INTEGER )
obsolete "Eiffel/S 1.3 compatibility" |
|||
|
||||
Yes | to_c:
ANY
-- Address of actual sequence of values, -- for passing to external (non-Eiffel) routines. |
to_c
: POINTER
-- Address of actual sequence of values, -- for passing to external (non-Eiffel) routines |
||
from_c(
ptr : POINTER; cnt : INTEGER )
-- Creates array from its external representation |
||||
linear_representation:
LINEAR [G]
-- Representation as a linear structure |
||||
Yes | to_external:
POINTER
-- Gives C access into the internal `storage' of the ARRAY. -- Result is pointing the element at index `lower'. -- -- NOTE: do not free/realloc the Result. Resizing of the array -- can makes this pointer invalid. |
to_external
: POINTER
obsolete "Eiffel/S 1.3 compatibility" |
||
|
||||
Yes | Yes | copy
(other: like Current)
-- Reinitialize by copying all the items of `other'. -- (This is also used by `clone'.) |
copy(other: like Current) | copy(
other : like Current )
-- Reinitialize by copying all the items of 'other'. -- (This is also used by 'clone'.) -- (From GENERAL) |
subarray
(start_pos, end_pos: INTEGER): like Current
-- Array made of items of current array within -- bounds `start_pos' and `end_pos'. |
sub_array(low, up: INTEGER): like Current | |||
slice(low,
up: INTEGER): like Current
-- Create a new collection initialized with elements of -- range `low'..`up'. Result has the same dynamic type -- as Current collection. The `lower' index of the new -- collection is the same as `lower' of Current. |
||||
|
||||
frozen fill_tagged_out_memory | ||||
|
||||
prune
(v: G)
-- Remove first occurrence of `v' if any. -- (Precondition is false.) |
||||
extend
(v: G)
-- Add `v' to structure. -- (Precondition is false.) |
||||
|
||||
adjust_capacity (n: INTEGER) | ||||
|
||||
arycpy
(old_area: POINTER; newsize, s, n: INTEGER): like area
-- New area of size `newsize' containing `n' items -- from `oldarea'. -- Old items are at position `s' in new area. |
||||
auto_resize
(minindex, maxindex: INTEGER)
-- Rearrange array so that it can accommodate -- indices down to `minindex' and up to `maxindex'. -- Do not lose any previously entered item. -- If area must be extended, ensure that space for at least -- additional_space item is added. |
||||
area:
SPECIAL [T];
-- Special data zone |
frozen area : POINTER | |||
empty_area: BOOLEAN | ||||
make_area
(n: INTEGER)
-- Creates a special object for `n' entries. |
||||
set_area
(other: like area)
-- Make `other' the new `area' |
||||
spsubcopy
(source, target: POINTER; s, e, i: INTEGER)
-- Copy elements of `source' within bounds `s' -- and `e' to `target' starting at index `i'. |
||||
spclearall
(p: POINTER)
-- Reset all items to default value. |
||||
frozen b_area : POINTER | ||||
frozen pcount : INTEGER | ||||
frozen size_item : INTEGER | ||||
c_move(
lower_index, number, distance : INTEGER )
-- Eiffel/S 1.3 compatibility |
||||
c_put_default(
index : INTEGER )
-- Eiffel/S 1.3 compatibility |
||||
c_array_make( cnt : INTEGER; lwr : INTEGER ) | ||||
c_array_copy( other : ARRAY[G] ) | ||||
c_array_is_equal( other : ARRAY[G] ) : BOOLEAN | ||||
c_array_resize( cnt : INTEGER; lwr : INTEGER ) | ||||
c_array_resize( cnt : INTEGER; lwr : INTEGER ) | ||||
c_array_put( i : INTEGER; v : G ) | ||||
c_og_move( dst : POINTER; dst_index : INTEGER; src : POINTER; src_size : INTEGER ) | ||||
c_wipe_out
-- Empty the array, discard all items |
||||
free
-- Free the memory used by the Current COLLECTION (objects -- pointed by the Current COLLECTION are not affected). -- Assume you don't use Current any more. obsolete "Since release -0.81, the Garbage Collector is % %implemented. This feature will be soon removed." |
||||
frozen
equal_like(e1,
e2: like item): BOOLEAN
-- Note: this feature is called to avoid calling `equal' -- on expanded types (no automatic conversion to -- corresponding reference type). |
||||
storage:
NATIVE_ARRAY[E];
-- Internal access to storage location. |
||||
set_upper(new_upper: like upper) |
ARRAY_ROUTINES | Context |
make_from_array
(an_array: ARRAY [G]; min_index: INTEGER): ARRAY [G]
-- Create a new array and initialize it -- with items from `an_array'. |
|
has (an_array:
ARRAY [G]; v: G): BOOLEAN
-- Does `v' appear in `an_array'? -- Use `=? |
VE, SE |
subarray
(an_array: ARRAY [G]; start_pos, end_pos, min_index: INTEGER): ARRAY [G]
-- Array made up of items from `an_array' within -- bounds `start_pos' and `end_pos' |
GLex:
0
GYacc: 2 |
subcopy
(an_array, other: ARRAY [G]; start_pos, end_pos, index_pos: INTEGER)
-- Copy items of `other' within bounds `start_pos' and `end_pos' -- to `an_array' starting at index `index_pos'. |
VE, SE
GLex: 1 GYacc: 0 |
clear_all
(an_array: ARRAY [G])
-- Reset all items to default values. |
VE |