Linked Lists is a module that provides basic linked list data structures.
Simply install to your roblox-ts project as follows:
npm i @rbxts/linked-lists
Wally users can install this package by adding the following line to their Wally.toml
under [dependencies]
:
LinkedLists = "bytebit/[email protected]"
Then just run wally install
.
Model files are uploaded to every release as .rbxmx
files. You can download the file from the Releases page and load it into your project however you see fit.
New versions of the asset are uploaded with every release. The asset can be added to your Roblox Inventory and then inserted into your Place via Toolbox by getting it here.
Documentation can be found here, is included in the TypeScript files directly, and was generated using TypeDoc.
Below is a simple example showing the use of a singly-linked list to implement a queue:
roblox-ts example
import { SinglyLinkedList } from "@rbxts/linked-lists";
export class Queue {
private readonly linkedList = new SinglyLinkedList<defined>();
public push(value: defined) {
this.linkedList.pushToTail(value);
}
public pop() {
return this.linkedList.popHeadValue();
}
}
Luau example
local SinglyLinkedList = require(path.to.modules["linked-lists"]).SinglyLinkedList
local Queue = {}
Queue.__index = Queue
function new()
local self = {}
setmetatable(self, Queue)
self.linkedList = SinglyLinkedList.new()
return self
end
function Queue:push(value)
self.linkedList:pushToTail(value)
end
function Queue:pop()
return self.linkedList:popHeadValue()
end
return {
new = new
}