Added every to ListExtensions

This commit is contained in:
Adam Ramberg 2019-04-07 17:57:57 +02:00
parent e976823647
commit 4b10374850
2 changed files with 12 additions and 2 deletions

View File

@ -137,7 +137,17 @@ namespace UnityAtoms.Extensions
public static bool Some<T>(this List<T> list, Func<T, bool> func)
{
return EqualityComparer<T>.Default.Equals(list.First(func), default(T));
return !EqualityComparer<T>.Default.Equals(list.First(func), default(T));
}
public static bool Every<T>(this List<T> list, Func<T, bool> func)
{
for (int i = 0; list != null && i < list.Count; ++i)
{
if (!func(list[i])) return false;
}
return true;
}
public static bool AddIfNotExists<T>(this List<T> list, T item)

View File

@ -20,4 +20,4 @@ namespace UnityAtoms.Extensions
return v2 + (distance.normalized * maxDistance);
}
}
}
}