Currentl RTL Queue is dynamic growing, with initial capacity to 4.
Could we have a new constructor that allows user to specific a larger initial capacity at the very beginning? For example, I may want a queue with initial capacity of 1000, if I know the maximum number of items to be enqueued will never exceed 1000. This way, the multiple calls to Grow are saved, while the Queue can be effectively used as a nice circular buffer.
I know I can change the RTL source myself, but it would be good to have this new featue with the standard RTL
Queue<T> = public class(IEnumerable<T>)
private
fItems: array of T;
fTail: Integer := 0;
fHead: Integer := 0;
fCount: Integer := 0;
method Grow(aCapacity: Integer);
method IsEmpty: Boolean; inline;
method CalcCapacity(aNewCapacity: Integer): Integer;
method Init;
method GetNonGenericEnumerator: IEnumerator; implements IEnumerable.GetEnumerator;
method IsEqual(Item1: T; Item2: T): Boolean;
public
constructor;
method GetEnumerator: IEnumerator<T>;
method Contains(aItem: T): Boolean;
method Clear;
method Peek: T;
method Enqueue(aItem: T);
method Dequeue: T;
method ToArray: array of T;
property Count: Integer read fCount;
end;