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

holy-quad-tree

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holy-quad-tree

Optimized QuadTree made by Sopur

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Sopur's QuadTree library

This project was inspired by Timohausmann's "quadtree-js" and how slow it was
This library is extremely optimized to the point of being able to handle millions of inserts and retrieves in less than a second

Why I made this

A lot of the QuadTree's I found were so unbearably slow that I had to make my own
...
And one of my friends made a QuadTree in C++ that was (legit) 10x slower
So just to flex I'm making this public

How to use

Please look at the source for details, or just look below for examples

Basic example

const QuadTree = require("holy-quad-tree");
const qt = new QuadTree.QuadTree(
    new QuadTree.Bound(100, 100), // Width, height
    10, // Max objects before splitting
    100 // Max depth
); // Please look at the source for more details/comments

// Make everything
const Node1 = new QuadTree.Node(
    10, // X
    10, // Y
    20, // Width
    20, // Height
    "Test1" // Identifier
);
const Node2 = new QuadTree.Node(
    10, // X
    10, // Y
    20, // Width
    20, // Height
    "Test2" // Identifier
);

// Insert everything thing
qt.insert(Node1);
qt.insert(Node2);

// Retrieve what we have
qt.retrieve(
    new QuadTree.Node(
        5, // X
        5, // Y
        30, // Width
        30 // Height
    ) // Search area
); // Returns: [Node] x2

// Lets remove an object (Second one)
qt.removeObject(Node2);

// Lets try retrieving again
qt.retrieve(
    new QuadTree.Node(
        5, // X
        5, // Y
        30, // Width
        30 // Height
    ) // Search area
); // Returns: [Node] x1
// 2nd object was removed!

qt.clear(); // Deallocate everything

Keywords

FAQs

Package last updated on 08 Oct 2021

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