Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!helios!n025fc From: n025fc@tamuts.tamu.edu (Kevin Weller) Newsgroups: comp.lang.c Subject: Re: Genralizing Pointer Routines Message-ID: Date: 12 Dec 90 19:10:48 GMT References: <1990Dec12.002520.25210@doe.utoronto.ca> Sender: news@helios.TAMU.EDU Organization: Texas A&M University, Computer Science Department Lines: 41 In-reply-to: david@doe.utoronto.ca's message of 12 Dec 90 00:25:20 GMT In article <1990Dec12.002520.25210@doe.utoronto.ca> david@doe.utoronto.ca (David Megginson) writes: One trick which I know is to define a generic structure or two to get at linked-list pointers. For example, struct list1 { struct list1 * next; }; struct list2 { struct list2 * next; struct list2 * prev; }; Now, you can write functions to deal with any arbitrary linked list of structures, as long as the links are always the first element of the structures. .... David Megginson That's the way I do it. A whole subsection of my own C library is devoted to this (when it's "done," I hope to release this library as freeware, ISAM manager and all). I was assigned to write two programs in Pascal class, both doing the same thing, but one with an array and the other with a linked list. I wanted to write two sets of low-level procedures to handle the two different data structure types, then just plug in the right set of routines into one high-level program like I would do in C. Hah! I had to introduce one kludge after another due to Pascal's data typing rules until the low-level stuff was no longer very general. C, by comparison, has so many features supporting procedural abstraction that Pascal lacks, and I guess I've been spoiled. -- Kevin L. Weller /-------+--------------------\ internet: n025fc@tamuts.tamu.edu | aTm | GIG 'EM, AGGIES! | CIS: 73327,1447 \-------+--------------------/