This constructor constructs a new position that is in the range specified
by start
and end
. By using len
, it is possible to enforce that a
certain number of additional positions are available in the selected range.
This guarantees that there's space for a LogootNode of length len
at this
position between start
and end
.
The length of the allocation to make. The length is never
actually stored in the Logoot position, but is used when finding space for
the position to be created and len
position(s) after it.
This will cause the new position to have a value greater
than or equal to this. This value is tricky: It must be the end of the last
node. So if A
is at [1]
and an allocation after it is desired, then
[2]
would need to be passed to start
.
This will cause the new position to have a value less than or
equal to this, subject to the value of len
.
This will cause the new position to have a value less than or
equal to this, subject to the value of len
.
This will cause the new position to have a value greater
than or equal to this. This value is tricky: It must be the end of the last
node. So if A
is at [1]
and an allocation after it is desired, then
[2]
would need to be passed to start
.
Internal array length
Returns the last index of the array. This is useful because before this,
the algorithm code often contained many occurences of length - 1
. This
is used to cut down redundancy.
Return this position if it is between min
or max
, otherwise return
min
if this is less and max
if this is greater.
The minimum output.
The maximum output.
If defined, the output number of levels will be
equal to preserve_levels
.
Either this position, min, or max. It is not copied, so if you want to modify it, you should copy it.
Duplicates this position.
True if this object is equal to the one provided.
Return a copy of this position, but with the number of levels specified by
level
. If this position has fewer levels, zeroes will be added in place.
True if this object is greater than the one provided.
True if this object is greater than or equal to the one provided.
Returns a new position with offset
subtracted from the lowest level of
the position.
An array accessor
An array accessor
True if this object is less than the one provided.
True if this object is less than or equal to the one provided.
Returns a new position with offset
added to the lowest level of the
position.
Generated using TypeDoc
A comparable position from the original Logootish algorithm, This is just an array of numbers with some utility functions. In Logoot, it must always be possible to allocate a position between any possible two positions. In this algorithm, a position with more
levels
(or elements in the array) comes first. Positions are represented in writing the same as arrays:[1,2,3]
const a = new LogootishPosition() console.log(a.toString()) // [0] const b = a.offsetLowest(1) console.log(b.toString()) // [1] console.log(new LogootishPosition(1, a, b).toString()) // [0] console.log(new LogootishPosition(2, a, b).toString()) // [0,0]