Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!sdcsvax!ucsdhub!esosun!seismo!uunet!nuchat!sugar!peter From: peter@sugar.UUCP Newsgroups: comp.lang.misc,comp.lang.c Subject: Re: software ICs vs. libraries Message-ID: <932@sugar.UUCP> Date: Thu, 29-Oct-87 06:55:42 EST Article-I.D.: sugar.932 Posted: Thu Oct 29 06:55:42 1987 Date-Received: Sat, 31-Oct-87 20:27:39 EST References: <1691@culdev1.UUCP> Organization: Sugar Land UNIX - Houston, TX Lines: 62 Xref: utgpu comp.lang.misc:786 comp.lang.c:4966 In article <1691@culdev1.UUCP>, drw@culdev1.UUCP (Dale Worley) writes: > Another feature of "software ICs" comes from the fact that they are > part of an object-oriented system. One can actually write, say, a > linked list manager that will work on objects of *any* type. In most > languages, this is impossible to do in a library routine. You can do it in 'C'. In fact the standard 'C' library for the Amiga comes with exactly this tool. Insert(ListHead, ListNode, PredNode) - Insert a node in a list. AddHead(ListHead, ListNode) - Insert at the head of the list: Insert(ListHead, ListNode, NULL); AddTail(ListHead, ListNode) - Insert at the tail of the list: Insert(ListHead, ListNode, ListHead->lh_Tail); Remove(ListNode) - Removes it from whatever List it's in. RemHead(ListHead) - Removes and returns the head of a list. return_val = ListHead->lh_Head; Remove(return_val); return return_val; RemTail(ListHead) - Removes and returns the tail of a list. As Joe Isuzu says "well, you know..." Enqueue(ListHead, ListNode) - Adds it on a priority basis. RemHead will return the highpri node, RemTail the lowpri node. FIFO ordering if priorities match. FindName(ListHead, "Name") - Finds the first node matching Name. FindName(ListNode, "Name") - Finds the next node matching Name. This deals with objects called "nodes". But, of course, you can pass any struct to these functions so long as the first element of the struct is a list or a node. This is one place 'C' outshines more modern and more heavily typed languages like Modula. -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- Disclaimer: These U aren't mere opinions... these are *values*.