Options
All
  • Public
  • Public/Protected
  • All
Menu

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]

example
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]

Hierarchy

Index

Type aliases

Static JSON

JSON: LogootInt.JSON[]

Constructors

constructor

  • 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.

    throws

    {TypeError} Will throw if start is greater than end.

    Parameters

    • Default value len: number = 0

      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.

    • Optional start: LogootishPosition

      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.

    • Optional end: LogootishPosition

      This will cause the new position to have a value less than or equal to this, subject to the value of len.

    Returns LogootishPosition

Properties

array

array: LogootInt[] = [new LogootInt(0)]

Optional Readonly end

This will cause the new position to have a value less than or equal to this, subject to the value of len.

immutable

immutable: boolean = false

Optional Readonly start

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.

Accessors

length

  • get length(): number

levels

  • get levels(): number
  • 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.

    Returns number

Methods

clamp

  • Return this position if it is between min or max, otherwise return min if this is less and max if this is greater.

    Parameters

    • min: LogootishPosition

      The minimum output.

    • max: LogootishPosition

      The maximum output.

    • Optional preserve_levels: undefined | number

      If defined, the output number of levels will be equal to preserve_levels.

    Returns LogootishPosition

    Either this position, min, or max. It is not copied, so if you want to modify it, you should copy it.

cmp

Private cmp_level

copy

eq

equivalentPositionAtLevel

  • 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.

    Parameters

    • level: number

    Returns LogootishPosition

gt

gteq

inverseOffsetLowest

iterator

l

level

lt

lteq

offsetLowest

toJSON

toString

  • toString(): string

Static fromInts

Static fromJSON

Generated using TypeDoc