|
2 | 2 | BangPatterns, UndecidableInstances #-} |
3 | 3 |
|
4 | 4 | -- | An implementation of Okasaki's implicit queues holding elements of some |
5 | | --- semigroup. We track the sum of them all. |
| 5 | +-- semigroup. We track the sum of them all. This structure is designed to |
| 6 | +-- support efficient *sliding window* algorithms for streams. |
6 | 7 | module Data.AnnotatedQueue |
7 | 8 | ( Queue |
8 | 9 | , ViewL (..) |
@@ -120,16 +121,16 @@ on `m`, for a total of 2 units of work. |
120 | 121 |
|
121 | 122 | In the last case, we have two possibilities, depending on the prefix: |
122 | 123 |
|
123 | | -1. The prefix has one element. Then the debit allowance on `m` is 0. We force `m` |
124 | | -(for free). We do 1 unit of unshared work. We create a suspension for the |
| 124 | +1. The prefix has one element. Then the debit allowance on `m` is 0. We force |
| 125 | +`m` (for free). We do 1 unit of unshared work. We create a suspension for the |
125 | 126 | recursive call and place 2 debits on it to pay for that. Since the debit |
126 | | -allowance for the suspension only allows 1 debit, we pay one of them off now. |
127 | | -So the amortized cost is 2. |
| 127 | +allowance for the result middle only allows 1 debit, we pay one of them off |
| 128 | +now. So the amortized cost is 2. |
128 | 129 |
|
129 | | -2. The prefix has two elements. Then the debit allowance on `m` is 1. We pay off |
130 | | -that debit and force `m`. We do 1 unit of unshared work. We create a suspension |
131 | | -for the recursive call and place 2 debits on it. This is within the debit allowance |
132 | | -for the result. So the amortized cost is 2. |
| 130 | +2. The prefix has two elements. Then the debit allowance on `m` is 1. We pay |
| 131 | +off that debit and force `m`. We do 1 unit of unshared work. We create a |
| 132 | +suspension for the recursive call and place 2 debits on it. This is within the |
| 133 | +debit allowance for the result middle. So the amortized cost is 2. |
133 | 134 | -} |
134 | 135 |
|
135 | 136 | data ViewL s = EmptyL | ViewL !s !(Queue s) |
|
0 commit comments