class ArrayLinkedVariables : ArrayRow.ArrayRowVariables


Store a set of variables and their values in an array-based linked list. The general idea is that we want to store a list of variables that need to be ordered, space efficient, and relatively fast to maintain (add/remove). ArrayBackedVariables implements a sparse array, so is rather space efficient, but maintaining the array sorted is costly, as we spend quite a bit of time recopying parts of the array on element deletion. LinkedVariables implements a standard linked list structure, and is able to be faster than ArrayBackedVariables even though it's more costly to set up (pool of objects...), as the elements removal and maintenance of the structure is a lot more efficient. This ArrayLinkedVariables class takes inspiration from both of the above, and implement a linked list stored in several arrays. This allows us to be a lot more efficient in terms of setup (no need to deal with pool of objects...), resetting the structure, and insertion/deletion of elements.

Summary

Public functions

Unit
add(variable: SolverVariable!, value: Float, removeFromDefinition: Boolean)

Add value to an existing variable The code is broadly identical to the put() method, only differing in in-line deletion, and of course doing an add rather than a put

Unit

Clear the list of variables

Boolean

Returns true if the variable is contained in the list

Unit

print out the variables and their values

Unit

Divide the values of all the variables in the list by the given amount

Float

Return the value of a variable, 0 if not found

Int
Int
Int
getId(index: Int)

get Id in mCache.mIndexedVariables given the index

Int

Get the next index in mArrayIndices given the current one

Float
getValue(index: Int)

get value in mArrayValues given the index

SolverVariable!
getVariable(index: Int)

Return a variable from its position in the linked list

Float

Return the value of a variable from its position in the linked list

Int
indexOf(variable: SolverVariable!)
Unit

Invert the values of all the variables in the list

Unit
put(variable: SolverVariable!, value: Float)

Insert a variable with a given value in the linked list

Float
remove(variable: SolverVariable!, removeFromDefinition: Boolean)

Remove a variable from the list

Int

Show size in bytes

String!

Returns a string representation of the list

Float
use(definition: ArrayRow!, removeFromDefinition: Boolean)

Update the current list with a new definition

Protected properties

Cache!

Public functions

add

Added in 1.1.0-alpha13
fun add(variable: SolverVariable!, value: Float, removeFromDefinition: Boolean): Unit

Add value to an existing variable The code is broadly identical to the put() method, only differing in in-line deletion, and of course doing an add rather than a put

Parameters
variable: SolverVariable!

the variable we want to add

value: Float

its value

clear

Added in 1.1.0-alpha13
fun clear(): Unit

Clear the list of variables

contains

Added in 1.1.0-alpha13
fun contains(variable: SolverVariable!): Boolean

Returns true if the variable is contained in the list

Parameters
variable: SolverVariable!

the variable we are looking for

Returns
Boolean

return true if we found the variable

display

Added in 1.1.0-alpha13
fun display(): Unit

print out the variables and their values

divideByAmount

Added in 1.1.0-alpha13
fun divideByAmount(amount: Float): Unit

Divide the values of all the variables in the list by the given amount

Parameters
amount: Float

amount to divide by

get

Added in 1.1.0-alpha13
fun get(v: SolverVariable!): Float

Return the value of a variable, 0 if not found

Parameters
v: SolverVariable!

the variable we are looking up

Returns
Float

the value of the found variable, or 0 if not found

getCurrentSize

Added in 1.1.0-alpha13
fun getCurrentSize(): Int

getHead

Added in 1.1.0-alpha13
fun getHead(): Int

getId

Added in 1.1.0-alpha13
fun getId(index: Int): Int

get Id in mCache.mIndexedVariables given the index

getNextIndice

Added in 1.1.0-alpha13
fun getNextIndice(index: Int): Int

Get the next index in mArrayIndices given the current one

getValue

Added in 1.1.0-alpha13
fun getValue(index: Int): Float

get value in mArrayValues given the index

getVariable

Added in 1.1.0-alpha13
fun getVariable(index: Int): SolverVariable!

Return a variable from its position in the linked list

Parameters
index: Int

the index of the variable we want to return

Returns
SolverVariable!

the variable found, or null

getVariableValue

Added in 1.1.0-alpha13
fun getVariableValue(index: Int): Float

Return the value of a variable from its position in the linked list

Parameters
index: Int

the index of the variable we want to look up

Returns
Float

the value of the found variable, or 0 if not found

indexOf

Added in 1.1.0-alpha13
fun indexOf(variable: SolverVariable!): Int

invert

Added in 1.1.0-alpha13
fun invert(): Unit

Invert the values of all the variables in the list

put

Added in 1.1.0-alpha13
fun put(variable: SolverVariable!, value: Float): Unit

Insert a variable with a given value in the linked list

Parameters
variable: SolverVariable!

the variable to add in the list

value: Float

the value of the variable

remove

Added in 1.1.0-alpha13
fun remove(variable: SolverVariable!, removeFromDefinition: Boolean): Float

Remove a variable from the list

Parameters
variable: SolverVariable!

the variable we want to remove

Returns
Float

the value of the removed variable

sizeInBytes

Added in 1.1.0-alpha13
fun sizeInBytes(): Int

Show size in bytes

Returns
Int

size in bytes

toString

fun toString(): String!

Returns a string representation of the list

Returns
String!

a string containing a representation of the list

use

Added in 1.1.0-alpha13
fun use(definition: ArrayRow!, removeFromDefinition: Boolean): Float

Update the current list with a new definition

Parameters
definition: ArrayRow!

the row containing the definition

Protected properties

mCache

Added in 1.1.0-alpha13
protected val mCacheCache!