mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
|||
namespace Brutal.VulkanApi.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for IDisposable objects.
|
||||
/// </summary>
|
||||
public static class DisposableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes each element in the provided span.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of IDisposable objects.</typeparam>
|
||||
/// <param name="inObjects">The span of IDisposable objects to dispose.</param>
|
||||
public static void Dispose<T>(this Span<T> inObjects)
|
||||
where T : IDisposable
|
||||
{
|
||||
foreach (var obj in inObjects)
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes each element in the provided array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of IDisposable objects.</typeparam>
|
||||
/// <param name="inObjects">The array of IDisposable objects to dispose.</param>
|
||||
public static void Dispose<T>(this T[] inObjects)
|
||||
where T : IDisposable
|
||||
{
|
||||
foreach (var obj in inObjects)
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes each element in the provided enumerable collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of IDisposable objects.</typeparam>
|
||||
/// <param name="inObjects">The enumerable collection of IDisposable objects to dispose.</param>
|
||||
public static void Destroy<T>(this IEnumerable<T> inObjects)
|
||||
where T : IDisposable
|
||||
{
|
||||
using var enumerator = inObjects.GetEnumerator();
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
enumerator.Current.Dispose();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue