MCPcopy
hub / github.com/Effect-TS/effect / CollisionNode

Class CollisionNode

packages/effect/src/internal/hashMap/node.ts:106–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105/** @internal */
106export class CollisionNode<out K, out V> {
107 readonly _tag = "CollisionNode"
108
109 constructor(
110 readonly edit: number,
111 readonly hash: number,
112 readonly children: Array<Node<K, V>>
113 ) {}
114
115 modify(
116 edit: number,
117 shift: number,
118 f: HashMap.UpdateFn<V>,
119 hash: number,
120 key: K,
121 size: SizeRef
122 ): Node<K, V> {
123 if (hash === this.hash) {
124 const canEdit = canEditNode(this, edit)
125 const list = this.updateCollisionList(
126 canEdit,
127 edit,
128 this.hash,
129 this.children,
130 f,
131 key,
132 size
133 )
134 if (list === this.children) return this
135
136 return list.length > 1 ? new CollisionNode(edit, this.hash, list) : list[0]! // collapse single element collision list
137 }
138 const v = f(O.none())
139 if (O.isNone(v)) return this
140 ++size.value
141 return mergeLeaves(
142 edit,
143 shift,
144 this.hash,
145 this,
146 hash,
147 new LeafNode(edit, hash, key, v)
148 )
149 }
150
151 updateCollisionList(
152 mutate: boolean,
153 edit: number,
154 hash: number,
155 list: Array<Node<K, V>>,
156 f: HashMap.UpdateFn<V>,
157 key: K,
158 size: SizeRef
159 ) {
160 const len = list.length
161 for (let i = 0; i < len; ++i) {
162 const child = list[i]!
163 if ("key" in child && equals(key, child.key)) {

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…