Volume Control
Application-specific hotkeys for Windows
VolumeControl.TypeExtensions.ListExtensions Class Reference

Extensions for the generic List<T> object. More...

Collaboration diagram for VolumeControl.TypeExtensions.ListExtensions:

Static Public Member Functions

static void SelectiveUpdate< T > (this List< T > l, IEnumerable< T > other)
 Similar to List<T>.AddRange(IEnumerable<T>), but designed for unique elements.
Removes elements from l that are not present in other .
Adds elements from other to l that aren't already present somewhere in the list.
More...
 
static IList< T > ForEach< T > (this IList< T > list, Action< T > action)
 
static IList ForEach (this IList list, Action< object?> action)
 
static void AddRange (this IList list, IEnumerable enumerable)
 Adds a range of items to the list . More...
 
static void AddIfUnique (this IList list, object obj)
 Adds obj to the list if it isn't a duplicate of any existing elements. More...
 
static void AddRangeIfUnique (this IList list, IEnumerable range)
 Calls AddIfUnique(IList, object) on the given range of objects. More...
 
static TList ConvertEach< TList, TOut, TIn > (this IEnumerable< TIn > enumerable, Func< TIn, TOut > converter)
 Converts each element in the given enumerable from type TIn to type TOut , and returns the converted objects as a new list of type TList . More...
 
static IList< TOut > ConvertEach< TOut, TIn > (this IEnumerable< TIn > enumerable, Func< TIn, TOut > converter)
 Converts each element in the given enumerable from type TIn to type TOut , and returns the converted objects as a new List<T>. More...
 
static bool IndexOf< T > (this IList< T > list, T item, out int index)
 Gets the index of the first occurrence of item in this list . More...
 

Detailed Description

Extensions for the generic List<T> object.

Member Function Documentation

◆ AddIfUnique()

static void VolumeControl.TypeExtensions.ListExtensions.AddIfUnique ( this IList  list,
object  obj 
)
static

Adds obj to the list if it isn't a duplicate of any existing elements.

Parameters
listList
objObject to add to the list. The object is only added if it isn't a duplicate of an existing element, as determined by object.Equals(object?).

◆ AddRange()

static void VolumeControl.TypeExtensions.ListExtensions.AddRange ( this IList  list,
IEnumerable  enumerable 
)
static

Adds a range of items to the list .

Parameters
list(implicit) The list to add the items to.
enumerableAn IEnumerable of items to add.

◆ AddRangeIfUnique()

static void VolumeControl.TypeExtensions.ListExtensions.AddRangeIfUnique ( this IList  list,
IEnumerable  range 
)
static

Calls AddIfUnique(IList, object) on the given range of objects.

Parameters
listList
rangeA range of objects to add to the list. Each object is only added if it isn't a duplicate of an existing element, as determined by object.Equals(object?).

◆ ConvertEach< TList, TOut, TIn >()

static TList VolumeControl.TypeExtensions.ListExtensions.ConvertEach< TList, TOut, TIn > ( this IEnumerable< TIn >  enumerable,
Func< TIn, TOut >  converter 
)
static

Converts each element in the given enumerable from type TIn to type TOut , and returns the converted objects as a new list of type TList .

Template Parameters
TListThe type of list to return.
TOutThe type to convert each item to.
TInThe type to convert each item from.
Parameters
enumerableAny type implementing IEnumerable<T>.
converterA converter method that accepts TIn and returns TOut .
Returns
The converted list of items.
Type Constraints
TList :IList 
TList :IEnumerable 
TList :IList<TOut> 
TList :IEnumerable<TOut> 
TList :ICollection 
TList :ICollection<TOut> 
TList :new() 

◆ ConvertEach< TOut, TIn >()

static IList<TOut> VolumeControl.TypeExtensions.ListExtensions.ConvertEach< TOut, TIn > ( this IEnumerable< TIn >  enumerable,
Func< TIn, TOut >  converter 
)
static

Converts each element in the given enumerable from type TIn to type TOut , and returns the converted objects as a new List<T>.

Template Parameters
TOutThe type to convert each item to.
TInThe type to convert each item from.
Parameters
enumerableAny type implementing IEnumerable<T>.
converterA converter method that accepts TIn and returns TOut .
Returns
The converted list of items.

◆ ForEach()

static IList VolumeControl.TypeExtensions.ListExtensions.ForEach ( this IList  list,
Action< object?>  action 
)
static
Returns
The resulting list ; this can safely be ignored when using this method outside of a pipeline.

◆ ForEach< T >()

static IList<T> VolumeControl.TypeExtensions.ListExtensions.ForEach< T > ( this IList< T >  list,
Action< T >  action 
)
static
Returns
The resulting list ; this can safely be ignored when using this method outside of a pipeline.

◆ IndexOf< T >()

static bool VolumeControl.TypeExtensions.ListExtensions.IndexOf< T > ( this IList< T >  list,
item,
out int  index 
)
static

Gets the index of the first occurrence of item in this list .

Template Parameters
TThe type of object in the IList<T>.
Parameters
list(implicit) The IList<T> to search.
itemThe object to locate in the IList<T>.
indexThe index of item if found in the list; otherwise -1.
Returns
true when item was found in the list; otherwise false.

◆ SelectiveUpdate< T >()

static void VolumeControl.TypeExtensions.ListExtensions.SelectiveUpdate< T > ( this List< T >  l,
IEnumerable< T >  other 
)
static

Similar to List<T>.AddRange(IEnumerable<T>), but designed for unique elements.
Removes elements from l that are not present in other .
Adds elements from other to l that aren't already present somewhere in the list.

Template Parameters
T
Parameters
lThe generic list on which to operate.
otherAny enumerable list of type T .

The documentation for this class was generated from the following file: