Ejemplo n.º 1
0
 // There are some things that only LinkedLists can do:  只有linkedLists可以做的
 public static void testLinkedList() {
   LinkedList ll = new LinkedList();
   Collection1.fill(ll, 5);
   print(ll); // Treat it like a stack, pushing:
   ll.addFirst("one");
   ll.addFirst("two");
   print(ll); // Like "peeking" at the top of a stack:
   System.out.println(ll.getFirst()); // Like popping a stack:
   System.out.println(ll.removeFirst());
   System.out.println(ll.removeFirst());
   // Treat it like a queue, pulling elements off the tail end:
   System.out.println(ll.removeLast());
   // With the above operations, it's a dequeue!
   print(ll);
 }
Ejemplo n.º 2
0
 // Wrap Collection1.fill() for convenience:
 public static List fill(List a) {
   return (List) Collection1.fill(a);
 }