UnityEssentials
Small but useful tools and features for Unity
Static Public Member Functions | Static Private Member Functions | List of all members
UnityEngine.IEnumerableExtensions Class Reference

Extensions for IEnumerable More...

Collaboration diagram for UnityEngine.IEnumerableExtensions:
Collaboration graph

Static Public Member Functions

static IEnumerable< T > CloneAll< T > (this IEnumerable< T > enumerable)
 Creates a new enumerable with all the elements of the original one cloned in it. More...
 
static void DebugLog< T > (this IEnumerable< T > enumerable, string separator=", ", string message="", Object context=null)
 Creates a 'Debug.Log' message with all the contents in the enumerable. More...
 
static void DebugLogWarning< T > (this IEnumerable< T > enumerable, string separator=", ", string message="", Object context=null)
 Creates a 'Debug.LogWarning' message with all the contents in the enumerable. More...
 
static void DebugLogError< T > (this IEnumerable< T > enumerable, string separator=", ", string message="", Object context=null)
 Creates a 'Debug.LogError' message with all the contents in the enumerable. More...
 
static string ToStringAllElements< T > (this IEnumerable< T > enumerable, string separator=", ")
 Get an string of all elements. More...
 
static IEnumerable< T > GetShuffled< T > (this IEnumerable< T > enumerable)
 Shuffles the enumerable using the Fisher-Yates-Durstenfeld method. More...
 
static T GetRandomElement< T > (this IEnumerable< T > enumerable)
 Return a random element. More...
 
static T GetRandomElement< T > (this IEnumerable< T > enumerable, System.Random rnd)
 Return a random element. More...
 
static HashSet< T > ToHashSet< T > (this IEnumerable< T > source, IEqualityComparer< T > comparer=null)
 Copies the elements to a new HashSet. More...
 
static bool IsNullOrEmpty< T > (this IEnumerable< T > source)
 Indicates whether the IEnumerable is null or does not contain any element. More...
 

Static Private Member Functions

static IEnumerable< T > GetShuffled< T > (this IEnumerable< T > source, System.Random rnd)
 Shuffles the enumerable using the Fisher-Yates-Durstenfeld method. More...
 

Detailed Description

Extensions for IEnumerable

Definition at line 11 of file IEnumerableExtensions.cs.

Member Function Documentation

◆ CloneAll< T >()

static IEnumerable<T> UnityEngine.IEnumerableExtensions.CloneAll< T > ( this IEnumerable< T >  enumerable)
static

Creates a new enumerable with all the elements of the original one cloned in it.

Returns
A new IEnumerable with all elements of the original enumerable cloned in it.
Type Constraints
T :ICloneable 

Definition at line 17 of file IEnumerableExtensions.cs.

◆ DebugLog< T >()

static void UnityEngine.IEnumerableExtensions.DebugLog< T > ( this IEnumerable< T >  enumerable,
string  separator = ", ",
string  message = "",
Object  context = null 
)
static

Creates a 'Debug.Log' message with all the contents in the enumerable.

Parameters
separatorThe string that will be in-between each string of each element (the default is ', ').
messageThe message that will be displayed at the beginning of the 'Debug.Log' message.
contextObject to which the message applies.

Definition at line 28 of file IEnumerableExtensions.cs.

◆ DebugLogError< T >()

static void UnityEngine.IEnumerableExtensions.DebugLogError< T > ( this IEnumerable< T >  enumerable,
string  separator = ", ",
string  message = "",
Object  context = null 
)
static

Creates a 'Debug.LogError' message with all the contents in the enumerable.

Parameters
separatorThe string that will be in-between each string of each element (the default is ', ').
messageThe message that will be displayed at the beginning of the 'Debug.Log' message.
contextObject to which the message applies.

Definition at line 50 of file IEnumerableExtensions.cs.

◆ DebugLogWarning< T >()

static void UnityEngine.IEnumerableExtensions.DebugLogWarning< T > ( this IEnumerable< T >  enumerable,
string  separator = ", ",
string  message = "",
Object  context = null 
)
static

Creates a 'Debug.LogWarning' message with all the contents in the enumerable.

Parameters
separatorThe string that will be in-between each string of each element (the default is ', ').
messageThe message that will be displayed at the beginning of the 'Debug.Log' message.
contextObject to which the message applies.

Definition at line 39 of file IEnumerableExtensions.cs.

◆ GetRandomElement< T >() [1/2]

static T UnityEngine.IEnumerableExtensions.GetRandomElement< T > ( this IEnumerable< T >  enumerable)
static

Return a random element.

Returns
A random element.

Definition at line 95 of file IEnumerableExtensions.cs.

◆ GetRandomElement< T >() [2/2]

static T UnityEngine.IEnumerableExtensions.GetRandomElement< T > ( this IEnumerable< T >  enumerable,
System.Random  rnd 
)
static

Return a random element.

Parameters
rndPseudo random number generator to be used.
Returns
A random element.

Definition at line 105 of file IEnumerableExtensions.cs.

◆ GetShuffled< T >() [1/2]

static IEnumerable<T> UnityEngine.IEnumerableExtensions.GetShuffled< T > ( this IEnumerable< T >  enumerable)
static

Shuffles the enumerable using the Fisher-Yates-Durstenfeld method.

Returns
A new enumerable with all the elements in the original shuffled.

Definition at line 69 of file IEnumerableExtensions.cs.

◆ GetShuffled< T >() [2/2]

static IEnumerable<T> UnityEngine.IEnumerableExtensions.GetShuffled< T > ( this IEnumerable< T >  source,
System.Random  rnd 
)
staticprivate

Shuffles the enumerable using the Fisher-Yates-Durstenfeld method.

Parameters
rndPseudo random number generator to be used.
Returns
A new enumerable with all the elements in the original shuffled.

Definition at line 79 of file IEnumerableExtensions.cs.

◆ IsNullOrEmpty< T >()

static bool UnityEngine.IEnumerableExtensions.IsNullOrEmpty< T > ( this IEnumerable< T >  source)
static

Indicates whether the IEnumerable is null or does not contain any element.

Returns
True if the value IEnumerable is null or does not contain any element. Otherwise, false.

Definition at line 125 of file IEnumerableExtensions.cs.

◆ ToHashSet< T >()

static HashSet<T> UnityEngine.IEnumerableExtensions.ToHashSet< T > ( this IEnumerable< T >  source,
IEqualityComparer< T >  comparer = null 
)
static

Copies the elements to a new HashSet.

Parameters
comparerThe IEqualityComparer<T> implementation to use when comparing values in the set, or null to use the default EqualityComparer<T> implementation for the set type.
Returns
A new HashSet with all the elements in the collection.

Definition at line 116 of file IEnumerableExtensions.cs.

◆ ToStringAllElements< T >()

static string UnityEngine.IEnumerableExtensions.ToStringAllElements< T > ( this IEnumerable< T >  enumerable,
string  separator = ", " 
)
static

Get an string of all elements.

Parameters
separatorThe string that will be in-between each string of each element (the default is ', ').
Returns
The result of all elements .ToString() concatenated separated by a separator string.

Definition at line 60 of file IEnumerableExtensions.cs.


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