MUD-Dev
mailing list archive
[ Other Periods
| Other mailing lists
| Search
]
Date:
[ Previous
| Next
]
Thread:
[ Previous
| Next
]
Index:
[ Author
| Date
| Thread
]
Command Parsers, continued
As mentioned in my previous post, I am using unique namespaces to refer
to both hard and softcoded functions. The namespaces take the form of a
case insensitive string of length ~7 characters, at most. (they can be
longer, but internal functionality discourages it. Now, on to searching
through the db for functions (and anything else named, for that matter,
which means virtually everything in the entire db.)
Let me introduce the alphatree.
class alphatree{ // perhaps templatize the class?
protected:
named * member;
public:
virtual named * search(mudstring &name);
virtual void addmember(named * member, mudstring &name);
virtual void remmember(mudstring &name);
};
class ATleaf: public alphatree{
public:
named * search(mudstring &name){
if(member.check(name))
return member;
else
return NULL;
}
void addmember(named * member, mudstring &name);
void remmember(mudstring &name);
};
class ATmononode: public alphatree{
alphatree *branch;
char name;
public:
. . .
};
class ATbinode: public alphatree{
alphatree *branch[2];
char name[2];
public:
. . .
};
class ATtrinode. . . . class AThexnode
class ATfull: public alphatree{
alphatree *branch[36];
public:
. . .
};
For the fullnode, the 36 branches are direct linked to the coresponding
characters by an enumeration switch. Its a lot faster than any other
library tree I've found, and saves memory over most of them for large
namespaces ( > 4000 names ) I think I'm losing a bit on the smaller lists,
but what the hell... its adaptable. That's important. If anyone knows a
better way to do this, let me know.
__ _ __ _ _ , , , ,
/_ / / ) /_ /_) / ) /| /| / /\ First Light of a Nova Dawn
/ / / \ /_ /_) / \ /-|/ |/ /_/ Final Night of a World Gone
Nathan F. Yospe - University of Hawaii Dept of Physics - yospe#hawaii,edu
- Thread context:
- Re: Its nice to be back, (continued)
- MUD Design Digest V1 #56,
coder coder#ibm,net, Wed 18 Dec 1996, 03:42 GMT
- Re: Call for Opinions: MIGE,
Chris Lawrence clawrenc#xsvr1,cup.hp.com, Wed 27 Nov 1996, 17:18 GMT
- Command Parsers, continued,
Nathan Yospe yospe#hawaii,edu, Mon 25 Nov 1996, 01:28 GMT
- Command Parsing,
Nathan Yospe yospe#hawaii,edu, Sun 24 Nov 1996, 23:06 GMT
- <Possible follow-up(s)>
- command parsing,
Chris Gray cg#ami-cg,GraySage.Edmonton.AB.CA, Thu 13 Mar 1997, 15:00 GMT
- Re: command parsing,
Adam Wiggins nightfall#inficad,com, Thu 13 Mar 1997, 16:22 GMT
- command parsing,
claw claw#null,net, Tue 18 Mar 1997, 02:08 GMT
[ Other Periods
| Other mailing lists
| Search
]