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

extremeqt

v1.0.8

Published

An Extremely fast and lightweight QuadTree made in C++ for NodeJS

Downloads

21

Readme

ExtremeQT

Extreme QuadTree is an insanely fast QuadTree library made in C++. This QuadTree includes moving entities and deleting them making it great for game engines/collision systems. It uses the Node Addon API to run native C++ code in NodeJS. If you want to use this in raw C++, just include src/qt/tree.cpp.

Installing

npm i extremeqt

Bench marking

This bench mark is against the extremely popular JS QuadTree, timohausmann-quadtree-js. All benchmarks can be seen in the benchmarks/ folder

Inserting

  • timohausmann: 120ms on average
  • ExtremeQT: 110ms on average

Retrieving

Note: timohausmann's QuadTree would return around 400 things on average, while ExtremeQT would return around 15

  • timohausmann: 14 seconds on average
  • ExtremeQT: 18ms on average

Examples

const ExtQT = require("extremeqt");
const width = 100;
const height = 100;

const qt = new ExtQT.Instance(width, height);

qt.create(3, 50, 50); // Create an entity on the QuadTree with an ID of 3, at position 50, 50.
console.log(qt.get(20, 20, 60, 60)); // Get all entities in a square with the width and height of 60, at position 20,20
qt.move(3, 70, 70); // Moves an entity with an ID of 3 into position 70,70
qt.destroy(3); // Deletes an entity with an ID of 3

qt.deallocate(); // Do this when you will not be using the quadtree anymore. Otherwise it will cause a memory leak.

Documentation

Constructor

new Instance(width, height)

  • width - The width of the QuadTree
  • height - The height of the QuadTree

Instance.create

Places an entity on the QuadTree

create(id, x, y)

  • id - The identifier of the entity
  • x - Its position on the X-axis
  • y - Its position on the Y-axis

Instance.destroy

Deletes an entity on the QuadTree

destroy(id)

  • id - The identifier of the entity

Instance.move

Moves an entity to a different position

move(id, x, y)

  • id - The identifier of the entity
  • x - The new position on the X-axis
  • y - The new position on the Y-axis

Instance.get

Gets all the entities in the provided square

get(x, y, width, height)

  • x - The start position on the X-axis
  • y - The start position on the Y-axis
  • width - The width of the square
  • height - The height of the square

Instance.deallocate

Deallocates the QuadTree

deallocate()

Limitations

  • All positions, IDs, and the QuadTree dimensions all have to be unsigned 32bit numbers, limiting their values to under 4294967296.
  • All positions, IDs, and the QuadTree dimensions cannot be negative
  • You cannot create, move, or get entities outside the QuadTree statically set dimensions.
  • There cannot be more than 10 entities in a 2x2 space