Project

General

Profile

Actions

Feature #16993

open

Sets: from hash keys using Hash#key_set

Added by marcandre (Marc-Andre Lafortune) almost 4 years ago. Updated almost 4 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:98968]

Description

To create a set from hash keys currently implies a temporary array for all keys, rehashing all those keys and rebuilding a hash. Instead, the hash could be copied and its values set to true.

h = {a: 1}
# Now:
Set.new(h.keys) # => Set[:a]
# After
h.key_set # => Set[:a], efficiently.

Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #16989: Sets: need ♥️Assignedknu (Akinori MUSHA)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0