1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Package diff provides a diff implementation
// for finite, indexable sequences with comparable elements
package diff
import (
bits "0dev.org/bits"
)
// Interface abstracts the required knowledge to perform a diff
// on any two comparable, fixed-length sequences
type Interface interface {
// The sequences' lengths
Len() (int, int)
// True when the sequences' elements at those indices are equal
Equal(int, int) bool
}
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Package diff provides a diff algorithm implementation
// for finite, indexable sequences with comparable elements.
package diff
import (
bits "0dev.org/bits"
)
// Interface abstracts the required knowledge to perform a diff
// on any two fixed-length sequences with comparable elements.
type Interface interface {
// The sequences' lengths
Len() (int, int)
// True when the sequences' elements at those indices are equal
Equal(int, int) bool
}
|
124
125
126
127
128
129
130
|
}
} else { // End of current of match
inMatch = false // ... and reset the current one
}
}
return
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
}
} else { // End of current of match
inMatch = false // ... and reset the current one
}
}
return
}
// A diff.Interface implementation with plugable Equal function
type D struct {
Len1, Len2 int
EqualFunc func(i, j int) bool
}
// Required per diff.Interface
func (d D) Len() (int, int) {
return d.Len1, d.Len2
}
// Required per diff.Interface
func (d D) Equal(i, j int) bool {
return d.EqualFunc(i, j)
}
|