LisaacTM Platform

FAST_ARRAY


Resizable, fixed lower bound array.Unlike ARRAY, the `lower' bound of a FAST_ARRAY is frozen to 0. Thus, some memory is saved and looping toward `lower' bound (which is 0) run a little bit faster.
General purpose resizable FAST_ARRAYs. The only difference with ARRAY is the fact that the `lower' bound is actually frozen to 0. The `item' access is likely to be more efficient as well as loop going from `upper' to `lower' just because `lower' is 0. Keep in mind that even if the `lower' is frozen to 0 it is really better to use the `lower' attribute, and not 0 directly, just because you may decide in the future to use another COLLECTION implementation.
Like ARRAY, the FAST_ARRAY implementation uses only one chunk of memory, the `storage' area which is a NATIVE_ARRAY. One must keep in mind that this internal `storage' area is always kept left align. Thus, you can expect good performances while using a FAST_ARRAY to modelize a stack behavior with `add_last' / `last' / `remove_last'. Conversely `add_first' and `remove_first' are likely to slow down your program if they are too often used. If the fact that `lower' is stuck to 0 do matter, also consider ARRAY.
Inherit/Insert Summary
parent_arrayed_collection
parent_arrayed No developed.
parent_collection No developed.
 
Constructor Summary
create
Make array with range [0 .. new_count - 1]. When new_count = 0 the array is empty.
create_with_capacity
Create an empty array with at least needed_capacity.
create_with_native_array_byte size
 
Slot Summary
lower
Frozen lower bound.
Creation and modification:
Minimum index.
See also upper, valid_index, item.
make_with_map_object
BSBS: A revoir.
make_with_native_array_byte size
make
Make array with range [0 .. new_count - 1]. When new_count = 0 the array is empty.
with_capacity
Create an empty array with at least needed_capacity.
storage
Internal access to storage location.
element_sizeof
The size in number of bytes for type E. The size in number of bytes for type E.
capacity
Internal storage capacity in number of item.
upper
Upper index bound. Maximum index.
See also lower, valid_index, item.
set_count
to_native_array_uinteger_8
add_last_buffer from to
get_buffer_from_byte size_bytes
 
Hashable.
hash_code
 
Modification:
set_capacity
Resize capacity the array, but not count.
fast_resize
resize
Resize the array. When new_count is greater than count, new positions are initialized with appropriate default values.
 
Implementation of deferred:
is_empty
end is_empty Is collection empty ?
See also count.
item
Item at the corresponding index i.
put to
Make element the item at index i.
put_last
add first
add_first
Add a new item in first position : count is increased by one and all other items are shifted right.
add_last
Add a new item at the end : count is increased by one.
count
end count Number of available indices.
See also is_empty, lower, upper.
clear
Discard all items in order to make it is_empty.
copy
Copy other onto Current. Reinitialize by copying all the items of other.
set_all_with
Set all items with value v.
first
The very first item.
See also last, item.
second
last
The last item.
See also first, item.
add to
Add a new element at rank index : count is increased by one and range [index .. upper] is shifted right by one position.
remove_last
Remove the last item.
remove_tail
Remove the last n item(s).
replace_all with
Replace all occurrences of the element old_value by new_value using equal for comparison.
fast_replace_all with
Replace all occurrences of the element old_value by new_value using operator = for comparison.
reverse
Reverse the order of the elements.
 
MHMH : reference_at :
reference_at with
Searches the first item such that cmp(e, item) is true. Returns NULL if no one match.
 
Sort (BSBS: to put in ARRAYED_COLLECTION)
bubble_sort
Bubble sort
bubble_sort_with
Bubble sort
quick_sort_from to
quick_sort_from to with
Quick sort algorithm (naive implementation)
quick_sort
quick_sort_with
 
