Package uk.ac.ebi.utils.collections
Class ListUtils
java.lang.Object
uk.ac.ebi.utils.collections.ListUtils
Miscellanea utilities about lists.
- Author:
- brandizi date: Dec 13, 2009
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
Adds the element i in list, as inList.add(int, Object)
, but independently on list.size().static <T> T
Gets the i element of list, independently on list.size().static OptionsMap
A little helper, which turns a row (typically from a table) into a dictionary, where the keys are the column headers.static <T> T
Sets the element i in list, independently on the list size.static <T> List<T>
The union of all the parameters (the list elements) in a single list
-
Constructor Details
-
ListUtils
public ListUtils()
-
-
Method Details
-
set
Sets the element i in list, independently on the list size. That is: if i < list.size() calls list.set (i, v), otherwise adds i - list.size() null elements to list and then adds v as the last element, which will be the i element. -
get
Gets the i element of list, independently on list.size(). That is: i < list.size () ? list.get ( i ) : null -
add
Adds the element i in list, as inList.add(int, Object)
, but independently on list.size(). That is: calls list.add (i, v) if i <= list.size() (and shifts all elements from i upward as usually), callsset ( list, i, v)
otherwise (i.e.: adds null element up to i-1 and v as last element). -
union
The union of all the parameters (the list elements) in a single list -
getRow
A little helper, which turns a row (typically from a table) into a dictionary, where the keys are the column headers. In other words, the result is such that:
result [ headers[j] ] == row [j], for j in [0..min-len (headers, row) )
- Throws:
IllegalArgumentException
- if headers is null or empty, to prevent serious misses from a table. If the row is null or empty, it returns an empty dictionary, since this often happens for inputs like CSV.
-