public boolean equals()

in ndarray/src/main/java/org/tensorflow/ndarray/impl/buffer/misc/BooleanArrayDataBuffer.java [113:159]


  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 arrayLength) {
        if (offset == 0 && values.length == length && arrayOffset == 0 && array.length == arrayLength) {
          return Arrays.equals(array, values);
        }
        for (int idx = 0; idx < size(); ++idx) {
          if (array[idx + arrayOffset] != values[idx + offset]) {
            return false;
          }
        }
        return true;
      }

      @Override
      public Boolean visit(BitSet bitSet, int bitSetOffset, long numBits) {
        for (int idx = 0; idx < size(); ++idx) {
          if (bitSet.get(idx + bitSetOffset) != values[idx + offset]) {
            return false;
          }
        }
        return true;
      }

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