<commit_before>// Copyright (C) 2015 The Protocol Authors.

package protocol

// The Vector type represents v version vector. The zero value is v usable
// version vector. The vector has slice semantics and some operations on it
// are "append-like" in that they may return the same vector modified, or v
// new allocated Vector with the modified contents.
type Vector []Counter

// Counter represents v single counter in the version vector.
type Counter struct {
	ID    uint64
	Value uint64
}

// Update returns v Vector with the index for the specific ID incremented by
// one. If it is possible, the vector v is updated and returned. If it is not,
// v copy will be created, updated and returned.
func (v Vector) Update(ID uint64) Vector {
	for i := range v {
		if v[i].ID == ID {
			// Update an existing index
			v[i].Value++
			return v
		} else if v[i].ID > ID {
			// Insert v new index
			nv := make(Vector, len(v)+1)
			copy(nv, v[:i])
			nv[i].ID = ID
			nv[i].Value = 1
			copy(nv[i+1:], v[i:])
			return nv
		}
	}
	// Append v new new index
	return append(v, Counter{ID, 1})
}

// Merge returns the vector containing the maximum indexes from v and b. If it
// is possible, the vector v is updated and returned. If it is not, v copy
// will be created, updated and returned.
func (v Vector) Merge(b Vector) Vector {
	var vi, bi int
	for bi < len(b) {
		if vi == len(v) {
			// We've reach the end of v, all that remains are appends
			return append(v, b[bi:]...)
		}
<commit_msg>Unbreak comments<commit_after>// Copyright (C) 2015 The Protocol Authors.

package protocol

// The Vector type represents a version vector. The zero value is a usable
// version vector. The vector has slice semantics and some operations on it
// are "append-like" in that they may return the same vector modified, or v
// new allocated Vector with the modified contents.
type Vector []Counter

// Counter represents a single counter in the version vector.
type Counter struct {
	ID    uint64
	Value uint64
}

// Update returns a Vector with the index for the specific ID incremented by
// one. If it is possible, the vector v is updated and returned. If it is not,
// a copy will be created, updated and returned.
func (v Vector) Update(ID uint64) Vector {
	for i := range v {
		if v[i].ID == ID {
			// Update an existing index
			v[i].Value++
			return v
		} else if v[i].ID > ID {
			// Insert a new index
			nv := make(Vector, len(v)+1)
			copy(nv, v[:i])
			nv[i].ID = ID
			nv[i].Value = 1
			copy(nv[i+1:], v[i:])
			return nv
		}
	}
	// Append a new index
	return append(v, Counter{ID, 1})
}

// Merge returns the vector containing the maximum indexes from v and b. If it
// is possible, the vector v is updated and returned. If it is not, a copy
// will be created, updated and returned.
func (v Vector) Merge(b Vector) Vector {
	var vi, bi int
	for bi < len(b) {
		if vi == len(v) {
			// We've reach the end of v, all that remains are appends
			return append(v, b[bi:]...)
		}

{'fraction_non_alphanumeric': 0.1039919490103992, 'fraction_numerical': 0.009392821200939282, 'mean_word_length': 2.960159362549801, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4189736', 'n_tokens_mistral': 1010, 'n_tokens_neox': 917, 'n_words': 450}