Skip to content

Commit

Permalink
Add generic uint64SliceAsByteSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Bilas authored and maciej committed Jan 31, 2018
1 parent e488a0b commit d3a8c12
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions serialization_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func (bc *bitmapContainer) asLittleEndianByteSlice() []byte {
return by
}

func uint64SliceAsByteSlice(slice []uint64) []byte {
by := make([]byte, len(slice)*8)

for i, v := range slice {
binary.LittleEndian.PutUint64(by[i*8:], v)
}

return by
}

func byteSliceAsUint16Slice(slice []byte) []uint16 {
if len(slice)%2 != 0 {
panic("Slice size should be divisible by 2")
Expand Down

0 comments on commit d3a8c12

Please sign in to comment.