MCPcopy Create free account
hub / github.com/apache/calcite / allSameElement

Method allSameElement

core/src/main/java/org/apache/calcite/util/Util.java:2371–2380  ·  view source on GitHub ↗

Returns whether all of the elements of a list are equal. The list is assumed to be non-empty.

(List<E> list)

Source from the content-addressed store, hash-verified

2369 /** Returns whether all of the elements of a list are equal.
2370 * The list is assumed to be non-empty. */
2371 private static <E> boolean allSameElement(List<E> list) {
2372 final Iterator<E> iterator = list.iterator();
2373 final E first = iterator.next();
2374 while (iterator.hasNext()) {
2375 if (!Objects.equals(first, iterator.next())) {
2376 return false;
2377 }
2378 }
2379 return true;
2380 }
2381
2382 /** Converts an iterable into a list with unique elements.
2383 *

Callers 1

distinctListMethod · 0.95

Calls 4

iteratorMethod · 0.65
equalsMethod · 0.65
nextMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected