Class EventQueueBase<TEvent, TPoint, TPointDelta>
Represents a generic mutable event queue.
public abstract class EventQueueBase<TEvent, TPoint, TPointDelta> : IMutableEventQueue<TEvent, TPoint, TPointDelta>, IEventQueue<TEvent, TPoint, TPointDelta>, IReadOnlyEventQueue<TEvent, TPoint, TPointDelta>, IReadOnlyCollection<EnqueuedEvent<TEvent, TPoint, TPointDelta>>, IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>>, IEnumerable
Type Parameters
TEvent
Event type.
TPoint
Queue point type.
TPointDelta
Queue point delta type.
- Inheritance
-
EventQueueBase<TEvent, TPoint, TPointDelta>
- Implements
-
IMutableEventQueue<TEvent, TPoint, TPointDelta>IEventQueue<TEvent, TPoint, TPointDelta>IReadOnlyEventQueue<TEvent, TPoint, TPointDelta>IReadOnlyCollection<EnqueuedEvent<TEvent, TPoint, TPointDelta>>IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>>
- Derived
- Inherited Members
Constructors
EventQueueBase(TPoint)
Creates a new empty EventQueueBase<TEvent, TPoint, TPointDelta> instance with Default point comparer.
protected EventQueueBase(TPoint startPoint)
Parameters
startPoint
TPointSpecifies the starting point of this queue.
EventQueueBase(TPoint, IComparer<TPoint>)
Creates a new empty EventQueueBase<TEvent, TPoint, TPointDelta> instance.
protected EventQueueBase(TPoint startPoint, IComparer<TPoint> comparer)
Parameters
startPoint
TPointSpecifies the starting point of this queue.
comparer
IComparer<TPoint>Queue point comparer.
Properties
Comparer
Queue point comparer.
public IComparer<TPoint> Comparer { get; }
Property Value
- IComparer<TPoint>
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
CurrentPoint
Specifies the current point that this queue is in.
public TPoint CurrentPoint { get; }
Property Value
- TPoint
StartPoint
Specifies the starting point of this queue.
public TPoint StartPoint { get; }
Property Value
- TPoint
Methods
AddDelta(TPoint, TPointDelta?)
Adds delta
to the specified point
in order to create a new point.
[Pure]
protected abstract TPoint AddDelta(TPoint point, TPointDelta? delta)
Parameters
point
TPointOriginal point.
delta
TPointDeltaPoint delta to add to
point
.
Returns
- TPoint
New point.
Clear()
Removes all events from this queue.
public void Clear()
Dequeue()
Attempts to dequeue the next event that should be processed.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? Dequeue()
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance or null when no events are waiting for processing.
Enqueue(TEvent, TPointDelta)
Adds a new event to this queue that happens exactly once with its
DequeuePoint equal to
CurrentPoint moved by the specified delta
.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> Enqueue(TEvent @event, TPointDelta delta)
Parameters
event
TEventUnderlying event.
delta
TPointDeltaPoint delta used for moving DequeuePoint forward.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
Enqueue(TEvent, TPointDelta, int)
Adds a new repeatable event to this queue with its DequeuePoint equal to
CurrentPoint moved by the specified delta
.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> Enqueue(TEvent @event, TPointDelta delta, int repetitions)
Parameters
event
TEventUnderlying event.
delta
TPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
repetitions
intNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
Exceptions
- ArgumentOutOfRangeException
When
repetitions
is less than 1.
EnqueueAt(TEvent, TPoint)
Adds a new event to this queue that happens exactly once.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> EnqueueAt(TEvent @event, TPoint dequeuePoint)
Parameters
event
TEventUnderlying event.
dequeuePoint
TPointQueue point at which this event should be dequeued.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
EnqueueAt(TEvent, TPoint, TPointDelta, int)
Adds a new repeatable event to this queue.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> EnqueueAt(TEvent @event, TPoint dequeuePoint, TPointDelta delta, int repetitions)
Parameters
event
TEventUnderlying event.
dequeuePoint
TPointQueue point at which this event should be dequeued for the first time.
delta
TPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
repetitions
intNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
Exceptions
- ArgumentOutOfRangeException
When
repetitions
is less than 1.
EnqueueInfinite(TEvent, TPointDelta)
Adds a new infinitely repeatable event to this queue with its DequeuePoint
equal to CurrentPoint moved by the specified delta
.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> EnqueueInfinite(TEvent @event, TPointDelta delta)
Parameters
event
TEventUnderlying event.
delta
TPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
EnqueueInfiniteAt(TEvent, TPoint, TPointDelta)
Adds a new infinitely repeatable event to this queue.
public EnqueuedEvent<TEvent, TPoint, TPointDelta> EnqueueInfiniteAt(TEvent @event, TPoint dequeuePoint, TPointDelta delta)
Parameters
event
TEventUnderlying event.
dequeuePoint
TPointQueue point at which this event should be dequeued for the first time.
delta
TPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
GetEnumerator()
Returns an enumerator that iterates through the collection.
[Pure]
public IEnumerator<EnqueuedEvent<TEvent, TPoint, TPointDelta>> GetEnumerator()
Returns
- IEnumerator<EnqueuedEvent<TEvent, TPoint, TPointDelta>>
An enumerator that can be used to iterate through the collection.
GetEvents(TPoint)
Returns information about all currently registered events in this queue,
from CurrentPoint to the specified endPoint
.
[Pure]
public IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>> GetEvents(TPoint endPoint)
Parameters
endPoint
TPointLargest event point to include in the result.
Returns
- IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>>
New IEnumerable<T> instance.
GetNext()
Attempts to return information about the next event to happen.
[Pure]
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? GetNext()
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance or null when this queue is empty.
Move(TPointDelta)
Moves the CurrentPoint forward.
public void Move(TPointDelta delta)
Parameters
delta
TPointDeltaPoint delta to move the CurrentPoint forward by.