Primitive VecSeq does not implement equals or hashing methods

Description

VecSeq (as produced by (seq (vector-of :long 1 2 3))) does not implements equals, hashCode, or hasheq and does not play with any other Clojure collections or sequences appropriately in this regard.

Approach: Implement Object.hashCode(), Object.equals(), and IHashEq.hasheq() in the primitive vector seq implementation. All of these leverage the prim vec seq itself rather than the underlying prim vec as it was quite a big simpler. The hasheq() impl calls Murmur3/hashOrdered, which takes an Iterable, so Iterable was also implemented using an iterator over the seq.

Some existing tests were expanded to include coverage of the primitive vec seq.

Patch: clj-1364-2.patch

Environment

None

Activity

Show:
Andy Fingerhut
December 29, 2019, 2:31 AM

VecSeq also does not implement interface IObj, whereas calling seqon a regular Clojure vector results in an object that does implement that interface. Any interest in piling additional changes to this ticket for that, or making a separate ticket for it?

Andy Fingerhut
December 29, 2019, 2:40 AM

Went ahead and created similar to this one in that they are both regarding interfaces that seqs on normal vectors implement, but VecSeq does not.

Stuart Halloway
October 19, 2020, 12:44 PM

After applying the patch, I still see .equals returning false, in both directions.

Stuart Halloway
October 19, 2020, 12:50 PM

I expected to find that equals would copy the existing equiv except for the comparison test, but it differs also in the construction of the cond, local names, and in (unnecessarily?) calling seq on itself.

Alex Miller
October 19, 2020, 3:37 PM

The example in the description was actually wrong - it was using vector-of :int instead of vector-of :long. However, I also added a new patch that makes the equals case more similar to the equiv.

Fixed

Assignee

Unassigned

Reporter

Alex Miller

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Priority

Major
Configure