| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public Iterator<IndexValue> getNonZeroIterator(int start) |
| 72 | { |
| 73 | final Iterator<IndexValue> origIter = vec.getNonZeroIterator(startPosition+start); |
| 74 | |
| 75 | Iterator<IndexValue> newIter = new Iterator<IndexValue>() |
| 76 | { |
| 77 | IndexValue nextVal = origIter.hasNext() ? origIter.next() : new IndexValue(Integer.MAX_VALUE, Double.NaN); |
| 78 | IndexValue curVal = new IndexValue(-1, Double.NaN); |
| 79 | @Override |
| 80 | public boolean hasNext() |
| 81 | { |
| 82 | return nextVal.getIndex() < length+startPosition; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public IndexValue next() |
| 87 | { |
| 88 | if(!hasNext()) |
| 89 | throw new NoSuchElementException(); |
| 90 | curVal.setIndex(nextVal.getIndex()-startPosition); |
| 91 | curVal.setValue(nextVal.getValue()); |
| 92 | if(origIter.hasNext()) |
| 93 | nextVal = origIter.next(); |
| 94 | else |
| 95 | nextVal.setIndex(Integer.MAX_VALUE); |
| 96 | |
| 97 | return curVal; |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public void remove() |
| 102 | { |
| 103 | throw new UnsupportedOperationException("Not supported yet."); |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | return newIter; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public Vec clone() |