website/docs/ddoc/primitives/handy_http_primitives.multi...

55 lines
17 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>MultiValueMap (handy_http_primitives.multivalue_map.MultiValueMap)</title>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="style.css" rel="stylesheet" />
<script src="script.js" type="text/javascript"></script>
<link href="search-results.html" rel="prefetch" />
</head>
<body>
<div id="page-header">
<div id="logotype">
<span>Documentation</span>
<nav>
<a href="http://dlang.org/">Dlang.org</a>
</nav>
</div>
<form action="search-docs.html" id="search">
<input name="searchTerm" placeholder="Find a symbol name..." type="search" />
<input type="submit" value="Go" />
</form>
</div>
<div id="page-body">
<div id="page-content">
<h1>MultiValueMap</h1><div class="breadcrumbs"><a class="breadcrumb" href="handy_http_primitives.html">handy_http_primitives</a> <a class="breadcrumb" href="handy_http_primitives.multivalue_map.html">multivalue_map</a> </div><div><div class="documentation-comment synopsis"><div><p>A multi-valued mapping, where a key is mapped to one or more values. The map
is sorted by keys for O(log(n)) lookup and retrieval, and O(n*log(n))
insertion.</p><p><tt class="inline-code">KeyType</tt> is the type used for the map's keys.
<tt class="inline-code">ValueType</tt> is the type used for the map's values.
<tt class="inline-code">KeySort</tt> is a function that takes two operands and returns true if the
first one is less than the second.
<tt class="inline-code">KeyEquals</tt> is a function that takes two operands and returns true if they
are equal.</p></div></div></div><div class="annotated-prototype"><div class="aggregate-prototype"><div class="attributes"></div><span class="builtin-type">struct</span> MultiValueMap (<div class="parameters-list toplevel"><div class="template-parameter-item parameter-item"> <span><span class="name" data-ident="KeyType">KeyType</span></span></div><div class="template-parameter-item parameter-item"> <span><span class="name" data-ident="ValueType">ValueType</span></span></div><div class="template-parameter-item parameter-item"> <span><a class="lang-feature" href="http://dpldocs.info/template-alias-parameter">alias</a> <span class="name" data-ident="KeySort">KeySort</span> = <span class="lambda-expression"><div class="parameters-list"><span class="paren">(</span><div class="runtime-parameter-item parameter-item"><span class="parameter-type-holder"><span class="parameter-type"><span class="name" data-ident="a">a</span></span></span></div><span class="comma">,</span><div class="runtime-parameter-item parameter-item"><span class="parameter-type-holder"><span class="parameter-type"><span class="name" data-ident="b">b</span></span></span></div><span class="paren">)</span></div> =&gt; <span class="name" data-ident="a">a</span> &lt; <span class="name" data-ident="b">b</span></span></span></div><div class="template-parameter-item parameter-item"> <span><a class="lang-feature" href="http://dpldocs.info/template-alias-parameter">alias</a> <span class="name" data-ident="KeyEquals">KeyEquals</span> = <span class="lambda-expression"><div class="parameters-list"><span class="paren">(</span><div class="runtime-parameter-item parameter-item"><span class="parameter-type-holder"><span class="parameter-type"><span class="name" data-ident="a">a</span></span></span></div><span class="comma">,</span><div class="runtime-parameter-item parameter-item"><span class="parameter-type-holder"><span class="parameter-type"><span class="name" data-ident="b">b</span></span></span></div><span class="paren">)</span></div> =&gt; <span class="name" data-ident="a">a</span> == <span class="name" data-ident="b">b</span></span></span></div></div>) {<div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.Entry.html"><span class="builtin-type">struct</span> <span class="name">Entry</span>;</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.length.html"><tt class="highlighted"><span class="hid">size_t</span></tt> <span class="name">length</span>();</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.contains.html"><tt class="highlighted"><span class="type">bool</span></tt> <span class="name">contains</span>(KeyType k);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.keys.html"><tt class="highlighted"><span class="hid">KeyType</span>[]</tt> <span class="name">keys</span>();</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.getAll.html"><tt class="highlighted"><span class="hid">ValueType</span>[]</tt> <span class="name">getAll</span>(KeyType k);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.getFirst.html"><tt class="highlighted"><span class="hid">Optional</span>!<span class="hid">ValueType</span></tt> <span class="name">getFirst</span>(KeyType k);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.add.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">add</span>(KeyType k, ValueType v);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.clear.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">clear</span>();</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.remove.html"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">remove</span>(KeyType k);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.asAssociativeArray.html"><tt class="highlighted"><span class="hid">ValueType</span>[][<span class="hid">KeyType</span>]</tt> <span class="name">asAssociativeArray</span>();</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.fromAssociativeArray.1.html"><span class="storage-class">static</span> <tt class="highlighted"><span class="hid">MultiValueMap</span>!(<span class="hid">KeyType</span>, <span class="hid">ValueType</span>, <span class="hid">KeySort</span>)</tt> <span class="name">fromAssociativeArray</span>(ValueType[][KeyType] aa);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.fromAssociativeArray.2.html"><span class="storage-class">static</span> <tt class="highlighted"><span class="hid">MultiValueMap</span>!(<span class="hid">KeyType</span>, <span class="hid">ValueType</span>, <span class="hid">KeySort</span>)</tt> <span class="name">fromAssociativeArray</span>(ValueType[KeyType] aa);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.Builder.html"><span class="builtin-type">struct</span> <span class="name">Builder</span>;</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.opIndex.1.html"><tt class="highlighted"><span class="kwrd">inout</span>(<span class="hid">Entry</span>)[]</tt> <span class="name">opIndex</span>();</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.opIndex.2.html"><tt class="highlighted"><span class="hid">ValueType</span></tt> <span class="name">opIndex</span>(KeyType key);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.opApply.html"><tt class="highlighted"><span class="type">int</span></tt> <span class="name">opApply</span>(int delegate(const ref KeyType, const ref ValueType) dg);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.opBinaryRight.html"><tt class="highlighted"><span class="hid">ValueType</span>[]</tt> <span class="name">opBinaryRight</span>(string lhs);</a></div><div class="aggregate-member"><a href="handy_http_primitives.multivalue_map.MultiValueMap.toString.html"><tt class="highlighted"><span class="type">string</span></tt> <span class="name">toString</span>();</a></div>}</div></div><h2 id="members"><a class="header-anchor" href="#members">Members</a></h2><h3 class="member-list-header hide-from-toc" id="function"><a class="header-anchor" href="#function">Functions</a></h3><dl class="member-list native"><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.add.html">add</a><div class="simplified-prototype" style="max-width: 35ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">add</span>(KeyType k, ValueType v)</div></dt><dd><div><p>Adds a single key -&gt; value pair to the map, with time complexity of
O(n*log(n)) due to sorting the new entry by its key.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.asAssociativeArray.html">asAssociativeArray</a><div class="simplified-prototype" style="max-width: 45ch;"><tt class="highlighted"><span class="hid">ValueType</span>[][<span class="hid">KeyType</span>]</tt> <span class="name">asAssociativeArray</span>()</div></dt><dd><div><p>Gets this multivalue map as an associative array, where each key is
mapped to a list of values.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.clear.html">clear</a><div class="simplified-prototype" style="max-width: 13ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">clear</span>()</div></dt><dd><div><p>Clears this map of all values.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.contains.html">contains</a><div class="simplified-prototype" style="max-width: 26ch;"><tt class="highlighted"><span class="type">bool</span></tt> <span class="name">contains</span>(KeyType k)</div></dt><dd><div><p>Determines if this map contains a value for the given key.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.getAll.html">getAll</a><div class="simplified-prototype" style="max-width: 31ch;"><tt class="highlighted"><span class="hid">ValueType</span>[]</tt> <span class="name">getAll</span>(KeyType k)</div></dt><dd><div><p>Gets all values associated with a given key, allocated in a new array.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.getFirst.html">getFirst</a><div class="simplified-prototype" style="max-width: 41ch;"><tt class="highlighted"><span class="hid">Optional</span>!<span class="hid">ValueType</span></tt> <span class="name">getFirst</span>(KeyType k)</div></dt><dd><div><p>Gets the first value associated with a given key, as per the order in
which the values were inserted.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.keys.html">keys</a><div class="simplified-prototype" style="max-width: 17ch;"><tt class="highlighted"><span class="hid">KeyType</span>[]</tt> <span class="name">keys</span>()</div></dt><dd><div><p>Gets a list of all keys in this map, allocated in a new array.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.length.html">length</a><div class="simplified-prototype" style="max-width: 16ch;"><tt class="highlighted"><span class="hid">size_t</span></tt> <span class="name">length</span>()</div></dt><dd><div><p>Gets the number of unique keys in this map.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.opApply.html">opApply</a><div class="simplified-prototype" style="max-width: 74ch;"><tt class="highlighted"><span class="type">int</span></tt> <span class="name">opApply</span>(int delegate(const ref KeyType, const ref ValueType) dg)</div></dt><dd><div><p><tt class="inline-code">opApply</tt> implementation to allow iterating over this map by all pairs
of keys and values.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.opBinaryRight.html">opBinaryRight</a><div class="simplified-prototype" style="max-width: 40ch;"><tt class="highlighted"><span class="hid">ValueType</span>[]</tt> <span class="name">opBinaryRight</span>(string lhs)</div></dt><dd><div><p>Implements opBinaryRight for the &quot;in&quot; operator, such that <tt class="inline-code">k in m</tt> will
resolve to the list of values for key <tt class="inline-code">k</tt> in the multivalue map <tt class="inline-code">m</tt> if
that key exists, or <tt class="inline-code">null</tt> if not.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.opIndex.1.html">opIndex</a><div class="simplified-prototype" style="max-width: 26ch;"><tt class="highlighted"><span class="kwrd">inout</span>(<span class="hid">Entry</span>)[]</tt> <span class="name">opIndex</span>()</div></dt><dd><div><p>Implements the empty index operator, which just returns the entire list
of entries in this map.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.opIndex.2.html">opIndex</a><div class="simplified-prototype" style="max-width: 33ch;"><tt class="highlighted"><span class="hid">ValueType</span></tt> <span class="name">opIndex</span>(KeyType key)</div></dt><dd><div><p>Convenience overload to get the first value for a given key. Note: this
will throw an exception if no values exist for the given key. To avoid
this, use <tt class="inline-code">getFirst</tt> and deal with the missing value yourself.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.remove.html">remove</a><div class="simplified-prototype" style="max-width: 24ch;"><tt class="highlighted"><span class="type">void</span></tt> <span class="name">remove</span>(KeyType k)</div></dt><dd><div><p>Removes a key from the map, thus removing all values associated with
that key.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.toString.html">toString</a><div class="simplified-prototype" style="max-width: 18ch;"><tt class="highlighted"><span class="type">string</span></tt> <span class="name">toString</span>()</div></dt><dd><div><p>Converts this map into a human-readable string which lists each key and
all of the values for that key.</p></div></dd></dl><h3 class="member-list-header hide-from-toc" id="static function"><a class="header-anchor" href="#static function">Static functions</a></h3><dl class="member-list native"><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.fromAssociativeArray.1.html">fromAssociativeArray</a><div class="simplified-prototype" style="max-width: 97ch;"><tt class="highlighted"><span class="hid">MultiValueMap</span>!(<span class="hid">KeyType</span>, <span class="hid">ValueType</span>, <span class="hid">KeySort</span>)</tt> <span class="name">fromAssociativeArray</span>(ValueType[][KeyType] aa)</div></dt><dd><div><p>Constructs a multivalued map from an associative array.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.fromAssociativeArray.2.html">fromAssociativeArray</a><div class="simplified-prototype" style="max-width: 95ch;"><tt class="highlighted"><span class="hid">MultiValueMap</span>!(<span class="hid">KeyType</span>, <span class="hid">ValueType</span>, <span class="hid">KeySort</span>)</tt> <span class="name">fromAssociativeArray</span>(ValueType[KeyType] aa)</div></dt><dd><div><p>Constructs a multivalued map from an associative array of single values.</p></div></dd></dl><h3 class="member-list-header hide-from-toc" id="struct"><a class="header-anchor" href="#struct">Structs</a></h3><dl class="member-list native"><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.Builder.html">Builder</a><div class="simplified-prototype" style="max-width: 15ch;"><span class="builtin-type">struct</span> <span class="name">Builder</span></div></dt><dd><div><p>An efficient builder that can be used to construct a multivalued map
with successive <tt class="inline-code">add</tt> calls, which is more efficient than doing so
directly due to the builder's deferred sorting.</p></div></dd><dt><a href="handy_http_primitives.multivalue_map.MultiValueMap.Entry.html">Entry</a><div class="simplified-prototype" style="max-width: 13ch;"><span class="builtin-type">struct</span> <span class="name">Entry</span></div></dt><dd><div><p>The internal structure used to store each key and set of values.</p></div></dd></dl><div></div></div>
<div id="page-nav"><a class="parent" href="handy_http_primitives.html">handy_http_primitives</a> <a class="parent" href="handy_http_primitives.multivalue_map.html">multivalue_map</a>
<span class="type-separator">aliases</span><ul><li><a class="alias" href="handy_http_primitives.multivalue_map.CaseInsensitiveStringMultiValueMap.html">CaseInsensitiveStringMultiValueMap</a></li><li><a class="alias" href="handy_http_primitives.multivalue_map.StringMultiValueMap.html">StringMultiValueMap</a></li></ul><span class="type-separator">structs</span><ul><li><a class="struct current" href="handy_http_primitives.multivalue_map.MultiValueMap.html">MultiValueMap</a></li></ul></div>
</div>
<div id="page-footer">Page generated by <a href="https://github.com/adamdruppe/adrdox">adrdox</a></div>
</body>
</html>