// Too bad Java doesn't support generic arrays or varargs public static Stack<String> makeName(String... strings) { Stack<String> rv = Stack.<String>emptyInstance(); for (int i = strings.length - 1; i >= 0; i--) { rv = rv.push(strings[i]); } return rv; }
public static <T> Stack<T> makeStack(Iterator<T> it) { if (!it.hasNext()) return Stack.<T>emptyInstance(); T next = it.next(); return Stack.<T>makeStack(it).push(next); }
public Stack<T> reverse() { return reverseImpl(Stack.<T>emptyInstance()); }