Class RingBuffer<T>
Inheritance
System.Object
Inherited Members
Show
Syntax
public class RingBuffer<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
RingBuffer(Int32, UnityEngine.ILogger)
Declaration
public RingBuffer(int bitCount, UnityEngine.ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | bitCount | |
| UnityEngine.ILogger | logger |
RingBuffer(Int32, IEqualityComparer<T>, UnityEngine.ILogger)
Declaration
public RingBuffer(int bitCount, IEqualityComparer<T> comparer, UnityEngine.ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | bitCount | |
| System.Collections.Generic.IEqualityComparer<T> | comparer | |
| UnityEngine.ILogger | logger |
Fields
Sequencer
Declaration
public readonly Sequencer Sequencer
Properties
Read
Declaration
public uint Read { get; }
Write
Declaration
public uint Write { get; }
Count
Number of non-null items in buffer NOTE: this is not distance from read to write
Declaration
public int Count { get; }
Capacity
Declaration
public int Capacity { get; }
Item[UInt32]
Declaration
public T this[uint index] { get; }
Item[Int32]
Declaration
public T this[int index] { get; }
IsFull
Declaration
public bool IsFull { get; }
Methods
DistanceToRead(UInt32)
Declaration
public long DistanceToRead(uint from)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | from |
Returns
| Type | Description |
|---|---|
| System.Int64 |
Enqueue(T)
Declaration
public uint Enqueue(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item |
Returns
| Type | Description |
|---|---|
| System.UInt32 | sequence of written item |
TryPeak(out T)
Tries to read the item at read index same as but does not remove the item after reading it
Declaration
public bool TryPeak(out T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if item exists, or false if it is missing |
Exists(UInt32)
Does item exist at index Index will be moved into bounds
Declaration
public bool Exists(uint index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | index |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if item exists, or false if it is missing |
RemoveNext()
Removes the item at read index and increments read index can be used after to do the same as
Declaration
public void RemoveNext()
Dequeue()
Removes next item and increments read index Assumes next items exists, best to use this with
Declaration
public T Dequeue()
Returns
| Type | Description |
|---|---|
| T |
TryDequeue(out T)
Tries to remove the item at read index
Declaration
public bool TryDequeue(out T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if item exists, or false if it is missing |
InsertAt(UInt32, T)
Declaration
public void InsertAt(uint index, T item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | index | |
| T | item |
RemoveAt(UInt32)
Declaration
public void RemoveAt(uint index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | index |
MoveReadToNextNonEmpty()
Moves read index to next non empty position this is useful when removing items from buffer in random order. Will stop when write == read, or when next buffer item is not empty
Declaration
public void MoveReadToNextNonEmpty()
MoveReadOne()
Moves read 1 index
Declaration
public void MoveReadOne()
ClearAndRelease(Action<T>)
Declaration
public void ClearAndRelease(Action<T> releaseItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<T> | releaseItem |