| 897 | |
| 898 | /** @internal */ |
| 899 | export const fromIterable = <K, V>(entries: Iterable<readonly [K, V]>): HashMap<K, V> => { |
| 900 | let root: Node<K, V> = emptyNode |
| 901 | let size = 0 |
| 902 | const added = { value: false } |
| 903 | |
| 904 | for (const [key, value] of entries) { |
| 905 | const hash = Hash.hash(key) |
| 906 | added.value = false |
| 907 | root = root.set(NaN, 0, hash, key, value, added) |
| 908 | if (added.value) { |
| 909 | size++ |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | return new HashMapImpl(false, 0, root, size) |
| 914 | } |
| 915 | |
| 916 | /** @internal */ |
| 917 | export const isEmpty = <K, V>(self: HashMap<K, V>): boolean => (self as HashMapImpl<K, V>).size === 0 |