DotVector

extension DotVector
  • Search for a given counter key in the version vector.

    Declaration

    Swift

    internal func search(_ key: String) -> Index

    Parameters

    key

    the counter to locate

    Return Value

    the index in the vector where the counter key should be to stay ordered

  • Locate the counter for the given key, returning 0 if not found

    Declaration

    Swift

    internal func counter(of key: String) -> UInt64

    Parameters

    key

    the key to look for

    Return Value

    the counter value if found or nil

  • Create new instance holding a version vector with the counter for the given key incremented by one.

    Declaration

    Swift

    internal func inc(_ key: String) -> Array<Element>

    Parameters

    key

    the key of the counter to increment

    Return Value

    new VersionVector instance

  • Determine if this version vector descends from another.

    Declaration

    Swift

    internal func descends(_ other: `Self`) -> Bool

    Parameters

    rhs

    the version vector to check against

    Return Value

    true if this instance descends from or is equal to other

  • Generate a Dot instance using the counter + 1 for the given key

    Declaration

    Swift

    internal func dot(of key: String) -> Dot

    Parameters

    key

    the key of the counter to use

    Return Value

    new Dot instance

  • Merge two Dot collections. Resulting collection of Dot entities will be ordered by their id value and counters will be the max value found in both collections.

    Declaration

    Swift

    internal func merge(_ other: `Self`) -> Array<Element>

    Parameters

    other

    the collection to merge with

    Return Value

    new collection of Dot instances