Other.
from_collection
Initialize the current object with the contents of model.
Infix '=='
Do both collections have the same lower, upper, and items? The basic = is used for comparison of items.
is_equal_map
Do both collections have the same lower, upper, and items? Feature == is used for comparison of items.
all_default
Do all items have their type's default value? Note: for non NULL items, the test is performed with the is_default predicate.
occurrences
Number of occurrences of element using equal for comparison.
fast_occurrences
Number of occurrences of element using basic = for comparison.
first_index_of
Give the index of the first occurrence of element using == for comparison. Answer upper + 1 when element is not inside.
index_of start
Using is_equal for comparison, gives the index of the first occurrence of element at or after start_index. Answer upper + 1 when element when the search fail.
reverse_index_of start
Using is_equal for comparison, gives the index of the first occurrence of element at or before start_index. Search is done in reverse direction, which means from the start_index down to the lower index . Answer lower -1 when the search fail.
fast_first_index_of
Give the index of the first occurrence of element using basic = for comparison. Answer upper + 1 when element is not inside.
fast_index_of start
Using basic = for comparison, gives the index of the first occurrence of element at or after start_index. Answer upper + 1 when element when the search fail.
fast_reverse_index_of
fast_reverse_index_of start
Using basic = comparison, gives the index of the first occurrence of element at or before start_index. Search is done in reverse direction, which means from the start_index down to the lower index . Answer lower -1 when the search fail.
subarray to
slice New collection consisting of items at indexes in [min .. max]. Result has the same dynamic type as Current. See also slice.
force to
Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).
remove_first
Remove the first element of the collection.
remove_head
Remove the n elements of the collection.
remove
Remove the item at position index. Followings items are shifted left by one position.
remove to
remove_since
 
Guru Section.
set_upper
 
Interfacing with C:
to_external
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_native_array
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.
 

Inherit/Insert Detail

parent_arrayed_collection

.../base/collection/fast_array.li line #32

Section:
Inherit

Profile:
+ SelfSELFparent_arrayed_collection :Expanded  ARRAYED_COLLECTIONV)

parent_arrayed

.../base/collection/low_level/arrayed_collection.li line #12

Section:
Inherit

Profile:
- SelfSELFparent_arrayed : ARRAYED

parent_collection

.../base/collection/low_level/arrayed_collection.li line #14

Section:
Inherit

Profile:
- SelfSELFparent_collection : COLLECTIONV)

Constructor Detail

create

.../base/collection/fast_array.li line #42

Section:
Public

Profile:
- SelfSELFcreate   new_count : INTEGERSELF

Description:
Make array with range [0 .. new_count - 1]. When new_count = 0 the array is empty.

create_with_capacity

.../base/collection/fast_array.li line #52

Section:
Public

Profile:
- SelfSELFcreate_with_capacity   new_count : INTEGERSELF

Description:
Create an empty array with at least needed_capacity.

create_with_native_array_byte size

.../base/collection/fast_array.li line #61

Section:
Public

Profile:
- SelfSELFcreate_with_native_array_byte   na : NATIVE_ARRAYUINTEGER_8)  size   s : INTEGERSELF

Detail slot

lower

.../base/collection/fast_array.li line #36

Section:
Public

Profile:
- SelfSELFlower : INTEGER

Description:
Frozen lower bound.
Creation and modification:
Minimum index.
See also upper, valid_index, item.

make_with_map_object

.../base/collection/fast_array.li line #69

Section:
Public

Profile:
- SelfSELFmake_with_map_object   obj : OBJECT

Description:
BSBS: A revoir.

make_with_native_array_byte size

.../base/collection/fast_array.li line #84

Section:
Public

Profile:
- SelfSELFmake_with_native_array_byte   na : NATIVE_ARRAYUINTEGER_8)  size   s : INTEGER

make

.../base/collection/fast_array.li line #98

Section:
Public

Profile:
- SelfSELFmake   new_count : INTEGER

Description:
Make array with range [0 .. new_count - 1]. When new_count = 0 the array is empty.

with_capacity

.../base/collection/fast_array.li line #121

Section:
Public

Profile:
- SelfSELFwith_capacity   needed_capacity : INTEGER

Description:
Create an empty array with at least needed_capacity.

storage

.../base/collection/low_level/arrayed_collection.li line #18

Section:
Public

Profile:
+ SelfSELFstorage : NATIVE_ARRAYV)

Description:
Internal access to storage location.

element_sizeof

.../base/collection/low_level/arrayed_collection.li line #23

Section:
Public

Profile:
- SelfSELFelement_sizeof : INTEGER

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

capacity

.../base/collection/low_level/arrayed_collection.li line #35

Section:
Public

Profile:
+ SelfSELFcapacity : INTEGER

Description:
Internal storage capacity in number of item.

upper

.../base/collection/low_level/arrayed_collection.li line #38

Section:
Public

Profile:
+ SelfSELFupper : INTEGER

Description:
Upper index bound. Maximum index.
See also lower, valid_index, item.

set_count

.../base/collection/low_level/arrayed_collection.li line #167

Section:
Public

Profile:
- SelfSELFset_count   new_count : INTEGER

to_native_array_uinteger_8

.../base/collection/low_level/arrayed_collection.li line #172

Section:
Public

Profile:
- SelfSELFto_native_array_uinteger_8 : NATIVE_ARRAYUINTEGER_8)

add_last_buffer from to

.../base/collection/low_level/arrayed_collection.li line #177

Section:
Public

Profile:
- SelfSELFadd_last_buffer   buf : FAST_ARRAYUINTEGER_8)  from   beg : INTEGER  to   end : INTEGER

get_buffer_from_byte size_bytes

.../base/collection/low_level/arrayed_collection.li line #200

Section:
Public

Profile:
- SelfSELFget_buffer_from_byte   i : INTEGER  size_bytes   s : INTEGERFAST_ARRAYUINTEGER_8)

Hashable.

hash_code

.../base/collection/fast_array.li line #144

Section:
Public

Profile:
- SelfSELFhash_code : INTEGER

Modification:

set_capacity

.../base/collection/fast_array.li line #161

Section:
Public

Profile:
- SelfSELFset_capacity   new_capacity : INTEGER

Description:
Resize capacity the array, but not count.

fast_resize

.../base/collection/fast_array.li line #180

Section:
Public

Profile:
- SelfSELFfast_resize   new_count : INTEGER

resize

.../base/collection/fast_array.li line #188

Section:
Public

Profile:
- SelfSELFresize   new_count : INTEGER

Description:
Resize the array. When new_count is greater than count, new positions are initialized with appropriate default values.

Implementation of deferred:

is_empty

.../base/collection/fast_array.li line #224

Section:
Public

Profile:
- SelfSELFis_empty : BOOLEAN

Description:
end is_empty Is collection empty ?
See also count.

item

.../base/collection/fast_array.li line #226

Section:
Public

Profile:
- SelfSELFitem   i : INTEGERV

Description:
Item at the corresponding index i.

See:
lower, upper, valid_index, put, swap

put to

.../base/collection/fast_array.li line #231

Section:
Public

Profile:
- SelfSELFput   element : V  to   i : INTEGER

Description:
Make element the item at index i.

See:
lower, upper, valid_index, item, swap, force.

put_last

.../base/collection/fast_array.li line #236

Section:
Public

Profile:
- SelfSELFput_last   element : V

add first

.../base/collection/fast_array.li line #241

Section:
Public

Profile:
- SelfSELFadd   element : V  first   n : INTEGER

add_first

.../base/collection/fast_array.li line #261

Section:
Public

Profile:
- SelfSELFadd_first   element : V

Description:
Add a new item in first position : count is increased by one and all other items are shifted right.

See:
add_last, first, last, add.

add_last

.../base/collection/fast_array.li line #273

Section:
Public

Profile:
- SelfSELFadd_last   element : V

Description:
Add a new item at the end : count is increased by one.

See:
add_first, last, first, add.

count

.../base/collection/fast_array.li line #291

Section:
Public

Profile:
- SelfSELFcount : INTEGER

Description:
end count Number of available indices.
See also is_empty, lower, upper.

clear

.../base/collection/fast_array.li line #293

Section:
Public

Profile:
- SelfSELFclear 

Description:
Discard all items in order to make it is_empty.

See:
clear_all.

copy

.../base/collection/fast_array.li line #301

Section:
Public

Profile:
- SelfSELFcopy   other : SELF

Description:
Copy other onto Current. Reinitialize by copying all the items of other.

set_all_with

.../base/collection/fast_array.li line #322

Section:
Public

Profile:
- SelfSELFset_all_with   v : V

Description:
Set all items with value v.

See:
set_slice_with.

first

.../base/collection/low_level/arrayed_collection.li line #64

Section:
Public

Profile:
- SelfSELFfirst : V

Description:
The very first item.
See also last, item.

second

.../base/collection/low_level/arrayed_collection.li line #66

Section:
Public

Profile:
- SelfSELFsecond : V

last

.../base/collection/low_level/arrayed_collection.li line #68

Section:
Public

Profile:
- SelfSELFlast : V

Description:
The last item.
See also first, item.

add to

.../base/collection/low_level/arrayed_collection.li line #70

Section:
Public

Profile:
- SelfSELFadd   element : V  to   index : INTEGER

