static bool setAddOrMoveToEnd(L l, A a) { int i = l.indexOf(a); if (i >= 0 && i == l(l)-1) false; if (i >= 0) l.remove(i); l.add(a); true; }