using Brutal.Memory;
namespace Brutal.Collections;
///
/// Base class for native-memory backed lists
///
public interface INativeList : ISpanLike, IDisposable
{
public ElementCount Count { get; set; }
public ElementCount Capacity { get; set; }
///
/// Matching C# List's Clear(), zeroes count but preserves capacity
///
public void Clear();
///
/// Set the capacity to the actual number of elements in the list, if the current
///
public void TrimExcess();
///
/// Increase the capacity of the vector (the total number of elements that the vector can hold without requiring
/// reallocation) to a value that's greater or equal to newCapacity. If new_cap is greater than the current
/// Capacity, new storage is then allocated; otherwise the function does nothing.
///
/// The new max size
public void EnsureCapacity(ElementCount capacity);
///
/// Reset the array and free memory
///
public void Free();
}
public interface INativeList : INativeList, ISpanLike, IEnumerable
where T : unmanaged
{
///
/// Get or set an element at an index
///
public ref T this[Index index] { get; }
///
/// Add an element to the end of the list
///
/// The item to add
public void Add(T item);
///
/// Add a range of elements to the end of the list
///
/// The items to add
public void AddRange(ReadOnlySpan items);
///
/// Insert an element at an index, shifting all later elements up by one
///
/// The index to insert at
/// The item to insert
public void Insert(ElementCount index, T item);
///
/// Remove an element at an index, shifting all later elements down by one
///
/// The index to remove at
public void RemoveAt(ElementCount index);
}