Re: [CODE] Introduction Snippet

From: Patrick Dughi (dughi@imaxx.net)
Date: 11/13/00


        I recommend using a hash array for lookup and modification of
players knowledge of eachother.  Look at the dynamic board 2.2 (?) code
for examples of how a board stores the uid and post number (and guarentees
that even if post numbers move, this will be valid) for each person that
reads a post.

        Once it's loaded into memory, the lookup time is probably
averaging around 4-5 (cause my algorithm sucked, and it clusters).
Technically, it could be closer to 1.

        Trees work too, but are probably harder for a newbie to
conceptually work out, and much more difficult to implement without
resorting to external libraries, or a step-by-step howto.  Of course, if
you've got a copy of CLR, you're all set.

        The mean case time for a linked list, tree, and hash search are
n/2, n lg n (i believe), and n/2.  Yes, a hash can be as bad as a linked
list.  big O cases are n/2, n lg n, 1 - I don't have clr here at work, so
I'm guessing, but i know best case of hash is '1'. :)

        That means it's good.


> char *name;
> there instead, strcmp can easily handle this and it would IMHO make the
> informative code more maintenance friendly.

        Maybe more friendly, but certainly noticably slower.  string
operations are much slower than their related integer operations.  Stick
to fast int lookups.
                                        PjD


     +------------------------------------------------------------+
     | 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