I have a use case where we need to store timestamped data, split off everything before time.Now(), then iterate that split in ascending order in its entirety. I've made a couple improvements to the treap to accomplish this. Would you like to merge them back in?
The nil pivot short-circuit around the compare method was yielding about a 35% increase in performance for my particular use case. My comparison function is about as simple as you can compare timestamps:
func compare(a, b interface{}) int {
pA := a.(myItem)
pB := b.(myItem)
if pA.Timestamp.Equal(pB.Timestamp) {
return 0
}
if pA.Timestamp.Before(pB.Timestamp) {
return -1
}
return 1
}
Hi,
I have a use case where we need to store timestamped data, split off everything before
time.Now()
, then iterate that split in ascending order in its entirety. I've made a couple improvements to the treap to accomplish this. Would you like to merge them back in?The nil pivot short-circuit around the compare method was yielding about a 35% increase in performance for my particular use case. My comparison function is about as simple as you can compare timestamps: