Project

General

Profile

Actions

Feature #4553

closed

Add Set#pick and Set#pop

Added by adgar (Michael Edgar) over 10 years ago. Updated almost 4 years ago.

Status:
Rejected
Priority:
Normal
Target version:
[ruby-core:<unknown>]

Description

=begin
A very common operation on sets is to take an arbitrary element from them at O(1) cost. I know typically
it's suggested that library additions go out as a gem to see community review. However, to me it seems
to be a glaring omission to lack such an operation on a built-in, fundamental data structure, so I've
gone straight to the bug tracker.

I wasn't too sure which method names to use as I've often heard "take" in lieu of "pop," so I just used the
names Wikipedia uses. Consider them flexible. "Pick" selects an arbitrary element, and "pop" selects and
deletes it.

I've provided a very simple patch that implements the necessary behavior. Thoughts?
=end


Files

pick_pop.diff (1.06 KB) pick_pop.diff implementation and tests for Set#pick and Set#pop adgar (Michael Edgar), 04/05/2011 08:10 AM
Actions

Also available in: Atom PDF