npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

estruturadedados

v1.0.0

Published

Some Data Structs implementations in Javascript for browsers or node.js

Downloads

4

Readme

EstruturasDeDados

Some Data Structs implementations in Javascript for browsers or node.js

Data Structs implementated

  • List
  • Stack
  • Binary Search Tree
  • Queue
  • Map

Instalation

There are 2 ways for install EstruturasDeDados:

- In browsers
- In Node.js

If you need in browsers:

- Download and copy the file "src/estruturas.js" to your path folder
- Then put in your HTML file <script src='path/to/estruturas.js'></script>

If you need in Node:

- $ npm install estruturasdedados
- var ESTRUTURAS = require('estruturasdedados')

Then let the magic begin

Exemples

List:

//Here you create a instance of List
var lista = new ESTRUTURAS.List();

//If you want to insert a capacity, you can do that
var lista = new ESTRUTURAS.List(10);

//Here you just add a item in list
lista.addItem({'foo': "bar"});

//Or if you want, you can pass the index that you will input with the method "setItem"
lista.setItem(1,{'test' => 2});

//You can get some itens
var obj = lista.getItem(0);

//If you want add an array with some objects
lista.addRange([{"foo": "bar"},{"teste": 1}]);

//You can insert an item at the specified index like that
lista.insert(0,{"foo": 2});

//Then, if you want clear the List
lista.clear();

//If you need search an item
var index = lista.find({"foo": "bar"});

//Checking if item exists
var flag = lista.exists({"foo": "bar"});

//You can execute a function in all elements
lista.forEach(function(item){
	console.log(item);
});

//Then you can remove one item at specified index
lista.removeAt(0);

//Or remove a range
lista.removeRange(1,3);

//You also can get a subList with method
var mySubList = lista.getRange(1,3);

Binary Search Tree:

//Here you create a instance of Binary Search Tree
var tree = new ESTRUTURAS.ArvoreBinariaBusca();

//Creating one node of your Binary Search Tree
var no = ESTRUTURAS.ArvoreBinariaBusca.newNo();

//Our node have home method, but you only need "setValue" and "getValue"
no.setValue(10);
var value = no.getValue();

//If you want put your no into the tree you need this
tree.addNo(no);

//Then you can search for some value in your tree like that. It may return one "No" object, if the value wasn't in tree, it will return false
var noS = tree.seach(10);

Stack(FIFO strategy) and Queue(LIFO strategy):

//First you should create an instance of your Struct. We will use Queue in other exemples
var struct = new ESTRUTURAS.Pilha();  //for Stack
var struct = new ESTRUTURAS.Fila();    //for Queue

//Then, you may add itens
struct.addItem({"foo": "bar"});

//You can get some objects following the strategy of the struct
var obj = struct.getItem();

//You also can clear you struct
struct.clear();

//Or check if is empty
struct.empty();

//Or check the size 
struct.size();

Map:

//Creating an instance of your Map
var map = new ESTRUTURAS.Map();

//Adding an item on map
map.addItem("foo",{"barr": 10});

//You can remove an item with a key
map.removeItem("foo");

//Or get an item
var item = map.getItem("foo");

//Then you can clear
map.clear();

Magicians

RZorzal