This package has been deprecated

Author message:

Make your own

@rbxts/object-stack
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ObjectStack

A Stack data structure which is formed by creating a singly linked-list on already existing objects. All you need to do is add a previousNode?: T field to your object you wish to use in the Stack.

See the index.d.ts file for documentation on each member and method.

Demo:

import ObjectStack from "@rbxts/object-stack";

interface Token {
	type: "a" | "b" | "c";
	previousNode?: Token;
}

const objectStack = new ObjectStack<Token>();

objectStack.push({ type: "b" });
objectStack.push({ type: "a" });
objectStack.push({ type: "c" });

objectStack.pop(); // { type: "c" }
objectStack.isEmpty(); // false

// iterates through the stack, from top to bottom
for (let token = objectStack.top; token; token = token.previousNode) {
	const x = token.type;
}

Install

DownloadsWeekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

4.2 kB

Total Files

4

Last publish

Collaborators

  • validark