Go to the first, previous, next, last section, table of contents.


Class Set

Class Set is much like Class Plain, except for storing no values with the keys: Values always come back as 't'. This can cut the space needs in half.

Sets are appropriate any time all that matters is the presence or absence of the key, not the value associated with it.

To facilitate this use, a Set returns nil for missing keys, rather than throwing an error (as do Index and kin):

root:
makeIndex --> _x
root:
t --> _x["a"]
root:
_x["a"]
root: t
pop _x["b"]
Sorry: No such property: "b"
root:
makeSet --> _x
root:
t --> _x["a"]
root:
_x["a"]
root: t
pop _x["b"]
root: nil

Often the main reason to use a Set rather than an Index will be simple space efficiency: Set needs a minimum of one slot on disk per stored value, while Index needs a minimum of two (one each for key and value).

Class Set adds no properties to those of Class Plain. See section Class Hash. See section Class Index.


Go to the first, previous, next, last section, table of contents.