| 135 | } |
| 136 | |
| 137 | public IPersistentMap assoc(Object key, Object val){ |
| 138 | if(key == null) { |
| 139 | if(hasNull && val == nullValue) |
| 140 | return this; |
| 141 | return new PersistentHashMap(meta(), hasNull ? count : count + 1, root, true, val); |
| 142 | } |
| 143 | Box addedLeaf = new Box(null); |
| 144 | INode newroot = (root == null ? BitmapIndexedNode.EMPTY : root) |
| 145 | .assoc(0, hash(key), key, val, addedLeaf); |
| 146 | if(newroot == root) |
| 147 | return this; |
| 148 | return new PersistentHashMap(meta(), addedLeaf.val == null ? count : count + 1, newroot, hasNull, nullValue); |
| 149 | } |
| 150 | |
| 151 | public Object valAt(Object key, Object notFound){ |
| 152 | if(key == null) |