Description:
Add a new element at rank index : count is increased by one and range [index .. upper] is shifted right by one position.

See:
add_first, add_last, append_collection.

remove_last

.../base/collection/low_level/arrayed_collection.li line #81

Section:
Public

Profile:
- SelfSELFremove_last 

Description:
Remove the last item.

See:
remove_first, remove, remove_tail.

remove_tail

.../base/collection/low_level/arrayed_collection.li line #86

Section:
Public

Profile:
- SelfSELFremove_tail   n : INTEGER

Description:
Remove the last n item(s).

See:
remove_head, remove, remove_last.

replace_all with

.../base/collection/low_level/arrayed_collection.li line #91

Section:
Public

Profile:
- SelfSELFreplace_all   old_value : V  with   new_value : V

Description:
Replace all occurrences of the element old_value by new_value using equal for comparison.

See:
fast_replace_all, move.

fast_replace_all with

.../base/collection/low_level/arrayed_collection.li line #96

Section:
Public

Profile:
- SelfSELFfast_replace_all   old_value : V  with   new_value : V

Description:
Replace all occurrences of the element old_value by new_value using operator = for comparison.

See:
replace_all, move.

reverse

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

Section:
Public

Profile:
- SelfSELFreverse 

Description:
Reverse the order of the elements.

MHMH : reference_at :

reference_at with

.../base/collection/fast_array.li line #331

Section:
Public

Profile:
- SelfSELFreference_at   e : V  with   cmp :{VV);  BOOLEAN}V

Description:
Searches the first item such that cmp(e, item) is true. Returns NULL if no one match.

Sort (BSBS: to put in ARRAYED_COLLECTION)

bubble_sort

.../base/collection/fast_array.li line #350

Section:
Public

Profile:
- SelfSELFbubble_sort 

Description:
Bubble sort

bubble_sort_with

.../base/collection/fast_array.li line #356

Section:
Public

Profile:
- SelfSELFbubble_sort_with   cmp :{VV);  BOOLEAN}

Description:
Bubble sort

quick_sort_from to

.../base/collection/fast_array.li line #384

Section:
Public

Profile:
- SelfSELFquick_sort_from   low : INTEGER  to   up : INTEGER

quick_sort_from to with

.../base/collection/fast_array.li line #387

Section:
Public

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

Description:
Quick sort algorithm (naive implementation)

quick_sort

.../base/collection/fast_array.li line #408

Section:
Public

Profile:
- SelfSELFquick_sort 

quick_sort_with

.../base/collection/fast_array.li line #410

Section:
Public

Profile:
- SelfSELFquick_sort_with   cmp :{VV);  BOOLEAN}

Other.

from_collection

.../base/collection/fast_array.li line #416

Section:
Public

Profile:
- SelfSELFfrom_collection   model : COLLECTIONV)

Description:
Initialize the current object with the contents of model.

Infix '=='

.../base/collection/fast_array.li line #428

Section:
Public

Profile:
- SelfSELF== ' Right 60  other : EBOOLEAN

Description:
Do both collections have the same lower, upper, and items? The basic = is used for comparison of items.

See:
is_equal_map, same_items.

is_equal_map

.../base/collection/fast_array.li line #444

Section:
Public

Profile:
- SelfSELFis_equal_map   other : SELFBOOLEAN

Description:
Do both collections have the same lower, upper, and items? Feature == is used for comparison of items.

See:
==, same_items.

all_default

.../base/collection/fast_array.li line #456

Section:
Public

Profile:
- SelfSELFall_default : BOOLEAN

Description:
Do all items have their type's default value? Note: for non NULL items, the test is performed with the is_default predicate.

See:
clear_all.

occurrences

.../base/collection/fast_array.li line #464

Section:
Public

Profile:
- SelfSELFoccurrences   element : VINTEGER

Description:
Number of occurrences of element using equal for comparison.

See:
fast_occurrences, index_of.

fast_occurrences

.../base/collection/fast_array.li line #469

Section:
Public

Profile:
- SelfSELFfast_occurrences   element : VINTEGER

Description:
Number of occurrences of element using basic = for comparison.

See:
occurrences, index_of.

first_index_of

.../base/collection/fast_array.li line #474

Section:
Public

Profile:
- SelfSELFfirst_index_of   element : VINTEGER

Description:
Give the index of the first occurrence of element using == for comparison. Answer upper + 1 when element is not inside.

