Searched refs:comparator (Results 1 - 25 of 49) sorted by relevance

12

/libcore/ojluni/src/main/java/java/util/function/
H A DBinaryOperator.java51 * @param <T> the type of the input arguments of the comparator
52 * @param comparator a {@code Comparator} for comparing the two values
57 public static <T> BinaryOperator<T> minBy(Comparator<? super T> comparator) { argument
58 Objects.requireNonNull(comparator);
59 return (a, b) -> comparator.compare(a, b) <= 0 ? a : b;
66 * @param <T> the type of the input arguments of the comparator
67 * @param comparator a {@code Comparator} for comparing the two values
72 public static <T> BinaryOperator<T> maxBy(Comparator<? super T> comparator) { argument
73 Objects.requireNonNull(comparator);
74 return (a, b) -> comparator
[all...]
/libcore/luni/src/test/java/libcore/java/util/
H A DComparatorTest.java43 private <T> void checkComparison(Comparator<T> comparator, T[] items) { argument
45 assertEquals(0, comparator.compare(items[i], items[i]));
47 assertTrue(comparator.compare(items[i], items[j]) < 0);
48 assertTrue(comparator.compare(items[j], items[i]) > 0);
54 Comparator<Item> comparator = Comparator.comparingDouble(Item::getOrderAsDouble);
55 checkComparison(comparator, orderedItems);
59 Comparator<Item> comparator = Comparator.comparingInt(Item::getOrderAsInt);
60 checkComparison(comparator, orderedItems);
64 Comparator<Item> comparator = Comparator.comparingLong(Item::getOrderAsLong);
65 checkComparison(comparator, orderedItem
[all...]
H A DSpliteratorTester.java62 List<T> expectedElements, Comparator<T> comparator) {
76 Collections.sort(expectedElements, comparator);
77 Collections.sort(recorder, comparator);
118 List<T> expectedElements, Comparator<T> comparator) {
154 Collections.sort(expectedElements, comparator);
155 Collections.sort(recorder, comparator);
174 List<T> expectedElements, Comparator<T> comparator) {
175 runBasicSplitTests(spliterable.spliterator(), expectedElements, comparator);
306 public static <T> void runSortedTests(Iterable<T> spliterable, Comparator<T> comparator) { argument
314 Collections.sort(sortedElements, comparator);
61 runBasicIterationTests_unordered(Spliterator<T> spliterator, List<T> expectedElements, Comparator<T> comparator) argument
117 runBasicSplitTests(Spliterator<T> spliterator, List<T> expectedElements, Comparator<T> comparator) argument
173 runBasicSplitTests(Iterable<T> spliterable, List<T> expectedElements, Comparator<T> comparator) argument
[all...]
H A DTreeSetTest.java44 assertEquals(0, deserialized.comparator().compare("X", "x"));
104 * comparator. http://b/5552608
132 assertEquals(0, deserialized.comparator().compare("X", "x"));
/libcore/ojluni/src/main/java/java/util/
H A DSortedSet.java38 * interface (or be accepted by the specified comparator). Furthermore, all
40 * (or <tt>comparator.compare(e1, e2)</tt>) must not throw a
47 * explicit comparator is provided) must be <i>consistent with equals</i> if
64 * sorted set sorted according to the specified comparator. 3) A
110 * Returns the comparator used to order the elements in this set,
114 * @return the comparator used to order the elements in this set,
118 Comparator<? super E> comparator(); method in interface:SortedSet
138 * set's comparator (or, if the set has no comparator, using
167 * with this set's comparator (o
[all...]
H A DPriorityQueue.java92 * priority queue is ordered by comparator, or by the elements'
93 * natural ordering, if comparator is null: For each node n in the
105 * The comparator, or null if priority queue uses elements'
108 private final Comparator<? super E> comparator; field in class:PriorityQueue
140 * whose elements are ordered according to the specified comparator.
142 * @param comparator the comparator that will be used to order this
147 public PriorityQueue(Comparator<? super E> comparator) { argument
148 this(DEFAULT_INITIAL_CAPACITY, comparator);
153 * that orders its elements according to the specified comparator
162 PriorityQueue(int initialCapacity, Comparator<? super E> comparator) argument
748 public Comparator<? super E> comparator() { method in class:PriorityQueue
[all...]
H A DSortedMap.java39 * interface (or be accepted by the specified comparator). Furthermore, all
41 * {@code comparator.compare(k1, k2)}) must not throw a
48 * explicit comparator is provided) must be <em>consistent with equals</em> if
68 * creates an empty sorted map sorted according to the specified comparator.</li>
115 * Returns the comparator used to order the keys in this map, or
119 * @return the comparator used to order the keys in this map,
123 Comparator<? super K> comparator(); method in interface:SortedMap
142 * cannot be compared to one another using this map's comparator
143 * (or, if the map has no comparator, using natural ordering).
170 * with this map's comparator (o
[all...]
H A DTreeSet.java38 * comparator is provided) must be <i>consistent with equals</i> if it is to
129 * comparator. All elements inserted into the set must be <i>mutually
130 * comparable</i> by the specified comparator: {@code comparator.compare(e1,
136 * @param comparator the comparator that will be used to order this set.
140 public TreeSet(Comparator<? super E> comparator) { argument
141 this(new TreeMap<>(comparator));
171 this(s.comparator());
230 * and this set uses natural ordering, or its comparator
386 public Comparator<? super E> comparator() { method in class:TreeSet
[all...]
H A DComparator.java45 * The ordering imposed by a comparator <tt>c</tt> on a set of elements
51 * Caution should be exercised when using a comparator capable of imposing an
53 * Suppose a sorted set (or sorted map) with an explicit comparator <tt>c</tt>
62 * to an empty {@code TreeSet} with comparator {@code c}.
72 * order for the data structure to serialize successfully, the comparator (if
76 * <i>imposed ordering</i> that a given comparator <tt>c</tt> imposes on a
92 * <p>Unlike {@code Comparable}, a comparator may optionally permit
100 * @param <T> the type of objects that may be compared by this comparator
136 * any comparator that violates this condition should clearly indicate
137 * this fact. The recommended language is "Note: this comparator
377 nullsFirst(Comparator<? super T> comparator) argument
398 nullsLast(Comparator<? super T> comparator) argument
[all...]
H A DTreeMap.java46 * whether or not an explicit comparator is provided, must be <em>consistent
117 * The comparator used to maintain order in this tree map, or
122 private final Comparator<? super K> comparator; field in class:TreeMap
149 comparator = null;
154 * comparator. All keys inserted into the map must be <em>mutually
155 * comparable</em> by the given comparator: {@code comparator.compare(k1,
162 * @param comparator the comparator that will be used to order this map.
166 public TreeMap(Comparator<? super K> comparator) { argument
283 public Comparator<? super K> comparator() { method in class:TreeMap
1146 public Comparator<? super E> comparator() { return m.comparator(); } method in class:TreeMap.KeySet
1864 public Comparator<? super K> comparator() { method in class:TreeMap.AscendingSubMap
1957 public Comparator<? super K> comparator() { method in class:TreeMap.DescendingSubMap
2061 public Comparator<? super K> comparator() { throw new InternalError(); } method in class:TreeMap.SubMap
[all...]
/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/
H A DHttpRetryExceptionTest.java34 // comparator for HttpRetryException objects
35 private static final SerializableAssert comparator = new SerializableAssert() { field in class:HttpRetryExceptionTest
53 LOCATION), comparator);
61 100, LOCATION), comparator);
/libcore/luni/src/main/java/libcore/util/
H A DCollectionUtils.java83 * not use {@link Object#equals}: only the comparator defines equality.
85 public static <T> void removeDuplicates(List<T> list, Comparator<? super T> comparator) { argument
86 Collections.sort(list, comparator);
89 if (comparator.compare(list.get(j - 1), list.get(i)) != 0) {
/libcore/ojluni/src/main/java/java/util/stream/
H A DSortedOps.java59 * @param comparator the comparator to order elements by
62 Comparator<? super T> comparator) {
63 return new OfRef<>(upstream, comparator);
104 private final Comparator<? super T> comparator; field in class:SortedOps.OfRef
117 this.comparator = comp;
121 * Sort using the provided comparator.
123 * @param comparator The comparator to be used to evaluate ordering.
125 OfRef(AbstractPipeline<?, T, ?> upstream, Comparator<? super T> comparator) { argument
61 makeRef(AbstractPipeline<?, T, ?> upstream, Comparator<? super T> comparator) argument
305 protected final Comparator<? super T> comparator; field in class:SortedOps.AbstractRefSortingSink
309 AbstractRefSortingSink(Sink<? super T> downstream, Comparator<? super T> comparator) argument
334 SizedRefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) argument
374 RefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) argument
[all...]
H A DStream.java384 * @param comparator a <a href="package-summary.html#NonInterference">non-interfering</a>,
389 Stream<T> sorted(Comparator<? super T> comparator); argument
813 * @param comparator a <a href="package-summary.html#NonInterference">non-interfering</a>,
820 Optional<T> min(Comparator<? super T> comparator); argument
830 * @param comparator a <a href="package-summary.html#NonInterference">non-interfering</a>,
837 Optional<T> max(Comparator<? super T> comparator); argument
H A DReferencePipeline.java394 public final Stream<P_OUT> sorted(Comparator<? super P_OUT> comparator) { argument
395 return SortedOps.makeRef(this, comparator);
516 public final Optional<P_OUT> max(Comparator<? super P_OUT> comparator) { argument
517 return reduce(BinaryOperator.maxBy(comparator));
521 public final Optional<P_OUT> min(Comparator<? super P_OUT> comparator) { argument
522 return reduce(BinaryOperator.minBy(comparator));
/libcore/ojluni/src/main/java/java/util/concurrent/
H A DPriorityBlockingQueue.java145 * priority queue is ordered by comparator, or by the elements'
146 * natural ordering, if comparator is null: For each node n in the
158 * The comparator, or null if priority queue uses elements'
161 private transient Comparator<? super E> comparator; field in class:PriorityBlockingQueue
210 * comparator.
213 * @param comparator the comparator that will be used to order this
220 Comparator<? super E> comparator) {
225 this.comparator = comparator;
219 PriorityBlockingQueue(int initialCapacity, Comparator<? super E> comparator) argument
588 public Comparator<? super E> comparator() { method in class:PriorityBlockingQueue
[all...]
H A DConcurrentSkipListSet.java119 * the specified comparator.
121 * @param comparator the comparator that will be used to order this set.
125 public ConcurrentSkipListSet(Comparator<? super E> comparator) { argument
126 m = new ConcurrentSkipListMap<E,Object>(comparator);
154 m = new ConcurrentSkipListMap<E,Object>(s.comparator());
390 public Comparator<? super E> comparator() { method in class:ConcurrentSkipListSet
391 return m.comparator();
475 * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}.
494 * <p>The spliterator's comparator (se
[all...]
H A DConcurrentSkipListMap.java326 * handle infusing comparator-vs-comparable choice into search
327 * loops. Static method cpr(comparator, x, y) is used for all
328 * comparisons, which works well as long as the comparator
370 * The comparator used to maintain order in this map, or null if
375 final Comparator<? super K> comparator; field in class:ConcurrentSkipListMap
389 * (Note that comparator must be separately initialized.)
645 * Compares using comparator or natural ordering if null.
738 Comparator<? super K> cmp = comparator;
774 Comparator<? super K> cmp = comparator;
816 Comparator<? super K> cmp = comparator;
1291 ConcurrentSkipListMap(Comparator<? super K> comparator) argument
2021 public Comparator<? super K> comparator() { method in class:ConcurrentSkipListMap
2372 public Comparator<? super K> comparator() { return m.comparator(); } method in class:ConcurrentSkipListMap.KeySet
2906 public Comparator<? super K> comparator() { method in class:ConcurrentSkipListMap.SubMap
3305 final Comparator<? super K> comparator; field in class:ConcurrentSkipListMap.CSLMSpliterator
3310 CSLMSpliterator(Comparator<? super K> comparator, Index<K,V> row, Node<K,V> origin, K fence, int est) argument
3321 KeySpliterator(Comparator<? super K> comparator, Index<K,V> row, Node<K,V> origin, K fence, int est) argument
3409 ValueSpliterator(Comparator<? super K> comparator, Index<K,V> row, Node<K,V> origin, K fence, int est) argument
3496 EntrySpliterator(Comparator<? super K> comparator, Index<K,V> row, Node<K,V> origin, K fence, int est) argument
[all...]
/libcore/support/src/test/java/org/apache/harmony/testframework/serialization/
H A DSerializationTest.java185 // default comparator for a class that has equals(Object) method
252 * Returns <code>comparator</code> for provided serializable
255 * The <code>comparator</code> is searched in the following order: <br>
257 * selected as </code>comparator</code>.<br>- if passed <code>object</code>
267 * @return object's comparator
279 // use default comparator
283 // TODO use generics to detect comparator
291 throw new RuntimeException("Failed to detect comparator");
313 * <code>object</code> using specified <code>comparator</code>.
317 * @param comparator
319 verifyGolden(Object test, Object object, SerializableAssert comparator) argument
356 verifyGolden(Object test, Object[] objects, SerializableAssert comparator) argument
386 verifySelf(Object object, SerializableAssert comparator) argument
415 verifySelf(Object[] objects, SerializableAssert comparator) argument
[all...]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/
H A DRefSortedMap.java88 private final Comparator<? super K> comparator; field in class:RefSortedMap
166 public Comparator<? super K> comparator() { method in class:RefSortedMap.SubMap
167 return RefSortedMap.this.comparator();
246 return comparator != null ? comparator.compare(start, end)
251 public RefSortedMap(Comparator<? super K> comparator) { argument
252 this.comparator = comparator;
262 this(map.comparator());
266 public Comparator<? super K> comparator() { method in class:RefSortedMap
[all...]
H A DPriorityQueueTest.java147 // Try removing an entry that the comparator says is equal
201 assertNull(queue.comparator());
211 assertNull(queue.comparator());
222 assertNull(queue.comparator());
224 MockComparator<Object> comparator = new MockComparator<Object>();
225 queue = new PriorityQueue<Object>(100, comparator);
228 assertEquals(comparator, queue.comparator());
259 assertEquals(objectComparator, integerQueue.comparator());
275 assertNull(integerQueue.comparator());
[all...]
H A DSortedMapTestBase.java183 assertEquals(ref.comparator(), map.comparator());
208 if (ref.comparator() != null &&
209 ref.comparator().compare(key0, key1) > 0) {
219 if (ref.comparator() != null && ref.comparator().compare(100, 0) < 0) {
H A DHashSetTest.java218 SerializationTest.verifySelf(hs, comparator);
219 SerializationTest.verifyGolden(this, hs, comparator);
308 private static final SerializationTest.SerializableAssert comparator = new field in class:HashSetTest
H A DRandomTest.java312 SerializationTest.verifyGolden(this, rand, comparator);
316 SerializationTest.verifySelf(rand, comparator);
319 public static final SerializationTest.SerializableAssert comparator = field in class:RandomTest
/libcore/ojluni/src/main/java/java/net/
H A DInMemoryCookieStore.java335 // @param comparator the prediction to decide whether or not
339 T comparator)
344 if ((index == comparator) || (index != null && comparator.compareTo(index) == 0)) {
361 } // end of comparator.compareTo(index) == 0
338 getInternal2(List<HttpCookie> cookies, Map<T, List<HttpCookie>> cookieIndex, T comparator) argument

Completed in 407 milliseconds

12