question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iterate EvictingQueue backwards

See original GitHub issue

EvictingQueue is mostly a wrapper over ArrayDeque which have a descendingIterator. EvictingQueue’s only constructor is private, so I can’t extend the class. And delegate() is also protected.

Either the constructor should be made protected or delegate public, I think, so I could do what I want

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kluevercommented, May 20, 2019

I think we’d want to hear some use cases first for why you’d want to iterate an EvictingQueue backwards before we make any changes.

0reactions
dacunni1commented, Dec 31, 2021

✋ use case here! I wanted to use an EvictingQueue to keep around the most recent N items. When I need to process (not remove) items from the queue, I’m only interested in the most recent items which may or may not be all N items. e.g. I may keep around 20 things but might only be interested in the most recent 10 right now. There’s no easy way to do this with EvictingQueue, so I’m forced to use another Deque implementation and manually evict things when necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - how to reverse iterate over Queue? - Stack Overflow
You could use Linq's Reverse() function: Queue myQueue; foreach (var item in myQueue.Reverse()) { // do things }.
Read more >
Iterate over a Queue in Java | Techie Delight
This post will discuss various methods to iterate through a queue in Java. As `Queue` implements `Iterable` interface, we can use enhanced for-loop...
Read more >
Iterating Backward Through a List - Baeldung
In this quick tutorial, we'll learn about various ways in which we can iterate backward through a list in Java.
Read more >
Size-limited queue that holds last N elements in Java - Intellipaat
Guava now has an EvictingQueue, a non-blocking queue which automatically evicts elements from the head of the queue when attempting to add new...
Read more >
Uses of Class com.google.common.annotations.GwtCompatible ...
A function from A to B with an associated reverse function from B to A ; used for converting ... A Multiset implementation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found