Anvil
Anvil.API.CollectionExtensions Class Reference

Various class extensions for generic collections. More...

Static Public Member Functions

static void AddElement< TKey, TValue, TCollection > (this IDictionary< TKey, TCollection > mutableLookup, TKey key, TValue value)
 Adds an element to a mutable lookup table
(E.g. Dictionary<Key,List<Value>>) More...
 
static void AddRange< T > (this IList< T > list, IEnumerable< T > values)
 Adds a range of values to the specified IList. More...
 
static bool ContainsElement< TKey, TValue, TCollection > (this IDictionary< TKey, TCollection > mutableLookup, TKey key, TValue value)
 Queries if a certain value exists in a mutable lookup table
(E.g. Dictionary<Key,List<Value>>) More...
 
static void DisposeAll (this IEnumerable< IDisposable?>? disposables)
 
static int InsertOrdered< T > (this List< T > sortedList, T item, IComparer< T >? comparer=null)
 Inserts an item into an already sorted list. More...
 
static bool RemoveElement< TKey, TValue, TCollection > (this IDictionary< TKey, TCollection > mutableLookup, TKey key, TValue value)
 Removes an element from a mutable lookup table
(E.g. Dictionary<Key,List<Value>>) More...
 
static ? TValue SafeGet< TKey, TValue > (this IDictionary< TKey, TValue > dictionary, TKey key)
 
static IEnumerable< T > SafeYield< T > (this T? item)
 Wraps this object instance into an IEnumerable<T> consisting of a single item.
If the item is null, returns an empty enumerable instead. More...
 
static IEnumerable< T > Yield< T > (this T item)
 Wraps this object instance into an IEnumerable<T> consisting of a single item. More...
 

Detailed Description

Various class extensions for generic collections.

Member Function Documentation

◆ AddElement< TKey, TValue, TCollection >()

static void Anvil.API.CollectionExtensions.AddElement< TKey, TValue, TCollection > ( this IDictionary< TKey, TCollection >  mutableLookup,
TKey  key,
TValue  value 
)
inlinestatic

Adds an element to a mutable lookup table
(E.g. Dictionary<Key,List<Value>>)

Parameters
mutableLookupThe lookup to modify.
keyThe key that the element should be added to.
valueThe value that should be added.
Type Constraints
TCollection :ICollection<TValue> 
TCollection :new() 

◆ AddRange< T >()

static void Anvil.API.CollectionExtensions.AddRange< T > ( this IList< T >  list,
IEnumerable< T >  values 
)
inlinestatic

Adds a range of values to the specified IList.

Parameters
listThe list to update.
valuesThe elements to add to the list.
Template Parameters
TThe list element type.

◆ ContainsElement< TKey, TValue, TCollection >()

static bool Anvil.API.CollectionExtensions.ContainsElement< TKey, TValue, TCollection > ( this IDictionary< TKey, TCollection >  mutableLookup,
TKey  key,
TValue  value 
)
inlinestatic

Queries if a certain value exists in a mutable lookup table
(E.g. Dictionary<Key,List<Value>>)

Parameters
mutableLookupThe lookup to query.
keyThe key to lookup.
valueThe value to be searched.
Type Constraints
TCollection :ICollection<TValue> 

◆ InsertOrdered< T >()

static int Anvil.API.CollectionExtensions.InsertOrdered< T > ( this List< T >  sortedList,
item,
IComparer< T >?  comparer = null 
)
inlinestatic

Inserts an item into an already sorted list.

Parameters
sortedListThe sorted list.
itemThe item to insert.
comparerA custom comparer to use when comparing the item against elements in the collection.
Template Parameters
TThe type of item to insert.

◆ RemoveElement< TKey, TValue, TCollection >()

static bool Anvil.API.CollectionExtensions.RemoveElement< TKey, TValue, TCollection > ( this IDictionary< TKey, TCollection >  mutableLookup,
TKey  key,
TValue  value 
)
inlinestatic

Removes an element from a mutable lookup table
(E.g. Dictionary<Key,List<Value>>)

Parameters
mutableLookupThe lookup to modify.
keyThe key that the element should be removed from.
valueThe value that should be removed.
Type Constraints
TCollection :ICollection<TValue> 
TCollection :new() 

◆ SafeYield< T >()

static IEnumerable<T> Anvil.API.CollectionExtensions.SafeYield< T > ( this T?  item)
inlinestatic

Wraps this object instance into an IEnumerable<T> consisting of a single item.
If the item is null, returns an empty enumerable instead.

Template Parameters
TType of the object.
Parameters
itemThe instance that will be wrapped.
Returns
An IEnumerable<T> consisting of a single item.

◆ Yield< T >()

static IEnumerable<T> Anvil.API.CollectionExtensions.Yield< T > ( this T  item)
inlinestatic

Wraps this object instance into an IEnumerable<T> consisting of a single item.

Template Parameters
TType of the object.
Parameters
itemThe instance that will be wrapped.
Returns
An IEnumerable<T> consisting of a single item.

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