OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package lzw | 5 package lzw |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "errors" | 9 "errors" |
10 "fmt" | 10 "fmt" |
11 "io" | 11 "io" |
12 ) | 12 ) |
13 | 13 |
14 // A writer is a buffered, flushable writer. | 14 // A writer is a buffered, flushable writer. |
15 type writer interface { | 15 type writer interface { |
16 » WriteByte(byte) error | 16 » io.ByteWriter |
17 Flush() error | 17 Flush() error |
18 } | 18 } |
19 | 19 |
20 // An errWriteCloser is an io.WriteCloser that always returns a given error. | 20 // An errWriteCloser is an io.WriteCloser that always returns a given error. |
21 type errWriteCloser struct { | 21 type errWriteCloser struct { |
22 err error | 22 err error |
23 } | 23 } |
24 | 24 |
25 func (e *errWriteCloser) Write([]byte) (int, error) { | 25 func (e *errWriteCloser) Write([]byte) (int, error) { |
26 return 0, e.err | 26 return 0, e.err |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 w: bw, | 253 w: bw, |
254 order: order, | 254 order: order, |
255 write: write, | 255 write: write, |
256 width: 1 + lw, | 256 width: 1 + lw, |
257 litWidth: lw, | 257 litWidth: lw, |
258 hi: 1<<lw + 1, | 258 hi: 1<<lw + 1, |
259 overflow: 1 << (lw + 1), | 259 overflow: 1 << (lw + 1), |
260 savedCode: invalidCode, | 260 savedCode: invalidCode, |
261 } | 261 } |
262 } | 262 } |
OLD | NEW |