"Lewis, Jason" wrote: > > I am working on a introduction code snip for Circle and need some opinions. > > First, Would a linked list be the best way to do this? > A linked list is one way to do it ande has its advantages and disadvantages. > struct have_met { > > int known; ^^^ Make this a long, since player IDs are also long. > struct have_met *next; > struct have_met *prev; Make sure you really need prev. This single entry will eat up a lot of RAM. > } > > kinda thing or is there a more memory efficient way? > Off the top of my head, I would probably use an array (not fixed length, but allocated and reallocated using CREATE and RECREATE as needed). Arrays are much more efficient for checking but less efficient to expand (realloc basically has to copy the entire array to a new area of memory). Each player will have an array of unsigned longs (each of which is 32 bits, and you can use each bit as a single boolean value representing weather or not the player has been introduced). The length of the array should start out as top_idnum/32 + 1 size then be increased as necessary. Saving this to the pfile is much more difficult, if you don't use ASCII pfiles then you will at least have to hack in something on the side to save this info to a separate file in an ascii format. Since the size of the array can grow almost indefinately (well, it can grow to 256 megs per player in its most space efficient format) it would be greatly inefficient to use a fixed-record sized file for this as the standard CircleMUD pfile is. If you need some code for this then reply back to the list and I'll be glad to help. Regards, Peter +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/11/01 PDT