like
a mapping is a thing wot says "x means y"
and "a means b"
and "1 means 2"
and thus
take that map
and input 1
you get 2
input a, you get b
etc.(edited)
Ady (WriteEscape) - Today at 10:25 AM
yup
mcmonkey - Today at 10:25 AM
in this specific case we're referring to an unordered hash map
which has two key words
unordered
which is an English word, IE it does not care what order you put things in
and hash
a hash is a technical thing
basically, it's "abc"'s hash is 5, "taco"'s hash is 7, "potato"'s hash is 2
and ifwe read "abc"'s hash
it's still 5
it's a calculation
(any algorithm, which specific one we use doesn't matter)
that takes some input data
say, some text (in this case it is indeed text, but it can be literally anything hashable)
and gives back a number
in this case, a 32-bit signed integer number
though it could theoretically give back anything
for the purposes of a hash map, a simple 32-bit integer is very useful
if you have that hash setup mentioned above
you can then do like
Ady (WriteEscape) - Today at 10:28 AM
oooo neat
mcmonkey - Today at 10:28 AM
a list with 10 entries in it
and in slot 5 of the list
is "abc"
or , well, a sub-list
which includes "abc"
so if you have another thing whose hash is also "5" , it would also be in that sub-list
so then instead of saying
"is taco the thing I want? Nope. How about potato? nope. How about abc? YAY!"
you get to say
"I want only items in slot 5"
and the first item is 'abc'
and often the correct item is the only item if your hashmap is balanced
so you get it with only an array-indexing operation and an equality check
which is super fast to do that
instead of searching a long list
piecce by piece
that's a super simple naive example of a hashmap
the actual hashmap code used by things like Java C# or d2 is a lot more complex on the inside
but Denizen 1 and 2 heavily rely on hashmaps
YAML in particular is just a giant series of layered hashmaps
when you do "my.key.here" in YAML toread a key
you're reading the root map for 'my'
then the submap for 'key'
then the map within that for 'here'
which, is only more efficient that reading a general big map in very specific cases actually
(When you have hilariously large and evenly structured data)
(and bad hashmap code :P )
so also
the question you might ask is
"So there's na array in every hashmap the size of all possible values of a 32 bit signed integer"
no, there are not 4 billion wide lists
that's where the cleverness of the code comes in
using modulo operations and rebalancing algorithms and such
a short naive example:
say your hash is from -300 to 300
but you only have 3 entries
you could make a 10-wide array
and do hash module 10, absolute value
or similar to that
so 325 becomes 5
and the code works out
that modulo op is why we use simple small integers for hashmaps
so... I think that about covers the basics ;P