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

sorted-linked-list

v1.0.6

Published

An ADT implemenation of a sorted, singly-linked, linked-list

Downloads

12

Readme

CircleCI GitHub issues npm

npm npm

Sorted Linked List Library

This repository contains a library for managing a sorted, singly-linked, linked list. The concept behind a linked-list is that developers can maintain an in-memory data structure to store a set of items without initially knowing the size and therefore without having to re-allocate arrays each time a limit is reached. Furthermore in this implementation the overall sort is maintained on the data and as the list get large, it converts to a skip-list to improve performance.

Installation

npm install sorted-linked-list

Usage

var LinkedList = require('sorted-linked-list');
var myList = new LinkedList();

Instantiation

The LinkedList can be instantiated with an optional parameter object to specify initial values of the list if needed. The only currently implemented option is 'values', but this is designed to be extended over time.

var parameters = { values: ['cat', 'dog', 'liger', 'donkey']};
var myList = new LinkedList(parameters);

Properties

- head

The head properties returns the first node in the list in LinkedList.Node format.

myList.insert('first');
console.log(myList.head.data);

- length

The length property returns the number of items in the list.

console.log(myList.length);

Methods

- insert

myList.insert('one');

Inserts a new item into the list.

myList.insert('dog');
myList.insert('cat');
myList.insert('monkey');
console.log(myList.head.data);

- remove

Removes an item in a list if the target value is found. Returns 'true' if an item was removed.

myList.insert('dog');
var isDeleted = myList.remove('dog');

- clear

Empties an existing LinkedList

myList.insert('dog');
myList.insert('cat');
myList.insert('monkey');
myList.clear();
console.log(myList.length);

- contains

Returns 'true' if the LinkedList contains the specified value.

myList.insert('dog');
var result = myList.contains('dog');

- iterator

Provides a method to iterate through the items in the Linked List

var current = myList.iterator();
while(!(x = current.next()).done) {
   console.log(x.value);
};

- toArray

Converts the LinkedList to an Array

var myArray = myList.toArray();
console.log(myArray.toString());