@Override public boolean equals(Object o) { if (o instanceof FastIndex) { FastIndex comp = (FastIndex) o; if (nonZeroEntries != comp.nonZeroEntries) { return false; } else { return Arrays.equals(entryNums, comp.entryNums) && Arrays.equals(entryVals, comp.entryVals); } } else if (o instanceof Index) { Index comp = (Index) o; if (nonZeroEntries() != comp.nonZeroEntries()) { return false; } else { for (int i = 0; i < nonZeroEntries; i++) { if (entryVals[i] != comp.get(entryNums[i])) { return false; } } return true; } } return false; }
/** * Creates an new <code>FastIndex</code> from any <code>Index</code>. * * @param index index to initialize from */ public FastIndex(Index index) { this(index.nonZeroEntries(), index.iterator()); }