mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
feat: Added extension method for peeking queues
This commit is contained in:
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added extension method for peeking queues
|
||||||
|
|
||||||
## [9.3.0] - 2019-04-16
|
## [9.3.0] - 2019-04-16
|
||||||
### Added
|
### Added
|
||||||
- Added SPlusUtils with ConvertToInt method taking LowWord/HighWord ushorts
|
- Added SPlusUtils with ConvertToInt method taking LowWord/HighWord ushorts
|
||||||
|
|||||||
@@ -43,5 +43,26 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
item = extends.Dequeue();
|
item = extends.Dequeue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Peeks the next item in the queue. Returns false if the queue is empty.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="extends"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Peek<T>(this Queue<T> extends, out T item)
|
||||||
|
{
|
||||||
|
if (extends == null)
|
||||||
|
throw new ArgumentNullException("extends");
|
||||||
|
|
||||||
|
item = default(T);
|
||||||
|
|
||||||
|
if (extends.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
item = extends.Peek();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user