screpl.utils.array module

screpl.utils.array. _default_compare ( a , b ) [source]

EUDFuncN

screpl.utils.array. _partition ( array , left , right , comp ) [source]

EUDFuncN - Used on REPLArray.sort (quicksort algorithm)

screpl.utils.array. _swap ( array , i , j ) [source]

EUDFuncN - Used on REPLArray.sort (quicksort algorithm)

class screpl.utils.array. REPLArray ( initval ) [source]

Bases: screpl.utils.struct.REPLStruct

static allocate ( max_size ) [source]
append ( value ) [source]
at ( index ) [source]
clear ( ) [source]
static construct ( max_size , initvals = None ) [source]
contains ( item ) [source]
delete ( index ) [source]

Deletes item with index

before

index

index+1

size-2

size-1

after

index+1

index+2

size-1

(empty)

fields = ['max_size', 'size', 'contents', 'end']
free ( ) [source]

Can be freed if the instance is initialized with allocate()

index ( item ) [source]

Returns the smallest index which has item.

If there is no such index, returns -1

insert ( index , value ) [source]

Inserts item on index

insert

index

index+1

index+2

size-1

size

size+1

before

v_i

v_(i+1)

v_(i+2)

v_(s-1)

(end)

after

value

v_i

v_(i+1)

v_(s-2)

v_(s-1)

(end)

pop ( ) [source]

Removes and returns item at last

sort ( comp = None ) [source]
values ( ) [source]

iterate over values in array

Example:

array = REPLArray.construct(5, [1, 2, 3, 2, 1])
for v in array.values():
    f_printf("%D", v)

# prints 1 2 3 2 1 on each lines
screpl.utils.array. create_refarray ( cls , empty_constructor ) [source]

Create a reference array class