Parameter:
element : element to search.

Require:
element not null.

Ensure:
Very good fonction

See:
fast_first_index_of, index_of start, last_index_of, reverse_index_of.

Description en francais:
Donne l'index de la premiere occurence de element en utilisant == pour la comparaison. Renvoi upper + 1 lorsque element est absent.

Necessite:
element pas null.

Voir:
fast_first_index_of, index_of, last_index_of, reverse_index_of.

index_of start

.../base/collection/fast_array.li line #483

Section:
Public

Profile:
- SelfSELFindex_of   element : V  start   start_index : 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 element when the search fail.

See:
fast_index_of, reverse_index_of, first_index_of.

reverse_index_of start

.../base/collection/fast_array.li line #492

Section:
Public

Profile:
- SelfSELFreverse_index_of   element : V  start   start_index : INTEGERINTEGER

Description:
Using is_equal for comparison, gives the index of the first occurrence of element at or before start_index. Search is done in reverse direction, which means from the start_index down to the lower index . Answer lower -1 when the search fail.

See:
fast_reverse_index_of, last_index_of, index_of.

fast_first_index_of

.../base/collection/fast_array.li line #497

Section:
Public

Profile:
- SelfSELFfast_first_index_of   element : VINTEGER

Description:
Give the index of the first occurrence of element using basic = for comparison. Answer upper + 1 when element is not inside.

See:
first_index_of, last_index_of, fast_last_index_of.

fast_index_of start

.../base/collection/fast_array.li line #506

Section:
Public

Profile:
- SelfSELFfast_index_of   element : V  start   start_index : INTEGERINTEGER

Description:
Using basic = for comparison, gives the index of the first occurrence of element at or after start_index. Answer upper + 1 when element when the search fail.

See:
index_of, fast_reverse_index_of, fast_first_index_of.

fast_reverse_index_of

.../base/collection/fast_array.li line #515

Section:
Public

Profile:
- SelfSELFfast_reverse_index_of   element : VINTEGER

fast_reverse_index_of start

.../base/collection/fast_array.li line #525

Section:
Public

Profile:
- SelfSELFfast_reverse_index_of   element : V  start   start_index : INTEGERINTEGER

Description:
Using basic = comparison, gives the index of the first occurrence of element at or before start_index. Search is done in reverse direction, which means from the start_index down to the lower index . Answer lower -1 when the search fail.

See:
reverse_index_of, fast_index_of, fast_last_index_of.

subarray to

.../base/collection/fast_array.li line #530

Section:
Public

Profile:
- SelfSELFsubarray   min : INTEGER  to   max : INTEGERSELF

Description:
slice New collection consisting of items at indexes in [min .. max]. Result has the same dynamic type as Current. See also slice.

force to

.../base/collection/fast_array.li line #539

Section:
Public

Profile:
- SelfSELFforce   element : V  to   index : INTEGER

Description:
Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).

See:
put, item, swap.

remove_first

.../base/collection/fast_array.li line #551

Section:
Public

Profile:
- SelfSELFremove_first 

Description:
Remove the first element of the collection.

See:
remove_last, remove, remove_head.

remove_head

.../base/collection/fast_array.li line #567

Section:
Public

Profile:
- SelfSELFremove_head   n : INTEGER

Description:
Remove the n elements of the collection.

See:
remove_tail, remove, remove_first.

remove

.../base/collection/fast_array.li line #573

Section:
Public

Profile:
- SelfSELFremove   index : INTEGER

Description:
Remove the item at position index. Followings items are shifted left by one position.

See:
remove_first, remove_head, remove_tail, remove_last.

remove to

.../base/collection/fast_array.li line #579

Section:
Public

Profile:
- SelfSELFremove   beg : INTEGER  to   end : INTEGER

remove_since

.../base/collection/fast_array.li line #594

Section:
Public

Profile:
- SelfSELFremove_since   beg : INTEGER

Guru Section.

set_upper

.../base/collection/fast_array.li line #608

Section:
Public

Profile:
- SelfSELFset_upper   new_upper : INTEGER

Interfacing with C:

to_external

.../base/collection/low_level/arrayed_collection.li line #117

Section:
Public

Profile:
- SelfSELFto_external : POINTER

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

.../base/collection/low_level/arrayed_collection.li line #133

Section:
Public

Profile:
- SelfSELFto_native_array : NATIVE_ARRAYV)

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