Table of Contents

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

int

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

item T

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

age TimeSpan

Returns

IEnumerable<T>

GetItemsOlderThan(TimeSpan)

Items older than (now – age).

public IEnumerable<T> GetItemsOlderThan(TimeSpan age)

Parameters

age TimeSpan

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

item T

Returns

DateTime?

OrderByAscending()

public void OrderByAscending()

OrderByDescending()

public void OrderByDescending()

Remove(T)

Removes the first matching item.

public bool Remove(T item)

Parameters

item T

Returns

bool

RemoveOlderThan(TimeSpan)

Removes all entries older than the specified age.

public void RemoveOlderThan(TimeSpan age)

Parameters

age TimeSpan

RemoveRange(IEnumerable<T>)

public void RemoveRange(IEnumerable<T> items)

Parameters

items IEnumerable<T>

Touch(T)

“Touches” an existing item, resetting its timestamp to now.

public void Touch(T item)

Parameters

item T