Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Other

Other Cant find a category above, use this one! Core mods not listed above go here!

Reply
 
Thread Tools Display Modes
Old 05-30-2006, 11:39 AM   #1 (permalink)
Forum Novice
 
Join Date: Oct 2003
Location: Vienna, Austria
Age: 22
Posts: 127
Send a message via ICQ to Arahil
Default using an entity's serial as hashcode

while writing an essay about hash-functions for school i stumbled over some text about hashtables in the wikipedia, and it says:
Quote:
The generally impossible/impractical ideal for a hash table's hash function is to map each key to a unique index (see perfect hashing), because this guarantees access to each data record in the first probe into the table.
but since runuo's entities (mobiles & items) use the serial as a unique identifier already, wouldn't using the serial as create such a 'perfect hashtable' and maybe speed up runuo a little bit?

just like
Code:
public override int GetHashCode() {
    return (int)this.m_Serial;
}
in both mobile.cs and item.cs.

so, what do you think?
Arahil is offline   Reply With Quote
Old 05-30-2006, 01:45 PM   #2 (permalink)
Forum Expert
 
Join Date: Dec 2005
Posts: 465
Default

That already is in there... and that is how it works I believe..

However, hashtables are slower to access than arraylists.
snicker7 is offline   Reply With Quote
Old 05-31-2006, 09:41 AM   #3 (permalink)
Forum Novice
 
Join Date: Oct 2003
Location: Vienna, Austria
Age: 22
Posts: 127
Send a message via ICQ to Arahil
Default

ah, never mind...
just noticed i was thinking in a totally wrong direction...
Arahil is offline   Reply With Quote
Old 05-31-2006, 02:21 PM   #4 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Mobile.Serial would bea HORRIBLE hashcode, since numbers are used again, it would create conflict.

If you wanted to use information from a user's hd ( like the serial of the hd or something like that ) then it ( would require a client to do this ) then you could create a true unique identification number.
Phantom is offline   Reply With Quote
Old 05-31-2006, 02:47 PM   #5 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 28
Posts: 4,886
Default

Quote:
Originally Posted by snicker7
However, hashtables are slower to access than arraylists.
Pure comedy, who told u that?
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 05-31-2006, 05:03 PM   #6 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by Sorious
Pure comedy, who told u that?
He might be talking about an unsorted hashtable, but even then just because of the nature of a hashtable and how it works, your able to get to a given key's value faster then a given element.

Thats at least what I have noticed...
Phantom is offline   Reply With Quote
Old 05-31-2006, 05:57 PM   #7 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

Quote:
Originally Posted by Phantom
Mobile.Serial would bea HORRIBLE hashcode, since numbers are used again, it would create conflict.

If you wanted to use information from a user's hd ( like the serial of the hd or something like that ) then it ( would require a client to do this ) then you could create a true unique identification number.
wt??

serials are unique. thats the best way of doing that.

but you dont need to override hashcode method in Mobile class unless you use Mobiles as the key values.
noobie is offline   Reply With Quote
Old 05-31-2006, 06:02 PM   #8 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

Quote:
Originally Posted by Phantom
He might be talking about an unsorted hashtable, but even then just because of the nature of a hashtable and how it works, your able to get to a given key's value faster then a given element.

Thats at least what I have noticed...
un/sorted hashtable?? that must be new! lol

for a specific index, arraylists are faster. (but still both O(1))
but if you are looking for a value (search) hashtables are faster. O(1) vs O(N)
noobie is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5