GithubHelp home page GithubHelp logo

Comments (4)

lemire avatar lemire commented on May 22, 2024

Good day,

They approach you describe would work. It should be reasonably fast.

It is clearly not optimal since it requires creating a new input object and then outputting yet another object. So, at a minimum, you have more memory allocations than you would like.

It is be possible to extend slightly the API to support your need, if it is in a performance-critical component of your code. I would be glad to implement this feature for you. It is not very hard to do. (You might even be able to do it on your own.) Of course, before I do so, I'd be interested in knowing more about your context as it is possible that this is not the right solution to your real problem.

  • Daniel

from roaring.

donovanhide avatar donovanhide commented on May 22, 2024

Hi Daniel,

thank you very much for the reply. Much appreciated!

My use case, in detail, is:

I have a PublicKey type which is a 32 bytes long Go array. A slice of PublicKeys is maintained. The index of each PublicKey is important and can never change. Rarely, a PublicKey might need to be deleted, but the index of the following PublicKeys must remain the same.

To make this efficient, it seems sensible to keep track of these garbage ids in a compressed bitset. If PublicKey i is deleted, then position i in the bitset is set. If PublicKey with index i is subsequently requested, the bitset is first consulted for a count of set bits below i and PublicKey with position i-count is returned from the slice. The bitset is effectively a concise way to preserve the deleted ids and get the correct PublicKey from the slice after deletions have occurred.

Hope that makes sense! I want to use a slice of PublicKeys, rather than a tree structure to minimise overall memory usage.

Any advice or extensions to the API would be very gratefully received :-)

from roaring.

lemire avatar lemire commented on May 22, 2024

Ok. I have added a Rank function. It should do what you seek.

(The technical term describing what I think you want is "rank".)

I am closing this. If it is not what you were seeking or if the implementation is faulty, please reopen.

from roaring.

donovanhide avatar donovanhide commented on May 22, 2024

Many thanks, looks like exactly what I need, will test and report back if any issues.

Much appreciated!

from roaring.

Related Issues (20)

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.