Exemple #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());
 }
Exemple #2
0
 public static T TryPoke <T>(this ISequenceView <T> sequence, T returnIfEmpty)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     return(sequence.Count == 0
                                 ? returnIfEmpty
                                 : sequence.Poke());
 }
Exemple #3
0
 public static bool TryPoke <T>(this ISequenceView <T> sequence, out T last)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException(nameof(sequence));
     }
     if (sequence.Count == 0)
     {
         last = default;
         return(false);
     }
     last = sequence.Poke();
     return(true);
 }
Exemple #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);
 }