0.2.2 • Published 7 months ago

data-structures-simple v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Data Structures Simple

License Language GitHub release (latest by date) Branches npm

Installation and Usage

npm

npm i data-structures-simple

yarn

yarn add data-structures-simple

bun

bun add data-structures-simple

Usage

import { LinkedList } from "data-structures-simple";

const list = new LinkedList();

list.addLast(1);
list.addLast(2);
list.addLast(3);
list.addLast(4);

console.log(list.toArray()); // [1, 2, 3, 4]

list.removeLast();

console.log(list.indexOf(4)); // -1

Documentation

LinkedList

Properties

Property NameDescriptionType
NodeThe node classclass

Methods

Method NameDescriptionReturn Value
addLastAdds an element at the end of the listvoid
addFirstAdds an element at the beginning of the listvoid
addAtAdds an element at the specified indexvoid
removeFirstRemoves the first element from the listvoid
removeLastRemoves the last element from the listvoid
removeRemoves the first occurrence of the specified element from the listvoid
reverseReverses the order of the elements in the listvoid
removeAtRemoves the element at the specified indexvoid
indexOfReturns the index of the first occurrence of the specified element in list.number (-1 if not found)
containsReturns true if the list contains the specified elementboolean
getSizeReturns the number of elements in the listnumber
isEmptyReturns true if the list is emptyboolean
toArrayReturns an array containing all of the elements in this listarray
getNodeReturns the node at the specified indexNode

Stack

import { Stack, DynamicStack } from "data-structures-simple";

// Stack (default) size = 10

// DynamicStack has no size limit

Properties

Property NameDescriptionType
Stackclass

Methods

Method NameDescriptionReturn Value
pushInsert a new element into the stack.void
popRemoves and returns the top element from the stack.item (T)
peekReturns the top element from the stack without removing it.item (T)
isEmptyReturns true if the stack is empty, false otherwise.boolean
toArrayReturns the stack as an array.array (T[])
sizeReturns the number of elements in the stack.number

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Author

Acknowledgments

Contact

Project Status

  • LinkedList
  • Stack
  • Queue
  • HashTable
  • Heap
  • Graph
  • Tree
  • Trie
  • Binary Search Tree

Project Statistics

GitHub code size in bytes GitHub repo size GitHub commit activity GitHub last commit GitHub contributors GitHub stars GitHub forks GitHub watchers GitHub issues GitHub closed issues GitHub pull requests

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.0

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

8 months ago