diff options
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/algebra/kl.spad.pamphlet | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b850bffb..da8ab9f6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-05-14 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * algebra/kl.spad.pamphlet (SortedCache): Use Reference List S. + 2009-05-13 Gabriel Dos Reis <gdr@cs.tamu.edu> Fix SF/2790725 diff --git a/src/algebra/kl.spad.pamphlet b/src/algebra/kl.spad.pamphlet index f9b26e86..b2ba8cad 100644 --- a/src/algebra/kl.spad.pamphlet +++ b/src/algebra/kl.spad.pamphlet @@ -58,12 +58,13 @@ SortedCache(S:CachableSet): Exports == Implementation where ++ It returns x with an integer associated with it. Implementation ==> add + import Reference List S shiftCache : (List S, N) -> Void insertInCache: (List S, List S, S, N) -> S - cach := [nil()]$Record(cche:List S) + cach := ref(nil$List(S)) - cache() == cach.cche + cache() == deref cach shiftCache(l, n) == for x in l repeat setPosition(x, n + position x) @@ -71,7 +72,7 @@ SortedCache(S:CachableSet): Exports == Implementation where clearCache() == for x in cache repeat setPosition(x, 0) - cach.cche := nil() + setref(cach,nil$List(S)) void enterInCache(x:S, equal?:S -> Boolean) == @@ -82,7 +83,7 @@ SortedCache(S:CachableSet): Exports == Implementation where return y scan := rest scan setPosition(x, 1 + #cache()) - cach.cche := concat(cache(), x) + setref(cach,concat(cache(), x)) x enterInCache(x:S, triage:(S, S) -> Integer) == @@ -96,13 +97,13 @@ SortedCache(S:CachableSet): Exports == Implementation where scan := rest scan pos := position y setPosition(x, pos + DIFF) - cach.cche := concat(cache(), x) + setref(cach, concat(cache(), x)) x insertInCache(before, after, x, pos) == if ((pos+1) = position first after) then shiftCache(after, DIFF) setPosition(x, pos + (((position first after) - pos)::N quo 2)) - cach.cche := concat(before, concat(x, after)) + setref(cach, concat(before, concat(x, after))) x @ |