Class StaticUtils

java.lang.Object
org.dmfs.rfc5545.recur.StaticUtils

public final class StaticUtils extends Object
A collection of static methods.
  • Constructor Details

    • StaticUtils

      public StaticUtils()
  • Method Details

    • ListToSortedArray

      public static int[] ListToSortedArray(List<Integer> list)
      Convert a List of Integers to a sorted array of ints.
      Parameters:
      list - The List to convert.
      Returns:
      an int[] or null if list is null.
    • ListToArray

      public static int[] ListToArray(List<Integer> list)
      Convert a List of Integers to an array of ints.
      Parameters:
      list - The List to convert.
      Returns:
      an int[] or null if list is null.
    • linearSearch

      public static int linearSearch(int[] array, int i)
      Perform a linear search for an integer in a given array. For small fields a linear search can be faster than a binary search. So use this if you know your field contains only few entries.
      Parameters:
      array - The array to search (the hay stack). Must not be null!
      i - The value to search for (the needle).
      Returns:
      the position of the value in the array or -1 if the value has not been found.
    • linearSearch

      public static int linearSearch(long[] array, long l)
      Perform a linear search for a long in a given array. For small fields a linear search can be faster than a binary search. So use this if you know your field contains only few entries.
      Parameters:
      array - The array to search (the hay stack). Must not be null!
      l - The value to search for (the needle).
      Returns:
      the position of the value in the array or -1 if the value has not been found.
    • linearSearch

      public static int linearSearch(long[] array, int start, int end, long l)
      Perform a linear search for a long in a given array. For small fields a linear search can be faster than a binary search. So use this if you know your field contains only few entries.
      Parameters:
      array - The array to search (the hay stack). Must not be null!
      start - the inclusive start position of the range to search
      end - the exclusive end position of the range to search
      l - The value to search for (the needle).
      Returns:
      the position of the value in the array or -1 if the value has not been found.