Class CollectionUtil
Provides utility methods for working with collections, including capacity management and element merging.
Inherited Members
Namespace: TriLibExporter
Assembly: Assembly-CSharp.dll
Syntax
public static class CollectionUtil
Methods
EnsureCapacityAndClear<T>(Dictionary<T, int>, int)
Ensures the capacity of a Dictionary<TKey, TValue> and clears its elements.
Declaration
public static void EnsureCapacityAndClear<T>(Dictionary<T, int> dictionary, int capacity) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Dictionary<T, int> | dictionary | The dictionary to modify. |
int | capacity | The required capacity for the dictionary. |
Type Parameters
Name | Description |
---|---|
T | The type of keys in the Dictionary<TKey, TValue>. |
EnsureCapacityAndClear<T>(HashSet<T>, int)
Ensures the capacity of a HashSet<T> and clears its elements.
Declaration
public static void EnsureCapacityAndClear<T>(HashSet<T> hashSet, int capacity) where T : struct
Parameters
Type | Name | Description |
---|---|---|
HashSet<T> | hashSet | The hash set to modify. |
int | capacity | The required capacity for the hash set. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the HashSet<T>. |
EnsureCapacityAndClear<T>(List<T>, int)
Ensures the capacity of a List<T> and clears its elements.
Declaration
public static void EnsureCapacityAndClear<T>(List<T> list, int capacity) where T : struct
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list to modify. |
int | capacity | The required capacity for the list. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the List<T>. |
MergeElements<T>(T[], HashSet<int>, List<int>, Dictionary<T, int>)
Merges elements from an array into a dictionary, avoiding duplicates and creating a mapping of indices.
Declaration
public static int MergeElements<T>(T[] elements, HashSet<int> removeSet, List<int> indices, Dictionary<T, int> elementToIndex) where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | elements | The array of elements to process. |
HashSet<int> | removeSet | A set of indices to be removed. |
List<int> | indices | A list to store the resulting indices of elements. |
Dictionary<T, int> | elementToIndex | A dictionary mapping elements to their indices. |
Returns
Type | Description |
---|---|
int | The number of remaining elements after removal. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the array. |
RemoveByIndices<T>(T[], HashSet<int>)
Removes elements from an array based on specified indices.
Declaration
public static int RemoveByIndices<T>(T[] array, HashSet<int> removeSet) where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to process. |
HashSet<int> | removeSet | A set of indices to be removed. |
Returns
Type | Description |
---|---|
int | The number of remaining elements in the array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the array. |