summary refs log tree commit diff stats
path: root/lib/pure/collections
diff options
context:
space:
mode:
authortreeform <starplant@gmail.com>2020-07-29 20:49:51 -0700
committerGitHub <noreply@github.com>2020-07-29 23:49:51 -0400
commit604f7461d786e31e7ae9df5a101770c329e00fe5 (patch)
tree1e2deebf2b15e3fe05b2156bb9f59616f786e217 /lib/pure/collections
parent20315637aa5c6f018d868b7c3c26ca1b52d4cc65 (diff)
downloadNim-604f7461d786e31e7ae9df5a101770c329e00fe5.tar.gz
Fix tables.CountTable largest and smallest (#15115)
It needs to have len defined first because of the assert .len > 0.  I just moved it up a bit to make them work.
Diffstat (limited to 'lib/pure/collections')
-rw-r--r--lib/pure/collections/tables.nim8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 3aa3af4e9..017a2f337 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -2293,6 +2293,10 @@ proc inc*[A](t: var CountTable[A], key: A, val = 1) =
     if val != 0:
       insertImpl()
 
+proc len*[A](t: CountTable[A]): int =
+  ## Returns the number of keys in ``t``.
+  result = t.counter
+
 proc smallest*[A](t: CountTable[A]): tuple[key: A, val: int] =
   ## Returns the ``(key, value)`` pair with the smallest ``val``. Efficiency: O(n)
   ##
@@ -2345,10 +2349,6 @@ proc getOrDefault*[A](t: CountTable[A], key: A; default: int = 0): int =
   ##   is in the table
   ctget(t, key, default)
 
-proc len*[A](t: CountTable[A]): int =
-  ## Returns the number of keys in ``t``.
-  result = t.counter
-
 proc del*[A](t: var CountTable[A], key: A) {.since: (1, 1).} =
   ## Deletes ``key`` from table ``t``. Does nothing if the key does not exist.
   ##