| 1 | (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh |
| 2 | * Jagannathan, and Stephen Weeks. |
| 3 | * |
| 4 | * MLton is released under a BSD-style license. |
| 5 | * See the file MLton-LICENSE for details. |
| 6 | *) |
| 7 | |
| 8 | structure Q = QueueLogarithmicExplicit(); |
| 9 | fun p q = Q.output(q, ", ", Int.output, Out.standard); |
| 10 | let val q = ref(Q.empty()) |
| 11 | in Iterate.for(1, 20, fn n => |
| 12 | (p(!q) ; |
| 13 | Out.newline Out.standard ; |
| 14 | q := Q.enqueue(!q,n))) |
| 15 | end |
| 16 | |
| 17 | |
| 18 | structure Q = QueuePersistentTwoList |
| 19 | |
| 20 | structure Q = Queue(QueuePersistentOrderOne()) |
| 21 | |
| 22 | |
| 23 | val q = Q.empty(): int Q.t |
| 24 | |
| 25 | Q.destruct q |
| 26 | |
| 27 | Q.dequeue q |
| 28 | |
| 29 | val q = Q.enqueue(Q.enqueue(q, 1), 2) |
| 30 | |
| 31 | val (one, q') = Q.dequeue q |
| 32 | |
| 33 | val (two, q'') = Q.dequeue q' |
| 34 | |
| 35 | Q.isEmpty q; |
| 36 | Q.isEmpty q'; |
| 37 | Q.isEmpty q'' |
| 38 | |
| 39 | local |
| 40 | functor Test = QueueTest (structure ListUtil = ListUtil) |
| 41 | (structure Queue = QueuePersistentList) ; |
| 42 | |
| 43 | structure Ephemeral = Test(structure Queue' = QueueEphemeral) |
| 44 | structure PersistentTwoList = Test(structure Queue' = QueuePersistentTwoList) |
| 45 | structure OrderOne = Test(structure Queue' = QueuePersistentOrderOne) |
| 46 | |
| 47 | val numOps = 1000 |
| 48 | in |
| 49 | val _ = (Ephemeral.test numOps ; |
| 50 | PersistentTwoList.test numOps ; |
| 51 | OrderOne.test numOps) |
| 52 | end |