<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Hash_array_mapped_trie</id>
	<title>Hash array mapped trie - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Hash_array_mapped_trie"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Hash_array_mapped_trie&amp;action=history"/>
	<updated>2026-05-05T01:03:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Hash_array_mapped_trie&amp;diff=5863900&amp;oldid=prev</id>
		<title>imported&gt;AnomieBOT: Dating maintenance tags: {{Citation needed}}</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Hash_array_mapped_trie&amp;diff=5863900&amp;oldid=prev"/>
		<updated>2025-06-20T16:20:36Z</updated>

		<summary type="html">&lt;p&gt;Dating maintenance tags: {{Citation needed}}&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Formatted data in computer science}}&lt;br /&gt;
{{Technical|date=October 2019}}&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;hash array mapped trie&amp;#039;&amp;#039;&amp;#039;&amp;lt;ref name=&amp;quot;bagwell&amp;quot; /&amp;gt; (&amp;#039;&amp;#039;&amp;#039;HAMT&amp;#039;&amp;#039;&amp;#039;, {{IPAc-en|ˈ|h|æ|m|t|}}) is an implementation of an [[associative array]] that combines the characteristics of a [[hash table]] and an [[array mapped trie]].&amp;lt;ref name=&amp;quot;bagwell&amp;quot;&amp;gt;{{cite report&lt;br /&gt;
|title=Ideal Hash Trees&lt;br /&gt;
|author=Phil Bagwell&lt;br /&gt;
|author-link=Phil Bagwell&lt;br /&gt;
|publisher=Infoscience Department, [[École Polytechnique Fédérale de Lausanne]]&lt;br /&gt;
|url=http://infoscience.epfl.ch/record/64398/files/idealhashtrees.pdf&lt;br /&gt;
|year=2000&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
It is a refined version of the more general notion of a [[Hash tree (persistent data structure)|hash tree]].&lt;br /&gt;
&lt;br /&gt;
== Operation ==&lt;br /&gt;
A HAMT is an array mapped trie where the keys are first hashed to ensure an even distribution of keys and a constant key length.&lt;br /&gt;
&lt;br /&gt;
In a typical implementation of HAMT&amp;#039;s array mapped trie, each node contains a table with some fixed number N of slots with each slot containing either a nil pointer or a pointer to another node. N is commonly 32.  As allocating space for N pointers for each node would be expensive, each node instead contains a bitmap which is N bits long where each bit indicates the presence of a non-nil pointer. This is followed by an array of pointers equal in length to the number of ones in the bitmap (its [[Hamming weight]]).&lt;br /&gt;
&lt;br /&gt;
== Advantages of HAMTs ==&lt;br /&gt;
The hash array mapped trie achieves almost hash table-like speed while using memory much more economically.{{citation needed|date=June 2025}}  Also, a hash table may have to be periodically resized, an expensive operation, whereas HAMTs grow dynamically.  Generally, HAMT performance is improved by a larger root table with some multiple of N slots; some HAMT variants allow the root to grow lazily&amp;lt;ref name=&amp;quot;bagwell&amp;quot; /&amp;gt; with negligible impact on performance.&lt;br /&gt;
&lt;br /&gt;
== Implementation details ==&lt;br /&gt;
Implementation of a HAMT involves the use of the [[Hamming weight|population count]] function, which counts the number of ones in the binary representation of a number.  This operation is available in [[Hamming weight#Processor support|many instruction set architectures]], but it is [[Hamming weight#Language support|available in only some high-level languages]]. Although population count can be implemented in software in [[Big-O notation|O(1)]] time using a [[Hamming weight#Efficient implementation|series of shift and add instructions]], doing so may perform the operation an order of magnitude slower.{{citation needed|date=October 2016}}&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
The programming languages [[Clojure]],&amp;lt;ref&amp;gt;{{cite web|url=https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java|title=clojure/clojure|website=GitHub|date=8 December 2022 }}&amp;lt;/ref&amp;gt; [[Scala (programming language)|Scala]], and [[Frege (programming language)|Frege]]&amp;lt;ref&amp;gt;{{cite web|url=https://github.com/Frege/frege/blob/master/frege/data/HashMap.fr|title=Frege/frege|website=GitHub|date=7 December 2022 }}&amp;lt;/ref&amp;gt; use a [[Persistent data structure|persistent]] variant of hash array mapped tries for their native hash map type. The [[Haskell (programming language)|Haskell]] library &amp;quot;unordered-containers&amp;quot; uses the same to implement persistent map and set data structures.&amp;lt;ref&amp;gt;Johan Tibell, A. [http://blog.johantibell.com/2012/03/announcing-unordered-containers-02.html Announcing unordered-containers 0.2]&amp;lt;/ref&amp;gt; Another Haskell library &amp;quot;stm-containers&amp;quot; adapts the algorithm for use in the context of [[software transactional memory]].&amp;lt;ref&amp;gt;Nikita Volkov, [https://nikita-volkov.github.io/stm-containers/ Announcing the &amp;quot;stm-containers&amp;quot; library], 2014&amp;lt;/ref&amp;gt; A [[JavaScript|Javascript]] HAMT library &amp;lt;ref&amp;gt;{{cite web|url=https://github.com/mattbierner/hamt|title=mattbierner/hamt|website=GitHub|date=27 November 2022 }}&amp;lt;/ref&amp;gt; based on the Clojure implementation is also available.  The [[Rubinius]]&amp;lt;ref&amp;gt;{{cite web|url=https://github.com/rubinius/rubinius/blob/540a4b446991e4d5c956023d37ec4f95372d539d/kernel/common/hash_hamt.rb|title=Ruby source file of Rubinius&amp;#039;s HAMT|website=[[GitHub]]|publisher=}}&amp;lt;/ref&amp;gt; implementation of [[Ruby (programming language)|Ruby]] includes a HAMT, mostly written in Ruby but with 3&amp;lt;ref&amp;gt;https://github.com/rubinius/rubinius/blob/master/machine/builtin/system.cpp#L1724-L1802 {{Dead link|date=February 2022}}&amp;lt;/ref&amp;gt; primitives. Large maps in [[Erlang (programming language)|Erlang]] use a [[Persistent data structure|persistent]] HAMT representation internally since release 18.0.&amp;lt;ref&amp;gt;{{Cite web | url=http://www.erlang.org/news/86 | title=Erlang Programming Language}}&amp;lt;/ref&amp;gt; The Pony programming language uses a HAMT for the hash map in its persistent collections package.&amp;lt;ref&amp;gt;{{Cite web | url=https://github.com/ponylang/ponyc/blob/master/packages/collections/persistent/map.pony | title=horse: Pony is an open-source, actor-model, capabilities-secure, high performance programming language: Ponylang/ponyc| website=[[GitHub]]| date=2018-11-26}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
The im and im-rc crates, which provide persistent collection types for the Rust programming language, use a HAMT for their persistent hash tables and hash sets.&lt;br /&gt;
&amp;lt;ref&amp;gt;{{cite web|url=https://docs.rs/im/|title=API docs for Rust im-rc crate}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The concurrent lock-free version&amp;lt;ref&amp;gt;Prokopec, A. [https://github.com/axel22/Ctries Implementation of Concurrent Hash Tries on GitHub]&amp;lt;/ref&amp;gt; of the hash trie called [[Ctrie]] is a mutable thread-safe implementation which ensures progress. The data-structure has been proven to be correct&amp;lt;ref&amp;gt;Prokopec, A. et al. (2011) [http://infoscience.epfl.ch/record/166908/files/ctries-techreport.pdf Cache-Aware Lock-Free Concurrent Hash Tries]. Technical Report, 2011.&amp;lt;/ref&amp;gt; - Ctrie operations have been shown to have the [[Atomicity (programming)|atomicity]], [[linearizability]] and [[lock free|lock-freedom]] properties.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Judy array]]&lt;br /&gt;
* [[Radix tree]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Hash Array Mapped Trie}}&lt;br /&gt;
[[Category:Associative arrays]]&lt;br /&gt;
[[Category:Hashing]]&lt;/div&gt;</summary>
		<author><name>imported&gt;AnomieBOT</name></author>
	</entry>
</feed>