Check-in [67794bdf14]
Overview
Comment:Added diff.D struct; Added an RFC1978 Predictor compressor implementation and a test
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67794bdf1483c0173b3b095a2b723e53fb25dc2d
User & Date: spaskalev on 2014-12-15 21:22:10.885
Other Links: manifest | tags
Context
2014-12-16
01:55
Added hamming weight lookup table for bytes in package bits. Added a PoC predictor decompressor implementation check-in: 60ca5b4b7b user: spaskalev tags: trunk
2014-12-15
21:22
Added diff.D struct; Added an RFC1978 Predictor compressor implementation and a test check-in: 67794bdf14 user: spaskalev tags: trunk
2014-12-14
20:41
Buffer stdout, use os.Args instead of flag check-in: 074a26f76b user: spaskalev tags: trunk
Changes
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)
}