Hi All,I need to know the current position is after the last element. The attached solution demonstrate what I want.
Is an internal solution exists for this task? I not found anything. Gabor
uses SysUtils, Generics.Collections; type TR=record i:Integer; end; TLEnumerator=class(specialize TCustomListEnumerator<TR>) private function GetAfterLast:Boolean; public property AfterLast:Boolean read GetAfterLast; end; TL=class(specialize TList<TR>) public function GetEnumerator:TLEnumerator; reintroduce; end; function TL.GetEnumerator:TLEnumerator; begin Result:=TLEnumerator.Create(Self); end; function TLEnumerator.GetAfterLast:Boolean; begin Result:=(FIndex>FList.Count-1); end; var R:TR; L:TL; E:TLEnumerator; begin L:=TL.Create; R.i:=28; L.Add(R); R.i:=32; L.Add(R); E:=L.GetEnumerator; WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F')); E.MoveNext; WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F')); E.MoveNext; WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F')); E.MoveNext; WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F')); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal