[Rd] BitSet equivalent? Java code usable?

Tommy Fortes tommy.fortes at gmail.com
Mon Oct 10 19:21:12 CEST 2011

If you don't have NAs in your bits, you might be able to use the raw
vector type. A raw value is one byte (8 bits), doesn't support NAs and
supports bit operations on all the bits at once:

  &, |, !, xor

You'd probably want to wrap it into a class that allows a more
BitSet-like view of it though. Maybe there's a package out there that
does that already?

...and if you DO have NAs, you could use two raw vectors (or two
consecutive raw-vector bits per BitSet bit).

Good luck!


2011/10/8 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
> On 07.10.2011 19:01, Joachim Harloff wrote:
>> Hi all,
>> I consider writing a R package on statistics for the sorting method as a
>> hobby. I have written a private Java application that I could use as a
>> basis. Therefore I'd like to ask two questions:
>> 1) logical vectors: Bit storage (small) and capable of bit operations?
>> The Java application relies on BitSet(s) for efficiency reasons. Arrays of
>> logical values cost far too much memory (in the 2nd level heap etc.) while
>> chunks of BitSets easily fit into the first processor cache. Moreover the
>> Bit operations or, xor, and, andnot, cardinality, clone, flip, equals,
>> intersects are much faster done for BitSets than equivalent functions
>> written for logical arrays. Is there any equivalent for BitSet in R? The
>> vector type "logical" seems to be not equally powerful and I do not know its
>> memory requirements. In BitSets a Bit requires just one Bit, no more.
> Logical values in R do have at least 3 values: TRUE, FALSE and NA, hence
> cannot be implemented in one bit.
>> 2) Can Java code be used?
>> Can I use some Java code for a R package (without translating it first to
>> C. This is not always simple)? Probably this sounds ugly but it would
>> greatly simplify the task for me.
> See the rJava package.
> Best,
> Uwe Ligges
>> Regards,
>> Joachim Harloff
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list