Uses of Interface
java.util.Comparator
Packages that useComparator
Package
Description
Provides classes that are fundamental to the design of the Java programming language.
Provides classes and interfaces for handling text, dates, numbers, and messages in a manner independent of natural languages.
The main API for dates, times, instants, and durations.
Generic API for calendar systems other than the default ISO.
Contains the collections framework, some internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes.
Utility classes commonly useful in concurrent programming.
Functional interfaces provide target types for lambda expressions and method references.
Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.
Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms.
Provides classes and interfaces for dealing with
javax.swing.JTable.Uses ofComparator injava.lang
Fields injava.lang declared asComparatorModifier and TypeFieldDescriptionstatic finalComparator<String>String.CASE_INSENSITIVE_ORDERA Comparator that ordersStringobjects as bycompareToIgnoreCase.Uses ofComparator injava.text
Classes injava.text that implementComparatorModifier and TypeClassDescriptionclassTheCollatorclass performs locale-sensitiveStringcomparison.classTheRuleBasedCollatorclass is a concrete subclass ofCollatorthat provides a simple, data-driven, table collator.Uses ofComparator injava.time
Methods injava.time that returnComparatorModifier and TypeMethodDescriptionstaticComparator<OffsetDateTime>OffsetDateTime.timeLineOrder()Gets a comparator that compares twoOffsetDateTimeinstances based solely on the instant.Uses ofComparator injava.time.chrono
Methods injava.time.chrono that returnComparatorModifier and TypeMethodDescriptionstaticComparator<ChronoLocalDate>ChronoLocalDate.timeLineOrder()Gets a comparator that comparesChronoLocalDatein time-line order ignoring the chronology.staticComparator<ChronoLocalDateTime<?>>ChronoLocalDateTime.timeLineOrder()Gets a comparator that comparesChronoLocalDateTimein time-line order ignoring the chronology.staticComparator<ChronoZonedDateTime<?>>ChronoZonedDateTime.timeLineOrder()Gets a comparator that comparesChronoZonedDateTimein time-line order ignoring the chronology.Uses ofComparator injava.util
Methods injava.util that returnComparatorModifier and TypeMethodDescriptionComparator<? superE>PriorityQueue.comparator()Returns the comparator used to order the elements in this queue, ornullif this queue is sorted according to thenatural ordering of its elements.Comparator<? superK>SortedMap.comparator()Returns the comparator used to order the keys in this map, ornullif this map uses thenatural ordering of its keys.Comparator<? superE>SortedSet.comparator()Returns the comparator used to order the elements in this set, ornullif this set uses thenatural ordering of its elements.Comparator<? superK>TreeMap.comparator()Comparator<? superE>TreeSet.comparator()static <T,U extendsComparable<? super U>>
Comparator<T>Accepts a function that extracts aComparablesort key from a typeT, and returns aComparator<T>that compares by that sort key.static <T,U> Comparator<T> Comparator.comparing(Function<? super T, ? extends U> keyExtractor,Comparator<? super U> keyComparator) Accepts a function that extracts a sort key from a typeT, and returns aComparator<T>that compares by that sort key using the specifiedComparator.static <K extendsComparable<? super K>,V>
Comparator<Map.Entry<K,V>> Map.Entry.comparingByKey()Returns a comparator that comparesMap.Entryin natural order on key.static <K,V> Comparator<Map.Entry<K, V>> Map.Entry.comparingByKey(Comparator<? super K> cmp) Returns a comparator that comparesMap.Entryby key using the givenComparator.static <K,V extendsComparable<? super V>>
Comparator<Map.Entry<K,V>> Map.Entry.comparingByValue()Returns a comparator that comparesMap.Entryin natural order on value.static <K,V> Comparator<Map.Entry<K, V>> Map.Entry.comparingByValue(Comparator<? super V> cmp) Returns a comparator that comparesMap.Entryby value using the givenComparator.static <T> Comparator<T>Comparator.comparingDouble(ToDoubleFunction<? super T> keyExtractor) Accepts a function that extracts adoublesort key from a typeT, and returns aComparator<T>that compares by that sort key.static <T> Comparator<T>Comparator.comparingInt(ToIntFunction<? super T> keyExtractor) Accepts a function that extracts anintsort key from a typeT, and returns aComparator<T>that compares by that sort key.static <T> Comparator<T>Comparator.comparingLong(ToLongFunction<? super T> keyExtractor) Accepts a function that extracts alongsort key from a typeT, and returns aComparator<T>that compares by that sort key.defaultComparator<? superT>Spliterator.getComparator()static <T extendsComparable<? super T>>
Comparator<T>Comparator.naturalOrder()Returns a comparator that comparesComparableobjects in natural order.static <T> Comparator<T>Comparator.nullsFirst(Comparator<? super T> comparator) Returns a null-friendly comparator that considersnullto be less than non-null.static <T> Comparator<T>Comparator.nullsLast(Comparator<? super T> comparator) Returns a null-friendly comparator that considersnullto be greater than non-null.defaultComparator<T>Comparator.reversed()Returns a comparator that imposes the reverse ordering of this comparator.static <T> Comparator<T>Collections.reverseOrder()Returns a comparator that imposes the reverse of thenatural ordering on a collection of objects that implement theComparableinterface.static <T> Comparator<T>Collections.reverseOrder(Comparator<T> cmp) Returns a comparator that imposes the reverse ordering of the specified comparator.static <T extendsComparable<? super T>>
Comparator<T>Comparator.reverseOrder()Returns a comparator that imposes the reverse of thenatural ordering.defaultComparator<T>Comparator.thenComparing(Comparator<? superT> other) Returns a lexicographic-order comparator with another comparator.default <U extendsComparable<? super U>>
Comparator<T>Comparator.thenComparing(Function<? superT, ? extends U> keyExtractor) Returns a lexicographic-order comparator with a function that extracts aComparablesort key.default <U> Comparator<T>Comparator.thenComparing(Function<? superT, ? extends U> keyExtractor,Comparator<? super U> keyComparator) Returns a lexicographic-order comparator with a function that extracts a key to be compared with the givenComparator.defaultComparator<T>Comparator.thenComparingDouble(ToDoubleFunction<? superT> keyExtractor) Returns a lexicographic-order comparator with a function that extracts adoublesort key.defaultComparator<T>Comparator.thenComparingInt(ToIntFunction<? superT> keyExtractor) Returns a lexicographic-order comparator with a function that extracts anintsort key.defaultComparator<T>Comparator.thenComparingLong(ToLongFunction<? superT> keyExtractor) Returns a lexicographic-order comparator with a function that extracts alongsort key.Methods injava.util with parameters of typeComparatorModifier and TypeMethodDescriptionstatic <T> intArrays.binarySearch(T[] a, int fromIndex, int toIndex, T key,Comparator<? super T> c) Searches a range of the specified array for the specified object using the binary search algorithm.static <T> intArrays.binarySearch(T[] a, T key,Comparator<? super T> c) Searches the specified array for the specified object using the binary search algorithm.static <T> intCollections.binarySearch(List<? extends T> list, T key,Comparator<? super T> c) Searches the specified list for the specified object using the binary search algorithm.static <T> intArrays.compare(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex,Comparator<? super T> cmp) Compares twoObjectarrays lexicographically over the specified ranges.static <T> intArrays.compare(T[] a, T[] b,Comparator<? super T> cmp) Compares twoObjectarrays lexicographically using a specified comparator.static <T> intObjects.compare(T a, T b,Comparator<? super T> c) Returns 0 if the arguments are identical andc.compare(a, b)otherwise.static <T,U> Comparator<T> Comparator.comparing(Function<? super T, ? extends U> keyExtractor,Comparator<? super U> keyComparator) Accepts a function that extracts a sort key from a typeT, and returns aComparator<T>that compares by that sort key using the specifiedComparator.static <K,V> Comparator<Map.Entry<K, V>> Map.Entry.comparingByKey(Comparator<? super K> cmp) Returns a comparator that comparesMap.Entryby key using the givenComparator.static <K,V> Comparator<Map.Entry<K, V>> Map.Entry.comparingByValue(Comparator<? super V> cmp) Returns a comparator that comparesMap.Entryby value using the givenComparator.static <T> booleanArrays.equals(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex,Comparator<? super T> cmp) Returns true if the two specified arrays of Objects, over the specified ranges, areequal to one another.static <T> booleanArrays.equals(T[] a, T[] a2,Comparator<? super T> cmp) Returnstrueif the two specified arrays of Objects areequal to one another.static <T> TCollections.max(Collection<? extends T> coll,Comparator<? super T> comp) Returns the maximum element of the given collection, according to the order induced by the specified comparator.static <T> TCollections.min(Collection<? extends T> coll,Comparator<? super T> comp) Returns the minimum element of the given collection, according to the order induced by the specified comparator.static <T> intArrays.mismatch(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex,Comparator<? super T> cmp) Finds and returns the relative index of the first mismatch between twoObjectarrays over the specified ranges, otherwise return -1 if no mismatch is found.static <T> intArrays.mismatch(T[] a, T[] b,Comparator<? super T> cmp) Finds and returns the index of the first mismatch between twoObjectarrays, otherwise return -1 if no mismatch is found.static <T> Comparator<T>Comparator.nullsFirst(Comparator<? super T> comparator) Returns a null-friendly comparator that considersnullto be less than non-null.static <T> Comparator<T>Comparator.nullsLast(Comparator<? super T> comparator) Returns a null-friendly comparator that considersnullto be greater than non-null.static <T> voidArrays.parallelSort(T[] a, int fromIndex, int toIndex,Comparator<? super T> cmp) Sorts the specified range of the specified array of objects according to the order induced by the specified comparator.static <T> voidArrays.parallelSort(T[] a,Comparator<? super T> cmp) Sorts the specified array of objects according to the order induced by the specified comparator.static <T> Comparator<T>Collections.reverseOrder(Comparator<T> cmp) Returns a comparator that imposes the reverse ordering of the specified comparator.static <T> voidArrays.sort(T[] a, int fromIndex, int toIndex,Comparator<? super T> c) Sorts the specified range of the specified array of objects according to the order induced by the specified comparator.static <T> voidArrays.sort(T[] a,Comparator<? super T> c) Sorts the specified array of objects according to the order induced by the specified comparator.static <T> voidCollections.sort(List<T> list,Comparator<? super T> c) Sorts the specified list according to the order induced by the specified comparator.default voidList.sort(Comparator<? superE> c) Sorts this list according to the order induced by the specifiedComparator.defaultComparator<T>Comparator.thenComparing(Comparator<? superT> other) Returns a lexicographic-order comparator with another comparator.default <U> Comparator<T>Comparator.thenComparing(Function<? superT, ? extends U> keyExtractor,Comparator<? super U> keyComparator) Returns a lexicographic-order comparator with a function that extracts a key to be compared with the givenComparator.Constructors injava.util with parameters of typeComparatorModifierConstructorDescriptionPriorityQueue(int initialCapacity,Comparator<? superE> comparator) Creates aPriorityQueuewith the specified initial capacity that orders its elements according to the specified comparator.PriorityQueue(Comparator<? superE> comparator) Creates aPriorityQueuewith the default initial capacity and whose elements are ordered according to the specified comparator.TreeMap(Comparator<? superK> comparator) Constructs a new, empty tree map, ordered according to the given comparator.TreeSet(Comparator<? superE> comparator) Constructs a new, empty tree set, sorted according to the specified comparator.Uses ofComparator injava.util.concurrent
Methods injava.util.concurrent that returnComparatorModifier and TypeMethodDescriptionComparator<? superK>ConcurrentSkipListMap.comparator()Comparator<? superE>ConcurrentSkipListSet.comparator()Comparator<? superE>PriorityBlockingQueue.comparator()Returns the comparator used to order the elements in this queue, ornullif this queue uses thenatural ordering of its elements.Constructors injava.util.concurrent with parameters of typeComparatorModifierConstructorDescriptionConcurrentSkipListMap(Comparator<? superK> comparator) Constructs a new, empty map, sorted according to the specified comparator.ConcurrentSkipListSet(Comparator<? superE> comparator) Constructs a new, empty set that orders its elements according to the specified comparator.PriorityBlockingQueue(int initialCapacity,Comparator<? superE> comparator) Creates aPriorityBlockingQueuewith the specified initial capacity that orders its elements according to the specified comparator.Uses ofComparator injava.util.function
Methods injava.util.function with parameters of typeComparatorModifier and TypeMethodDescriptionstatic <T> BinaryOperator<T>BinaryOperator.maxBy(Comparator<? super T> comparator) Returns aBinaryOperatorwhich returns the greater of two elements according to the specifiedComparator.static <T> BinaryOperator<T>BinaryOperator.minBy(Comparator<? super T> comparator) Returns aBinaryOperatorwhich returns the lesser of two elements according to the specifiedComparator.Uses ofComparator injava.util.stream
Methods injava.util.stream with parameters of typeComparatorModifier and TypeMethodDescriptionStream.max(Comparator<? superT> comparator) Returns the maximum element of this stream according to the providedComparator.Collectors.maxBy(Comparator<? super T> comparator) Returns aCollectorthat produces the maximal element according to a givenComparator, described as anOptional<T>.Stream.min(Comparator<? superT> comparator) Returns the minimum element of this stream according to the providedComparator.Collectors.minBy(Comparator<? super T> comparator) Returns aCollectorthat produces the minimal element according to a givenComparator, described as anOptional<T>.Stream.sorted(Comparator<? superT> comparator) Returns a stream consisting of the elements of this stream, sorted according to the providedComparator.Uses ofComparator injavax.swing
Methods injavax.swing that returnComparatorModifier and TypeMethodDescriptionComparator<?>DefaultRowSorter.getComparator(int column) Returns theComparatorfor the specified column.protectedComparator<? superComponent>SortingFocusTraversalPolicy.getComparator()Returns the Comparator which will be used to sort the Components in a focus traversal cycle.Methods injavax.swing with parameters of typeComparatorModifier and TypeMethodDescriptionvoidDefaultRowSorter.setComparator(int column,Comparator<?> comparator) Sets theComparatorto use when sorting the specified column.protected voidSortingFocusTraversalPolicy.setComparator(Comparator<? superComponent> comparator) Sets the Comparator which will be used to sort the Components in a focus traversal cycle.Constructors injavax.swing with parameters of typeComparatorModifierConstructorDescriptionSortingFocusTraversalPolicy(Comparator<? superComponent> comparator) Constructs a SortingFocusTraversalPolicy with the specified Comparator.Uses ofComparator injavax.swing.table
Methods injavax.swing.table that returnComparatorModifier and TypeMethodDescriptionComparator<?>TableRowSorter.getComparator(int column) Returns theComparatorfor the specified column.