@internal
| 844 | |
| 845 | /** @internal */ |
| 846 | class HashMapImpl<K, V> implements HashMap<K, V> { |
| 847 | readonly [HashMapTypeId]: HashMapTypeId = HashMapTypeId |
| 848 | |
| 849 | _editable: boolean |
| 850 | _edit: number |
| 851 | _root: Node<K, V> |
| 852 | _size: number |
| 853 | |
| 854 | constructor( |
| 855 | editable: boolean, |
| 856 | edit: number, |
| 857 | root: Node<K, V>, |
| 858 | size: number |
| 859 | ) { |
| 860 | this._editable = editable |
| 861 | this._edit = edit |
| 862 | this._root = root |
| 863 | this._size = size |
| 864 | } |
| 865 | |
| 866 | get size(): number { |
| 867 | return this._size |
| 868 | } |
| 869 | |
| 870 | [Symbol.iterator](): IterableIterator<[K, V]> { |
| 871 | return new HashMapIterator(this._root, toEntry) |
| 872 | } |
| 873 | |
| 874 | [Equal_.symbol](that: Equal_.Equal): boolean { |
| 875 | if (isHashMap(that)) { |
| 876 | const thatImpl = that as HashMapImpl<K, V> |
| 877 | if (this.size !== thatImpl.size) { |
| 878 | return false |
| 879 | } |
| 880 | for (const [key, value] of this) { |
| 881 | const otherValue = pipe(that, get(key)) |
| 882 | if (Option.isNone(otherValue) || !Equal_.equals(value, otherValue.value)) { |
| 883 | return false |
| 884 | } |
| 885 | } |
| 886 | return true |
| 887 | } |
| 888 | return false |
| 889 | } |
| 890 | |
| 891 | [Hash.symbol](): number { |
| 892 | return Hash.optimize(hashMapSeed ^ this._root.subtreeHash()) |
| 893 | } |
| 894 | |
| 895 | [NodeInspectSymbol](): unknown { |
| 896 | return toJson(this) |
| 897 | } |
| 898 | |
| 899 | toString(): string { |
| 900 | return `HashMap(${format(Array.from(this))})` |
| 901 | } |
| 902 | |
| 903 | toJSON(): unknown { |
nothing calls this directly
no outgoing calls
no test coverage detected