Class Pipe<T>
A linked list that can add/remove from head/tail. No heap pressure.
Constructors
Pipe(int)
A linked list that can add/remove from head/tail. No heap pressure.
Declaration
public Pipe(int capacity = 1024)
Properties
Capacity
Total length of the data
Declaration
public int Capacity { get; init; }
Data
Raw data of this pipe
Declaration
public T[] Data { get; init; }
IsFull
True if the pipe reached max capacity
Declaration
public bool IsFull { get; }
this[int]
Get filled data at index
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | Local index from "Start" |
Length
Length of the filled data
Declaration
public int Length { get; }
Start
Head index of the filled data
Declaration
public int Start { get; }
Methods
LinkToHead(T)
Add data before head
Declaration
public bool LinkToHead(T data)
Returns
Type | Description |
---|---|
bool | True if the data is added |
LinkToTail(T)
Add data after tail
Declaration
public bool LinkToTail(T data)
Returns
Type | Description |
---|---|
bool | True if the data is added |
Reorganize()
Move data at head to the first of the internal array
Declaration
public void Reorganize()
Reset()
Declaration
public void Reset()
Sort(IComparer<T>)
Declaration
public void Sort(IComparer<T> comparer)
TryPeekHead(out T)
Get data at head without remove the data from pipe
Declaration
public bool TryPeekHead(out T data)
Returns
Type | Description |
---|---|
bool | True if length of pipe is not 0 |
TryPeekTail(out T)
Get data at tail without remove the data from pipe
Declaration
public bool TryPeekTail(out T data)
Returns
Type | Description |
---|---|
bool | True if length of pipe is not 0 |
TryPopHead(out T)
Get and remove data at head
Declaration
public bool TryPopHead(out T data)
Returns
Type | Description |
---|---|
bool | True if pipe is not empty |
TryPopTail(out T)
Get and remove data at tail
Declaration
public bool TryPopTail(out T data)
Returns
Type | Description |
---|---|
bool | True if pipe is not empty |