using Misaki.HighPerformance.LowLevel.Buffer; namespace Misaki.HighPerformance.LowLevel.Collections.Contracts; public unsafe interface IUnsafeCollection : IDisposable { /// /// Indicates whether the object has been created. Returns true if the object is created, otherwise false. /// bool IsCreated { get; } /// /// Removes all elements from the collection. The collection will be empty after this operation. /// void Clear(); /// /// Returns a pointer to an unmanaged memory location. This pointer can be used for low-level memory operations. /// /// The method returns a void pointer to the unsafe memory location. void* GetUnsafePtr(); } public interface IUnsafeCollection : IUnsafeCollection, IEnumerable where T : unmanaged { /// /// Gets the number of elements in a collection. The value is read-only. /// int Count { get; } /// /// Changes the size of a collection to the specified value. /// /// This is to adjust the element count of the collection, not the size of the underlying buffer in memory. /// Specifies the new size to which the collection should be adjusted. /// Specifies allocation options that may affect how memory is managed during the resize operation. void Resize(int newSize, AllocationOption option); } public interface IUnsafeHashCollection : IEnumerable, IDisposable where T : unmanaged { /// /// Indicates whether the object has been created. Returns true if the object is created, otherwise false. /// bool IsCreated { get; } /// /// Gets the number of elements in a collection. The value is read-only. /// int Count { get; } /// /// Removes all elements from the collection. The collection will be empty after this operation. /// void Clear(); /// /// Changes the size of a collection to the specified value. /// /// This is to adjust the element count of the collection, not the size of the underlying buffer in memory. /// Specifies the new size to which the collection should be adjusted. /// Specifies allocation options that may affect how memory is managed during the resize operation. void Resize(int newSize, AllocationOption option); } public interface IUnTypedCollection : IUnsafeCollection { /// /// The total size of the buffer in bytes. /// nuint Size { get; } ref T GetElementAt(nuint index) where T : unmanaged; }