| 934 | |
| 935 | /** @internal */ |
| 936 | export const fromIterable = <K, V>(entries: Iterable<readonly [K, V]>): HashMap<K, V> => { |
| 937 | let root: Node<K, V> = emptyNode |
| 938 | let size = 0 |
| 939 | const added = { value: false } |
| 940 | |
| 941 | for (const [key, value] of entries) { |
| 942 | const hash = Hash.hash(key) | 0 |
| 943 | added.value = false |
| 944 | root = root.set(NaN, 0, hash, key, value, added) |
| 945 | if (added.value) { |
| 946 | size++ |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | return new HashMapImpl(false, 0, root, size) |
| 951 | } |
| 952 | |
| 953 | /** @internal */ |
| 954 | export const isEmpty = <K, V>(self: HashMap<K, V>): boolean => (self as HashMapImpl<K, V>).size === 0 |