Class CircularList<T>
ICollection<T> where every item knows the previous and the next item in collection.
Namespace: GGL.Collections
Assembly: GGL.dll
Syntax
[Serializable]
public class CircularList<T>
Type Parameters
Name | Description |
---|---|
T | where every item knows the previous and the next item in collection. |
Remarks
The last item is bind to the first one.
Constructors
| Edit this page View SourceCircularList()
Create an empty list
Declaration
public CircularList()
CircularList(IEnumerable<T>)
Create a circular list from a commnon one.
Declaration
public CircularList(IEnumerable<T> data)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | data |
CircularList(int)
Create an empty list with an initial capacity
Declaration
public CircularList(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | where every item knows the previous and the next item in collection. |
Methods
| Edit this page View SourceAdd(T, out ListNode<T>)
Add item in circular list.
Declaration
public void Add(T item, out ListNode<T> createdListNode)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to be added. |
ListNode<T> | createdListNode | Created node in list. |
AddAfter(ListNode<T>, T)
Add item in list right after the specified node.
Declaration
public ListNode<T> AddAfter(ListNode<T> listNode, T item)
Parameters
Type | Name | Description |
---|---|---|
ListNode<T> | listNode | where every item knows the previous and the next item in collection. |
T | item | where every item knows the previous and the next item in collection. |
Returns
Type | Description |
---|---|
ListNode<T> | where every item knows the previous and the next item in collection. |
AddBefore(ListNode<T>, T)
Add item in list right before the specified node.
Declaration
public ListNode<T> AddBefore(ListNode<T> listNode, T item)
Parameters
Type | Name | Description |
---|---|---|
ListNode<T> | listNode | where every item knows the previous and the next item in collection. |
T | item | where every item knows the previous and the next item in collection. |
Returns
Type | Description |
---|---|
ListNode<T> | where every item knows the previous and the next item in collection. |
FindNode(T)
Get the node of a contained item if it exists.
Declaration
public ListNode<T> FindNode(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
ListNode<T> |
FirstNode()
Get the first node of the list.
Declaration
public ListNode<T> FirstNode()
Returns
Type | Description |
---|---|
ListNode<T> | where every item knows the previous and the next item in collection. |
LastNode()
Get the last node of the list.
Declaration
public ListNode<T> LastNode()
Returns
Type | Description |
---|---|
ListNode<T> | where every item knows the previous and the next item in collection. |
Remove(ListNode<T>)
Remove a node from list
Declaration
public bool Remove(ListNode<T> listNode)
Parameters
Type | Name | Description |
---|---|---|
ListNode<T> | listNode | where every item knows the previous and the next item in collection. |
Returns
Type | Description |
---|---|
bool | True if succeeded to remove. |