Java Utililty Methods List Value Add

List of utility methods to do List Value Add

Description

The list of methods to do List Value Add are organized into topic(s).

Method

Listadd(List vector, int[] sparseVector)
The addition of two vectors, one of which is a sparse vector with value 1.
List<Integer> result = new ArrayList<Integer>(vector);
for (int offset : sparseVector) {
    if (offset == -1) {
        continue;
    result.set(offset, result.get(offset) + 1);
return result;
...
voidadd(List list, Object[] array)
add
list.addAll(Arrays.asList(array));
voidadd(List data, Object... values)
add
data.add(values);
voidadd(List> target, E value)
add
int dbsize = target.size();
switch (dbsize) {
case 1:
    target.get(0).add(value);
    break;
default:
    throw new IllegalArgumentException();
ArrayListadd(List a, List b)
add
ArrayList<String> ret = new ArrayList<String>();
for (String s : a) {
    ret.add(s);
for (String s : b) {
    ret.add(s);
return ret;
...
booleanadd(List list, String value)
Adds the value to the list if neither null nor empty string.
if (value == null)
    return false;
if (value.length() == 0)
    return false;
list.add(value);
return true;
Listadd(List aList, T anObj)
Adds an object to the given list and returns list (creates list if missing).
if (aList == null)
    aList = new Vector();
aList.add(anObj);
return aList;
voidadd(List aList, T anObject)
If @List is Empty inizialize it to a new @ArrayList
if (aList == null) {
    aList = new ArrayList<T>();
aList.add(anObject);
voidadd(List current, T toAdd)
Generic addition of an item to a List (without repeats) -- used to accommodate ObservableLists in front-end
for (int i = 0; i < current.size(); i++) {
    if (current.get(i).equals(toAdd)) {
        current.remove(i);
        i--;
current.add(toAdd);
voidadd(List list, int i, T v)
Adds the element i in list, as in List#add(int,Object) , but independently on list.size().
if (i <= list.size())
    list.add(i, v);
else
    set(list, i, v);