No, you can't give them a fixed length without adding extra code. What a
linked list is, is a structure with a pointer to a differenty structure of
the same kind. So when you hit 21, you just unlink the first one, and strap
the new one onto the end. Like, after adding a new history log, remove the
first one, add the new one to the last spot (Make sure to have a variable
for last and first spot.) Now remember, if its less than 20, just keep
strapping it onto the end, no need to unlink the first one. And make sure to
free all that stuff, so you don't get leaks.
Davion
From: Robin Björklund <[EMAIL PROTECTED]>
To: <[email protected]>
Subject: storage fixed linked list
Date: Thu, 7 Aug 2003 16:37:03 +0200
Greetings,
I'm currently trying to code something that'll store the last 20
tells/gossips/whatever more channel we want.
This history should be viewable through a command let's call it history.
Syntax would be: history <channel>
Anyway I first did this with arrays but I was told that it consumed lots of
memory I was also told to take a
look at linked lists. I've been taking a look at them for the last 3 hours.
Though, linked lists doesn't have a
size it seems, they keep growing, what would I do to make them just list
the
*last* 20 tells or last 20
gossips. Would I remove the first node once I hit 21 nodes? Would I list
the
last 20 nodes? wouldn't that
list be huge if I don't remove a node once I hit 21. Is there anyway to
give
a linked list a fixed size? Or
am I just dreaming...
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail