Newsgroups: comp.sys.mac.programmer Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!linus!linus!laf@mitre.org From: laf@mitre.org (Lee Fyock) Subject: Re: How to best do a linked list on Mac Message-ID: <1991Jun13.181159.23906@linus.mitre.org> Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: asgard.mitre.org Organization: The MITRE Corporation References: <1991Jun10.002416.5656@gn.ecn.purdue.edu> <14026@goofy.Apple.COM> Date: Thu, 13 Jun 1991 18:11:59 GMT In article <14026@goofy.Apple.COM>, casseres@apple.com (David Casseres) writes: > > In article , > francis@zaphod.uchicago.edu (Francis Stracke) writes: > > > My favorite solution is to declare an array type, then allocate a > > handle to such an array, and resize it dynamically. > > > > That way you can do it with only one handle (though you may want to > > have an array of handles, if your records are large), and you can > > index into the array rather than searching the list. > > This works fine but it isn't a linked list -- it's a dynamically sized > array. It's good as long as all you will do is add elements at the end > or remove them from the end, but it doesn't allow you to add elements > in the middle, or remove them from the middle and reclaim their storage > space. For adding or deleting elements from the middel of an array that has been allocated as a handle, use Munger! For example, given that filesH is a handle to an array of handles and fileIndex is the index (into the array) of the handle you want to delete from the array, errLong = Munger(filesH, fileIndex * sizeof(Handle), NULL, (long) sizeof(char **), 1L, NULL); will delete the fileIndex'th (:-) handle from the array. Munger is documented in IM I, pages 468-470. Lee Fyock laf@mitre.org