From: knu@... Date: 2016-11-05T09:34:05+00:00 Subject: [ruby-core:77965] [Ruby trunk Feature#12210] Add IdentitySet class that compares members by identity Issue #12210 has been updated by Akinori MUSHA. Note that SortedSet#compare_by_identity is unimplemented when SortedSet uses rbtree. `rbtree.readjust { |a, b| a.object_id <=> b.object_id }` comes pretty close, but rbtree treats string keys specially by storing a copy of each string key given, so it does not work as expected for string keys. There needs some way provided on the rbtree side. ---------------------------------------- Feature #12210: Add IdentitySet class that compares members by identity https://bugs.ruby-lang.org/issues/12210#change-61296 * Author: Tim Perkins * Status: Closed * Priority: Normal * Assignee: Akinori MUSHA ---------------------------------------- This subclass of Set handles a use case that we ran into where we needed to track instances of objects that might compare as equal. I was surprised that there was not a core way to do this. IdentitySet allows you to do the following (trivial example using strings): ~~~ruby a_str = "a" s = IdentitySet.new([a_str, a_str, "b", "b"]) p s # => # ~~~ ---Files-------------------------------- identity_set.diff (1.18 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: