Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-12

Queue integer values

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reimar Grabowski

Hi all,

I need a queue that can store integer values. Is there any way to use TQueue for this task or does a generic queue class exist which I can use? If both answers are no what is my next best option?

R.

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

leledumbo
to Reimar Grabowski
I need a queue that can store integer values. Is there any way to use

TQueue for this task

You can extend TQueue to have a method to insert the integer as pointers. Ex:

type
  TMyQueue = class(TQueue)
  public
    procedure AddInt(const Integer: i);
  end;

... // implementation

procedure TMyQueue.AddInt(const Integer: i);
var
  p: PInteger;
begin
  New(p);
  p^:=i;
  Add(p);
end;

Just don't forget to Dispose all the contents before destroying the queue or you'll have memory leak.

or does a generic queue class exist which I can use?

AFAIR, no. Last time I check, only list and map have been implemented. But you can make your own, it's not difficult.

View this message in context: http://old.nabble.com/Queue-integer-values-tp26817366p26824766.html Sent from the Free Pascal - General mailing list .

Reply by email

Reimar Grabowski
to leledumbo
You can extend TQueue to have a method to insert the integer as pointers.

Thanks for the answer, but I already found a way of using TQueue directly to solve my problem.

R.

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email