LisaacTM Platform

NATIVE_ARRAY


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).
Inherit/Insert Summary
parent_safe_equal No developed.
 
Constructor Summary
create
Allocate a new array of nb_elements of type E. The new array is initialized with default values.
 
Basic features:
object_size
For detect error.
element_sizeof
The size in number of bytes for type E.
calloc_intern
Allocate a new array of 'nb_elements' of type E. The new array is initialized with default values.
realloc with
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
item
To read an item. Assume that calloc is already done and that index is the range [0 .. nb_elements-1].
put to
To write an item. Assume that calloc is already done and that index is the range [0 .. nb_elements-1].
 
Displacement
Infix '+'
other is in element index
 
Comparison:
memcmp until
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
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 until
Same jobs as memcmp but uses infix = instead equal.
slice_fast_memcmp
Same jobs as slice_memcmp but uses infix "=" instead of is_equal.
deep_memcmp until
Same jobs as memcmp but uses is_deep_equal instead equal.
slice_deep_memcmp
Same jobs as slice_memcmp but uses is_deep_equal instead of is_equal.
 
Searching:
first_index_of until
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 until
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 from
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 until
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 from
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 until
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 until
Look for element using == for comparison. Also consider has to choose the most appropriate.
fast_has until
Look for element using basic = for comparison. Also consider has to choose the most appropriate.
 
Removing:
remove_first
Assume upper is a valid index. Move range [1 .. upper] by 1 position left.
remove until
Assume upper is a valid index. Move range [index + 1 .. upper] by 1 position left.
 
Replacing:
replace_all with until
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 with until
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 to until
Copy range [0 .. src_capacity - 1] of src to range [dest .. dest + src_capacity - 1] of Self. No subscript checking.
slice_copy to from to
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 until
Set all elements in range [0 .. upper] with value v.
set_slice_with from until
Set all elements in range [lower .. upper] with value v.
clear_all
Set all elements in range [0 .. upper] with the default value.
clear to
Set all elements in range [lower .. upper] with the default value
copy_from until
Assume upper is a valid index both in Current and model.
deep_twin_from
To implement deep_twin. Allocate a new array of capacity initialized with deep_twin. Assume capacity is valid both in Current and model.
move to by
Move range [lower .. upper] by offset positions. Freed positions are not initialized to default values.
occurrences until
Number of occurrences of element in range [0..upper] using equal for comparison. See also fast_occurrences to chose the apropriate one.
slice_occurrences from until
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 until
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 from until
Number of occurrences of element in range [lower .. upper] using basic "=" for comparison. See also slice_occurrences to chose the apropriate one.
all_default
Do all items in range [0 .. upper] have their type's default value?
slice_default to
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
Gives access to the C pointer on the area of storage.
is_null
is_not_null
 
Guru Section
println
force_put to
Used in Memory count: not to use directly without caution !
quick_sort_from to with
Quick sort algorithm (naive implementation)
 

Inherit/Insert Detail

parent_safe_equal

.../base/collection/low_level/native_array.li line #16

Section:
Inherit

Profile:
- SelfSELFparent_safe_equal : SAFE_EQUALV)

Constructor Detail

create

.../base/collection/low_level/native_array.li line #57

Section:
Public

Profile:
- SelfSELFcreate   nb_elements : INTEGERNATIVE_ARRAYV)

Description:
Allocate a new array of nb_elements of type E. The new array is initialized with default values.

Basic features:

object_size

.../base/collection/low_level/native_array.li line #24

Section:
Public

Profile:
- SelfSELFobject_size : INTEGER

Description:
For detect error.

element_sizeof

.../base/collection/low_level/native_array.li line #26

Section:
Public

Profile:
- SelfSELFelement_sizeof : INTEGER

Description:
The size in number of bytes for type E.

calloc_intern

.../base/collection/low_level/native_array.li line #37

Section:
Public

Profile:
- SelfSELFcalloc_intern   nb_elements : INTEGERNATIVE_ARRAYV)

Description:
Allocate a new array of 'nb_elements' of type E. The new array is initialized with default values.

realloc with

.../base/collection/low_level/native_array.li line #73

Section:
Public

Profile:
- SelfSELFrealloc   old_nb_elts : INTEGER  with   new_nb_elts : INTEGERNATIVE_ARRAYV)

Description:
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

.../base/collection/low_level/native_array.li line #101

Section:
Public

Profile:
- SelfSELFfirst : V

item

.../base/collection/low_level/native_array.li line #103

Section:
Public

Profile:
- SelfSELFitem   index : INTEGERV

Description:
To read an item. Assume that calloc is already done and that index is the range [0 .. nb_elements-1].

put to

.../base/collection/low_level/native_array.li line #114

Section:
Public

Profile:
- SelfSELFput   element : V  to   index : INTEGER

