Re: recursion on dynamic array of pointers

[ DelphiLand FAQ ]

Posted by Bart on April 29, 2004 at 17:25:36:

In Reply to: recursion posted by Slayerspike on April 29, 2004 at 05:27:35:

: Im dealing with pointers and using a linked list off them. How do i use recursion on a dynamic array of pointers to search the queue and show back if a name is in the queue. any working code or ideas would be apreciated. thanx

Try this:

function InList(FirstPointer : Pointer; SearchedName : string) : boolean;
IF (Pointer^.Name == SearchedName)
THEN Result := true
ELSE IF Pointer^.Pointer nil
THEN Result := false
ELSE InList(Pointer^.Pointer, SearchedName);

//In this function Pointer^.Pointer is the pointer which points to the next item in the list and SearchedName is the string you would like to find.

Related Articles and Replies:

[ DelphiLand FAQ ]