data structures - java: sparse bit vector -


Is there a famous library for sparse bit vectors in Java?

(And there are guidelines for how rare is it useful to use them?)

Sparse matrices (1d, 2d and 3d) in it. It also has a skilled bit vector, in which instead of 8 bits boolean [] does, with 1 value per bit.

However, sparse matrix does not directly support bits - only pairs and objects, you can mark the bit index for long index by (bitIndex> 6) Double matrix can be wrapped, as each long 64-bit repeats are repeated by a long, long price, and reaching long-bits recovered to use bit manipulation, do a little bit of work, but the spineless vector Not to apply the device elsewhere. Once your cover is working, you can avoid converting doubles for a long time, and using a foil source code available for double 1d spurs matrix as the starting point, apply a real sparse long 1d matrix. You can.

EDIT: More info. For storage of colt vectors / matrix no memory is required initially, assuming that all the bits are initially 0. Setting the value for zero consumes memory. Setting the value back to 0 continues to use memory, although the memory of zero values ​​is retrieved periodically.

If bits are really sparse, then there is only one bit set in each backing long value, so the storage overhead will be very bad, with 64 bit per bit bit stored. But as you mention the specific case, if 20-40% is sparse, then the upper part will be very low, probably no waste storage if the bits are clustered in the category, e.g. Bits from 0-100, then 1000-1100, and 2000-2200 (value in hex.) Overall, only 1/16 bits of the field have been assigned, but clustering means that the bits are replaced with the wasted space Has not been deposited


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -