Options
All
  • Public
  • Public/Protected
  • All
Menu

A position in Logoot. 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. So, if it is necessary to create a position between A and B, then another level can be added to the position to make it come after A and before B. Positions are represented in writing the same as arrays: [1,2,3]

example
const a = new LogootPosition()
console.log(a.toString()) // [0]

const b = a.offsetLowest(1)
console.log(b.toString()) // [1]

console.log(new LogootPosition(1, a, b).toString()) // [0]
console.log(new LogootPosition(2, a, b).toString()) // [0,0]

Hierarchy

  • LogootPosition

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.

    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: LogootPosition

      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: LogootPosition

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

    Returns LogootPosition

Properties

Protected array

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

Optional end

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

Optional 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: LogootPosition

      The minimum output.

    • max: LogootPosition

      The maximum output.

    • Optional preserve_levels: undefined | number

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

    Returns LogootPosition

cmp

copy

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 LogootPosition

inverseOffsetLowest

l

  • l(n: number): LogootInt

level

  • level(n: number): LogootInt

offsetLowest

toJSON

toString

  • toString(): string

Static fromJSON

Generated using TypeDoc