Forum: Ruby-core [ruby-trunk - Feature #6589][Open] Set#rehash

0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2012-06-14 04:55
(Received via mailing list)
Issue #6589 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: 2.0.0


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
F24ff61beb80aa5f13371aa22a35619c?d=identicon&s=25 mame (Yusuke Endoh) (Guest)
on 2012-07-14 11:38
(Received via mailing list)
Issue #6589 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned


----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-28086

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: 2.0.0


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 yhara (Yutaka HARA) (Guest)
on 2012-10-25 12:45
(Received via mailing list)
Issue #6589 has been updated by yhara (Yutaka HARA).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-31536

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2012-11-12 05:12
(Received via mailing list)
Issue #6589 has been updated by marcandre (Marc-Andre Lafortune).


Comment about this trivial but needed feature would be appreciated.

----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-32799

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2012-11-24 18:06
(Received via mailing list)
Issue #6589 has been updated by headius (Charles Nutter).


Is it specified that Set must be hashtable-based forever? There are
alternate ways to implement a Set.
----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-33820

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2012-11-25 03:17
(Received via mailing list)
Issue #6589 has been updated by marcandre (Marc-Andre Lafortune).


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".

----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-33839

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
6789224081b49822eb70f6740beb5ed5?d=identicon&s=25 knu (Akinori MUSHA) (Guest)
on 2013-07-27 08:49
(Received via mailing list)
Issue #6589 has been updated by knu (Akinori MUSHA).


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
- ...

----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-40711

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
6789224081b49822eb70f6740beb5ed5?d=identicon&s=25 knu (Akinori MUSHA) (Guest)
on 2013-07-31 08:13
(Received via mailing list)
Issue #6589 has been updated by knu (Akinori MUSHA).

Status changed from Assigned to Feedback

I added some notes to the rdoc in r42265.
----------------------------------------
Feature #6589: Set#rehash
https://bugs.ruby-lang.org/issues/6589#change-40772

Author: marcandre (Marc-Andre Lafortune)
Status: Feedback
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


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-thi...
http://stackoverflow.com/questions/10361400/deleti...
This topic is locked and can not be replied to.