Coder Social home page Coder Social logo

flatqueue's Introduction

Stand with Ukraine

Hi! I'm Volodymyr Agafonkin.

I'm a software engineer. I created Leaflet, the number one library for interactive web maps, and maintain 40+ other open source projects with a focus on algorithms, computational geometry and data visualization. I'm building the future of maps at Mapbox. Here are a few of my best tech articles: https://agafonkin.com

I'm a musician. I write songs, play guitar and sing in Obiymy Doschu. If you like beautiful, evocative rock music with lush string arrangements, check out our last album.

I'm a father to beautiful 9-year-old twin girls, I'm happily married and live in Kyiv, Ukraine. I love baking, photography, strength training, martial arts, reading sci-fi and fantasy, and exploring quiet parks. You can find tidbits of my life on X (Twitter), Instagram and Facebook.

flatqueue's People

Contributors

allen-b1 avatar mourner avatar pschiffmann avatar yurivish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flatqueue's Issues

Improve documentation and naming of arguments

I tried using FlatQueue but accidentally mixed up id and value parameters.

I was under the impression that id would be some order-index, whereas value would be the actual data associated with that element. However, in reality it's the other way around.
The naming of the id parameter is what led to this confusion.

Before I understood the issue, I even wrote a wrapper because I wanted to pop the data associated with the element (instead of the order-index), because I thought FlatQueue only allowed popping the order-index.
The naming of the peek() / peekValue() functions made my confusion worse.

Even when I understood this, it also wasn't clear to me wether the order-index (value parameter) had to be an integer, or wether it could also be a rational number. It was also unclear wether the order-index could be negative.
And lastly, it also wasn't clear what happens if the same order-index is used multiple times.

It's also not clear how people should check for items in the queue: while(flatqueue.length > 0) or while(flatqueue.peekValue() !== undefined); for API stability, this should probably be documented.

Shrink internal arrays

Currently, once a FlatQueue was filled, it will use a considerable amount of memory, even when the queue is less full (even after a clear).

That happens because the FlatQueue itself will only use this.length to track the size of the queue, but the ids and values arrays will never be shrunk again (to match the current this.length).

There should be a way to trigger a cleanup of the queue, or it should clean up after itself using some heuristic.

Add support for Node.js require

Add support for being able to use require instead of import.

This is useful when working with Node.js and you for some reason can't use ES modules

Popped items can't be garbage collected

Hi!
I noticed that you only reduce this.length in pop() and clear(), but don't actually update ids. That means if I store large objects (e.g. DOM nodes) in the queue, they might not get garbage collected even if my code has no other references to them.
I don't know what the performance impact would be to always shrink ids. In any case, it should be safe to assign undefined to the unused indexes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.