using System.Collections.Generic;
namespace GameKit.Dependencies.Utilities
{
public static class HashSetsFN
{
///
/// Adds a collection of items.
///
public static void AddRange(this HashSet hashSet, IEnumerable items)
{
foreach (T item in items)
hashSet.Add(item);
}
///
/// Returns values as a list.
///
///
public static List ToList(this HashSet collection, bool useCache)
{
List result = useCache ? CollectionCaches.RetrieveList() : new(collection.Count);
//No need to clear the list since it's already clear.
collection.ToList(ref result, clearLst: false);
return result;
}
///
/// Adds values to a list.
///
///
public static void ToList(this HashSet collection, ref List lst, bool clearLst)
{
if (clearLst)
lst.Clear();
foreach (T item in collection)
lst.Add(item);
}
}
}