Example #1
0
 public static T Oldest <T>(this ISequenceView <T> sequence)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     return(sequence.IsStack
                                 ? sequence.Poke()
                                 : sequence.Peek());
 }
Example #2
0
 public static T TryPeek <T>(this ISequenceView <T> sequence, T returnIfEmpty)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     return(sequence.Count == 0
                                 ? returnIfEmpty
                                 : sequence.Peek());
 }
Example #3
0
 public static bool TryPeek <T>(this ISequenceView <T> sequence, out T next)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     if (sequence.Count == 0)
     {
         next = default;
         return(false);
     }
     next = sequence.Peek();
     return(true);
 }
Example #4
0
 public static bool TryOldest <T>(this ISequenceView <T> sequence, out T oldest)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     if (sequence.Count == 0)
     {
         oldest = default;
         return(false);
     }
     oldest = sequence.IsStack
                                 ? sequence.Poke()
                                 : sequence.Peek();
     return(true);
 }