mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-12-13 15:01:58 +01:00
20 lines
489 B
Go
20 lines
489 B
Go
|
package roaring
|
||
|
|
||
|
import (
|
||
|
"encoding/binary"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
// writeTo for runContainer16 follows this
|
||
|
// spec: https://github.com/RoaringBitmap/RoaringFormatSpec
|
||
|
//
|
||
|
func (b *runContainer16) writeTo(stream io.Writer) (int, error) {
|
||
|
buf := make([]byte, 2+4*len(b.iv))
|
||
|
binary.LittleEndian.PutUint16(buf[0:], uint16(len(b.iv)))
|
||
|
for i, v := range b.iv {
|
||
|
binary.LittleEndian.PutUint16(buf[2+i*4:], v.start)
|
||
|
binary.LittleEndian.PutUint16(buf[2+2+i*4:], v.length)
|
||
|
}
|
||
|
return stream.Write(buf)
|
||
|
}
|