1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00
This commit is contained in:
Brian Fiete 2022-02-22 07:16:56 -08:00
parent 168d47a865
commit 0a856c91ff

View file

@ -413,12 +413,21 @@ namespace System.Collections
/// Returns the object at the head of the queue. The object remains in the /// Returns the object at the head of the queue. The object remains in the
/// queue. If the queue is empty, this method returns an error /// queue. If the queue is empty, this method returns an error
public Result<T> Peek() public Result<T> TryPeek()
{ {
if (mSize == 0) if (mSize == 0)
return .Err; return .Err;
return .Ok(mItems[mHead]); return .Ok(mItems[mHead]);
} }
/// Returns the object at the head of the queue. The object remains in the
/// queue. If the queue is empty, this method fails
public T Peek()
{
if (mSize == 0)
Runtime.FatalError("Queue empty");
return mItems[mHead];
}
/// Returns true if the queue contains at least one object equal to 'item'. /// Returns true if the queue contains at least one object equal to 'item'.
public bool Contains(T item) public bool Contains(T item)