Java Utililty Methods List xor

List of utility methods to do List xor

Description

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

Method

voidxor(List l1, List l2)
Adds object from list 2 to list 1, unless they are already present (then removes them).
int size = l1.size();
for (int i = 0, iMax = l2.size(); i < iMax; i++)
    if (!l1.contains(l2.get(i)))
        l1.add(l2.get(i));
for (int i = size - 1; i >= 0; i--)
    if (l2.contains(l1.get(i)))
        l1.remove(i);
byte[]xor(List blocs)
xor
final byte result[] = new byte[blocs.get(0).length];
for (int i = 0; i < result.length; i++) {
    result[i] = xor(blocs, i);
return result;
ListxorOnLists(List l1, List l2)
xor On Lists
boolean xor = l1 == null ^ l2 == null;
if (xor) {
    return l1 == null ? l2 : l1;
if (l1 != null) {
    l1.clear();
    return l1;
return null;