Project

General

Profile

Actions

Feature #6589

closed

Set#rehash

Feature #6589: Set#rehash

Added by marcandre (Marc-Andre Lafortune) over 13 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
[ruby-core:45642]

Description

There should be a way to rehash a Set.

s = Set.new([[]])
s.first << 1
# s.rehash # Does not exist!
s.include? [1] # => false, want true

See also:

http://stackoverflow.com/questions/10992423/is-this-expected-behaviour-for-a-set-of-arrays-in-ruby
http://stackoverflow.com/questions/10361400/deleting-a-modified-object-from-a-set-in-a-no-op


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #12970: == Equality of recursive sets failsClosedActions

Updated by mame (Yusuke Endoh) over 13 years ago Actions #1 [ruby-core:46458]

  • Status changed from Open to Assigned

Updated by yhara (Yutaka HARA) almost 13 years ago Actions #2 [ruby-core:48258]

  • Target version changed from 2.0.0 to 2.6

Updated by marcandre (Marc-Andre Lafortune) almost 13 years ago Actions #3 [ruby-core:49241]

Comment about this trivial but needed feature would be appreciated.

Updated by headius (Charles Nutter) almost 13 years ago Actions #4 [ruby-core:50045]

Is it specified that Set must be hashtable-based forever? There are alternate ways to implement a Set.

Updated by marcandre (Marc-Andre Lafortune) almost 13 years ago Actions #5 [ruby-core:50060]

headius (Charles Nutter) wrote:

Is it specified that Set must be hashtable-based forever? There are alternate ways to implement a Set.

Alternate ways of implementing Set with check/insertion in O(1) that would also work if structures change without a rehash functionality?

In any case, the documentation states that "Set uses Hash as storage", but more importantly that "The equality of each couple of elements is determined according to Object#eql? and Object#hash".

Updated by knu (Akinori MUSHA) about 12 years ago Actions #6 [ruby-core:56223]

Actually, an undocumented "feature" is that Set does not support an element being modified once it is added.

Maybe we should "clarify" that in the document, or add such a method that recalculates identities of elements. I'm yet to decide which, and the name we could give it.

  • rehash (let's be honest)
  • reset (re-set the set)
  • sync
  • ...

Updated by knu (Akinori MUSHA) about 12 years ago Actions #7 [ruby-core:56280]

  • Status changed from Assigned to Feedback

I added some notes to the rdoc in r42265.

Updated by marcandre (Marc-Andre Lafortune) almost 9 years ago Actions #8

  • Related to Bug #12970: == Equality of recursive sets fails added

Updated by knu (Akinori MUSHA) about 8 years ago Actions #9

  • Status changed from Feedback to Closed

Applied in changeset trunk|r60360.


Add Set#reset

This method resets the internal state of a set after modification to
existing elements, reindexing and deduplicating them. [Feature #6589]

Actions

Also available in: PDF Atom