Description:
To write an item. Assume that calloc is already done and that index is the range [0 .. nb_elements-1].

Displacement

Infix '+'

.../base/collection/low_level/native_array.li line #132

Section:
Public

Profile:
- SelfSELF+ ' Left 80  other : INTEGERNATIVE_ARRAYV)

Description:
other is in element index

Comparison:

memcmp until

.../base/collection/low_level/native_array.li line #145

Section:
Public

Profile:
- SelfSELFmemcmp   other : NATIVE_ARRAYV)  until   capacity : INTEGERBOOLEAN

Description:
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

.../base/collection/low_level/native_array.li line #162

Section:
Public

Profile:
- SelfSELFslice_memcmp  ( at : INTEGER, other : NATIVE_ARRAYV), other_lower : INTEGER, other_upper : INTEGER) : BOOLEAN

Description:
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 until

.../base/collection/low_level/native_array.li line #182

Section:
Public

Profile:
- SelfSELFfast_memcmp   other : NATIVE_ARRAYV)  until   capacity : INTEGERBOOLEAN

Description:
Same jobs as memcmp but uses infix = instead equal.

slice_fast_memcmp

.../base/collection/low_level/native_array.li line #196

Section:
Public

Profile:
- SelfSELFslice_fast_memcmp  ( at : INTEGER, other : NATIVE_ARRAYV), other_lower : INTEGER, other_upper : INTEGER) : BOOLEAN

Description:
Same jobs as slice_memcmp but uses infix "=" instead of is_equal.

deep_memcmp until

.../base/collection/low_level/native_array.li line #213

Section:
Public

Profile:
- SelfSELFdeep_memcmp   other : NATIVE_ARRAYV)  until   capacity : INTEGERBOOLEAN

Description:
Same jobs as memcmp but uses is_deep_equal instead equal.

slice_deep_memcmp

.../base/collection/low_level/native_array.li line #241

Section:
Public

Profile:
- SelfSELFslice_deep_memcmp  ( at : INTEGER, other : NATIVE_ARRAYV), other_lower : INTEGER, other_upper : INTEGER) : BOOLEAN

Description:
Same jobs as slice_memcmp but uses is_deep_equal instead of is_equal.

Searching:

first_index_of until

.../base/collection/low_level/native_array.li line #277

Section:
Public

Profile:
- SelfSELFfirst_index_of   element : V  until   upper : INTEGERINTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #293

Section:
Public

Profile:
- SelfSELFindex_of  ( element : V, start_index : INTEGER)  until   upper : INTEGERINTEGER

Description:
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 from

.../base/collection/low_level/native_array.li line #314

Section:
Public

Profile:
- SelfSELFreverse_index_of   element : V  from   upper : INTEGERINTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #334

Section:
Public

Profile:
- SelfSELFfast_index_of  ( element : V, start_index : INTEGER)  until   upper : INTEGERINTEGER

Description:
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 from

.../base/collection/low_level/native_array.li line #355

Section:
Public

Profile:
- SelfSELFfast_reverse_index_of   element : V  from   upper : INTEGERINTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #376

Section:
Public

Profile:
- SelfSELFfast_first_index_of   element : V  until   upper : INTEGERINTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #395

Section:
Public

Profile:
- SelfSELFhas   element : V  until   upper : INTEGERBOOLEAN

Description:
Look for element using == for comparison. Also consider has to choose the most appropriate.

fast_has until

.../base/collection/low_level/native_array.li line #412

Section:
Public

Profile:
- SelfSELFfast_has   element : V  until   upper : INTEGERBOOLEAN

Description:
Look for element using basic = for comparison. Also consider has to choose the most appropriate.

Removing:

remove_first

.../base/collection/low_level/native_array.li line #431

Section:
Public

Profile:
- SelfSELFremove_first   upper : INTEGER

Description:
Assume upper is a valid index. Move range [1 .. upper] by 1 position left.

remove until

.../base/collection/low_level/native_array.li line #445

Section:
Public

Profile:
- SelfSELFremove   index : INTEGER  until   upper : INTEGER

Description:
Assume upper is a valid index. Move range [index + 1 .. upper] by 1 position left.

Replacing:

replace_all with until

.../base/collection/low_level/native_array.li line #465

Section:
Public

Profile:
- SelfSELFreplace_all   old_value : V  with   new_value : V  until   upper : INTEGER

Description:
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 with until

.../base/collection/low_level/native_array.li line #480

Section:
Public

Profile:
- SelfSELFfast_replace_all   old_value : V  with   new_value : V  until   upper : INTEGER

Description:
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 to until

.../base/collection/low_level/native_array.li line #499

Section:
Public

Profile:
- SelfSELFcopy   src : NATIVE_ARRAYV)  to   dest : INTEGER  until   src_capacity : INTEGER

Description:
Copy range [0 .. src_capacity - 1] of src to range [dest .. dest + src_capacity - 1] of Self. No subscript checking.

slice_copy to from to

.../base/collection/low_level/native_array.li line #517

Section:
Public

Profile:
- SelfSELFslice_copy   src : NATIVE_ARRAYV)  to   dest : INTEGER  from   src_min : INTEGER  to   src_max : INTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #541

Section:
Public

Profile:
- SelfSELFset_all_with   v : V  until   upper : INTEGER

Description:
Set all elements in range [0 .. upper] with value v.

set_slice_with from until

.../base/collection/low_level/native_array.li line #553

Section:
Public

Profile:
- SelfSELFset_slice_with   v : V  from   lower : INTEGER  until   upper : INTEGER

Description:
Set all elements in range [lower .. upper] with value v.

clear_all

.../base/collection/low_level/native_array.li line #568

Section:
Public

Profile:
- SelfSELFclear_all   upper : INTEGER

Description:
Set all elements in range [0 .. upper] with the default value.

clear to

.../base/collection/low_level/native_array.li line #581

Section:
Public

Profile:
- SelfSELFclear   lower : INTEGER  to   upper : INTEGER

Description:
Set all elements in range [lower .. upper] with the default value

copy_from until

.../base/collection/low_level/native_array.li line #595

Section:
Public

Profile:
- SelfSELFcopy_from   model : NATIVE_ARRAYV)  until   upper : INTEGER

Description:
Assume upper is a valid index both in Current and model.

deep_twin_from

.../base/collection/low_level/native_array.li line #606

Section:
Public

Profile:
- SelfSELFdeep_twin_from   capacity : INTEGERNATIVE_ARRAYV)

Description:
To implement deep_twin. Allocate a new array of capacity initialized with deep_twin. Assume capacity is valid both in Current and model.

move to by

.../base/collection/low_level/native_array.li line #628

Section:
Public

Profile:
- SelfSELFmove   lower : INTEGER  to   upper : INTEGER  by   offset : INTEGER

Description:
Move range [lower .. upper] by offset positions. Freed positions are not initialized to default values.

occurrences until

.../base/collection/low_level/native_array.li line #650

Section:
Public

Profile:
- SelfSELFoccurrences   element : V  until   upper : INTEGERINTEGER

Description:
Number of occurrences of element in range [0..upper] using equal for comparison. See also fast_occurrences to chose the apropriate one.

slice_occurrences from until

.../base/collection/low_level/native_array.li line #667

Section:
Public

Profile:
- SelfSELFslice_occurrences   element : V  from   lower : INTEGER  until   upper : INTEGERINTEGER

Description:
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 until

.../base/collection/low_level/native_array.li line #687

Section:
Public

Profile:
- SelfSELFfast_occurrences   element : V  until   upper : INTEGERINTEGER

Description:
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 from until

.../base/collection/low_level/native_array.li line #704

Section:
Public

Profile:
- SelfSELFslice_fast_occurrences   element : V  from   lower : INTEGER  until   upper : INTEGERINTEGER

Description:
Number of occurrences of element in range [lower .. upper] using basic "=" for comparison. See also slice_occurrences to chose the apropriate one.

all_default

.../base/collection/low_level/native_array.li line #724

Section:
Public

Profile:
- SelfSELFall_default   upper : INTEGERBOOLEAN

Description:
Do all items in range [0 .. upper] have their type's default value?

slice_default to

.../base/collection/low_level/native_array.li line #742

Section:
Public

Profile:
- SelfSELFslice_default   lower : INTEGER  to   upper : INTEGERBOOLEAN

Description:
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

.../base/collection/low_level/native_array.li line #769

Section:
Public

Profile:
- SelfSELFto_external : POINTER

Description:
Gives access to the C pointer on the area of storage.

is_null

.../base/collection/low_level/native_array.li line #772

Section:
Public

Profile:
- SelfSELFis_null : BOOLEAN

is_not_null

.../base/collection/low_level/native_array.li line #774

Section:
Public

Profile:
- SelfSELFis_not_null : BOOLEAN

Guru Section

println

.../base/collection/low_level/native_array.li line #780

Section:
Public

Profile:
- SelfSELFprintln 

force_put to

.../base/collection/low_level/native_array.li line #782

Section:
Public

Profile:
- SelfSELFforce_put   element : V  to   index : INTEGER

Description:
Used in Memory count: not to use directly without caution !

quick_sort_from to with

.../base/collection/low_level/native_array.li line #791

Section:
Public

Profile:
- SelfSELFquick_sort_from   low : INTEGER  to   up : INTEGER  with   cmp :{VV);  BOOLEAN}

Description:
Quick sort algorithm (naive implementation)