MV-Register Merge
MV-Register Merge
A multi-value register (MV-Register) stores all concurrent values. Each value is tagged with a vector clock.
To merge two registers:
- Combine all versions from both registers.
- Discard any version whose vector clock is dominated by another version.
- If two versions have equal clocks and values, keep one copy.
Return the remaining versions sorted by Value ascending.
Types
type MVValue struct {
Value string
VC []int
}
Function signature
func MergeMVRegister(a, b []MVValue) []MVValue
Example
a = [{Value:"x", VC:[1,0]}, {Value:"y", VC:[0,1]}]
b = [{Value:"z", VC:[2,0]}]
"z" dominates "x", so result = [{"y", [0,1]}, {"z", [2,0]}]
Constraints
0 <= len(a), len(b) <= 10000- Vector clocks may differ in length; missing entries are treated as 0.
Run tests to see results
No issues detected