Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

splaytree

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

splaytree

Fast Splay tree for Node and browser

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
603K
increased by1.73%
Maintainers
1
Weekly downloads
 
Created

What is splaytree?

The splaytree npm package provides an implementation of a splay tree, which is a self-adjusting binary search tree. It allows for efficient access, insertion, and deletion operations by moving frequently accessed elements closer to the root, thus optimizing subsequent operations.

What are splaytree's main functionalities?

Insertion

This feature allows you to insert elements into the splay tree. The tree adjusts itself so that the most recently accessed element is moved to the root.

const SplayTree = require('splaytree');
const tree = new SplayTree();
tree.insert(10);
tree.insert(20);
tree.insert(5);
console.log(tree.root.key); // 5

Search

This feature allows you to search for elements in the splay tree. The tree adjusts itself so that the most recently accessed element is moved to the root.

const SplayTree = require('splaytree');
const tree = new SplayTree();
tree.insert(10);
tree.insert(20);
tree.insert(5);
const node = tree.find(20);
console.log(node.key); // 20
console.log(tree.root.key); // 20

Deletion

This feature allows you to delete elements from the splay tree. The tree adjusts itself to maintain its properties after the deletion.

const SplayTree = require('splaytree');
const tree = new SplayTree();
tree.insert(10);
tree.insert(20);
tree.insert(5);
tree.remove(10);
console.log(tree.find(10)); // null

Other packages similar to splaytree

Keywords

FAQs

Package last updated on 21 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc