Class ListUtil
java.lang.Object
org.ampere.base.util.ListUtil
- All Implemented Interfaces:
PACTEdef
-
Field Summary
Fields inherited from interface org.ampere.base.util.PACTEdef
AMBIGUOUS, DOUBLE_TAG, FREQUENCY_NAME, FREQUENCY_TAG, TIME_NAME, TIME_TAG, UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T> asList(T[] values) Build a list of valuesstatic char[]static <T> List<T> build(T... list) merge a value into an ArrayListstatic <T> List<T> buildIntersection(List<T> list1, List<T> list2) build the intersection of two listsstatic <D> List<D> only to test generic member mechanisms.static <T> List<T> builtList(T val, int n) static char[]concat(char... inputs) static <T> T[]concatenate(T[] begining, T... following) static <T> T[]concatenate(T begining, T... following) static booleancontains(int[] values, int value) test if an array of int contains a given valuestatic booleantest if an array of int contains a given valuestatic <T> booleancontains(T[] values, T value) test if an array contains a given valuestatic int[]convert2intArray(List<Integer> list) static <T> intgetIndex(T[] values, T target) test if an array contains a given valuestatic <T> booleanstatic <T> booleanisEmpty(T[] list) static <T> StringlistToString(String header, List<T> v, String sep) static <T> voidmerge list2 into list1static <T> List<T> merge a value into an Liststatic <T> voidprintArray(PrintWriter out, T[] v, String sep) print a vector of PacteObjectstatic <T> voidprintArrayList(PrintWriter out, String header, List<T> v, String sep) static <T> voidprintArrayList(PrintWriter out, String header, List<T> v, String begin, String sep, String end) static <T> voidprintArrayList(PrintWriter out, String header, List<T> v, String begin, String sep, String end, int nbOfChars) print an ArrayListstatic <T> intstatic <T> intsize(T[] list) static <T> Stringbuild a tring representation of the liststatic <T> StringtoString(T[] list) build a tring representation of the list
-
Constructor Details
-
ListUtil
public ListUtil()
-
-
Method Details
-
merge
-
merge
-
build
merge a value into an ArrayList- Type Parameters:
T- type of the list- Parameters:
list- input list- Returns:
- the built list
-
buildIntersection
-
printArray
print a vector of PacteObject -
listToString
-
printArrayList
-
printArrayList
-
printArrayList
public static <T> void printArrayList(PrintWriter out, String header, List<T> v, String begin, String sep, String end, int nbOfChars) print an ArrayList- Type Parameters:
T- type of element to be printed- Parameters:
out- output streamheader- title of the list, may be nullv- list to be printedbegin- string starting the list, like "["sep- separator like ","end- string ending the list, like "]"nbOfChars- maximal number of characters per line
-
convert2intArray
-
builtList
-
builtList
only to test generic member mechanisms. In this case the type of the return value is defined by the left side type !- Type Parameters:
D- type of the element- Returns:
-
toString
-
toString
build a tring representation of the list- Type Parameters:
T- class of the element- Parameters:
list- input list- Returns:
- a representative string
-
concat
public static char[] concat(char... inputs) -
build
-
concatenate
public static <T> T[] concatenate(T[] begining, T... following) -
concatenate
public static <T> T[] concatenate(T begining, T... following) -
contains
public static <T> boolean contains(T[] values, T value) test if an array contains a given value- Type Parameters:
T- type of values- Parameters:
values- array of valuesvalue- given value- Returns:
- true if the array contains the given value.
-
getIndex
public static <T> int getIndex(T[] values, T target) test if an array contains a given value- Type Parameters:
T- type of values- Parameters:
values- array of valuestarget- searched value- Returns:
- the found index or UNKNOWN.
-
contains
public static boolean contains(int[] values, int value) test if an array of int contains a given value- Parameters:
values- array of valuesvalue- given value- Returns:
- true if the array contains the given value.
-
contains
-
isEmpty
-
size
-
isEmpty
public static <T> boolean isEmpty(T[] list) -
size
public static <T> int size(T[] list) -
asList
Build a list of values- Type Parameters:
T- type of values- Parameters:
values- array of values- Returns:
- a void list if the input array is null, else return the Arrays.asList().
-