I tried, but it won't work. The reason is that IncrementAtEnd is for range key. If we encountered an RangeKey in any of the slots, we would need to increment at the end. That's why we need to always OR it with previous results.

IncremenKey is for single key, and we would increment at end ONLY IF we are at the last slot. I previously tried use the index to determine if it are at the last slot, but the "break" statement above would cause the loop to break out before we hit the slotEndIndex. As a result, we are using two different flag to keep track of these two different situation.

I think once we include a true/false map, then it would be more clear.

I am adding some tests for the SetKey method specifically.