Class TimestampedList<T>
- Namespace
- RisingV.Shared.Collections
- Assembly
- RisingV.Shared.dll
A thread-safe list that tracks items with timestamps.
public class TimestampedList<T>
Type Parameters
T
- Inheritance
-
TimestampedList<T>
- Inherited Members
- Extension Methods
Properties
Count
public int Count { get; }
Property Value
Items
All current items (ignores timestamps).
public IEnumerable<T> Items { get; }
Property Value
- IEnumerable<T>
TimedItems
All items paired with their timestamps.
public IEnumerable<(T Item, DateTime Timestamp)> TimedItems { get; }
Property Value
- IEnumerable<(T Item, DateTime Timestamp)>
Methods
Add(T)
Adds a new item stamped with the current time.
public void Add(T item)
Parameters
itemT
Clear()
Clears the entire list.
public void Clear()
GetItemsNewerThan(TimeSpan)
Items newer than or equal to (now – age).
public IEnumerable<T> GetItemsNewerThan(TimeSpan age)
Parameters
ageTimeSpan
Returns
- IEnumerable<T>
GetItemsOlderThan(TimeSpan)
Items older than (now – age).
public IEnumerable<T> GetItemsOlderThan(TimeSpan age)
Parameters
ageTimeSpan
Returns
- IEnumerable<T>
GetTimestamp(T)
Gets the timestamp for when the item was added or last touched, or null if missing.
public DateTime? GetTimestamp(T item)
Parameters
itemT
Returns
OrderByAscending()
public void OrderByAscending()
OrderByDescending()
public void OrderByDescending()
Remove(T)
Removes the first matching item.
public bool Remove(T item)
Parameters
itemT
Returns
RemoveOlderThan(TimeSpan)
Removes all entries older than the specified age.
public void RemoveOlderThan(TimeSpan age)
Parameters
ageTimeSpan
RemoveRange(IEnumerable<T>)
public void RemoveRange(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>
Touch(T)
“Touches” an existing item, resetting its timestamp to now.
public void Touch(T item)
Parameters
itemT