import * as fathymCommon from "https://deno.land/x/fathym_common@v0.2.173/src/common/iterables/Stack.ts";
This is a simple implementation of a stack data structure.
Examples
From direct import
From direct import
import { Stack } from "@fathym/common/iterables";
const stack = new Stack<number>();
stack.Push(1);
stack.Push(2);
stack.Pop(); // Output: 2
stack.Peek(); // Output: 1
stack.Pop(); // Output: 1
stack.IsEmpty(); // Output: true
From common import
From common import
import { Stack } from "@fathym/common";
const stack = new Stack<number>();
stack.Push(1);
stack.Push(2);
stack.Pop(); // Output: 2
stack.Pop(); // Output: 1