A Question #30
-
I am implementing the art tree step by step according to the code of this project. In the process, I have a question that I haven't figured out yet and I would like to ask. That is, the processing of the According to my understanding, the storage logic of
func (a *artNode[T]) index (c byte) int {
switch a.kind {
case Node4:
node := a.node4()
for index := 0; index < int(node.childrenNum); index++ {
if node.keys[index] == c {
return index
}
}
case Node16:
node := a.node16()
bitfield := uint(0)
for index := uint(0); index < node16Max; index++ {
if node.keys[index] == c {
bitfield |= 1 << index
}
}
mask := (1 << node.childrenNum) - 1
bitfield &= uint(mask)
if bitfield != 0 {
return bits.TrailingZeros(bitfield)
}
...
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This was an attempt to save memory, but it wasn't worth it. See the updated version. I recently refactored the code significantly. |
Beta Was this translation helpful? Give feedback.
This was an attempt to save memory, but it wasn't worth it. See the updated version. I recently refactored the code significantly.