22 lines
No EOL
3.5 KiB
HTML
22 lines
No EOL
3.5 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Dict — Ludic</title>
|
||
<meta name="description" content="A hash map from string keys to int values — the everyday lookup a game needs, like resource counts or an id registry by name.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Dict</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Dict</h1></div>
|
||
<p class="ns-blurb">A hash map from string keys to <code>int</code> values — the everyday lookup a game needs, like resource counts or an id registry by name. A <code>Dict</code> is backed by an open-addressing hash table (FNV-1a, linear probing, tombstone deletes, growing at load factor 0.7), so <code>get</code>/<code>set</code>/<code>has</code> are O(1) on average rather than the linear scan a list would give. Create one with <code>Dict.new</code>, then <code>set</code> / <code>get</code> / <code>get_or</code> / <code>has</code> / <code>remove</code> / <code>size</code> / <code>clear</code> / <code>keys</code>. Values are <code>int</code> (which also holds an <code>entity</code> or any small id); for richer values use the <code>Value.*</code> tree. Arguments are positional. The runtime is spliced in only when a program mentions <code>Dict.*</code> (or <code>Set.*</code>).</p>
|
||
<div class="ns-methods"><a class="ns-method" href="dict-new.html"><code class="nm-sig">Dict.new() -> Dict</code><span class="nm-tip">Create an empty string-keyed map.</span></a><a class="ns-method" href="dict-set.html"><code class="nm-sig">Dict.set(d, key, value)</code><span class="nm-tip">Insert or update a key.</span></a><a class="ns-method" href="dict-get.html"><code class="nm-sig">Dict.get(d, key) -> int</code><span class="nm-tip">Look up a key (0 if absent).</span></a><a class="ns-method" href="dict-get_or.html"><code class="nm-sig">Dict.get_or(d, key, fallback) -> int</code><span class="nm-tip">Look up a key with an explicit default.</span></a><a class="ns-method" href="dict-has.html"><code class="nm-sig">Dict.has(d, key) -> bool</code><span class="nm-tip">Is a key present?</span></a><a class="ns-method" href="dict-remove.html"><code class="nm-sig">Dict.remove(d, key)</code><span class="nm-tip">Delete a key.</span></a><a class="ns-method" href="dict-size.html"><code class="nm-sig">Dict.size(d) -> int</code><span class="nm-tip">How many keys are stored.</span></a><a class="ns-method" href="dict-clear.html"><code class="nm-sig">Dict.clear(d)</code><span class="nm-tip">Remove every key.</span></a><a class="ns-method" href="dict-keys.html"><code class="nm-sig">Dict.keys(d) -> []pointer</code><span class="nm-tip">Every key, as a slice of strings.</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |