lcontainers.inc 876 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. constructor TLFront.Create(const DefaultItem: __front_type__);
  2. begin
  3. FEmptyItem:=DefaultItem;
  4. Clear;
  5. end;
  6. function TLFront.GetEmpty: Boolean;
  7. begin
  8. Result:=FCount = 0;
  9. end;
  10. function TLFront.First: __front_type__;
  11. begin
  12. Result:=FEmptyItem;
  13. if FCount > 0 then
  14. Result:=FItems[FBottom];
  15. end;
  16. function TLFront.Remove: __front_type__;
  17. begin
  18. Result:=FEmptyItem;
  19. if FCount > 0 then begin
  20. Result:=FItems[FBottom];
  21. Dec(FCount);
  22. Inc(FBottom);
  23. if FBottom >= MAX_FRONT_ITEMS then
  24. FBottom:=0;
  25. end;
  26. end;
  27. function TLFront.Insert(const Value: __front_type__): Boolean;
  28. begin
  29. Result:=False;
  30. if FCount < MAX_FRONT_ITEMS then begin
  31. if FTop >= MAX_FRONT_ITEMS then
  32. FTop:=0;
  33. FItems[FTop]:=Value;
  34. Inc(FCount);
  35. Inc(FTop);
  36. Result:=True;
  37. end;
  38. end;
  39. procedure TLFront.Clear;
  40. begin
  41. FCount:=0;
  42. FBottom:=0;
  43. FTop:=0;
  44. end;