ByteBuffer.Truncate(n int)

R=r
DELTA=22  (17 added, 0 deleted, 5 changed)
OCL=28781
CL=28815
This commit is contained in:
Robert Griesemer 2009-05-14 10:14:29 -07:00
parent a8db4593ab
commit 28db3e8411
2 changed files with 22 additions and 5 deletions

View file

@ -39,9 +39,17 @@ func (b *ByteBuffer) Len() int {
return len(b.buf) - b.off
}
// Truncates the buffer so it contains n bytes.
// It preserves the data in the buffer at positions [0 : n].
// It is an error to call b.Truncate(n) with n > b.Len().
func (b *ByteBuffer) Truncate(n int) {
b.buf = b.buf[0 : b.off + n];
}
// Reset resets the buffer so it has no content.
// b.Reset() is the same as b.Truncate(0).
func (b *ByteBuffer) Reset() {
b.off = len(b.buf)
b.buf = b.buf[0 : b.off];
}
// Write appends the contents of p to the buffer. The return