@Test(invocationCount = 10) public void add() { final Random random = new Random(); final List<Vec<double[]>> elements = new ArrayList<>(); final ParetoFront<Vec<double[]>> set = new ParetoFront<>(Vec::dominance); for (int i = 0; i < 500; ++i) { final Vec<double[]> point = circle(random); elements.add(point); set.add(point); Assert.assertEquals( new HashSet<>(set), new HashSet<>(Pareto.front(ISeq.of(elements)).asList()) ); } }
@Override public boolean add(final T element) { requireNonNull(element); boolean updated = false; final Iterator<T> iterator = _population.iterator(); while (iterator.hasNext()) { final T existing = iterator.next(); int cmp = _dominance.compare(element, existing); if (cmp > 0) { iterator.remove(); updated = true; } else if (cmp < 0 || _equals.test(element, existing)) { return updated; } } _population.add(element); return true; }
ParetoFront extends AbstractSet<T> { @Override public boolean add(final T element) { requireNonNull(element); boolean updated = false; final Iterator<T> iterator = _population.iterator(); while (iterator.hasNext()) { final T existing = iterator.next(); int cmp = _dominance.compare(element, existing); if (cmp > 0) { iterator.remove(); updated = true; } else if (cmp < 0 || _equals.test(element, existing)) { return updated; } } _population.add(element); return true; } }
ParetoFront extends AbstractSet<T> { @Override public boolean add(final T element) { requireNonNull(element); boolean updated = false; final Iterator<T> iterator = _population.iterator(); while (iterator.hasNext()) { final T existing = iterator.next(); int cmp = _dominance.compare(element, existing); if (cmp > 0) { iterator.remove(); updated = true; } else if (cmp < 0 || _equals.test(element, existing)) { return updated; } } _population.add(element); return true; } ParetoFront(
		final Comparator<? super T> dominance,
		final BiPredicate<? super T, ? super T> equals
	);  ParetoFront(final Comparator<? super T> dominance); }
ParetoFront extends AbstractSet<T> { @Override public boolean add(final T element) { requireNonNull(element); boolean updated = false; final Iterator<T> iterator = _population.iterator(); while (iterator.hasNext()) { final T existing = iterator.next(); int cmp = _dominance.compare(element, existing); if (cmp > 0) { iterator.remove(); updated = true; } else if (cmp < 0 || _equals.test(element, existing)) { return updated; } } _population.add(element); return true; } ParetoFront(
		final Comparator<? super T> dominance,
		final BiPredicate<? super T, ? super T> equals
	);  ParetoFront(final Comparator<? super T> dominance); @Override boolean add(final T element); @Override boolean addAll(final Collection<? extends T> elements); ParetoFront<T> merge(final ParetoFront<? extends T> elements); ParetoFront<T> trim(
		final int size,
		final ElementComparator<? super T> comparator,
		final ElementDistance<? super T> distance,
		final ToIntFunction<? super T> dimension
	); @Override Iterator<T> iterator(); @Override int size(); @Override boolean isEmpty(); ISeq<T> toISeq(); static Collector<C, ?, ParetoFront<C>> toParetoFront(); static Collector<T, ?, ParetoFront<T>> toParetoFront(final Comparator<? super T> dominance); }
ParetoFront extends AbstractSet<T> { @Override public boolean add(final T element) { requireNonNull(element); boolean updated = false; final Iterator<T> iterator = _population.iterator(); while (iterator.hasNext()) { final T existing = iterator.next(); int cmp = _dominance.compare(element, existing); if (cmp > 0) { iterator.remove(); updated = true; } else if (cmp < 0 || _equals.test(element, existing)) { return updated; } } _population.add(element); return true; } ParetoFront(
		final Comparator<? super T> dominance,
		final BiPredicate<? super T, ? super T> equals
	);  ParetoFront(final Comparator<? super T> dominance); @Override boolean add(final T element); @Override boolean addAll(final Collection<? extends T> elements); ParetoFront<T> merge(final ParetoFront<? extends T> elements); ParetoFront<T> trim(
		final int size,
		final ElementComparator<? super T> comparator,
		final ElementDistance<? super T> distance,
		final ToIntFunction<? super T> dimension
	); @Override Iterator<T> iterator(); @Override int size(); @Override boolean isEmpty(); ISeq<T> toISeq(); static Collector<C, ?, ParetoFront<C>> toParetoFront(); static Collector<T, ?, ParetoFront<T>> toParetoFront(final Comparator<? super T> dominance);  }