<snapdata remixID="10175846"><project name="Hash Map" app="Snap! 6, https://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAFeklEQVR4Xu2dyyunbRjHL3I+G4cJWVAoh1iIEk0aC2WDWGJhYaOUMmXvj7BUFvgLlFGiZIEiRc2WiIRyWBCm+3n7Te878+I34xn3levzbJye57qu7/f7cT8nJebx8fFR2HDAkwMxAOjJedoGDgAgIHh1AAC92k9zAIQBrw4AoFf7aQ6AMODVAQD0aj/NARAGvDoAgF7tpzkAwoBXBwDQq/00B0AY8OoAAHq1n+YACANeHQBAr/bTHABhwKsDAOjVfpoDIAx4dQAAvdpPcwCEAa8OAKBX+2kOgDDg1QEA9Go/zQEQBrw6AIBe7ac5AMKAVwcA0Kv9NAdAGPDqAAB6tZ/mAAgDXh0AQK/20xwAYcCrAwDo1X6aAyAMeHUAAL3aT3MAhAGvDgCgV/tpDoAw4NUBAPRqP80BEAa8OgCAXu2nOQDCgFcHADBk+9fW1uT29lYeHh5CriySmJgo5eXlkpubG3ptXwUBMETnl5aWpK6uTjIzMyU2NjbEyv+UcmCvrq5KRUWFFBYWhl7fR0EADMn15eVlqa6ulpycnJAqPl3Ggd7a2vrX+7xFAwAMyeW3hOIte4Vkz5NlADAkhyNQ1NfXS0xMjMzNzUlpaemP6u77GxsbUXf79u2bDA8Py8LCgkxPT0tjY2Nw/ec2AIzaRjs7RqBIS0uTq6urAMLT01Pp7OyUlZWV4Jqwo6NDZmdn5ezsTAYHB+Xr168yMDAgFxcXcnBwIGVlZcHP3ba1tSXFxcXB9eT9/b3s7e0F15cAaIep31IaATAlJUVGRkZkYmJC4uLixP0/8Ozs7AAy9/mHDx/k/PxcamtrZXJyUtrb24OvHWRu/8h2cnIiX758kampqeC47e1tAPytRIzt/PMK6B6ZLC4uytDQULAC5uXliTsNz8zMyO7uroyPj8vOzo4UFRXJ4eGh1NTUBDcxkRXQraDumPn5eenq6pK7uzs5OjpiBTTGVdRy3/K67C17RW3AH+7ITcgfGvfzYZubm8FptKGhIaSKPIb560a+twZuZUpOTg7uft3H9PT0QOLl5WUoUo+Pj2V/f19aWlr+c70YSnFPRVgBQzbe3eG6G4ZPnz7Jzc2NrK+v/wDxta0KCgqCNyDu+vC9bAAYcpKR12WpqalyfX0tzc3NEh8fH3KX91MOAEPO0p2G3ebubiMPjkNu8a7KAeATcXZ3d0tPT4+0tbVJfn5+VKFHVr+mpqbgL1fYXnYAAJ/xyL25SEhICB4Eu4+jo6NSWVkpGRkZLzvLHlE5AIDP2OReqfX19f2yR1JSkmRlZQVvKkpKSqIymp3+3wEAfIYM9/ikv7//lz3c6dW9UhsbGwPAV/5mAeALp2AHm3vAHDkFV1VVcQp+JXT/PhwAnzDTvX/t7e2Vz58/y8ePH0O0nFIACANqHGAFVBOFzUEA0GbualQDoJoobA4CgDZzV6MaANVEYXMQALSZuxrVAKgmCpuDAKDN3NWoBkA1UdgcBABt5q5GNQCqicLmIABoM3c1qgFQTRQ2BwFAm7mrUQ2AaqKwOQgA2sxdjWoAVBOFzUEA0GbualQDoJoobA4CgDZzV6MaANVEYXMQALSZuxrVAKgmCpuDAKDN3NWoBkA1UdgcBABt5q5GNQCqicLmIABoM3c1qgFQTRQ2BwFAm7mrUQ2AaqKwOQgA2sxdjWoAVBOFzUEA0GbualQDoJoobA4CgDZzV6MaANVEYXMQALSZuxrVAKgmCpuDAKDN3NWoBkA1UdgcBABt5q5GNQCqicLmIABoM3c1qgFQTRQ2BwFAm7mrUQ2AaqKwOQgA2sxdjWoAVBOFzUEA0GbualQDoJoobA4CgDZzV6MaANVEYXMQALSZuxrVAKgmCpuDAKDN3NWo/g67beO39KYA9wAAAABJRU5ErkJggg==</thumbnail><stage name="Stage" width="480" height="360" costume="0" color="255,255,255,1" tempo="60" threadsafe="false" penlog="false" volume="100" pan="0" lines="round" ternary="false" hyperops="true" codify="false" inheritance="true" sublistIDs="false" scheduled="false" id="1"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQVR4Xu3VwQkAAAjEMN1/abewn7jAQRC64wgQIECAAIF3gX1fNEiAAAECBAiMAHsCAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails><costumes><list struct="atomic" id="2"></list></costumes><sounds><list struct="atomic" id="3"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites><sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="80,80,80,1" pen="tip" id="8"><costumes><list struct="atomic" id="9"></list></costumes><sounds><list struct="atomic" id="10"></list></sounds><blocks></blocks><variables></variables><scripts><script x="10" y="64.99999999999994"><block s="doSetVar"><l>map</l><custom-block s="new Hash Map"></custom-block></block><custom-block s="set key: %txt value: %s of %l"><l>John</l><l>20</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Tim</l><l>19</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Aaron</l><l>13</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Sam</l><l>15</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Robert</l><l>21</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Paul</l><l>33</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Emma</l><l>18</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Anna</l><l>19</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Paul</l><l>33</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>William</l><l>20</l><block var="map"/></custom-block><custom-block s="set key: %txt value: %s of %l"><l>Margaret</l><l>34</l><block var="map"/></custom-block></script><script x="273" y="174.33333333333317"><custom-block s="get value %txt of %l"><l>Aaron</l><block var="map"/></custom-block></script><script x="289.66666666666663" y="31.166666666666572"><custom-block s="size of map %l"><block var="map"/></custom-block></script><script x="173" y="359.33333333333326"><custom-block s="for each key %upvar in map %l %ca"><l>key</l><block var="map"/><script><block s="doSayFor"><block s="reportJoinWords"><list><block var="key"/><l>: </l><custom-block s="get value %txt of %l"><block var="key"/><block var="map"/></custom-block></list></block><l>1</l></block></script></custom-block></script><script x="340" y="246.16666666666654"><custom-block s="does key %txt exist in %l ?"><l>Paul</l><block var="map"/></custom-block></script><script x="392" y="127.83333333333343"><custom-block s="delete key %txt of %l"><l>Paul</l><block var="map"/></custom-block></script><script x="372" y="312.66666666666663"><custom-block s="clear map %l"><block var="map"/></custom-block></script><script x="247" y="96.99999999999991"><custom-block s="map %l as list"><block var="map"/></custom-block></script></scripts></sprite><watcher var="map" style="normal" x="13" y="15" color="243,118,29" extX="232" extY="307" hidden="true"/></sprites></stage><hidden></hidden><headers></headers><code></code><blocks><block-definition s="new Hash Map" type="reporter" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doDeclareVariables"><list><l>initial capacity</l><l>linked lists</l></list></block><block s="doSetVar"><l>initial capacity</l><l>16</l></block><block s="doSetVar"><l>linked lists</l><block s="reportNewList"><list></list></block></block><block s="doWarp"><script><block s="doRepeat"><block var="initial capacity"/><script><block s="doAddToList"><block s="reportNewList"><list></list></block><block var="linked lists"/></block></script></block></script></block><block s="doReport"><block s="reportNewList"><list><l>0</l><block var="linked lists"/></list><comment w="132" collapsed="false">The hash map&apos;s contents are stored as follows:&#xD;A list containing the size, and another list of linked lists</comment></block></block></script></block-definition><block-definition s="set key: %&apos;key&apos; value: %&apos;value&apos; of %&apos;hash map&apos;" type="command" category="other"><comment x="0" y="0" w="147" collapsed="false">Changes the value associated with a key, creating a new key if it does not exist</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input><input type="%l"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ["text", "number"]);</l></block><list><block var="key"/></list></block><block s="doDeclareVariables"><list><l>hash</l><l>capacity</l><l>bins</l></list></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doSetVar"><l>capacity</l><block s="reportListAttribute"><l><option>length</option></l><block var="bins"/></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportModulus"><block s="reportDifference"><custom-block s="compute hash %txt"><block var="key"/></custom-block><l>1</l></block><block var="capacity"/></block><l>1</l></block><comment w="160.4404296875" collapsed="false">Compute the hash value and map that to a position in the table</comment></block><block s="doIfElse"><block s="reportListIsEmpty"><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block><script><block s="doReplaceInList"><block var="hash"/><block var="bins"/><custom-block s="☠︎ link %l"><block s="reportNewList"><list><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block></list></block></custom-block></block><block s="doReplaceInList"><l>1</l><block var="hash map"/><block s="reportSum"><block s="reportListItem"><l>1</l><block var="hash map"/></block><l>1</l></block></block></script><script><custom-block s="catch %upvar %cs"><l>already exists</l><script><block s="doWarp"><script><block s="doForEach"><l>pair</l><block s="reportListItem"><block var="hash"/><block var="bins"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="pair"/></block><block var="key"/></block><script><block s="doReplaceInList"><l>2</l><block var="pair"/><block var="value"/></block><custom-block s="throw %s"><block var="already exists"/></custom-block></script></block></script></block></script></block><block s="doReplaceInList"><block var="hash"/><block var="bins"/><block s="reportCONS"><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block></block><block s="doReplaceInList"><l>1</l><block var="hash map"/><block s="reportSum"><block s="reportListItem"><l>1</l><block var="hash map"/></block><l>1</l></block></block></script></custom-block></script></block><block s="doIf"><block s="reportGreaterThan"><block s="reportQuotient"><block s="reportListItem"><l>1</l><block var="hash map"/></block><block var="capacity"/></block><l>0.75</l></block><script><block s="doDeclareVariables"><list><l>bigger bins</l><l>b</l></list></block><block s="doSetVar"><l>bigger bins</l><block s="reportNewList"><list></list></block></block><block s="doWarp"><script><block s="doRepeat"><block s="reportProduct"><l>2</l><block var="capacity"/></block><script><block s="doAddToList"><block s="reportNewList"><list></list></block><block var="bigger bins"/></block></script></block><block s="doForEach"><l>bin</l><block var="bins"/><script><block s="doForEach"><l>pair</l><block var="bin"/><script><block s="doSetVar"><l>key</l><block s="reportListItem"><l>1</l><block var="pair"/></block></block><block s="doSetVar"><l>value</l><block s="reportListItem"><l>2</l><block var="pair"/></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportModulus"><block s="reportDifference"><custom-block s="compute hash %txt"><block var="key"/></custom-block><l>1</l></block><block s="reportProduct"><l>2</l><block var="capacity"/></block></block><l>1</l></block><comment w="160.4404296875" collapsed="false">Compute the hash value and map that to a position in the table</comment></block><block s="doIfElse"><block s="reportListIsEmpty"><block s="reportListItem"><block var="hash"/><block var="bigger bins"/></block></block><script><block s="doReplaceInList"><block var="hash"/><block var="bigger bins"/><custom-block s="☠︎ link %l"><block s="reportNewList"><list><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block></list></block></custom-block></block></script><script><block s="doReplaceInList"><block var="hash"/><block var="bigger bins"/><block s="reportCONS"><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block><block s="reportListItem"><block var="hash"/><block var="bigger bins"/></block></block></block></script></block></script></block></script></block></script></block><block s="doReplaceInList"><l>2</l><block var="hash map"/><block var="bigger bins"/></block></script><comment w="121" collapsed="false">If the load factor exceeds the threshold, rehash.</comment></block></script></block-definition><block-definition s="compute hash %&apos;key&apos;" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input></inputs><script><block s="doIf"><block s="reportEquals"><block var="key"/><l></l></block><script><block s="doReport"><l>1</l></block></script></block><block s="doDeclareVariables"><list><l>hash</l><l>minHash</l><l>maxHash</l></list></block><block s="doSetVar"><l>hash</l><l>1</l></block><block s="doSetVar"><l>minHash</l><l>-2147483648</l></block><block s="doSetVar"><l>maxHash</l><l>2147483647</l></block><block s="doWarp"><script><block s="doFor"><l>i</l><l>1</l><block s="reportStringSize"><block var="key"/></block><script><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportProduct"><block var="hash"/><l>37</l></block><block s="reportUnicode"><block s="reportLetter"><block var="i"/><block var="key"/></block></block></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block var="minHash"/><block s="reportModulus"><block s="reportDifference"><block var="hash"/><block var="minHash"/></block><block s="reportSum"><block s="reportDifference"><block var="maxHash"/><block var="minHash"/></block><l>1</l></block></block></block></block></script></block><block s="doReport"><block var="hash"/></block></script></block></script><scripts><script x="405.12109375" y="408.5000000000004"><block var="hash"/></script></scripts></block-definition><block-definition s="catch %&apos;tag&apos; %&apos;action&apos;" type="command" category="control"><header></header><code></code><translations>de:fange _ _&#xD;ca:agafa _ _&#xD;es:atrapar _ _&#xD;fr:attrape _ _&#xD;pt:captura _ _&#xD;</translations><inputs><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doCallCC"><block s="reifyScript"><script><block s="doSetVar"><l>tag</l><block var="cont"/></block><block s="doRun"><block var="action"/><list></list></block></script><list><l>cont</l></list></block></block></script></block-definition><block-definition s="throw %&apos;cont&apos;" type="command" category="control"><header></header><code></code><translations>de:wirf _&#xD;ca:llança _&#xD;es:lanzar _&#xD;fr:lance _&#xD;pt:lança _&#xD;</translations><inputs><input type="%s">catchtag</input></inputs><script><block s="doRun"><block var="cont"/><list></list></block></script></block-definition><block-definition s="get value %&apos;key&apos; of %&apos;hash map&apos;" type="reporter" category="other"><comment x="0" y="0" w="157" collapsed="false">Returns the value associated with a key, or False if the key is not found</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ["text", "number"]);</l></block><list><block var="key"/></list></block><block s="doDeclareVariables"><list><l>hash</l><l>capacity</l><l>bins</l></list></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doSetVar"><l>capacity</l><block s="reportListAttribute"><l><option>length</option></l><block var="bins"/></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportModulus"><block s="reportDifference"><custom-block s="compute hash %txt"><block var="key"/></custom-block><l>1</l></block><block var="capacity"/></block><l>1</l></block><comment w="160.4404296875" collapsed="false">Compute the hash value and map that to a position in the table</comment></block><block s="doIfElse"><block s="reportListIsEmpty"><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script><script><block s="doWarp"><script><block s="doForEach"><l>pair</l><block s="reportListItem"><block var="hash"/><block var="bins"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="pair"/></block><block var="key"/></block><script><block s="doReport"><block s="reportListItem"><l>2</l><block var="pair"/></block></block></script></block></script></block><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block></script></block-definition><block-definition s="map %&apos;hash map&apos; as list" type="reporter" category="other"><comment x="0" y="0" w="125" collapsed="false">Converts the hash map to a list of key-value pairs</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>pairs</l><l>bins</l></list></block><block s="doSetVar"><l>pairs</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doWarp"><script><block s="doForEach"><l>bin</l><block var="bins"/><script><block s="doForEach"><l>pair</l><block var="bin"/><script><block s="doAddToList"><block s="reportNewList"><list><block s="reportListItem"><l>1</l><block var="pair"/></block><block s="reportListItem"><l>2</l><block var="pair"/></block></list></block><block var="pairs"/></block></script></block></script></block><block s="doReport"><block var="pairs"/></block></script></block></script></block-definition><block-definition s="does key %&apos;key&apos; exist in %&apos;hash map&apos; ?" type="predicate" category="other"><comment x="0" y="0" w="154.99999999999977" collapsed="false">Returns True if the key is in the hash map, or False otherwise</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ["text", "number"]);</l></block><list><block var="key"/></list></block><block s="doDeclareVariables"><list><l>hash</l><l>capacity</l><l>bins</l></list></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doSetVar"><l>capacity</l><block s="reportListAttribute"><l><option>length</option></l><block var="bins"/></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportModulus"><block s="reportDifference"><custom-block s="compute hash %txt"><block var="key"/></custom-block><l>1</l></block><block var="capacity"/></block><l>1</l></block><comment w="160.4404296875" collapsed="false">Compute the hash value and map that to a position in the table</comment></block><block s="doIfElse"><block s="reportListIsEmpty"><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script><script><block s="doWarp"><script><block s="doForEach"><l>pair</l><block s="reportListItem"><block var="hash"/><block var="bins"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="pair"/></block><block var="key"/></block><script><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script></block></script></block><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block></script></block-definition><block-definition s="for each key %&apos;key&apos; in map %&apos;hash map&apos; %&apos;action&apos;" type="command" category="lists"><comment w="108" collapsed="false">Iterates over each of the keys in a map</comment><header></header><code></code><translations></translations><inputs><input type="%upvar"></input><input type="%l"></input><input type="%ca"></input></inputs><script><block s="doDeclareVariables"><list><l>pairs</l><l>bins</l></list></block><block s="doSetVar"><l>pairs</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doForEach"><l>bin</l><block var="bins"/><script><block s="doForEach"><l>pair</l><block var="bin"/><script><block s="doSetVar"><l>key</l><block s="reportListItem"><l>1</l><block var="pair"/></block></block><block s="doRun"><block var="action"/><list><block s="reportListItem"><l>1</l><block var="pair"/></block></list></block></script></block></script></block></script></block-definition><block-definition s="delete key %&apos;key&apos; of %&apos;hash map&apos;" type="command" category="other"><comment x="0" y="0" w="103.99999999999977" collapsed="false">Removes a key from the map, if it exists</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ["text", "number"]);</l></block><list><block var="key"/></list></block><block s="doDeclareVariables"><list><l>hash</l><l>capacity</l><l>bins</l></list></block><block s="doSetVar"><l>bins</l><block s="reportListItem"><l>2</l><block var="hash map"/></block></block><block s="doSetVar"><l>capacity</l><block s="reportListAttribute"><l><option>length</option></l><block var="bins"/></block></block><block s="doSetVar"><l>hash</l><block s="reportSum"><block s="reportModulus"><block s="reportDifference"><custom-block s="compute hash %txt"><block var="key"/></custom-block><l>1</l></block><block var="capacity"/></block><l>1</l></block></block><block s="doIf"><block s="reportNot"><block s="reportListIsEmpty"><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block></block><script><block s="doWarp"><script><custom-block s="%upvar for each %upvar of %l %ca"><l>index</l><l>pair</l><block s="reportListItem"><block var="hash"/><block var="bins"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="pair"/></block><block var="key"/></block><script><block s="doDeleteFromList"><block var="index"/><block s="reportListItem"><block var="hash"/><block var="bins"/></block></block><block s="doReplaceInList"><block var="hash"/><block var="bins"/><custom-block s="☠︎ link %l"><block s="reportListItem"><block var="hash"/><block var="bins"/></block></custom-block></block><block s="doStopThis"><l><option>this block</option></l></block></script></block></script></custom-block></script></block></script></block></script></block-definition><block-definition s="%&apos;#&apos; for each %&apos;item&apos; of %&apos;data&apos; %&apos;action&apos;" type="command" category="lists"><comment x="0" y="0" w="228.57142857142858" collapsed="false">This block carries out the given script for each item of the given list, like the primitive FOR EACH.&#xD;&#xD;What&apos;s different is that it provides the # variable, which will contain the item number in the list of each item in turn, 1 while processing item 1, and so on.</comment><header></header><code></code><translations>ca:_ per cada _ de _ _&#xD;</translations><inputs><input type="%upvar"></input><input type="%upvar"></input><input type="%l"></input><input type="%ca"></input></inputs><script><block s="doWarp"><script><block s="doIfElse"><custom-block s="☠︎ linked? %l"><block var="data"/></custom-block><script><block s="doSetVar"><l>#</l><l>1</l></block><block s="doUntil"><block s="reportListIsEmpty"><block var="data"/></block><script><block s="doSetVar"><l>item</l><block s="reportListItem"><l>1</l><block var="data"/></block></block><block s="doRun"><block var="action"/><list><block s="reportListItem"><l>1</l><block var="data"/></block></list></block><block s="doSetVar"><l>data</l><block s="reportCDR"><block var="data"/></block></block><block s="doChangeVar"><l>#</l><l>1</l></block></script></block></script><script><block s="doIf"><block s="reportNot"><block s="reportListIsEmpty"><block var="data"/></block></block><script><block s="doFor"><l>i</l><l>1</l><block s="reportListAttribute"><l><option>length</option></l><block var="data"/></block><script><block s="doSetVar"><l>#</l><block var="i"/></block><block s="doSetVar"><l>item</l><block s="reportListItem"><block var="i"/><block var="data"/></block></block><block s="doRun"><block var="action"/><list><block s="reportListItem"><block var="i"/><block var="data"/></block></list></block></script></block></script></block></script></block></script></block></script></block-definition><block-definition s="☠︎ linked? %&apos;data&apos;" type="predicate" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>data</l></list><l>return data.isLinked;</l></block><list><block var="data"/></list></block></block></script></block-definition><block-definition s="☠︎ link %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doIf"><block s="reportListIsEmpty"><block var="data"/></block><script><block s="doReport"><block var="data"/></block></script></block><block s="doReport"><block s="reportCONS"><block s="reportListItem"><l>1</l><block var="data"/></block><block s="reportCDR"><block var="data"/></block></block></block></script></block-definition><block-definition s="size of map %&apos;map&apos;" type="reporter" category="other"><comment x="0" y="0" w="112" collapsed="false">Reports the number of items in the hash map</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="map"/></block></block></script></block-definition><block-definition s="clear map %&apos;hash map&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>initial capacity</l><l>linked lists</l></list></block><block s="doSetVar"><l>initial capacity</l><l>16</l></block><block s="doSetVar"><l>linked lists</l><block s="reportNewList"><list></list></block></block><block s="doWarp"><script><block s="doRepeat"><block var="initial capacity"/><script><block s="doAddToList"><block s="reportNewList"><list></list></block><block var="linked lists"/></block></script></block></script></block><block s="doReplaceInList"><l>1</l><block var="hash map"/><l>0</l></block><block s="doReplaceInList"><l>2</l><block var="hash map"/><block var="linked lists"/></block></script></block-definition></blocks><variables><variable name="map"><list id="1009"><item><l>10</l></item><item><list id="1010"><item><list struct="atomic" id="1011"></list></item><item><list struct="atomic" id="1012"></list></item><item><list linked="linked" id="1013"><item><list struct="atomic" id="1014">Anna,19</list></item></list></item><item><list linked="linked" id="1015"><item><list struct="atomic" id="1016">William,20</list></item></list></item><item><list struct="atomic" id="1017"></list></item><item><list struct="atomic" id="1018"></list></item><item><list linked="linked" id="1019"><item><list struct="atomic" id="1020">Robert,21</list></item></list></item><item><list struct="atomic" id="1021"></list></item><item><list linked="linked" id="1022"><item><list struct="atomic" id="1023">Emma,18</list></item></list></item><item><list linked="linked" id="1024"><item><list struct="atomic" id="1025">Sam,15</list></item></list></item><item><list linked="linked" id="1026"><item><list struct="atomic" id="1027">Tim,19</list></item></list></item><item><list struct="atomic" id="1028"></list></item><item><list struct="atomic" id="1029"></list></item><item><list linked="linked" id="1030"><item><list struct="atomic" id="1031">Aaron,13</list></item></list></item><item><list linked="linked" id="1032"><item><list struct="atomic" id="1033">Paul,33</list></item></list></item><item><list linked="linked" id="1034"><item><list struct="atomic" id="1035">Margaret,34</list></item><item><list struct="atomic" id="1036">John,20</list></item></list></item></list></item></list></variable></variables></project><media name="Hash Map" app="Snap! 6, https://snap.berkeley.edu" version="1"></media></snapdata>