Lisaac prototype interface

Section Header
+ name := Strict NATIVE_ARRAY[E];
- comment :="Native array of collection library.";
This class gives access to the lowest level for arrays. As any low level array, you can
get high performances with NATIVE_ARRAYs, but you loose most valid bounds checks (as
you can do in plain C code for example).
Section Inherit
- parent_safe_equal:SAFE_EQUAL[E] :=
Section Public
Basic features:
- object_size:INTEGER :=
For detect error.
- element_sizeof:INTEGER <-
The size in number of bytes for type `E'.
- calloc_intern nb_elements:INTEGER :NATIVE_ARRAY[E] <-
Allocate a new array of 'nb_elements' of type `E'.
The new array is initialized with default values.
- create nb_elements:INTEGER :NATIVE_ARRAY[E] <-
Allocate a new array of `nb_elements' of type `E'.
The new array is initialized with default values.
- realloc old_nb_elts:INTEGER with new_nb_elts:INTEGER :NATIVE_ARRAY[E] <-
Assume Current is a valid NATIVE_ARRAY in range
[0 .. `old_nb_elts'-1]. Allocate a bigger new array in
range [0 .. `new_nb_elts'-1].
Old range is copied in the new allocated array.
New items are initialized with default values.
- first:E <-
- item index:INTEGER :E <-
To read an `item'.
Assume that `calloc' is already done and that `index' is
the range [0 .. `nb_elements'-1].
- put element:E to index:INTEGER <-
To write an item.
Assume that `calloc' is already done and that `index'
is the range [0 .. `nb_elements'-1].
Displacement
- '+' Left 80 other:INTEGER :NATIVE_ARRAY[E] <-
other is in element index
Comparison:
- memcmp other:NATIVE_ARRAY[E] until capacity:INTEGER :BOOLEAN <-
True if all elements in range [0..capacity-1] are
identical using `equal'. Assume Current and `other'
are big enough.
See also `fast_memcmp'.
- slice_memcmp (at:INTEGER,other:NATIVE_ARRAY[E],other_lower,other_upper:INTEGER) :BOOLEAN <-
True if all elements in range [0 .. `other_upper' - `other_lower'] are identical
to the elements in range [`other_lower' .. `other_upper'] of `other' using
`is_equal'. Assume `Current' and `other' are big enough.
See also `slice_fast_memcmp'.
- fast_memcmp other:NATIVE_ARRAY[E] until capacity:INTEGER :BOOLEAN <-
Same jobs as `memcmp' but uses infix `=' instead `equal'.
- slice_fast_memcmp (at:INTEGER, other:NATIVE_ARRAY[E], other_lower,other_upper:INTEGER) :BOOLEAN <-
Same jobs as `slice_memcmp' but uses infix "=" instead of `is_equal'.
- deep_memcmp other:NATIVE_ARRAY[E] until capacity:INTEGER :BOOLEAN <-
Same jobs as `memcmp' but uses `is_deep_equal' instead `equal'.
- slice_deep_memcmp (at:INTEGER,other:NATIVE_ARRAY[E],other_lower,other_upper:INTEGER) :BOOLEAN <-
Same jobs as `slice_memcmp' but uses `is_deep_equal' instead of `is_equal'.
Searching:
- first_index_of element:E until upper:INTEGER :INTEGER <-
Give the index of the first occurrence of `element' using
`==' for comparison.
Answer `upper + 1' when `element' is not inside.
See also `fast_index_of', `reverse_index_of'.
- index_of (element:E,start_index:INTEGER) until upper:INTEGER :INTEGER <-
Using `is_equal' for comparison, gives the index of the first occurrence of `element'
at or after `start_index'. Answer `upper + 1' when the search fail.
See also `fast_index_of', `reverse_index_of'.
- reverse_index_of element:E from upper:INTEGER :INTEGER <-
Give the index of the first occurrence of `element' using
`==' for comparison, from upper to lower.
Answer -1 when `element' is not inside.
- fast_index_of (element:E,start_index:INTEGER) until upper:INTEGER :INTEGER <-
Using basic `=' for comparison, gives the index of the first occurrence of
`element' at or after `start_index'. Answer `upper + 1' when the search fail.
See also `index_of', `reverse_index_of'.
- fast_reverse_index_of element:E from upper:INTEGER :INTEGER <-
Same as `reverse_index_of' but use basic `=' for comparison.
Search is done in reverse direction, which means from `upper' down to the
`0'. Answer `-1' when the search fail.
See also `reverse_index_of', `index_of'.
- fast_first_index_of element:E until upper:INTEGER :INTEGER <-
Same as `index_of' but use basic `=' for comparison.
`0'. Answer `upper + 1' when the search fail.
See also `fast_index_of', `reverse_index_of'.
- has element:E until upper:INTEGER :BOOLEAN <-
Look for `element' using `==' for comparison.
Also consider `has' to choose the most appropriate.
- fast_has element:E until upper:INTEGER :BOOLEAN <-
Look for `element' using basic `=' for comparison.
Also consider `has' to choose the most appropriate.
Removing:
- remove_first upper:INTEGER <-
Assume `upper' is a valid index.
Move range [1 .. `upper'] by 1 position left.
- remove index:INTEGER until upper:INTEGER <-
Assume `upper' is a valid index.
Move range [`index' + 1 .. `upper'] by 1 position left.
Replacing:
- replace_all old_value:E with new_value:E until upper:INTEGER <-
Replace all occurences of the element `old_value' by `new_value'
using `==' for comparison.
See also `fast_replace_all' to choose the apropriate one.
- fast_replace_all old_value:E with new_value:E until upper:INTEGER <-
Replace all occurences of the element `old_value' by `new_value'
using basic `=' for comparison.
See also `replace_all' to choose the apropriate one.
Adding:
- copy src:NATIVE_ARRAY[E] to dest:INTEGER until src_capacity:INTEGER <-
Copy range [0 .. `src_capacity - 1'] of `src' to range
[`dest' .. `dest + src_capacity - 1'] of `Self'.
No subscript checking.
- slice_copy src:NATIVE_ARRAY[E] to dest:INTEGER from src_min:INTEGER to src_max:INTEGER <-
Copy range [`src_min' .. `src_max'] of `src' to range
[`at' .. `at + src_max - src_min - 1'] of `Current'.
No subscript checking.
Other:
- set_all_with v:E until upper:INTEGER <-
Set all elements in range [0 .. upper] with
value `v'.
- set_slice_with v:E from lower:INTEGER until upper:INTEGER <-
Set all elements in range [`lower' .. `upper'] with value `v'.
- clear_all upper:INTEGER <-
Set all elements in range [0 .. `upper'] with
the default value.
- clear lower:INTEGER to upper:INTEGER <-
Set all elements in range [`lower' .. `upper'] with
the default value
- copy_from model:NATIVE_ARRAY[E] until upper:INTEGER <-
Assume `upper' is a valid index both in Current and `model'.
- deep_twin_from capacity:INTEGER :NATIVE_ARRAY[E] <-
To implement `deep_twin'. Allocate a new array of
`capacity' initialized with `deep_twin'.
Assume `capacity' is valid both in Current and `model'.
- move lower:INTEGER to upper:INTEGER by offset:INTEGER <-
Move range [`lower' .. `upper'] by `offset' positions.
Freed positions are not initialized to default values.
- occurrences element:E until upper:INTEGER :INTEGER <-
Number of occurrences of `element' in range [0..upper]
using `equal' for comparison.
See also `fast_occurrences' to chose the apropriate one.
- slice_occurrences element:E from lower:INTEGER until upper:INTEGER :INTEGER <-
Number of occurrences of `element' in range [`lower' .. `upper'] using
`is_equal' for comparison.
See also `slice_fast_occurrences' to chose the apropriate one.
- fast_occurrences element:E until upper:INTEGER :INTEGER <-
Number of occurrences of `element' in range [0..upper]
using basic "=" for comparison.
See also `fast_occurrences' to chose the apropriate one.
- slice_fast_occurrences element:E from lower:INTEGER until upper:INTEGER :INTEGER <-
Number of occurrences of `element' in range [`lower' .. `upper']
using basic "=" for comparison.
See also `slice_occurrences' to chose the apropriate one.
- all_default upper:INTEGER :BOOLEAN <-
Do all items in range [0 .. `upper'] have their type's
default value?
- slice_default lower:INTEGER to upper:INTEGER :BOOLEAN <-
Do all items in range [`lower' .. `upper'] have their type's default value?
Note: for non Void items, the test is performed with the `is_default' predicate.
Interfacing with C:
- to_external:POINTER <-
Gives access to the C pointer on the area of storage.
- is_null:BOOLEAN <-
- is_not_null:BOOLEAN <-
Guru Section
- force_put element:E to index:INTEGER <-
Used in Memory count: not to use directly without caution !