@Override public int hashCode() { final int word = length() >>> 6; int hash = 0; for (int i = 0; word >= i; i++) { hash = 127 * hash + (int) (words[i] ^ (words[i] >>> 32)); } return hash; }
@Override public int hashCode() { final int word = length() >>> 6; int hash = 0; for (int i = 0; word >= i; i++) { hash = 127 * hash + (int) (words[i] ^ (words[i] >>> 32)); } return hash; }
public boolean isEmpty() { return length() == 0; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BitVector other = (BitVector) obj; long[] otherBits = other.words; int commonWords = Math.min(words.length, otherBits.length); for (int i = 0; commonWords > i; i++) { if (words[i] != otherBits[i]) return false; } if (words.length == otherBits.length) return true; return length() == other.length(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BitVector other = (BitVector) obj; long[] otherBits = other.words; int commonWords = Math.min(words.length, otherBits.length); for (int i = 0; commonWords > i; i++) { if (words[i] != otherBits[i]) return false; } if (words.length == otherBits.length) return true; return length() == other.length(); }
@Override public String toString() { // possibly faster if done in JavaScript and all numerical properties // are // put into an array and sorted int length = length(); if (length == 0) { // a "length" of 0 means there are no bits set to true return "{}"; } StringBuilder sb = new StringBuilder("{"); // at this point, there is at least one true bit, nextSetBit can not // fail int next = nextSetBit(0); sb.append(next); // loop until nextSetBit returns -1 while ((next = nextSetBit(next + 1)) != -1) { sb.append(", "); sb.append(next); } sb.append("}"); return sb.toString(); }
public void flip(int fromIndex, int toIndex) { checkRange(fromIndex, toIndex); int length = length();
public void clear(int fromIndex, int toIndex) { checkRange(fromIndex, toIndex); int length = length(); if (fromIndex >= length) {