groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8565) Method from java.util.Deque to be added to Groovy List?
Date Sat, 05 May 2018 01:25:00 GMT


Paul King commented on GROOVY-8565:

I should mention {{tail}} (like removeFirst)  and {{init}} (like removeLast):
def items = [1, 2, 3]
assert items.last() == 3
assert items.init() == [1, 2]
assert items.first() == 1
assert items.tail() == [2, 3]

> Method from java.util.Deque to be added to Groovy List?
> -------------------------------------------------------
>                 Key: GROOVY-8565
>                 URL:
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Mike Rodent
>            Priority: Minor
> I was surprised to find that List in the GDK hasn't added `addFirst` method. AKA `shift`. 
Also `removeFirst` AKA `unshift`.
> I'm intrigued to see that in Groovy 3.0.0 (not in beta at time of writing) `push` and
`pop` *appear* to be changing from adding/removing at the end, as currently, to adding/removing
at the *beginning*, "to align with java.util.Stack".  So can we conclude that the need for
more stack/queue/deque methods has been recognised?
> Of course there are multiple ways of doing this... it's just that that means that it's
slightly less convenient to use a standard Groovy List as an interesting form of queue or
deque.  What you really want is parameterless methods for these standard queue-type operations.
> java.util.Deque has some other interesting methods which one might want to think about
too: offerXXX, peekXXX, getXXX.

This message was sent by Atlassian JIRA

View raw message