379 Object[] elements = al.getArray();
380 int len = elements.length;
381 // Mark matched elements to avoid re-checking
382 boolean[] matched = new boolean[len];
383 int k = 0;
384 outer: while (it.hasNext()) {
385 if (++k > len)
386 return false;
387 Object x = it.next();
388 for (int i = 0; i < len; ++i) {
389 if (!matched[i] && eq(x, elements[i])) {
390 matched[i] = true;
391 continue outer;
392 }
393 }
394 return false;
395 }
396 return k == len;
397 }
398
399 public boolean removeIf(Predicate<? super E> filter) {
400 return al.removeIf(filter);
401 }
402
403 public void forEach(Consumer<? super E> action) {
404 al.forEach(action);
405 }
406
407 /**
408 * Returns a {@link Spliterator} over the elements in this set in the order
409 * in which these elements were added.
410 *
411 * <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE},
412 * {@link Spliterator#DISTINCT}, {@link Spliterator#SIZED}, and
413 * {@link Spliterator#SUBSIZED}.
414 *
415 * <p>The spliterator provides a snapshot of the state of the set
416 * when the spliterator was constructed. No synchronization is needed while
417 * operating on the spliterator.
418 *
419 * @return a {@code Spliterator} over the elements in this set
420 * @since 1.8
|
379 Object[] elements = al.getArray();
380 int len = elements.length;
381 // Mark matched elements to avoid re-checking
382 boolean[] matched = new boolean[len];
383 int k = 0;
384 outer: while (it.hasNext()) {
385 if (++k > len)
386 return false;
387 Object x = it.next();
388 for (int i = 0; i < len; ++i) {
389 if (!matched[i] && eq(x, elements[i])) {
390 matched[i] = true;
391 continue outer;
392 }
393 }
394 return false;
395 }
396 return k == len;
397 }
398
399 public boolean removeAll(Predicate<? super E> filter) {
400 return al.removeAll(filter);
401 }
402
403 public void forEach(Consumer<? super E> action) {
404 al.forEach(action);
405 }
406
407 /**
408 * Returns a {@link Spliterator} over the elements in this set in the order
409 * in which these elements were added.
410 *
411 * <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE},
412 * {@link Spliterator#DISTINCT}, {@link Spliterator#SIZED}, and
413 * {@link Spliterator#SUBSIZED}.
414 *
415 * <p>The spliterator provides a snapshot of the state of the set
416 * when the spliterator was constructed. No synchronization is needed while
417 * operating on the spliterator.
418 *
419 * @return a {@code Spliterator} over the elements in this set
420 * @since 1.8
|