< prev index next >

src/java.base/share/classes/java/util/BitSet.java

Print this page




1037         for (int i = wordsInUse; --i >= 0; )
1038             h ^= words[i] * (i + 1);
1039 
1040         return (int)((h >> 32) ^ h);
1041     }
1042 
1043     /**
1044      * Returns the number of bits of space actually in use by this
1045      * {@code BitSet} to represent bit values.
1046      * The maximum element in the set is the size - 1st element.
1047      *
1048      * @return the number of bits currently in this bit set
1049      */
1050     public int size() {
1051         return words.length * BITS_PER_WORD;
1052     }
1053 
1054     /**
1055      * Compares this object against the specified object.
1056      * The result is {@code true} if and only if the argument is
1057      * not {@code null} and is a {@code Bitset} object that has
1058      * exactly the same set of bits set to {@code true} as this bit
1059      * set. That is, for every nonnegative {@code int} index {@code k},
1060      * <pre>((BitSet)obj).get(k) == this.get(k)</pre>
1061      * must be true. The current sizes of the two bit sets are not compared.
1062      *
1063      * @param  obj the object to compare with
1064      * @return {@code true} if the objects are the same;
1065      *         {@code false} otherwise
1066      * @see    #size()
1067      */
1068     public boolean equals(Object obj) {
1069         if (!(obj instanceof BitSet))
1070             return false;
1071         if (this == obj)
1072             return true;
1073 
1074         BitSet set = (BitSet) obj;
1075 
1076         checkInvariants();
1077         set.checkInvariants();




1037         for (int i = wordsInUse; --i >= 0; )
1038             h ^= words[i] * (i + 1);
1039 
1040         return (int)((h >> 32) ^ h);
1041     }
1042 
1043     /**
1044      * Returns the number of bits of space actually in use by this
1045      * {@code BitSet} to represent bit values.
1046      * The maximum element in the set is the size - 1st element.
1047      *
1048      * @return the number of bits currently in this bit set
1049      */
1050     public int size() {
1051         return words.length * BITS_PER_WORD;
1052     }
1053 
1054     /**
1055      * Compares this object against the specified object.
1056      * The result is {@code true} if and only if the argument is
1057      * not {@code null} and is a {@code BitSet} object that has
1058      * exactly the same set of bits set to {@code true} as this bit
1059      * set. That is, for every nonnegative {@code int} index {@code k},
1060      * <pre>((BitSet)obj).get(k) == this.get(k)</pre>
1061      * must be true. The current sizes of the two bit sets are not compared.
1062      *
1063      * @param  obj the object to compare with
1064      * @return {@code true} if the objects are the same;
1065      *         {@code false} otherwise
1066      * @see    #size()
1067      */
1068     public boolean equals(Object obj) {
1069         if (!(obj instanceof BitSet))
1070             return false;
1071         if (this == obj)
1072             return true;
1073 
1074         BitSet set = (BitSet) obj;
1075 
1076         checkInvariants();
1077         set.checkInvariants();


< prev index next >