public static T Oldest <T>(this ISequenceView <T> sequence) { if (sequence == null) { throw new ArgumentNullException(nameof(sequence)); } return(sequence.IsStack ? sequence.Poke() : sequence.Peek()); }
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()); }
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); }
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); }