// unclear semantics as to whether return null on null static ArrayList asList(A[] a) { return a == null ? new ArrayList() : new ArrayList(Arrays.asList(a)); } static ArrayList asList(int[] a) { if (a == null) null; ArrayList l = emptyList(a.length); for (int i : a) l.add(i); ret l; } static ArrayList asList(long[] a) { if (a == null) null; ArrayList l = emptyList(a.length); for (long i : a) l.add(i); ret l; } static ArrayList asList(float[] a) { if (a == null) null; ArrayList l = emptyList(a.length); for (float i : a) l.add(i); ret l; } static ArrayList asList(double[] a) { if (a == null) null; ArrayList l = emptyList(a.length); for (double i : a) l.add(i); ret l; } static ArrayList asList(Iterator it) { new ArrayList l; if (it != null) while (it.hasNext()) l.add(it.next()); ret l; } // disambiguation static ArrayList asList(ItIt s) { ret asList((Iterator) s); } static ArrayList asList(Iterable s) { if (s instanceof ArrayList) return (ArrayList) s; ArrayList l = new ArrayList(); if (s != null) for (A a : s) l.add(a); return l; } ifclass Producer static ArrayList asList(Producer p) { new ArrayList l; A a; if (p != null) while ((a = p.next()) != null) l.add(a); ret l; } endif static ArrayList asList(Enumeration e) { new ArrayList l; if (e != null) while (e.hasMoreElements()) l.add(e.nextElement()); return l; } ifclass ReverseChain static ArrayList asList(ReverseChain c) { ret c == null ? emptyList() : c.toList(); } endif ifclass Pair static L asList(Pair p) { ret p == null ?: ll(p.a, p.b); } endif