Vector clocks record one logical counter per process. Comparing two clocks reveals whether one event causally precedes the other, whether they are equal, or whether they represent concurrent events.
Design a VectorClockComparator class:
VectorClockComparator() creates a stateless comparator.String compare(int[] a, int[] b) returns the relationship of a to b.
Return exactly one of these strings:
"before" when a[i] <= b[i] for every i and at least one component is smaller."after" when a[i] >= b[i] for every i and at least one component is greater."equal" when every component matches."concurrent" when neither vector dominates the other.
Example 1:
Input:
Output:
Explanation: a never exceeds b, and its second component is smaller.
Example 2:
Input:
Output:
Explanation: a is greater in component 1 while b is greater in component 0. Neither vector dominates the other.
Constraints
1 <= a.length == b.length <= 10^50 <= a[i], b[i] <= 10^9- Return one of the four lowercase relationship strings exactly as specified.
- At most
100 calls are made to compare.