On Mon, Jul 24, 2017 at 11:11 PM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:
An API like this takes a lot of planning, design, and effort. It seems to
be a labor of love.
It does seem that way. Especially when considering the level of polish
on the documentation.
But I'm curious how developers might use keyed linked
lists like this? What are they used for in other language environments?
I wouldn't characterize RpgMap as a keyed linked list. I do see where
you're coming from, but I think that terminology may be a bit of a
stretch and obscures the design and intended use of the thing.
The RpgMap is more properly a type of "associative array":
<
https://en.wikipedia.org/wiki/Associative_array>
There are quite a few variations on this general structure. Most
languages that provide one as a built-in choose a hash-table-based
implementation. RpgMap uses a self-balancing binary search tree
instead. This has inherently different performance characteristics,
and the author also chose to allow duplicate keys, which makes this
less like a typical map and more like... well, a kind of highly
flexible, in-memory database. (The API contributes to this feeling as
well.)
In other languages, especially ones with a hash implementation, they
are used for pretty much anything and everything. Sometimes they even
take the place of arrays. (Just use consecutive integers as the keys.)
In Python, they form the basis of namespaces, objects, and symbol
tables. (An object's "properties" are ultimately just keys in a Python
dictionary. As are all variable names.) They are also an idiomatic way
in Python to handle some of the functionality that you might use RPG's
SELECT statement for. It's harder to think of where NOT to use
dictionaries in Python.
From a typical RPG programmer's standpoint, I guess an approachable
way to start thinking about how to use RpgMap would be to think of
everywhere you use lookup tables of some form. The lightest-weight
form of these would be alternating tables or arrays, the
heaviest-weight form would be physical files or SQL tables. RpgMap is
somewhere in between, and much, much more flexible than either,
because the keys can be almost anything, and the values can be almost
anything, including further maps.
John Y.
As an Amazon Associate we earn from qualifying purchases.