Ejemplo n.º 1
0
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    } else if (o instanceof SparseVector) {
      SparseVector vo = (SparseVector) o;

      int sz = size();
      int osz = vo.size();
      if (sz != osz) {
        return false;
      } else {
        if (!this.keySet().equals(vo.keySet())) {
          return false; // same keys
        }
        // we know that sparse vector values are always in key order. so just compare them.
        return this.values().equals(vo.values());
      }
    } else {
      return false;
    }
  }
Ejemplo n.º 2
0
 @Override
 public ObjectCollection<Double> values() {
   return CollectionUtils.objectCollection(vector.values());
 }