Show / Hide Table of Contents

Class IListExtensions

A class with extensions for IList

Inheritance
object
IListExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Phoenix.Aruba
Assembly: Phoenix.Plugin.Aruba.dll
Syntax
public static class IListExtensions

Methods

View Source

BinarySearch<T>(IList<T>, int, int, T, IComparer<T>)

The class List<T> has a BinarySearch method but there is no out-of-the-box BinarySearch method available on IList<T> So here it is. Searches a sorted list for a specific element given a comparer which defines the ordering of the list.

Declaration
public static int BinarySearch<T>(this IList<T> list, int index, int count, T item, IComparer<T> comparer = null)
Parameters
Type Name Description
IList<T> list

The list to search.

int index

The starting index of the list to search.

int count

The number of elements to search.

T item

The item to search for.

IComparer<T> comparer

The comparer corresponding to the ordering of the list, or null to use the default comparer.

Returns
Type Description
int

The index of the item in the collection, if it is found. If it is not found then the result is the bitwise complement of the index (which will be negative) where such an item should be found.

Type Parameters
Name Description
T

The list element type.

View Source

BinarySearch<T>(IList<T>, T, IComparer<T>)

Searches a sorted list for a specific element given a comparer which defines the ordering of the list.

Declaration
public static int BinarySearch<T>(this IList<T> list, T item, IComparer<T> comparer = null)
Parameters
Type Name Description
IList<T> list

The list to search.

T item

The item to search for.

IComparer<T> comparer

The comparer corresponding to the ordering of the list, or null to use the default comparer.

Returns
Type Description
int

The index of the item in the collection, if it is found. If it is not found then the result is the bitwise complement of the index (which will be negative) where such an item should be found.

Type Parameters
Name Description
T

The list element type.

View Source

InsertSorted<T>(IList<T>, T, IComparer<T>)

Insert an item into an IList in sorted order, assuming the list of already sorted.

Declaration
public static void InsertSorted<T>(this IList<T> items, T item, IComparer<T> comparer)
Parameters
Type Name Description
IList<T> items

The list.

T item

The item to insert.

IComparer<T> comparer

The comparison operator.

Type Parameters
Name Description
T

The type of the items.

View Source

SwapPositions<T>(IList<T>, int, int)

Swaps the positions of two elements within an IList.

Declaration
public static void SwapPositions<T>(this IList<T> items, int indexA, int indexB)
Parameters
Type Name Description
IList<T> items

The list.

int indexA

The index of one of the elements you wish to swap.

int indexB

The index of the other element you wish to swap.

Type Parameters
Name Description
T

The type of the items.

  • View Source
In this article
Back to top Generated by DocFX