Class IListExtensions
System.Collections.Generic.IList<T> Based Extension Methods
Inheritance
Namespace: GDX.Collections.Generic
Syntax
[VisualScriptingCompatible((short)2)]
public static class IListExtensions
Methods
| Improve this Doc View SourceAddUniqueItem<T>(IList<T>, T)
Add an item to a System.Collections.Generic.IList<T>, but only if it is not already contained.
Declaration
public static bool AddUniqueItem<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The System.Collections.Generic.IList<T> to add too. |
T | targetItem | The target object to add. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if this operation was able to add the item. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
AddUniqueRange<T>(IList<T>, T[])
Add a range of items to a System.Collections.Generic.IList<T>, checking if each item is unique prior to adding.
Declaration
public static void AddUniqueRange<T>(this IList<T> targetList, T[] targetItems)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The System.Collections.Generic.IList<T> to add too. |
T[] | targetItems | The array of items to add. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
ContainsItem<T>(IList<T>, T)
Does targetList
contain targetItem
?
Declaration
public static bool ContainsItem<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The System.Collections.Generic.IList<T> to look in. |
T | targetItem | The target object to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true/false |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
Avoids using System.Collections.Generic.EqualityComparer`1.
ContainsReference<T>(IList<T>, T)
Does targetList
contain targetItem
?
Declaration
public static bool ContainsReference<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The System.Collections.Generic.IList<T> to look in. |
T | targetItem | The target object to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true/false |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
Ignores equality check and end up comparing object pointers.
RemoveFirstItem<T>(IList<T>, T)
Removes the first targetItem
from the provided targetList
.
Declaration
public static bool RemoveFirstItem<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The target System.Collections.Generic.IList<T>. |
T | targetItem | The target object to remove from the |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the item was removed. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
Avoids using System.Collections.Generic.EqualityComparer`1.
RemoveItems<T>(IList<T>, T)
Removes all targetItem
from the provided targetList
.
Declaration
public static bool RemoveItems<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The target System.Collections.Generic.IList<T>. |
T | targetItem | The target object to remove from the |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the item was removed. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
Avoids using System.Collections.Generic.EqualityComparer`1, uses object pointers.
RemoveItemSwap<T>(IList<T>, Int32)
Replaces the object found at the provided index
with the last object in
targetList
, then removes the last item from the targetList
.
Declaration
public static void RemoveItemSwap<T>(this IList<T> targetList, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The target System.Collections.Generic.IList<T>. |
System.Int32 | index | The index of the item to remove. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
This make sure that you are always removing from the end of a System.Collections.Generic.IList<T>.
RemoveLastItem<T>(IList<T>, T)
Removes the last targetItem
from the provided targetList
.
Declaration
public static bool RemoveLastItem<T>(this IList<T> targetList, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The target System.Collections.Generic.IList<T>. |
T | targetItem | The target object to remove from the |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the item was removed. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |
Remarks
Avoids using System.Collections.Generic.EqualityComparer`1.
Shuffle<T>(IList<T>)
Shuffle the items in the targetList
.
Declaration
public static void Shuffle<T>(this IList<T> targetList)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | targetList | The target System.Collections.Generic.IList<T>. |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Collections.Generic.IList<T>. |