blob: 9971c65cbed267e6d7b1d52a86f4541aaf27b5df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class CvRDT:
pass
class Counter(CvRDT):
def __init__(self, count = 0): # constructor function
self._count = count
def value(self): # query function
return self._count
def increment(self): # update function
self._count += 1
def compare(self, other): # comparison function
return self.value() <= other.value()
def merge(self, other): # merge function
return Counter(max(self.value(), other.value()))
|