Doc string

drew/mqtt-clients
Drew Bednar 4 months ago
parent c2cc2e6a81
commit 872213900a

@ -73,6 +73,27 @@ func (vc *VectorClock[T]) Sync(v VectorClock[T]) ([]T, error) {
return vc.GetClock(), nil
}
// Increment increments the logical time at the specified index of the vector clock.
//
// This method updates the logical time for a given process (specified by the index) by
// incrementing the corresponding value in the vector clock. It ensures that the index
// is within the bounds of the vector clock. If the index is out of bounds or the vector
// clock is uninitialized, an error is returned.
//
// Parameters:
//
// index (int): The index of the process whose logical time is to be incremented.
// It must be within the range of the vector clock's length.
//
// Returns:
//
// []T: A copy of the updated vector clock after the logical time at the given index
// has been incremented.
//
// error: An error is returned if the index is out of bounds or the vector clock is uninitialized.
//
// Note: Handling of potential overflow for the underlying type T (uint32 or uint64) is currently
// not implemented and should be handled accordingly if required.
func (vc *VectorClock[T]) Increment(index int) ([]T, error) {
if index > len(vc.clock) || vc.clock == nil {
return nil, errors.New(fmt.Sprintf("Cannot access index: %d, clock is of length %d", index, len(vc.clock)))

Loading…
Cancel
Save