Class IListExtensions
Extension methods for IListExtensions.
Inherited Members
Namespace: Phoenix.BotBrain.Extensions
Assembly: Phoenix.Plugin.BotBrain.Lists.dll
Syntax
public static class IListExtensions
Methods
View SourceGetNearestItem(IList, int)
Finds the item closest to the given index in a list.
Declaration
public static object? GetNearestItem(this IList self, int index)
Parameters
Type | Name | Description |
---|---|---|
IList | self | The list being extended. |
int | index | The index. |
Returns
Type | Description |
---|---|
object | the item, or null if the list is empty. |
GetNearestItem<T>(IList<T>, int)
Finds the item closest to the given index in a list.
Declaration
public static T? GetNearestItem<T>(this IList<T> self, int index) where T : class
Parameters
Type | Name | Description |
---|---|---|
IList<T> | self | The list being extended. |
int | index | The index. |
Returns
Type | Description |
---|---|
T | the item, or null if the list is empty. |
Type Parameters
Name | Description |
---|---|
T | The item type. |
IndicesOf(IList, IEnumerable?)
Gets the indices of each object in an enumeration.
Declaration
public static IEnumerable<int> IndicesOf(this IList self, IEnumerable? items)
Parameters
Type | Name | Description |
---|---|---|
IList | self | The list being extended. |
IEnumerable | items | The items to use. |
Returns
Type | Description |
---|---|
IEnumerable<int> | The indices, or -1 if the item isn't found. |
IndicesOf<T>(IList<T>, IEnumerable<T>)
Gets the indices of each item in an enumeration.
Declaration
public static IEnumerable<int> IndicesOf<T>(this IList<T> self, IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | self | The list being extended. |
IEnumerable<T> | items | The items to use. |
Returns
Type | Description |
---|---|
IEnumerable<int> | The indices, or -1 if the item isn't found. |
Type Parameters
Name | Description |
---|---|
T | The item type. |
Move<T>(IList<T>, int, int)
Moves an item to a new index in a list.
Declaration
public static void Move<T>(this IList<T> self, int index, int newIndex)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | self | The list being extended. |
int | index | The original index. |
int | newIndex | The new index. |
Type Parameters
Name | Description |
---|---|
T | The item type. |
OrderBy(IList, IList)
Returns a new enumeration with the list items in the same order as the other list.
Declaration
public static IEnumerable<object> OrderBy(this IList self, IList other)
Parameters
Type | Name | Description |
---|---|---|
IList | self | The list being extended. |
IList | other | The other sorted list to use. |
Returns
Type | Description |
---|---|
IEnumerable<object> | An enumeration. |