/// <summary>Removes the first occurence of an item from the pool.</summary> /// <param name="item">The item to remove from the pool.</param> /// <returns><c>true</c> if <paramref name="item" /> was removed from the pool; otherwise, <c>false</c>.</returns> public bool Remove(T item) { var result = _items.Remove(item); if (result) { _ = _availableItems.Remove(item); } return(result); }
public static void RemoveTest() { var array = new UnmanagedArray <int>(3); array[0] = 1; array[1] = 2; array[2] = 3; using (var valueList = new UnmanagedValueList <int>(array, takeOwnership: true)) { Assert.That(() => valueList.Remove(1), Is.True ); Assert.That(() => valueList, Has.Property("Capacity").EqualTo((nuint)3) .And.Count.EqualTo((nuint)2) ); Assert.That(() => valueList[0], Is.EqualTo(2) ); Assert.That(() => valueList[1], Is.EqualTo(3) ); Assert.That(() => valueList.Remove(0), Is.False ); } using (var valueList = new UnmanagedValueList <int>()) { Assert.That(() => valueList.Remove(0), Is.False ); } }