<?xml version="1.0" encoding="windows-1252"?>
<node id="517487" title="Re: Using map to create a hash/bag from an array" created="2005-12-17 09:19:26" updated="2005-12-17 04:19:26">
<type id="11">
note</type>
<author id="170442">
jdporter</author>
<data>
<field name="doctext">
&lt;p&gt;
Semantic quibble: what you are talking about is not a bag, it is a set.
A bag is just like a set, except that elements can occur more than once.
You can use a hash to represent a bag, but it's a bit more involved.
One simple implementation could have a key's value indicate the number of times
the key occurs in the bag; but you'd still have to override the hash delete
function so that it decrements the count, and only deletes the key when the
count goes to zero.  Another, more obvious, implementation would be to use
an array. Then you'd have to write &lt;c&gt;exists&lt;/c&gt; and &lt;c&gt;delete&lt;/c&gt; functions.
Hiding all this behind TIE would probably make some sense.

All that being said, you could just use [dist://Set-Bag].
&lt;/p&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-170442"&gt;
We're building the house of the future together.
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
517458</field>
<field name="parent_node">
517458</field>
</data>
</node>
