You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An implementation of [Mergeable Replicated Data Types](https://doi.org/10.1145/3360580) (MRDTs) for Swift collection types, as introduced by Kaki et al. (OOPSLA 2019).
6
6
@@ -26,7 +26,7 @@ let merged = Set.merge(
26
26
left: ["a", "c"], // removed "b", added "c"
27
27
right: ["a", "b", "d"] // added "d"
28
28
)
29
-
// ["a", "c", "d"]
29
+
//=> ["a", "c", "d"]
30
30
```
31
31
32
32
### Ordered Set
@@ -40,7 +40,7 @@ let merged = OrderedSet.merge(
40
40
right: ["a", "b", "d", "c"], // swapped "c" and "d"
41
41
options: .init(isOrderedBeforeWhenConflicting: <)
42
42
)
43
-
// ["b", "a", "d", "c"]
43
+
//=> ["b", "a", "d", "c"]
44
44
```
45
45
46
46
A deterministic comparator is required to resolve ordering conflicts when the relative order of two elements cannot be determined from the merge inputs alone:
@@ -52,7 +52,7 @@ let merged = OrderedSet.merge(
52
52
right: ["a", "b", "y"], // added "y"
53
53
options: .init(isOrderedBeforeWhenConflicting: <)
54
54
)
55
-
// ["a", "b", "x", "y"]
55
+
//=> ["a", "b", "x", "y"]
56
56
```
57
57
58
58
### Dictionary
@@ -66,7 +66,7 @@ let merged = Dictionary.merge(
66
66
right: ["a":5, "b":2], // changed "a"
67
67
options: .init(mergeValue: { left, right inmax(left, right) })
68
68
)
69
-
// ["a": 5, "b": 2, "c": 4]
69
+
//=> ["a": 5, "b": 2, "c": 4]
70
70
```
71
71
72
72
For more control, separate closures can be provided for concurrent edits (where the base value is available) and concurrent insertions:
@@ -85,7 +85,7 @@ let merged = Dictionary.merge(
85
85
}
86
86
)
87
87
)
88
-
// ["a": 7, "b": 20]
88
+
//=> ["a": 7, "b": 20]
89
89
```
90
90
91
91
### Ordered Dictionary
@@ -102,7 +102,7 @@ let merged = OrderedDictionary.merge(
102
102
mergeValue: { left, right in [left, right].sorted().joined(separator: "|") }
0 commit comments