Java Reference
In-Depth Information
AND (&) 0000100001000000 size(64), length(10)
0000110001100000 size(64), length(11)
0000101101000000 size(64), length(10)
----------------
OR (|) 0000111101100000 size(64), length(11)
0000110001100000 size(64), length(11)
0000101101000000 size(64), length(10)
----------------
XOR (^) 0000011100100000 size(64), length(11)
Caution Unlike Vector and Hashtable , BitSet is not synchronized. You
mustexternallysynchronizeaccesstothisclasswhenusing BitSet inamultithreaded
context.
The Collections Framework has made Vector , Stack , Dictionary , and
Hashtable obsolete. These types continue to be part of the standard class library to
support legacy code.
The framework's Iterator interface has largely obsoleted the Enumeration
interface. However, because the java.util.StringTokenizer class (which is
somewhat useful, and which is briefly discussed in Chapter 6 ) uses Enumeration ,
this interface still has some credibility.
The Preferences API (see Appendix C) has made Properties largely obsolete.
However,thestandardclasslibrarystilluses Properties invariousplaces(suchas
in the context of XSLT, discussed in Chapter 10 ) . You'll probably have a few uses for
this class as well.
Because BitSet isstillrelevant,thisclasscontinuestobeimproved.Forexample,
Java 7 introduces new valueOf() class methods (such as static BitSet
valueOf(byte[] bytes) ) and instance methods (such as int previ-
ousSetBit(int fromIndex) ) into this class.
Note Itisnotsurprisingthat BitSet isstillbeingimproved(asrecentlyasJava7
attimeofwriting)whenyourealizetheusefulnessofvariable-lengthbitsets.Because
oftheircompactnessandotheradvantages,variable-lengthbitsetsareoftenusedtoim-
plement an operating system's priority queues and facilitate memory page allocation.
Unix-orientedfilesystemsalsousebitsetstofacilitatetheallocationof inodes (inform-
Search WWH ::




Custom Search