import { PointerList } from "https://deno.land/x/velo@0.1.5/src/utils/pointerList.ts";
Implements a fixed size doubly linked list. This implementation relies on a custom pointer system utilizing TypedArrays.
Reference: https://yomguithereal.github.io/posts/lru-cache#a-custom-pointer-system
To simplify the internals the list is implemented as a ring with a root indicating the first element. This allows for easy access to the front and back elements of the list.
The list will allow pushing any values if it is not full. To not destroy the index based structure use the newPointer() method to create a safe index.
const list = new PointerList(10);
const pointer = list.newPointer();
list.pushFront(pointer);
Methods
Inserts a pointer after a given reference pointer into the list
Moves a given pointer to the position after a reference pointer in the list
Returns the the next element of a given reference pointer. If the next element would be root undefined is returned.
Returns the the previous element of a given reference pointer. If the previous element would be the element before root undefined is returned.