Marshal takes a dense or sparse bit array and serializes it to a byte slice.
(ba BitArray)
| 26 | // Marshal takes a dense or sparse bit array and serializes it to a |
| 27 | // byte slice. |
| 28 | func Marshal(ba BitArray) ([]byte, error) { |
| 29 | if eba, ok := ba.(*bitArray); ok { |
| 30 | return eba.Serialize() |
| 31 | } else if sba, ok := ba.(*sparseBitArray); ok { |
| 32 | return sba.Serialize() |
| 33 | } else { |
| 34 | return nil, errors.New("not a valid BitArray") |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // Unmarshal takes a byte slice, of the same format produced by Marshal, |
| 39 | // and returns a BitArray. |
searching dependent graphs…