C++ and Linked Lists

From: Akuma/Chris Baggett/DOOMer (doomer@BAYOU.COM)
Date: 03/14/98


Ok, this is kinda CircleMUD related in that it has to do with
how clans are currently done (i know clans aren't in CircleMUD).

currently (the clan system I have I assume is some sort of snippet
because a previous coder installed it), the clans
are stored in a previously set array like so:

struct clan_info clan[MAX_CLANS+1];

well, I was thinking of instead of that, to just make it a class
and still access it like an array.
ie
class clan_info;
clan_info *clan;

and in the class have something like an operator []
clan_info* clan_info::operator[](int number) {
int i=0;
clan_info *cln;

for (i=0, cln=this; cln && i != number; i++, cln = cln->next_clan) ;
return (cln);
}

(i doubt the above would work but i hope the idea got through)
so I could do something like this.

clan[3].somekindainfo (or would it be clan[3]->somekindainfo?)
and access it that way? still like an array?
or would it be much less overhead
just to zip through the entire linked list once, find the clan
and return a pointer to it, and play with it from there?

thanks for any insight into this.

Code On
Akuma the Raging Coder

  +------------------------------------------------------------+
  | "The poets talk about love, but what I talk about is DOOM, |
  |      because in the end, DOOM is all that counts." -       |
  |   Alex Machine/George Stark/Stephen King, The Dark Half    |
  |        "Nothing is IMPOSSIBLE, Just IMPROBABLE"            |
  |   "Easier Said Than Done, But Better Done Than Said..."    |
  +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST