From 25d4f67e85d2afff10ec2cf924402c9e5812e6f2 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Tue, 23 Aug 2022 16:34:06 -0700 Subject: [PATCH] reformat cleanup --- Sources/CRDT/GCounter.swift | 8 ++++---- Sources/CRDT/GSet.swift | 10 +++++----- Sources/CRDT/LWWRegister.swift | 4 ++-- Sources/CRDT/ORSet.swift | 4 ++-- Sources/CRDT/PNCounter.swift | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Sources/CRDT/GCounter.swift b/Sources/CRDT/GCounter.swift index a00eb14..e88f6ef 100644 --- a/Sources/CRDT/GCounter.swift +++ b/Sources/CRDT/GCounter.swift @@ -10,12 +10,12 @@ import Foundation public struct GCounter { private var _storage: UInt internal let selfId: ActorID - + /// The counter's value. public var value: UInt { _storage } - + /// Increments the counter. @discardableResult public mutating func increment() -> UInt { @@ -24,7 +24,7 @@ public struct GCounter { } return _storage } - + /// Creates a new counter. /// - Parameters: /// - value: An optional parameter to set an initial counter value. @@ -52,7 +52,7 @@ extension GCounter: DeltaCRDT { _storage } } - + /// Computes and returns a diff from the current state of the counter to be used to update another instance. /// /// - Parameter state: The optional state of the remote CRDT. diff --git a/Sources/CRDT/GSet.swift b/Sources/CRDT/GSet.swift index 6de1672..52242b1 100644 --- a/Sources/CRDT/GSet.swift +++ b/Sources/CRDT/GSet.swift @@ -10,24 +10,24 @@ import Foundation public struct GSet { private var _storage: Set internal var currentTimestamp: LamportTimestamp - + /// The set of values. public var values: Set { _storage } - + /// The number of items in the set. public var count: Int { _storage.count } - + /// Inserts a new value into the set. /// - Parameter value: The value to insert. public mutating func insert(_ value: T) { _storage.insert(value) currentTimestamp.tick() } - + /// Returns a Boolean value that indicates whether the set contains the value you provide. /// - Parameter value: The value to compare. public func contains(_ value: T) -> Bool { @@ -72,7 +72,7 @@ extension GSet: DeltaCRDT { public struct GSetState { let values: Set } - + /// A struct that represents the differences to be merged to replicate the set. public struct GSetDelta { let lamportClock: LamportTimestamp diff --git a/Sources/CRDT/LWWRegister.swift b/Sources/CRDT/LWWRegister.swift index 56df23a..ddce769 100644 --- a/Sources/CRDT/LWWRegister.swift +++ b/Sources/CRDT/LWWRegister.swift @@ -22,7 +22,7 @@ public struct LWWRegister { } // MARK: Conformance of LWWRegister.Atom to PartiallyOrderable - + /// Returns a Boolean value that indicates if the atom is less-than or equal to another atom. /// - Parameters: /// - lhs: The first atom to compare. @@ -36,7 +36,7 @@ public struct LWWRegister { private var _storage: Atom internal let selfId: ActorID - + /// The value of the register. public var value: T { get { diff --git a/Sources/CRDT/ORSet.swift b/Sources/CRDT/ORSet.swift index b97b4cf..1ac440c 100644 --- a/Sources/CRDT/ORSet.swift +++ b/Sources/CRDT/ORSet.swift @@ -56,7 +56,7 @@ public struct ORSet { public func contains(_ value: T) -> Bool { !(metadataByValue[value]?.isDeleted ?? true) } - + /// The number of items in the set. public var count: Int { metadataByValue.filter { !$1.isDeleted }.count @@ -80,7 +80,7 @@ public struct ORSet { return isNewInsert } - + /// Removes a value from the set. /// - Parameter value: The value to remove. /// - Returns: The value removed from the set, or `nil` if the value didn't exist. diff --git a/Sources/CRDT/PNCounter.swift b/Sources/CRDT/PNCounter.swift index 7e25147..7ab7ecb 100644 --- a/Sources/CRDT/PNCounter.swift +++ b/Sources/CRDT/PNCounter.swift @@ -28,16 +28,16 @@ public struct PNCounter { @discardableResult public mutating func increment() -> Int { pos_value += 1 - return self.value + return value } /// Decrements the counter. @discardableResult public mutating func decrement() -> Int { neg_value += 1 - return self.value + return value } - + /// Creates a new counter. /// - Parameters: /// - value: An optional parameter to set an initial counter value. @@ -68,7 +68,7 @@ extension PNCounter: Replicable { extension PNCounter: DeltaCRDT { // public typealias DeltaState = Self.Atom // public typealias Delta = Self.Atom - + /// A struct that represents the state of a PNCounter. public struct PNCounterState { let pos: UInt