Package org.dmfs.rfc5545.recur
Class StaticUtils
java.lang.Object
org.dmfs.rfc5545.recur.StaticUtils
A collection of static methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intlinearSearch(int[] array, int i) Perform a linear search for an integer in a given array.static intlinearSearch(long[] array, int start, int end, long l) Perform a linear search for a long in a given array.static intlinearSearch(long[] array, long l) Perform a linear search for a long in a given array.static int[]ListToArray(List<Integer> list) static int[]ListToSortedArray(List<Integer> list)
-
Constructor Details
-
StaticUtils
public StaticUtils()
-
-
Method Details
-
ListToSortedArray
- Parameters:
list- TheListto convert.- Returns:
- an int[] or
nulliflistisnull.
-
ListToArray
- Parameters:
list- TheListto convert.- Returns:
- an int[] or
nulliflistisnull.
-
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 benull!i- The value to search for (the needle).- Returns:
- the position of the value in the array or
-1if 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 benull!l- The value to search for (the needle).- Returns:
- the position of the value in the array or
-1if 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 benull!start- the inclusive start position of the range to searchend- the exclusive end position of the range to searchl- The value to search for (the needle).- Returns:
- the position of the value in the array or
-1if the value has not been found.
-