@Test public void add() { PathWeight first = new PathWeight(2, 7); PathWeight second = new PathWeight(1, 2); PathWeight actual = first.add(second); assertEquals(0, actual.compareTo(new PathWeight(3, 9))); }
public PathWeight add(PathWeight toAdd) { List<Long> result = new ArrayList<>(); Iterator<Long> firstIterator = params.iterator(); Iterator<Long> secondIterator = toAdd.params.iterator(); while (firstIterator.hasNext() || secondIterator.hasNext()) { long first = firstIterator.hasNext() ? firstIterator.next() : 0L; long second = secondIterator.hasNext() ? secondIterator.next() : 0L; result.add(first + second); } return new PathWeight(result); }
PathWeight implements Comparable<PathWeight> { public PathWeight add(PathWeight toAdd) { List<Long> result = new ArrayList<>(); Iterator<Long> firstIterator = params.iterator(); Iterator<Long> secondIterator = toAdd.params.iterator(); while (firstIterator.hasNext() || secondIterator.hasNext()) { long first = firstIterator.hasNext() ? firstIterator.next() : 0L; long second = secondIterator.hasNext() ? secondIterator.next() : 0L; result.add(first + second); } return new PathWeight(result); } }
PathWeight implements Comparable<PathWeight> { public PathWeight add(PathWeight toAdd) { List<Long> result = new ArrayList<>(); Iterator<Long> firstIterator = params.iterator(); Iterator<Long> secondIterator = toAdd.params.iterator(); while (firstIterator.hasNext() || secondIterator.hasNext()) { long first = firstIterator.hasNext() ? firstIterator.next() : 0L; long second = secondIterator.hasNext() ? secondIterator.next() : 0L; result.add(first + second); } return new PathWeight(result); } PathWeight(long... params);  PathWeight(List<Long> params); }
PathWeight implements Comparable<PathWeight> { public PathWeight add(PathWeight toAdd) { List<Long> result = new ArrayList<>(); Iterator<Long> firstIterator = params.iterator(); Iterator<Long> secondIterator = toAdd.params.iterator(); while (firstIterator.hasNext() || secondIterator.hasNext()) { long first = firstIterator.hasNext() ? firstIterator.next() : 0L; long second = secondIterator.hasNext() ? secondIterator.next() : 0L; result.add(first + second); } return new PathWeight(result); } PathWeight(long... params);  PathWeight(List<Long> params); PathWeight add(PathWeight toAdd); long toLong(); @Override int compareTo(PathWeight o); }
PathWeight implements Comparable<PathWeight> { public PathWeight add(PathWeight toAdd) { List<Long> result = new ArrayList<>(); Iterator<Long> firstIterator = params.iterator(); Iterator<Long> secondIterator = toAdd.params.iterator(); while (firstIterator.hasNext() || secondIterator.hasNext()) { long first = firstIterator.hasNext() ? firstIterator.next() : 0L; long second = secondIterator.hasNext() ? secondIterator.next() : 0L; result.add(first + second); } return new PathWeight(result); } PathWeight(long... params);  PathWeight(List<Long> params); PathWeight add(PathWeight toAdd); long toLong(); @Override int compareTo(PathWeight o);  }