var c = new Counter[String].from(["a", "a", "b", "b", "b", "c"])
assert c.min == "c"
If more than one min exists, the first one is returned.
# Return the couple with the lowest value
#
# ~~~
# var c = new Counter[String].from(["a", "a", "b", "b", "b", "c"])
# assert c.min == "c"
# ~~~
#
# If more than one min exists, the first one is returned.
fun min: nullable E do
var min: nullable Int = null
var elem: nullable E = null
for e in map.keys do
var v = map[e]
if min == null or v < min then
min = v
elem = e
end
end
return elem
end
lib/counter/counter.nit:217,2--236,4