Class DeltaQueue
- java.lang.Object
-
- org.pushingpixels.lafwidget.utils.DeltaQueue
-
public class DeltaQueue extends Object
Delta queue. Follows a standard approach from OS world for effeciently keeping tracks of scheduled events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeltaQueue.Deltable
Base class for entries in aDeltaQueue
.static interface
DeltaQueue.DeltaMatcher
Interface for comparing two delta instances.
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<DeltaQueue.Deltable>
queue
List of entries.
-
Constructor Summary
Constructors Constructor Description DeltaQueue()
Constructs a new empty non-blocking synchronized delta queue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<DeltaQueue.Deltable>
dequeue(int delay)
Returns all deltables that have at most specified delay left.void
dump()
Dumps the contents of the delta queue.static void
main(String[] args)
For testing.void
queue(DeltaQueue.Deltable deltable)
Queues the specified deltable.void
removeMatching(DeltaQueue.DeltaMatcher matcher)
Removes all deltas matching the specified matcher.
-
-
-
Field Detail
-
queue
protected ArrayList<DeltaQueue.Deltable> queue
List of entries. ContainsDeltaQueue.Deltable
s.
-
-
Method Detail
-
queue
public void queue(DeltaQueue.Deltable deltable)
Queues the specified deltable. The specified deltable is placed somewhere in the queue based on the initial value of its delta. Note that when this method returns, the value of aDeltaQueue.Deltable.getDelta()
may have changed. Do not reuse or change the passed deltable after this method returns.- Parameters:
deltable
- Deltable.
-
dequeue
public List<DeltaQueue.Deltable> dequeue(int delay)
Returns all deltables that have at most specified delay left. The returned list may be empty.- Parameters:
delay
- Delay.- Returns:
- The possibly empty list of all deltables that have at most specified delay left.
-
removeMatching
public void removeMatching(DeltaQueue.DeltaMatcher matcher)
Removes all deltas matching the specified matcher.- Parameters:
matcher
- Delta matcher.
-
dump
public void dump()
Dumps the contents of the delta queue.
-
main
public static void main(String[] args)
For testing.- Parameters:
args
- Ignored.
-
-