public final class Median extends Object
| Modifier and Type | Method and Description |
|---|---|
static Pair<Byte,u.OptionalByte> |
of(byte... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Byte,u.OptionalByte> |
of(byte[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Character,u.OptionalChar> |
of(char... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Character,u.OptionalChar> |
of(char[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static <T extends Comparable<? super T>> |
of(Collection<T> c) |
static <T> Pair<T,u.Nullable<T>> |
of(Collection<T> c,
Comparator<? super T> cmp) |
static Pair<Double,u.OptionalDouble> |
of(double... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Double,u.OptionalDouble> |
of(double[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Float,u.OptionalFloat> |
of(float... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Float,u.OptionalFloat> |
of(float[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Integer,u.OptionalInt> |
of(int... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Integer,u.OptionalInt> |
of(int[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Long,u.OptionalLong> |
of(long... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Long,u.OptionalLong> |
of(long[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Short,u.OptionalShort> |
of(short... a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static Pair<Short,u.OptionalShort> |
of(short[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static <T extends Comparable<? super T>> |
of(T[] a)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static <T> Pair<T,u.Nullable<T>> |
of(T[] a,
Comparator<? super T> cmp)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static <T extends Comparable<? super T>> |
of(T[] a,
int fromIndex,
int toIndex)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
static <T> Pair<T,u.Nullable<T>> |
of(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> cmp)
Returns a
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even. |
@SafeVarargs public static Pair<Character,u.OptionalChar> of(char... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Character,u.OptionalChar> of(char[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])@SafeVarargs public static Pair<Byte,u.OptionalByte> of(byte... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Byte,u.OptionalByte> of(byte[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])@SafeVarargs public static Pair<Short,u.OptionalShort> of(short... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Short,u.OptionalShort> of(short[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])@SafeVarargs public static Pair<Integer,u.OptionalInt> of(int... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.
Median.of(1); // -> [1, empty]
Median.of(1, 3); // -> [1, 3]
Median.of(1, 3, 5); // -> [3, empty]
Median.of(1, 1); // -> [1, 1]
Median.of(1, 1, 3); // -> [1, empty]
Median.of(1, 1, 3, 5); // -> [1, 3]
Median.of(1, 1, 1, 3, 5); // -> [1, empty]
Median.of(1, 1, 1, 3, 3, 5); // -> [1, 3]
Median.of(1, 1, 1, 3, 3, 3, 5); // -> [3, empty]
a - IllegalArgumentException - if the specified Array is null or empty.public static Pair<Integer,u.OptionalInt> of(int[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - IllegalArgumentException - if specified array is empty or length is zero.@SafeVarargs public static Pair<Long,u.OptionalLong> of(long... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Long,u.OptionalLong> of(long[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])@SafeVarargs public static Pair<Float,u.OptionalFloat> of(float... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Float,u.OptionalFloat> of(float[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])@SafeVarargs public static Pair<Double,u.OptionalDouble> of(double... a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static Pair<Double,u.OptionalDouble> of(double[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.a - fromIndex - toIndex - of(int[])public static <T extends Comparable<? super T>> Pair<T,u.Nullable<T>> of(T[] a) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.T - a - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static <T extends Comparable<? super T>> Pair<T,u.Nullable<T>> of(T[] a, int fromIndex, int toIndex)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.T - a - fromIndex - toIndex - of(int[])public static <T> Pair<T,u.Nullable<T>> of(T[] a, Comparator<? super T> cmp) throws IllegalArgumentException
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.T - a - cmp - IllegalArgumentException - if the specified Array is null or empty.of(int[])public static <T> Pair<T,u.Nullable<T>> of(T[] a, int fromIndex, int toIndex, Comparator<? super T> cmp)
Pair with left is the value at the index of (a.length - 1) / 2 when the array is sorted,
and the right is the value at the index of a.length / 2 if the length of array is even.T - a - fromIndex - toIndex - cmp - of(int[])public static <T extends Comparable<? super T>> Pair<T,u.Nullable<T>> of(Collection<T> c)
T - c - public static <T> Pair<T,u.Nullable<T>> of(Collection<T> c, Comparator<? super T> cmp)
T - c - cmp - Copyright © 2021. All rights reserved.