| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | a linked list sort function |
On Sunday November 27 1994, Jon Guthrie writes to Ken Kavanagh: Hello Jon! JG> 25 Nov 94, Ken Kavanagh writes to Someone: >> can someone suggest a place to look for a sort function to be used to >> sort a already created linked list? JG> Bob Stout's SNIPPETS contains the code for a highly efficient generic JG> linked-list sort. where might I aquire this? JG> This is the relevant code. I've included the quick sort mostly to boost JG> my ego. The sortl that you're going to want to use is Ray Gardner's Merge JG> Sort. I can produce sample code if you need it, but it might take awhile JG> so I encourage you to try to use it without any. whew..I havent replied because I was looking at the code you provided. I must say that it is TOTALLY over my head! I stared at it..poked at it, stared at it some more..and basically I havent a clue what the parameters are..what I'm supposed to pass it and the whole thing makes me wanna shut the dam computer off. and here i was thinking I was making progress learning to program..what a brick wall! hehe I thank you very very very much for posting the code..but whew..I dont know what to do with it..I'll keep staring at it for a while longer..maybe in a few years I'll have learned enough to understand it! JG> void *sortl(void *list, void *(*getnext)(void *), JG> void (*setnext)(void *, void *), JG> int (*compare)(void *, void *)); if this was all from ?"snippets"?? then I'd love to get ahold of it and take a peekaboo. for what its worth..i have a double linked list (for no other purpose than to learn how they are made) which sorts as it builds and which I wanna allow the option to sort it under different criteria after all the data has been collected for the list. all I have for my list is: PNODEINFO NIstart; // pointer to start of info structure PNODEINFO NIlast; // pointer to end of info structure as I collect the data, it goes in: PNODEINFO node; // pointer to structure which when first initialized gets added with: static void dls_store_node(PNODEINFO i, PNODEINFO *start, PNODEINFO *last); i.e... dls_store_node(node, &NIstart, &NIlast); It took my awhile too, but I understand how that function does its majic pretty much :) but as follows...i dont know what to put in all the slots...sigh..thanks for helping me anyways! :) I'll keep trying to learn. JG> /* mergesort linked lists by Ray Gardner */ JG> /* split list into 2 parts, sort each recursively, merge */ JG> void *sortl(p, getnext, setnext, compare) JG> void *p, *(*getnext)(void *), (*setnext)(void *, void *); JG> int (*compare)(void *, void *); Cheers, Ken --- GoldED/2 2.42.G0614* Origin: Sound Stage BBS - Live Via Satellite - (604)944-6476 (1:153/7070) SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413 SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1 @PATH: 153/7070 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.