Dynamic (list-like) arrays in Delphi 
Author Message
 Dynamic (list-like) arrays in Delphi

Is there a mechanism for creating dynamic arrays  (vectors, linked-list,
etc) in Borland delphi 3 without implementing them from scratch?

I'm looking for an eqivalent of C++ STL's 'vector' and 'list' classes;
or Borland's (BIDS) TArrayAsXxxxx classes. If templates aren't possible,
perhaps something like the Java java.util.vector class?

When possible, please CC the reply to me by e-mail. Remove the .NOSPAM
from my e-mail address. Forgive me for the many crosspostings in this
thread.

--
May The Force be with you,
---
Sasmito Adibowo
http://www.*-*-*.com/



Mon, 17 Jul 2000 03:00:00 GMT  
 Dynamic (list-like) arrays in Delphi


says...

Quote:
> Is there a mechanism for creating dynamic arrays  (vectors, linked-list,
> etc) in Borland Delphi 3 without implementing them from scratch?

TList.

If that doesn't work because you're passing/getting to/from a DLL:

type
  TMyType = integer; { Or whatever }
  TMyArrayType = array[0..(High(Cardinal)-$f) div
SizeOf(TMyType)] of TMyType;
  PMyArrayType = ^TMyArrayType;

var
  p : PMyArrayType;
begin
  GetMem(p, NumOfItems * SizeOf(TMyType));
  {
    You can now access p with: p^[0] and upwards. In Delphi 2,
    you can even do p[0].

    Warning!
    If you access p^[I] and I >= NumOfItems, you will get
    unexpected results, most probably a GPF at some later time.
  }
  FreeMem(p, NumOfItems * SizeOf(TMyType));
end;

Thanx to Hallvard Vassbotn for additional input.

M.

--
Author of several unknown utilities for DOS and Windows.
http://www.delfidata.no/users/~martin



Mon, 17 Jul 2000 03:00:00 GMT  
 Dynamic (list-like) arrays in Delphi



]-Is there a mechanism for creating dynamic arrays  (vectors, linked-list,
]-etc) in Borland Delphi 3 without implementing them from scratch?
]-
]-I'm looking for an eqivalent of C++ STL's 'vector' and 'list' classes;
]-or Borland's (BIDS) TArrayAsXxxxx classes. If templates aren't possible,
]-perhaps something like the Java java.util.vector class?
]-
]-
]-When possible, please CC the reply to me by e-mail. Remove the .NOSPAM
]-from my e-mail address. Forgive me for the many crosspostings in this
]-thread.
]-

if a TList will not suit your need, you might try searching
for the (freeware) array classes by Peter Below (maybe at
Torry's Delphi Pages?)

Mark Vaughan



Tue, 18 Jul 2000 03:00:00 GMT  
 Dynamic (list-like) arrays in Delphi

I forget where, but there's an STL clone for Delphi called 'Spider
Components' which you might want to take a look at.

        Kult.



Tue, 18 Jul 2000 03:00:00 GMT  
 Dynamic (list-like) arrays in Delphi

On Thu, 29 Jan 1998 22:18:29 +0700, Sasmito Adibowo

Quote:

>Is there a mechanism for creating dynamic arrays  (vectors, linked-list,
>etc) in Borland Delphi 3 without implementing them from scratch?

>I'm looking for an eqivalent of C++ STL's 'vector' and 'list' classes;
>or Borland's (BIDS) TArrayAsXxxxx classes. If templates aren't possible,
>perhaps something like the Java java.util.vector class?

>When possible, please CC the reply to me by e-mail. Remove the .NOSPAM
>from my e-mail address. Forgive me for the many crosspostings in this
>thread.

>--
>May The Force be with you,
>---
>Sasmito Adibowo
>http://www.bitsmart.com/adib

Why wouldn't you just use the Tlist component?


Thu, 20 Jul 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Dynamic (list-like) arrays in Delphi

2. Delphi - Dynamic 2-dimensional arrays

3. Dynamic Link List - help pls!

4. dynamic array

5. Dynamic array in database

6. How to store dynamic array to memofield?

7. Dynamic Type array

8. Dynamic Array puzzle

9. How to declare dynamic array in fpc ??

10. dynamic arrays

11. Memory access; relative position (dynamic array)

12. Heap error while allocating dynamic array in protected.

 

 
Powered by phpBB® Forum Software