Class CircularLinkedList<T>
Represents a circular doubly linked list.
Namespace: Discord.Addons.MpGame.Collections
Assembly: Discord.Addons.MpGame.dll
Syntax
public sealed class CircularLinkedList<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | Specifies the element type of the linked list. |
Remarks
This code adapted from https://navaneethkn.wordpress.com/2009/08/18/circular-linked-list/
Constructors
| Improve this Doc View SourceCircularLinkedList(IEnumerable<T>)
Initializes a new instance of CircularLinkedList<T>
Declaration
public CircularLinkedList(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | Collection of objects that will be added to linked list |
CircularLinkedList(IEnumerable<T>, IEqualityComparer<T>)
Initializes a new instance of CircularLinkedList<T>
Declaration
public CircularLinkedList(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | Collection of objects that will be added to linked list |
IEqualityComparer<T> | comparer | Comparer used for item comparison |
Properties
| Improve this Doc View SourceCount
Gets total number of items in the list
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Head
Gets the head node. Returns null if no node found
Declaration
public Node<T> Head { get; }
Property Value
Type | Description |
---|---|
Node<T> |
Item[Int32]
Gets the item at the current index
Declaration
public Node<T> this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Zero-based index |
Property Value
Type | Description |
---|---|
Node<T> |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Tail
Gets Tail node. Returns null if no node found
Declaration
public Node<T> Tail { get; }
Property Value
Type | Description |
---|---|
Node<T> |
Methods
| Improve this Doc View SourceContains(T)
Determines whether a value is in the list.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to check |
Returns
Type | Description |
---|---|
Boolean | true if item exist, else false. |
Find(T)
Finds the supplied item and returns a node which contains item. Returns null if item not found
Declaration
public Node<T> Find(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to search |
Returns
Type | Description |
---|---|
Node<T> | Node<T> instance or null |
GetEnumerator()
Gets a forward enumerator
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
GetReverseEnumerator()
Gets a reverse enumerator
Declaration
public IEnumerator<T> GetReverseEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |