31 lines
8.6 KiB
HTML
31 lines
8.6 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`litemap`"><title>litemap - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="litemap" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate litemap</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../litemap/index.html">litemap</a><span class="version">0.8.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#litemap" title="`litemap`"><code>litemap</code></a><ul><li><a href="#performance-characteristics" title="Performance characteristics">Performance characteristics</a></li><li><a href="#pluggable-backends" title="Pluggable Backends">Pluggable Backends</a></li><li><a href="#const-construction" title="Const construction">Const construction</a></li></ul></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>litemap</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/litemap/lib.rs.html#5-83">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="litemap"><a class="doc-anchor" href="#litemap">§</a><code>litemap</code></h2>
|
||
<p><code>litemap</code> is a crate providing <a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a>, a highly simplistic “flat” key-value map
|
||
based off of a single sorted vector.</p>
|
||
<p>The main goal of this crate is to provide a map that is good enough for small
|
||
sizes, and does not carry the binary size impact of <a href="https://doc.rust-lang.org/1.93.1/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap"><code>HashMap</code></a>
|
||
or <a href="alloc::collections::BTreeMap"><code>BTreeMap</code></a>.</p>
|
||
<p>If binary size is not a concern, <a href="https://doc.rust-lang.org/1.93.1/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap"><code>std::collections::BTreeMap</code></a> may be a better choice
|
||
for your use case. It behaves very similarly to <a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> for less than 12 elements,
|
||
and upgrades itself gracefully for larger inputs.</p>
|
||
<h3 id="performance-characteristics"><a class="doc-anchor" href="#performance-characteristics">§</a>Performance characteristics</h3>
|
||
<p><a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> is a data structure with similar characteristics as <a href="https://doc.rust-lang.org/1.93.1/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap"><code>std::collections::BTreeMap</code></a> but
|
||
with slightly different trade-offs as it’s implemented on top of a flat storage (e.g. Vec).</p>
|
||
<ul>
|
||
<li><a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> iteration is generally faster than <code>BTreeMap</code> because of the flat storage.</li>
|
||
<li><a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> can be pre-allocated whereas <code>BTreeMap</code> can’t.</li>
|
||
<li><a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> has a smaller memory footprint than <code>BTreeMap</code> for small collections (< 20 items).</li>
|
||
<li>Lookup is <code>O(log(n))</code> like <code>BTreeMap</code>.</li>
|
||
<li>Insertion is generally <code>O(n)</code>, but optimized to <code>O(1)</code> if the new item sorts greater than the current items. In <code>BTreeMap</code> it’s <code>O(log(n))</code>.</li>
|
||
<li>Deletion is <code>O(n)</code> whereas <code>BTreeMap</code> is <code>O(log(n))</code>.</li>
|
||
<li>Bulk operations like <code>from_iter</code>, <code>extend</code> and deserialization have an optimized <code>O(n)</code> path
|
||
for inputs that are ordered and <code>O(n*log(n))</code> complexity otherwise.</li>
|
||
</ul>
|
||
<h3 id="pluggable-backends"><a class="doc-anchor" href="#pluggable-backends">§</a>Pluggable Backends</h3>
|
||
<p>By default, <a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> is backed by a <a href="alloc::vec::Vec"><code>Vec</code></a>; however, it can be backed by any appropriate
|
||
random-access data store, giving that data store a map-like interface. See the <a href="store/index.html" title="mod litemap::store"><code>store</code></a>
|
||
module for more details.</p>
|
||
<h3 id="const-construction"><a class="doc-anchor" href="#const-construction">§</a>Const construction</h3>
|
||
<p><a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a> supports const construction from any store that is const-constructible, such as a
|
||
static slice, via <a href="struct.LiteMap.html#method.from_sorted_store_unchecked" title="associated function litemap::LiteMap::from_sorted_store_unchecked"><code>LiteMap::from_sorted_store_unchecked()</code></a>. This also makes <a href="struct.LiteMap.html" title="struct litemap::LiteMap"><code>LiteMap</code></a>
|
||
suitable for use with [<code>databake</code>]. See <a href="./struct.LiteMap.html#impl-Bake-for-LiteMap%3CK,+V,+S%3E"><code>impl Bake for LiteMap</code></a> for more details.</p>
|
||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="store/index.html" title="mod litemap::store">store</a></dt><dd>Traits for pluggable LiteMap backends.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.LiteMap.html" title="struct litemap::LiteMap">LiteMap</a></dt><dd>A simple “flat” map based on a sorted vector</dd><dt><a class="struct" href="struct.OccupiedEntry.html" title="struct litemap::OccupiedEntry">Occupied<wbr>Entry</a></dt><dd>A view into an occupied entry in a <code>LiteMap</code>.</dd><dt><a class="struct" href="struct.VacantEntry.html" title="struct litemap::VacantEntry">Vacant<wbr>Entry</a></dt><dd>A view into a vacant entry in a <code>LiteMap</code>.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.Entry.html" title="enum litemap::Entry">Entry</a></dt><dd>An entry in a <code>LiteMap</code>, which may be either occupied or vacant.</dd></dl></section></div></main></body></html> |