类 Arrays2


  • public class Arrays2
    extends java.lang.Object
    Utils for Array.
    • 构造器概要

      构造器 
      构造器 说明
      Arrays2()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static <T> T[] concat​(java.util.function.IntFunction<T[]> maker, T[] array1, T... array2)
      Concat two array to new array.
      static <S,​T>
      T[]
      convert​(S[] array, java.util.function.IntFunction<T[]> maker, java.util.function.Function<? super S,​? extends T> function)
      Convert source array to target array.
      static <T> java.util.Optional<T> find​(@NonNull T @NonNull [] array, java.util.function.Predicate<? super T> predicate)
      Find the first element accepted by predicate in array.
      static <T> java.util.OptionalInt findIndex​(T[] array, int from, java.util.function.Predicate<? super T> predicate)
      Find the first element index accepted by predicate in array.
      static <T> java.util.OptionalInt findIndex​(T[] array, java.util.function.Predicate<? super T> predicate)
      Find the first element index accepted by predicate in array.
      static <T> T[] of​(T... values)
      Used to create a new array, with values.
      static <T> java.util.Optional<T> reverseFind​(@NonNull T @NonNull [] array, java.util.function.Predicate<? super T> predicate)
      Find the last element accepted by predicate in array.
      static <T> java.util.OptionalInt reverseFindIndex​(T[] array, int from, java.util.function.Predicate<? super T> predicate)
      Find the last element index accepted by predicate in array.
      static <T> java.util.OptionalInt reverseFindIndex​(T[] array, java.util.function.Predicate<? super T> predicate)
      Find the last element index accepted by predicate in array.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Arrays2

        public Arrays2()
    • 方法详细资料

      • of

        @SafeVarargs
        public static <T> T[] of​(T... values)
        Used to create a new array, with values. If a array is passed in, will return itself
        类型参数:
        T - the element type
        参数:
        values - the values.
        返回:
        array
      • find

        public static <T> java.util.Optional<T> find​(@NonNull T @NonNull [] array,
                                                     java.util.function.Predicate<? super T> predicate)
        Find the first element accepted by predicate in array. The element should not be null, or NullPointerException will be thrown.
        参数:
        array - array and it's elements can not be null
        返回:
        Optional
      • findIndex

        public static <T> java.util.OptionalInt findIndex​(T[] array,
                                                          java.util.function.Predicate<? super T> predicate)
        Find the first element index accepted by predicate in array.
        参数:
        array - the array
        返回:
        Optional
      • findIndex

        public static <T> java.util.OptionalInt findIndex​(T[] array,
                                                          int from,
                                                          java.util.function.Predicate<? super T> predicate)
        Find the first element index accepted by predicate in array.
        参数:
        from - the index from which to find, included.
        array - the array
        返回:
        Optional
      • reverseFind

        public static <T> java.util.Optional<T> reverseFind​(@NonNull T @NonNull [] array,
                                                            java.util.function.Predicate<? super T> predicate)
        Find the last element accepted by predicate in array. The element should not be null, or NullPointerException will be thrown.
        参数:
        array - array and it's elements can not be null
        返回:
        Optional
      • reverseFindIndex

        public static <T> java.util.OptionalInt reverseFindIndex​(T[] array,
                                                                 java.util.function.Predicate<? super T> predicate)
        Find the last element index accepted by predicate in array.
        参数:
        array - the array
        返回:
        Optional
      • reverseFindIndex

        public static <T> java.util.OptionalInt reverseFindIndex​(T[] array,
                                                                 int from,
                                                                 java.util.function.Predicate<? super T> predicate)
        Find the last element index accepted by predicate in array.
        参数:
        from - the index from which to find, included.
        array - the array
        返回:
        Optional
      • convert

        public static <S,​T> T[] convert​(S[] array,
                                              java.util.function.IntFunction<T[]> maker,
                                              java.util.function.Function<? super S,​? extends T> function)
        Convert source array to target array. This method is used as:
             String[] array = {"1", "2", "4"};
             Integer[] target = Arrays2.convert(array, Integer[]::new, Integer::valueOf);
         
        类型参数:
        S - source array element type
        T - target array element type
        参数:
        array - the source array
        maker - create the target array.
        function - convert source array element to target array element
        返回:
        the target array
      • concat

        @SafeVarargs
        public static <T> T[] concat​(java.util.function.IntFunction<T[]> maker,
                                     T[] array1,
                                     T... array2)
        Concat two array to new array. This method is used as:
             String[] array1 = {"1", "2", "4"};
             String[] array2 = {"4", "6", "8"};
             String[] array = Arrays2.concat(String[]::new, array1, array2);
         
        类型参数:
        T - array element type
        参数:
        maker - create the target array.
        返回:
        the target array