summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-12-15 15:34:00 +0100
committerAraq <rumpf_a@web.de>2017-12-15 15:34:00 +0100
commitb73bb911a909d62ef0ffcdb7b38c28fe5659fb23 (patch)
tree472ceffcb61991a76c17332774a8145044752607
parente0591d494190935c235fd8d89d2bf78d16e8c30d (diff)
parentcf9bee1702e41438ad3c55f33f64d179422df807 (diff)
downloadNim-b73bb911a909d62ef0ffcdb7b38c28fe5659fb23.tar.gz
Merge branch 'devel' of github.com:nim-lang/Nim into devel
-rw-r--r--lib/pure/collections/tables.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 38f8f97f5..01767956e 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -994,7 +994,7 @@ proc smallest*[A](t: CountTable[A]): tuple[key: A, val: int] =
   ## returns the (key,val)-pair with the smallest `val`. Efficiency: O(n)
   assert t.len > 0
   var minIdx = -1
-  for h in 1..high(t.data):
+  for h in 0..high(t.data):
     if t.data[h].val > 0 and (minIdx == -1 or t.data[minIdx].val > t.data[h].val):
       minIdx = h
   result.key = t.data[minIdx].key
@@ -1332,5 +1332,5 @@ when isMainModule:
 
   block: # CountTable.smallest
     var t = initCountTable[int]()
-    for v in items([4, 4, 5, 5, 5]): t.inc(v)
-    doAssert t.smallest == (4, 2)
+    for v in items([0, 0, 5, 5, 5]): t.inc(v)
+    doAssert t.smallest == (0, 2)