28 lines
719 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// containersindepth/DequeTest.java
2015-06-15 17:47:35 -07:00
import com.mindviewinc.util.*;
public class DequeTest {
static void fillTest(Deque<Integer> deque) {
for(int i = 20; i < 27; i++)
deque.addFirst(i);
for(int i = 50; i < 55; i++)
deque.addLast(i);
}
public static void main(String[] args) {
Deque<Integer> di = new Deque<>();
fillTest(di);
2015-11-03 12:00:44 -08:00
System.out.println(di);
2015-06-15 17:47:35 -07:00
while(di.size() != 0)
2015-11-03 12:00:44 -08:00
System.out.print(di.removeFirst() + " ");
System.out.println();
2015-06-15 17:47:35 -07:00
fillTest(di);
while(di.size() != 0)
2015-11-03 12:00:44 -08:00
System.out.print(di.removeLast() + " ");
2015-06-15 17:47:35 -07:00
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
[26, 25, 24, 23, 22, 21, 20, 50, 51, 52, 53, 54]
26 25 24 23 22 21 20 50 51 52 53 54
54 53 52 51 50 20 21 22 23 24 25 26
2015-09-07 11:44:36 -06:00
*/