title: How to implement a Enumerator that has IsFirst and IsLast functions?
body: <p>I am using Spring4D for all collections.</p>
  
  <p>Now there is a situation where I have to know whether the current value of the enumerator is the first (which is easy) or the last (which is hard) in the collection.</p>
  
  <pre><code>program Project1;
  
  {$APPTYPE CONSOLE}
  {$R *.res}
  
  uses
    System.SysUtils,
    Spring.Collections;
  
  var
    Enumerable: IEnumerable&lt;Integer&gt;;
    Enumerator: IEnumerator&lt;Integer&gt;;
  
  begin
    Enumerable := TEnumerable.Query&lt;Integer&gt;(TArray&lt;Integer&gt;.Create(1, 2, 3, 4, 5)
      ) as IEnumerable&lt;Integer&gt;;
    Enumerator := Enumerable.GetEnumerator;
    while Enumerator.MoveNext do
    begin
      WriteLn('Value = ', Enumerator.Current);
      WriteLn('First in collection? ', Enumerator.CurrentIsFirst);
      WriteLn('Last in collection? ', Enumerator.CurrentIsLast);
    end;
    ReadLn;
  
  end.
  </code></pre>
  
  <p><code>CurrentIsFirst</code> could be implemented using a local Boolean which is reset once the first value has passed.</p>
  
  <p>However I don't know an easy way to implement <code>CurrentIsLast</code>.</p>
  
  <p>It should be able to process lazy collections as they may contain too many values to fit into memory.</p>
  
  <p>How can I implement such a <code>CurrentIsLast</code> function?</p>