Helper Scripts Collection 1.3.1
API documentation for the helper scripts compatible with Unity3D
Public Types | Static Public Member Functions | List of all members
NikosAssets.Helpers.CollectionHelper Class Reference

Helps with ICollections and List<T>s More...

Public Types

enum  ItemMatching { MatchNone = 0 , MatchAtLeastOne = 1 , MatchAll = 2 , MatchAllIncludingAmount = 3 }
 An enum for collection matching checks (CollectionHelper.CollectionsMatcher)
 

Static Public Member Functions

static bool CollectionsMatcher (ItemMatching matching, ICollection colA, ICollection colB)
 Checks if the given ICollection<T>s match based on the desired matching setup, with colA being the main collection to check (outer loop). More...
 
static bool CollectionsMatchAllItems (ICollection colA, ICollection colB)
 Checks if the given ICollection elements all match against each other More...
 
static List< T > ListOfOne< T > (T item)
 Create a list with only 1 (the given) element in it More...
 
static int PointerHandler (bool increment, int pointer, int lengthOfCollection)
 Increment or decrement (and cycle around) correctly respecting the length of a collection More...
 
static void LogCollection< T > (ICollection< T > collection)
 Iterates through the collection and calls ToString() on each item or logs "null" if item was null More...
 
static bool CollectionIsNullOrEmpty (ICollection collection)
 Checks if the given ICollection is null or empty More...
 
static bool CollectionAndIndexChecker (ICollection collection, int i, bool logError=false)
 Checks if the given index (i ) is in bounds of the given ICollection (collection ) More...
 
static T GetListItemAtIndex< T > (List< T > list, int i, bool logError=false)
 Doesn't throw any Exceptions if the list is null or empty and if the index is out of bounds More...
 
static T GetQueueItemAtIndex< T > (Queue< T > queue, int i, bool logError=false)
 Doesn't throw any Exceptions if the queue is null or empty and if the index is out of bounds More...
 

Detailed Description

Helps with ICollections and List<T>s

Member Function Documentation

◆ CollectionAndIndexChecker()

static bool NikosAssets.Helpers.CollectionHelper.CollectionAndIndexChecker ( ICollection  collection,
int  i,
bool  logError = false 
)
static

Checks if the given index (i ) is in bounds of the given ICollection (collection )

Parameters
collection
i
logErrorLog index out of bounds error?
Returns
true, if i is in collection

◆ CollectionIsNullOrEmpty()

static bool NikosAssets.Helpers.CollectionHelper.CollectionIsNullOrEmpty ( ICollection  collection)
static

Checks if the given ICollection is null or empty

Parameters
collection
Returns
true if collection is null or empty, otherwise false

◆ CollectionsMatchAllItems()

static bool NikosAssets.Helpers.CollectionHelper.CollectionsMatchAllItems ( ICollection  colA,
ICollection  colB 
)
static

Checks if the given ICollection elements all match against each other

Parameters
colA
colB
Returns
true if matched successfully, otherwise false

◆ CollectionsMatcher()

static bool NikosAssets.Helpers.CollectionHelper.CollectionsMatcher ( ItemMatching  matching,
ICollection  colA,
ICollection  colB 
)
static

Checks if the given ICollection<T>s match based on the desired matching setup, with colA being the main collection to check (outer loop).

Parameters
matching
colA
colB
Returns
true if matched successfully, otherwise false

◆ GetListItemAtIndex< T >()

static T NikosAssets.Helpers.CollectionHelper.GetListItemAtIndex< T > ( List< T >  list,
int  i,
bool  logError = false 
)
static

Doesn't throw any Exceptions if the list is null or empty and if the index is out of bounds

Parameters
list
i
logErrorShould we at least log the errors?
Template Parameters
T
Returns
default value if the list is null or empty

◆ GetQueueItemAtIndex< T >()

static T NikosAssets.Helpers.CollectionHelper.GetQueueItemAtIndex< T > ( Queue< T >  queue,
int  i,
bool  logError = false 
)
static

Doesn't throw any Exceptions if the queue is null or empty and if the index is out of bounds

Parameters
queue
i
logErrorShould we at least log the errors?
Template Parameters
T
Returns
default value if the queue is null or empty

◆ ListOfOne< T >()

static List< T > NikosAssets.Helpers.CollectionHelper.ListOfOne< T > ( item)
static

Create a list with only 1 (the given) element in it

Parameters
item
Template Parameters
T
Returns
A list with count = 1

◆ LogCollection< T >()

static void NikosAssets.Helpers.CollectionHelper.LogCollection< T > ( ICollection< T >  collection)
static

Iterates through the collection and calls ToString() on each item or logs "null" if item was null

Parameters
collection
Template Parameters
T

◆ PointerHandler()

static int NikosAssets.Helpers.CollectionHelper.PointerHandler ( bool  increment,
int  pointer,
int  lengthOfCollection 
)
static

Increment or decrement (and cycle around) correctly respecting the length of a collection

Parameters
incrementincrement, otherwise decrement
pointerthe current index to increase or decrease
lengthOfCollectionthe length to loop around
Returns

The correct index, potentially looped around

pointer = 2; lengthOfCollection = 3; increment = true; result = 0