The value type.
Constructs a LocalList whose allowed Positions are given by
source
.
Using positions that were not generated by source
(or a replica of
source
) will cause undefined behavior.
The source for positions that may be used with this LocalList.
Whether this list is in its initial state, i.e., it has never been mutated.
The length of the list.
Returns an iterator for values in the list, in list order.
Deletes the given position, making it no longer present in this list.
Whether the position was actually deleted, i.e., it was initially present.
Returns an iterator of [index, value, position] tuples for every value in the list, in list order.
Returns the value currently at index.
Returns the value at position, or undefined if it is not currently present (hasPosition returns false).
Returns the position currently at index.
Returns the number of "seen" positions for waypoint
.
This is useful in some optimized list CRDTs.
Specifically, the return value is 1 + the max valueIndex across
all positions of the form [waypoint, valueIndex]
that have
been passed to set or setCreated.
Returns whether position is currently present in the list, i.e., its value is present.
Returns the current index of position.
If position is not currently present in the list (hasPosition returns false), then the result depends on searchDir:
To find the index where a position would be if
present, use searchDir = "right"
.
Loads saved state. The saved state must be from
a call to save on a LocalList whose source
constructor argument was a replica of this's
source
, so that we can understand the
saved state's Positions.
This method may only be called on a LocalList in its initial state (see inInitialState); it does not support "merging" in the sense of CRuntime.load.
Saved state from another LocalList's save call.
Used to deserialize values. Must be equivalent to save's valueArraySerializer.
Returns an iterator for present positions, in list order.
Returns saved state describing the current state of this LocalList, including its values.
The saved state may later be passed to load on a new instance of LocalList, to reconstruct the same list state.
Used to serialize values. Note that this may be called multiple times on distinct value arrays, and value arrays may contain non-contiguous values.
Sets the value at position.
Optimized variant of set for newly-created positions.
If you (or a remote replica) just created values.count
positions using [[CTotalOrder.createPosition]], you may call
this method with the first created position and the values to
set at the created positions. This may be faster than
calling set on each (position, value) individually.
The position for values[0].
The values to set.
Returns a copy of a section of this list, as an array. For both start and end, a negative index can be used to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
The beginning index of the specified portion of the list. If start is undefined, then the slice begins at index 0.
The end index of the specified portion of the list. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the list.
Returns an iterator for values in the list, in list order.
Generated using TypeDoc
A local (non-collaborative) data structure mapping Positions to values, in list order.
You can use a LocalList to maintain a sorted, indexable view of a CValueList, CList, or CText's values. For example, when using a CList, you could store its archived values in a LocalList. That would let you iterate over the archived values in list order.
To construct a LocalList that uses an existing list's positions, pass that list's
totalOrder
to our constructor.It is not safe to modify a LocalList while iterating over it. The iterator will attempt to throw an exception if it detects such modification, but this is not guaranteed.