Class DatedEventManager<DataType, TimeType>
This structures helps recording dated events and accessing them using time values. This structure is not thread-safe !
Inheritance
DatedEventManager<DataType, TimeType>
Inherited Members
Namespace: Xareus.Utils
Assembly: Xareus.Utils.dll
Syntax
public class DatedEventManager<DataType, TimeType> where TimeType : IComparable
Type Parameters
Name | Description |
---|---|
DataType | The data type of the event |
TimeType | The time type to use (must implement IComparable) |
Methods
Clear()
Remove All events from the manager
Declaration
public static void Clear()
GetEventsBetween(TimeType, TimeType)
Get all Events that between the startTime (included) and the endTime (included)
Declaration
public static List<DatedEventManager<DataType, TimeType>.EventRecord> GetEventsBetween(TimeType startTime, TimeType endTime)
Parameters
Type | Name | Description |
---|---|---|
TimeType | startTime | |
TimeType | endTime |
Returns
Type | Description |
---|---|
List<DatedEventManager<DataType, TimeType>.EventRecord> |
GetLastEventAt(TimeType)
Get the last event entry before or at the given time. If multiple events have the same time, only the one added last is returned
Declaration
public static DataType GetLastEventAt(TimeType time)
Parameters
Type | Name | Description |
---|---|---|
TimeType | time |
Returns
Type | Description |
---|---|
DataType |
GetLastEvents(int)
Get the last events that occured (using time)
Declaration
public static IEnumerable<DatedEventManager<DataType, TimeType>.EventRecord> GetLastEvents(int nbEvents = 1)
Parameters
Type | Name | Description |
---|---|---|
int | nbEvents | Maximum number of events to return |
Returns
Type | Description |
---|---|
IEnumerable<DatedEventManager<DataType, TimeType>.EventRecord> |
InsertEvent(DataType, TimeType)
Insert a new event in the Manager.
Declaration
public static void InsertEvent(DataType data, TimeType time)
Parameters
Type | Name | Description |
---|---|---|
DataType | data | |
TimeType | time |
RemoveEventsBefore(TimeType, bool)
Remove all records that happened before the given time
Declaration
public static void RemoveEventsBefore(TimeType time, bool includeGivenTime)
Parameters
Type | Name | Description |
---|---|---|
TimeType | time | |
bool | includeGivenTime | Also remove events that happened at the specific given time |