Operator `==` for CountTable does not work. #4946

Closed
konqoro opened this Issue Oct 24, 2016 · 2 comments

Projects

None yet

1 participant

@konqoro
Contributor
konqoro commented Oct 24, 2016 edited

test.nim

import tables

var t = initCountTable[int]()
var s = initCountTable[int]()

s.inc(1)
t.inc(1)
t.inc(1, -1)
# echo t.hasKey(1)
echo t == s
echo s == t

outputs:

true
false
@flyx flyx added a commit to flyx/Nim that referenced this issue Oct 24, 2016
@flyx flyx Fixes #4946 32d6a13
@flyx flyx added a commit to flyx/Nim that referenced this issue Oct 24, 2016
@flyx flyx Fixes #4946 f73acd9
@konqoro
Contributor
konqoro commented Oct 24, 2016

That was fast thank you! However there are cases that still fail:

var f = initCountTable[int]()
var n = initCountTable[int]()

f.inc(1)
n.inc(1)
n[1] -= 1
# echo n.hasKey(1)
echo f == n
echo n == f

and maybe mvalues and mpairs

@Araq Araq pushed a commit that closed this issue Oct 24, 2016
@flyx flyx Fixes #4946 7476e4f
@Araq Araq closed this in 7476e4f Oct 24, 2016
@konqoro
Contributor
konqoro commented Oct 24, 2016

Also this:

import tables

var t = initCountTable[int]()
var f = initCountTable[int]()

t.inc(1)
f.inc(1)

for key, val in f.mpairs():
    if key == 1:
        val = 0

# for val in mvalues():

echo t == f
echo f == t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment