@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; } }
@Override public ObjectCollection<Double> values() { return CollectionUtils.objectCollection(vector.values()); }