示例#1
0
 // 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;
 }
示例#2
0
  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);
  }
示例#3
0
 public Stack<T> reverse() {
   return reverseImpl(Stack.<T>emptyInstance());
 }