public boolean equals()

in ndarray/src/main/java/org/tensorflow/ndarray/impl/buffer/misc/BitSetDataBuffer.java [120:166]


  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof BooleanDataBuffer)) {
      return super.equals(obj);
    }
    BooleanDataBuffer other = (BooleanDataBuffer)obj;
    if (size() != other.size()) {
      return false;
    }
    return other.accept(new DataStorageVisitor<Boolean>() {

      @Override
      public Boolean visit(boolean[] array, int arrayOffset, int length) {
        for (int idx = 0; idx < size(); ++idx) {
          if (array[idx + arrayOffset] != bitSet.get(idx + offset)) {
            return false;
          }
        }
        return true;
      }

      @Override
      public Boolean visit(BitSet otherBitSet, int otherOffset, long otherNumBits) {
        if (offset == 0 && otherOffset == 0 && numBits == otherNumBits) {
          return bitSet.equals(otherBitSet);
        }
        for (int idx = 0; idx < size(); ++idx) {
          if (otherBitSet.get(idx + otherOffset) != bitSet.get(idx + offset)) {
            return false;
          }
        }
        return true;
      }

      @Override
      public Boolean fallback() {
        for (int idx = 0; idx < size(); ++idx) {
          if (other.getBoolean(idx) != bitSet.get(idx + offset)) {
            return false;
          }
        }
        return true;
      }
    });
  }