Class ReorderableEventQueueBase<TEvent, TPoint, TPointDelta>
Represents a generic mutable event queue that allows to modify registered events.
public abstract class ReorderableEventQueueBase<TEvent, TPoint, TPointDelta> : IMutableReorderableEventQueue<TEvent, TPoint, TPointDelta>, IMutableEventQueue<TEvent, TPoint, TPointDelta>, IReorderableEventQueue<TEvent, TPoint, TPointDelta>, IEventQueue<TEvent, TPoint, TPointDelta>, IReadOnlyReorderableEventQueue<TEvent, TPoint, TPointDelta>, IReadOnlyEventQueue<TEvent, TPoint, TPointDelta>, IReadOnlyCollection<EnqueuedEvent<TEvent, TPoint, TPointDelta>>, IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>>, IEnumerable where TEvent : notnull
Type Parameters
TEventEvent type.
TPointQueue point type.
TPointDeltaQueue point delta type.
- Inheritance
-
ReorderableEventQueueBase<TEvent, TPoint, TPointDelta>
- Implements
-
IMutableReorderableEventQueue<TEvent, TPoint, TPointDelta>IMutableEventQueue<TEvent, TPoint, TPointDelta>IReorderableEventQueue<TEvent, TPoint, TPointDelta>IEventQueue<TEvent, TPoint, TPointDelta>IReadOnlyReorderableEventQueue<TEvent, TPoint, TPointDelta>IReadOnlyEventQueue<TEvent, TPoint, TPointDelta>IReadOnlyCollection<EnqueuedEvent<TEvent, TPoint, TPointDelta>>IEnumerable<EnqueuedEvent<TEvent, TPoint, TPointDelta>>
- Derived
- Inherited Members
Constructors
ReorderableEventQueueBase(TPoint)
Creates a new empty ReorderableEventQueueBase<TEvent, TPoint, TPointDelta> instance with Default point comparer and Default event comparer.
protected ReorderableEventQueueBase(TPoint startPoint)
Parameters
startPointTPointSpecifies the starting point of this queue.
ReorderableEventQueueBase(TPoint, IEqualityComparer<TEvent>, IComparer<TPoint>)
Creates a new empty ReorderableEventQueueBase<TEvent, TPoint, TPointDelta> instance.
protected ReorderableEventQueueBase(TPoint startPoint, IEqualityComparer<TEvent> eventComparer, IComparer<TPoint> comparer)
Parameters
startPointTPointSpecifies the starting point of this queue.
eventComparerIEqualityComparer<TEvent>Event equality comparer.
comparerIComparer<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
EventComparer
Event equality comparer.
public IEqualityComparer<TEvent> EventComparer { get; }
Property Value
- IEqualityComparer<TEvent>
StartPoint
Specifies the starting point of this queue.
public TPoint StartPoint { get; }
Property Value
- TPoint
Methods
Add(TPointDelta?, TPointDelta)
Adds a and b together in order to create a new point delta.
[Pure]
protected abstract TPointDelta Add(TPointDelta? a, TPointDelta b)
Parameters
aTPointDeltaFirst point delta.
bTPointDeltaSecond point delta.
Returns
- TPointDelta
New point delta.
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
pointTPointOriginal point.
deltaTPointDeltaPoint delta to add to
point.
Returns
- TPoint
New point.
AdvanceDequeuePoint(TEvent, TPointDelta)
Modifies the existing event by moving the DequeuePoint
backward by the specified delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? AdvanceDequeuePoint(TEvent @event, TPointDelta delta)
Parameters
eventTEventEvent to modify.
deltaTPointDeltaPoint delta to move the current DequeuePoint backward by.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
Clear()
Removes all events from this queue.
public void Clear()
Contains(TEvent)
Checks whether or not this queue contains the specified event.
[Pure]
public bool Contains(TEvent @event)
Parameters
eventTEventEvent to check.
Returns
- bool
true when
eventexists, otherwise false.
DecreaseDelta(TEvent, TPointDelta)
Modifies the existing event by subtracting a value from
Delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? DecreaseDelta(TEvent @event, TPointDelta delta)
Parameters
eventTEventEvent to modify.
deltaTPointDeltaPoint delta to subtract.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
DecreaseRepetitions(TEvent, int)
Modifies the existing event by subtracting Repetitions.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? DecreaseRepetitions(TEvent @event, int count)
Parameters
eventTEventEvent to modify.
countintNumber of repetitions to subtract.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
Exceptions
- ArgumentOutOfRangeException
When new number of repetitions is less than 1.
DelayDequeuePoint(TEvent, TPointDelta)
Modifies the existing event by moving the DequeuePoint
forward by the specified delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? DelayDequeuePoint(TEvent @event, TPointDelta delta)
Parameters
eventTEventEvent to modify.
deltaTPointDeltaPoint delta to move the current DequeuePoint forward by.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
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
eventTEventUnderlying event.
deltaTPointDeltaPoint 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
eventTEventUnderlying event.
deltaTPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
repetitionsintNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
Exceptions
- ArgumentOutOfRangeException
When
repetitionsis 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
eventTEventUnderlying event.
dequeuePointTPointQueue 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
eventTEventUnderlying event.
dequeuePointTPointQueue point at which this event should be dequeued for the first time.
deltaTPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
repetitionsintNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>
New EnqueuedEvent<TEvent, TPoint, TPointDelta> instance.
Exceptions
- ArgumentOutOfRangeException
When
repetitionsis 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
eventTEventUnderlying event.
deltaTPointDeltaPoint 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
eventTEventUnderlying event.
dequeuePointTPointQueue point at which this event should be dequeued for the first time.
deltaTPointDeltaPoint 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.
GetEvent(TEvent)
Attempts to return event information.
[Pure]
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? GetEvent(TEvent @event)
Parameters
eventTEventEvent to get information for.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the provided
eventor null when event does not exist.
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
endPointTPointLargest 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.
IncreaseDelta(TEvent, TPointDelta)
Modifies the existing event by adding a value to Delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? IncreaseDelta(TEvent @event, TPointDelta delta)
Parameters
eventTEventEvent to modify.
deltaTPointDeltaPoint delta to add.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
IncreaseRepetitions(TEvent, int)
Modifies the existing event by adding Repetitions.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? IncreaseRepetitions(TEvent @event, int count)
Parameters
eventTEventEvent to modify.
countintNumber of repetitions to add.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
Exceptions
- ArgumentOutOfRangeException
When new number of repetitions is less than 1.
MakeInfinite(TEvent)
Modifies the existing event by making it repeat infinitely.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? MakeInfinite(TEvent @event)
Parameters
eventTEventEvent to modify.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
Move(TPointDelta)
Moves the CurrentPoint forward.
public void Move(TPointDelta delta)
Parameters
deltaTPointDeltaPoint delta to move the CurrentPoint forward by.
Remove(TEvent)
Attempts to remove the specified event.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? Remove(TEvent @event)
Parameters
eventTEventEvent to remove.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
Removed EnqueuedEvent<TEvent, TPoint, TPointDelta> instance or null when
eventdoes not exist.
SetDelta(TEvent, TPointDelta)
Modifies the existing event by changing the Delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? SetDelta(TEvent @event, TPointDelta delta)
Parameters
eventTEventEvent to modify.
deltaTPointDeltaPoint delta used for moving DequeuePoint forward on each repetition of this event.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
SetDequeuePoint(TEvent, TPoint)
Modifies the existing event by changing the DequeuePoint.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? SetDequeuePoint(TEvent @event, TPoint dequeuePoint)
Parameters
eventTEventEvent to modify.
dequeuePointTPointNext queue point at which this event should be dequeued.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
SetRepetitions(TEvent, int)
Modifies the existing event by changing the Repetitions.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? SetRepetitions(TEvent @event, int repetitions)
Parameters
eventTEventEvent to modify.
repetitionsintNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
eventor null when event does not exist.
Exceptions
- ArgumentOutOfRangeException
When
repetitionsis less than 1.
Subtract(TPointDelta?, TPointDelta)
Subtracts b from a in order to create a new point delta.
[Pure]
protected abstract TPointDelta Subtract(TPointDelta? a, TPointDelta b)
Parameters
aTPointDeltaFirst point delta.
bTPointDeltaSecond point delta.
Returns
- TPointDelta
New point delta.
SubtractDelta(TPoint, TPointDelta?)
Subtracts delta from the specified point in order to create a new point.
[Pure]
protected abstract TPoint SubtractDelta(TPoint point, TPointDelta? delta)
Parameters
pointTPointOriginal point.
deltaTPointDeltaPoint delta to subtract from
point.
Returns
- TPoint
New point.