NanoByte.Common  2.6.1
NanoByte.Common.Collections.CollectionExtensions Class Reference

Provides extension methods for ICollection<T>s. More...

Static Public Member Functions

static bool AddIfNew< T > (this ICollection< T > collection, T element)
 Adds an element to the collection if it does not already ICollection<T>.Contains the element. More...
 
static void AddRange< TCollection, TElements > (this ICollection< TCollection > collection, IEnumerable< TElements > elements)
 Adds multiple elements to the collection. More...
 
static void RemoveRange< TCollection, TElements > (this ICollection< TCollection > collection, IEnumerable< TElements > elements)
 Removes multiple elements from the collection. More...
 
static bool RemoveAll< T > (this ICollection< T > collection, Func< T, bool > condition)
 Removes all items from a collection that match a specific condition . More...
 

Detailed Description

Provides extension methods for ICollection<T>s.

Member Function Documentation

◆ AddIfNew< T >()

static bool NanoByte.Common.Collections.CollectionExtensions.AddIfNew< T > ( this ICollection< T >  collection,
element 
)
inlinestatic

Adds an element to the collection if it does not already ICollection<T>.Contains the element.

Returns
true if the element was added to the collection; true if the collection already contained the element.

This makes it possible to use a ICollection<T> with semantics similar to a HashSet<T>.

◆ AddRange< TCollection, TElements >()

static void NanoByte.Common.Collections.CollectionExtensions.AddRange< TCollection, TElements > ( this ICollection< TCollection >  collection,
IEnumerable< TElements >  elements 
)
inlinestatic

Adds multiple elements to the collection.

See also
List<T>.AddRange
Type Constraints
TElements :TCollection 

◆ RemoveAll< T >()

static bool NanoByte.Common.Collections.CollectionExtensions.RemoveAll< T > ( this ICollection< T >  collection,
Func< T, bool >  condition 
)
inlinestatic

Removes all items from a collection that match a specific condition .

Returns
true if any elements where removed.
See also
List<T>.RemoveAll

◆ RemoveRange< TCollection, TElements >()

static void NanoByte.Common.Collections.CollectionExtensions.RemoveRange< TCollection, TElements > ( this ICollection< TCollection >  collection,
IEnumerable< TElements >  elements 
)
inlinestatic

Removes multiple elements from the collection.

See also
List<T>.RemoveRange
Type Constraints
TElements :TCollection 

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