Skip to content

Commit

Permalink
reformat cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
heckj committed Aug 23, 2022
1 parent e83cd90 commit 25d4f67
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Sources/CRDT/GCounter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Foundation
public struct GCounter<ActorID: Hashable & Comparable> {
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 {
Expand All @@ -24,7 +24,7 @@ public struct GCounter<ActorID: Hashable & Comparable> {
}
return _storage
}

/// Creates a new counter.
/// - Parameters:
/// - value: An optional parameter to set an initial counter value.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions Sources/CRDT/GSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ import Foundation
public struct GSet<ActorID: Hashable & Comparable, T: Hashable> {
private var _storage: Set<T>
internal var currentTimestamp: LamportTimestamp<ActorID>

/// The set of values.
public var values: Set<T> {
_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 {
Expand Down Expand Up @@ -72,7 +72,7 @@ extension GSet: DeltaCRDT {
public struct GSetState {
let values: Set<T>
}

/// A struct that represents the differences to be merged to replicate the set.
public struct GSetDelta {
let lamportClock: LamportTimestamp<ActorID>
Expand Down
4 changes: 2 additions & 2 deletions Sources/CRDT/LWWRegister.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct LWWRegister<ActorID: Hashable & Comparable, T> {
}

// 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.
Expand All @@ -36,7 +36,7 @@ public struct LWWRegister<ActorID: Hashable & Comparable, T> {

private var _storage: Atom
internal let selfId: ActorID

/// The value of the register.
public var value: T {
get {
Expand Down
4 changes: 2 additions & 2 deletions Sources/CRDT/ORSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct ORSet<ActorID: Hashable & Comparable, T: Hashable> {
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
Expand All @@ -80,7 +80,7 @@ public struct ORSet<ActorID: Hashable & Comparable, T: Hashable> {

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.
Expand Down
8 changes: 4 additions & 4 deletions Sources/CRDT/PNCounter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public struct PNCounter<ActorID: Hashable & Comparable> {
@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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25d4f67

Please sign in to comment.