Class ResettableRingBuffer<T>
Writes values to a collection of a set size, overwriting old values as needed.
Inheritance
Inherited Members
Namespace: GameKit.Dependencies.Utilities.Types
Assembly: GameKit.Dependencies.dll
Syntax
public class ResettableRingBuffer<T> : IResettable, IEnumerable<T>, IEnumerable where T : IResettable
Type Parameters
Name | Description |
---|---|
T |
Constructors
ResettableRingBuffer()
Declaration
public ResettableRingBuffer()
Fields
Capacity
Maximum size allowed to be used within collection. Collection length may be larger than this value due to re-using larger collections.
Declaration
public int Capacity
Field Value
Type | Description |
---|---|
System.Int32 |
Collection
Collection being used.
Declaration
public T[] Collection
Field Value
Type | Description |
---|---|
T[] |
DEFAULT_CAPACITY
Default capacity when none is psecified.
Declaration
public const int DEFAULT_CAPACITY = 60
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
Count
Number of entries currently written.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Initialized
True if initialized.
Declaration
public bool Initialized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Returns value in actual index as it relates to simulated index.
Declaration
public T this[int simulatedIndex] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | simulatedIndex | Simulated index to return. A value of 0 would return the first simulated index in the collection. |
Property Value
Type | Description |
---|---|
T |
WriteIndex
Current write index of the collection.
Declaration
public int WriteIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Add(T)
Adds an entry to the collection.
Declaration
public void Add(T data)
Parameters
Type | Name | Description |
---|---|---|
T | data | Data to add. |
Clear()
Clears the collection to default values and resets indexing.
Declaration
public void Clear()
GetEnumerator()
Returns Enumerator for the collection.
Declaration
public ResettableRingBuffer<T>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
ResettableRingBuffer.Enumerator<> |
Initialize()
Initializes with default capacity.
Declaration
public void Initialize()
Initialize(Int32)
Initializes the collection at length.
Declaration
public void Initialize(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | Size to initialize the collection as. This cannot be changed after initialized. |
InitializeState()
Declaration
public void InitializeState()
Insert(Int32, T)
Inserts an entry into the collection. This is can be an expensive operation on larger buffers.
Declaration
public void Insert(int simulatedIndex, T data)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | simulatedIndex | Simulated index to return. A value of 0 would return the first simulated index in the collection. |
T | data | Data to insert. |
RemoveRange(Boolean, Int32)
Removes values from the simulated start of the collection.
Declaration
public void RemoveRange(bool fromStart, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | fromStart | True to remove from the start, false to remove from the end. |
System.Int32 | length | Number of entries to remove. |
Reset()
Resets the collection without clearing.
Declaration
[Obsolete("This method no longer functions. Use Clear() instead.")]
public void Reset()
ResetState()
Resets values when being placed in a cache.
Declaration
public void ResetState()
Explicit Interface Implementations
IEnumerable<T>.GetEnumerator()
Declaration
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |