Infohazard.Core 1.4.1
Infohazard Core Utility Library
Loading...
Searching...
No Matches
Infohazard.Core.ListQueue< T > Class Template Reference

A FIFO data structure similar to a Queue, except that it implements all List operations. More...

Public Member Functions

 ListQueue (int initialCapacity=32)
 Construct a new ListQueue with the given capacity. More...
 
 ListQueue (IEnumerable< T > enumerable)
 Construct a new ListQueue containing all the elements of the given sequence. More...
 
void Enqueue (T item)
 Add an item to the front of the queue. More...
 
void EnsureCapacity (int capacity)
 Ensures that the capacity of the queue is at least the given value, and grows if not. More...
 
Peek ()
 Returns the element at the front of the queue without removing it. More...
 
bool TryPeek (out T item)
 Get the element at the front of the queue if it is not empty, and return whether this was successful. More...
 
Dequeue ()
 Removes and returns the element at the front of the queue. More...
 
bool TryDequeue (out T item)
 Get the element at the front of the queue if it is not empty, remove it, and return whether this was successful. More...
 
IEnumerator< T > GetEnumerator ()
 
void Add (T item)
 
void Clear ()
 
bool Contains (T item)
 
void CopyTo (T[] array, int arrayIndex)
 
bool Remove (T item)
 
int IndexOf (T item)
 
void Insert (int index, T item)
 
void RemoveAt (int index)
 
void RemoveRange (int index, int count)
 Removes a range of items from the queue. More...
 

Properties

int Count [get, private set]
 
int Capacity [get]
 Current capacity, which will be automatically expanded when needed. More...
 
bool IsReadOnly [get]
 
this[int index] [get, set]
 

Detailed Description

A FIFO data structure similar to a Queue, except that it implements all List operations.

This enables much greater flexibility than the builtin .NET Queue class. Unlike a List, it has O(1) performance for both Enqueue and Dequeue operations (assuming there is enough room).

Template Parameters
TType of elements in the structure.

Constructor & Destructor Documentation

◆ ListQueue() [1/2]

Infohazard.Core.ListQueue< T >.ListQueue ( int  initialCapacity = 32)

Construct a new ListQueue with the given capacity.

Parameters
initialCapacityInitial capacity, which will be expanded as needed.

◆ ListQueue() [2/2]

Infohazard.Core.ListQueue< T >.ListQueue ( IEnumerable< T >  enumerable)

Construct a new ListQueue containing all the elements of the given sequence.

Parameters
enumerableSequence to initialize the queue.

Member Function Documentation

◆ Add()

void Infohazard.Core.ListQueue< T >.Add ( item)

◆ Clear()

void Infohazard.Core.ListQueue< T >.Clear ( )

◆ Contains()

bool Infohazard.Core.ListQueue< T >.Contains ( item)

◆ CopyTo()

void Infohazard.Core.ListQueue< T >.CopyTo ( T[]  array,
int  arrayIndex 
)

◆ Dequeue()

T Infohazard.Core.ListQueue< T >.Dequeue ( )

Removes and returns the element at the front of the queue.

Returns
The item at the front of the queue.
Exceptions
InvalidOperationExceptionIf the queue is empty.

◆ Enqueue()

void Infohazard.Core.ListQueue< T >.Enqueue ( item)

Add an item to the front of the queue.

The capacity of the queue will be grown if needed.

Parameters
itemThe item to add.

◆ EnsureCapacity()

void Infohazard.Core.ListQueue< T >.EnsureCapacity ( int  capacity)

Ensures that the capacity of the queue is at least the given value, and grows if not.

Parameters
capacityThe capacity to ensure.

◆ GetEnumerator()

IEnumerator< T > Infohazard.Core.ListQueue< T >.GetEnumerator ( )

◆ IndexOf()

int Infohazard.Core.ListQueue< T >.IndexOf ( item)

◆ Insert()

void Infohazard.Core.ListQueue< T >.Insert ( int  index,
item 
)

◆ Peek()

T Infohazard.Core.ListQueue< T >.Peek ( )

Returns the element at the front of the queue without removing it.

Returns
The item at the front of the queue.
Exceptions
InvalidOperationExceptionIf the queue is empty.

◆ Remove()

bool Infohazard.Core.ListQueue< T >.Remove ( item)

◆ RemoveAt()

void Infohazard.Core.ListQueue< T >.RemoveAt ( int  index)

◆ RemoveRange()

void Infohazard.Core.ListQueue< T >.RemoveRange ( int  index,
int  count 
)

Removes a range of items from the queue.

Parameters
indexThe first index to remove.
countThe number of items to remove.

◆ TryDequeue()

bool Infohazard.Core.ListQueue< T >.TryDequeue ( out T  item)

Get the element at the front of the queue if it is not empty, remove it, and return whether this was successful.

Parameters
itemThe item at the front of the queue.
Returns
Whether an item was available to dequeue.

◆ TryPeek()

bool Infohazard.Core.ListQueue< T >.TryPeek ( out T  item)

Get the element at the front of the queue if it is not empty, and return whether this was successful.

Parameters
itemThe item at the front of the queue.
Returns
Whether an item was available to peek.

Property Documentation

◆ Capacity

int Infohazard.Core.ListQueue< T >.Capacity
get

Current capacity, which will be automatically expanded when needed.

Expanding capacity is an O(n) operation, so it should be avoided when possible.

◆ Count

int Infohazard.Core.ListQueue< T >.Count
getprivate set

◆ IsReadOnly

bool Infohazard.Core.ListQueue< T >.IsReadOnly
get

◆ this[int index]

T Infohazard.Core.ListQueue< T >.this[int index]
getset


The documentation for this class was generated from the following file: