5 // bounds encapsulates the window of search for a single iteration of binary
8 // Callers may choose to treat the return values from Left() and Right() as
9 // inclusive or exclusive. *bounds makes no assumptions on the inclusivity of
12 // See: *gitobj/pack.Index for more.
14 // left is the left or lower bound of the bounds.
16 // right is the rightmost or upper bound of the bounds.
20 // newBounds returns a new *bounds instance with the given left and right
22 func newBounds(left, right int64) *bounds {
29 // Left returns the leftmost value or lower bound of this *bounds instance.
30 func (b *bounds) Left() int64 {
34 // right returns the rightmost value or upper bound of this *bounds instance.
35 func (b *bounds) Right() int64 {
39 // WithLeft returns a new copy of this *bounds instance, replacing the left
40 // value with the given argument.
41 func (b *bounds) WithLeft(new int64) *bounds {
48 // WithRight returns a new copy of this *bounds instance, replacing the right
49 // value with the given argument.
50 func (b *bounds) WithRight(new int64) *bounds {
57 // Equal returns whether or not the receiving *bounds instance is equal to the
60 // - If both the argument and receiver are nil, they are given to be equal.
61 // - If both the argument and receiver are not nil, and they share the same
62 // Left() and Right() values, they are equal.
63 // - If both the argument and receiver are not nil, but they do not share the
64 // same Left() and Right() values, they are not equal.
65 // - If either the argument or receiver is nil, but the other is not, they are
67 func (b *bounds) Equal(other *bounds) bool {
79 return b.left == other.left &&
80 b.right == other.right
83 // String returns a string representation of this bounds instance, given as:
86 func (b *bounds) String() string {
87 return fmt.Sprintf("[%d,%d]", b.Left(), b.Right())