mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
TryPeek
This commit is contained in:
parent
168d47a865
commit
0a856c91ff
1 changed files with 10 additions and 1 deletions
|
@ -413,13 +413,22 @@ namespace System.Collections
|
|||
|
||||
/// 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
|
||||
public Result<T> Peek()
|
||||
public Result<T> TryPeek()
|
||||
{
|
||||
if (mSize == 0)
|
||||
return .Err;
|
||||
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'.
|
||||
public bool Contains(T item)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue