1
1
/*
2
- * Copyright (c) 1995, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1995, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
33
33
import java .util .stream .IntStream ;
34
34
import java .util .stream .StreamSupport ;
35
35
36
+ import jdk .internal .util .ArraysSupport ;
37
+
36
38
/**
37
39
* This class implements a vector of bits that grows as needed. Each
38
40
* component of the bit set has a {@code boolean} value. The
@@ -1015,8 +1017,10 @@ public void andNot(BitSet set) {
1015
1017
}
1016
1018
1017
1019
/**
1018
- * Returns the hash code value for this bit set. The hash code depends
1019
- * only on which bits are set within this {@code BitSet}.
1020
+ * {@return the hash code value for this bit set}
1021
+ *
1022
+ * The hash code depends only on which bits are set within this
1023
+ * {@code BitSet}.
1020
1024
*
1021
1025
* <p>The hash code is defined to be the result of the following
1022
1026
* calculation:
@@ -1029,9 +1033,8 @@ public void andNot(BitSet set) {
1029
1033
* return (int)((h >> 32) ^ h);
1030
1034
* }}</pre>
1031
1035
* Note that the hash code changes if the set of bits is altered.
1032
- *
1033
- * @return the hash code value for this bit set
1034
1036
*/
1037
+ @ Override
1035
1038
public int hashCode () {
1036
1039
long h = 1234 ;
1037
1040
for (int i = wordsInUse ; --i >= 0 ; )
@@ -1052,7 +1055,7 @@ public int size() {
1052
1055
}
1053
1056
1054
1057
/**
1055
- * Compares this object against the specified object.
1058
+ * Compares this bit set against the specified object.
1056
1059
* The result is {@code true} if and only if the argument is
1057
1060
* not {@code null} and is a {@code BitSet} object that has
1058
1061
* exactly the same set of bits set to {@code true} as this bit
@@ -1065,11 +1068,12 @@ public int size() {
1065
1068
* {@code false} otherwise
1066
1069
* @see #size()
1067
1070
*/
1071
+ @ Override
1068
1072
public boolean equals (Object obj ) {
1069
- if (!(obj instanceof BitSet set ))
1070
- return false ;
1071
1073
if (this == obj )
1072
1074
return true ;
1075
+ if (!(obj instanceof BitSet set ))
1076
+ return false ;
1073
1077
1074
1078
checkInvariants ();
1075
1079
set .checkInvariants ();
@@ -1078,11 +1082,7 @@ public boolean equals(Object obj) {
1078
1082
return false ;
1079
1083
1080
1084
// Check words in use by both BitSets
1081
- for (int i = 0 ; i < wordsInUse ; i ++)
1082
- if (words [i ] != set .words [i ])
1083
- return false ;
1084
-
1085
- return true ;
1085
+ return ArraysSupport .mismatch (words , 0 , set .words , 0 , wordsInUse ) == -1 ;
1086
1086
}
1087
1087
1088
1088
/**
0 commit comments