LEFT | RIGHT |
(no file at all) | |
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 bzip2 | 5 package bzip2 |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "io" | 9 "io" |
10 ) | 10 ) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 func (br *bitReader) ReadBits(bits uint) (n int) { | 70 func (br *bitReader) ReadBits(bits uint) (n int) { |
71 n64 := br.ReadBits64(bits) | 71 n64 := br.ReadBits64(bits) |
72 return int(n64) | 72 return int(n64) |
73 } | 73 } |
74 | 74 |
75 func (br *bitReader) ReadBit() bool { | 75 func (br *bitReader) ReadBit() bool { |
76 n := br.ReadBits(1) | 76 n := br.ReadBits(1) |
77 return n != 0 | 77 return n != 0 |
78 } | 78 } |
79 | 79 |
| 80 func (br *bitReader) TryReadBit() (bit byte, ok bool) { |
| 81 if br.bits > 0 { |
| 82 br.bits-- |
| 83 return byte(br.n>>br.bits) & 1, true |
| 84 } |
| 85 return 0, false |
| 86 } |
| 87 |
80 func (br *bitReader) Err() error { | 88 func (br *bitReader) Err() error { |
81 return br.err | 89 return br.err |
82 } | 90 } |
LEFT | RIGHT |