public boolean equals()

in ndarray/src/main/java/org/tensorflow/ndarray/impl/buffer/raw/ShortRawDataBuffer.java [108:139]


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

      @Override
      public Boolean visit(ShortBuffer buffer) {
        if (memory.isArray()) {
          return buffer.equals(memory.toArrayShortBuffer());
        }
        return fallback();
      }

      @Override
      public Boolean fallback() {
        for (long idx = 0L; idx < size(); ++idx) {
          if (other.getShort(idx) != getShort(idx)) {
            return false;
          }
        }
        return true;
      }
    });
  }