[MLton-commit] r5406

Vesa Karvonen vesak at mlton.org
Tue Mar 6 09:31:47 PST 2007


Added isEmpty to CACHE.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig
U   mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml
U   mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun

----------------------------------------------------------------------

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig	2007-03-06 17:15:37 UTC (rev 5405)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig	2007-03-06 17:31:46 UTC (rev 5406)
@@ -29,6 +29,9 @@
    val size : 'a t -> Int.t
    (** Returns the number of elements in the cache. *)
 
+   val isEmpty : 'a t UnPr.t
+   (** {isEmpty c} is equivalent to {size x = 0}. *)
+
    val putWith : 'a t -> (Key.t -> 'a) -> Key.t * 'a
    (**
     * Puts a key dependent value into cache and returns the key and

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml	2007-03-06 17:15:37 UTC (rev 5405)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml	2007-03-06 17:31:46 UTC (rev 5406)
@@ -31,6 +31,8 @@
 
    fun size (IN {table, ...}) = T.size table
 
+   fun isEmpty c = 0 = size c
+
    fun putWith (t as IN {table, seed}) keyToValue = let
       val word = !seed before seed := Misc.ranqd1 (!seed)
       val key = wordToKey word

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun	2007-03-06 17:15:37 UTC (rev 5405)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun	2007-03-06 17:31:46 UTC (rev 5406)
@@ -20,6 +20,8 @@
    fun size c = gt#size c
    fun cap c = Array.length (gt#table c)
 
+   fun isEmpty c = 0 = size c
+
    fun sub c i = valOf (Array.sub (gt#table c, i))
    fun update c (i, v) = Array.update (gt#table c, i, v)
 




More information about the MLton-commit mailing list