MCPcopy Create free account
hub / github.com/effect-app/libs / HashMapImpl

Class HashMapImpl

repos/effect/packages/effect/src/internal/hashMap.ts:805–876  ·  view source on GitHub ↗

@internal

Source from the content-addressed store, hash-verified

803
804/** @internal */
805class HashMapImpl<K, V> implements HashMap<K, V> {
806 readonly [HashMapTypeId]: HashMapTypeId = HashMapTypeId
807
808 _editable: boolean
809 _edit: number
810 _root: Node<K, V>
811 _size: number
812
813 constructor(
814 editable: boolean,
815 edit: number,
816 root: Node<K, V>,
817 size: number
818 ) {
819 this._editable = editable
820 this._edit = edit
821 this._root = root
822 this._size = size
823 }
824
825 get size(): number {
826 return this._size
827 }
828
829 [Symbol.iterator](): Iterator<[K, V]> {
830 return this._root.iterator()
831 }
832
833 [Equal_.symbol](that: Equal_.Equal): boolean {
834 if (isHashMap(that)) {
835 const thatImpl = that as HashMapImpl<K, V>
836 if (this.size !== thatImpl.size) {
837 return false
838 }
839 for (const [key, value] of this) {
840 const otherValue = pipe(that, get(key))
841 if (Option.isNone(otherValue) || !Equal_.equals(value, otherValue.value)) {
842 return false
843 }
844 }
845 return true
846 }
847 return false
848 }
849
850 [Hash.symbol](): number {
851 let hash = Hash.string("HashMap")
852 for (const [key, value] of this) {
853 hash = hash ^ (Hash.hash(key) + Hash.hash(value))
854 }
855 return hash
856 }
857
858 [NodeInspectSymbol](): unknown {
859 return toJson(this)
860 }
861
862 toString(): string {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…