• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

What is Hashtable?

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
A hashtable is WC3's support for a type of data structure that supports any arbitary value or values as indexes to store data to.

This is like the dictonary structure in pythong but think of it as a nested dictionary.

The mechanics are that of a series of nested arrays using algerthims to get indexes which is useful due to its large range and due to its near O(1) speed compaired to simlar methods.
I would imagine they use 4 array like levels. Array level 1 is the general hashmap with efficency of O(1) for the parent key. This links to a linked list with O(n) where n is the number of hash collisions (mostly 1 unless highly populated) efficency which then links to a child hashmap. The child hashmap is the same as the parent but leading to the value and such at the end. This might not be the exact way it is done as they might use 2 hashtables were the parent one returns an additional value which combined with the child hash is used in the child hashtable.

As for you, you prety much use them as 2D arrays. Remember to flush values that are not needed to keep speed and efficency at reasonable levels.
 
Status
Not open for further replies.
Top