Project

General

Profile

Actions

Feature #21821

open

Add Stack and SizedStack classes

Feature #21821: Add Stack and SizedStack classes

Added by byroot (Jean Boussier) 5 days ago. Updated 5 days ago.

Status:
Open
Assignee:
-
Target version:
[ruby-core:<unknown>]

Description

Context

Queue and SizedQueue are very useful and performant constructs, however they only allow for FIFO queues.
Some use cases do call for LIFO queues AKA stacks.

For instance, in the case of connection pool, it's often preferable to use a stack.

Feature

I'd like to introduce Stack and SizedStack classes, to mirror Queue and SizedQueue.
They'd have exactly the same method and behavior at the exception of dequeuing order.

Thread namespace?

Currently Queue and SizedQueue are technically defined under Thread and aliased in Object.
I wonder if that's something we should do for Stack too, or just some historical thing we shouldn't perpetuate.


Related issues 1 (0 open1 closed)

Related to Ruby - Feature #21721: Allow `Queue` and `SizedQueue` to be used as LIFO queuesRejectedActions
Actions

Also available in: PDF Atom