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
TEvent
Event type.
TPoint
Queue point type.
TPointDelta
Queue 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
startPoint
TPointSpecifies 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
startPoint
TPointSpecifies the starting point of this queue.
eventComparer
IEqualityComparer<TEvent>Event equality comparer.
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
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
a
TPointDeltaFirst point delta.
b
TPointDeltaSecond 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
point
TPointOriginal point.
delta
TPointDeltaPoint 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
event
TEventEvent to modify.
delta
TPointDeltaPoint delta to move the current DequeuePoint backward by.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to check.
Returns
- bool
true when
event
exists, 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
event
TEventEvent to modify.
delta
TPointDeltaPoint delta to subtract.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to modify.
count
intNumber of repetitions to subtract.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to modify.
delta
TPointDeltaPoint delta to move the current DequeuePoint forward by.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
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.
GetEvent(TEvent)
Attempts to return event
information.
[Pure]
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? GetEvent(TEvent @event)
Parameters
event
TEventEvent to get information for.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the provided
event
or 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
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.
IncreaseDelta(TEvent, TPointDelta)
Modifies the existing event
by adding a value to Delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? IncreaseDelta(TEvent @event, TPointDelta delta)
Parameters
event
TEventEvent to modify.
delta
TPointDeltaPoint delta to add.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to modify.
count
intNumber of repetitions to add.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to modify.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or null when event does not exist.
Move(TPointDelta)
Moves the CurrentPoint forward.
public void Move(TPointDelta delta)
Parameters
delta
TPointDeltaPoint delta to move the CurrentPoint forward by.
Remove(TEvent)
Attempts to remove the specified event
.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? Remove(TEvent @event)
Parameters
event
TEventEvent to remove.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
Removed EnqueuedEvent<TEvent, TPoint, TPointDelta> instance or null when
event
does not exist.
SetDelta(TEvent, TPointDelta)
Modifies the existing event
by changing the Delta.
public EnqueuedEvent<TEvent, TPoint, TPointDelta>? SetDelta(TEvent @event, TPointDelta delta)
Parameters
event
TEventEvent to modify.
delta
TPointDeltaPoint 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
event
or 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
event
TEventEvent to modify.
dequeuePoint
TPointNext queue point at which this event should be dequeued.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or 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
event
TEventEvent to modify.
repetitions
intNumber of repetitions.
Returns
- EnqueuedEvent<TEvent, TPoint, TPointDelta>?
EnqueuedEvent<TEvent, TPoint, TPointDelta> instance associated with the modified
event
or null when event does not exist.
Exceptions
- ArgumentOutOfRangeException
When
repetitions
is 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
a
TPointDeltaFirst point delta.
b
TPointDeltaSecond 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
point
TPointOriginal point.
delta
TPointDeltaPoint delta to subtract from
point
.
Returns
- TPoint
New point.