Insert returns a new bit slice with N false elements inserted starting at given index. This must be a copy given the nature of the 8-bit aliasing.
(start, n int)
| 197 | // Insert returns a new bit slice with N false elements inserted starting at given index. |
| 198 | // This must be a copy given the nature of the 8-bit aliasing. |
| 199 | func (bs *Slice) Insert(start, n int) Slice { |
| 200 | ln := bs.Len() |
| 201 | if n <= 0 { |
| 202 | panic("bitslice.Insert: n <= 0") |
| 203 | } |
| 204 | if start > ln { |
| 205 | panic("bitslice.Insert: start index greater than length") |
| 206 | } |
| 207 | nln := ln + n |
| 208 | ss := Make(nln, 0) |
| 209 | for i := 0; i < start; i++ { |
| 210 | ss.Set(i, bs.Index(i)) |
| 211 | } |
| 212 | for i := start; i < ln; i++ { |
| 213 | ss.Set(i+n, bs.Index(i)) |
| 214 | } |
| 215 | return ss |
| 216 | } |
| 217 | |
| 218 | // String satisfies the fmt.Stringer interface |
| 219 | func (bs *Slice) String() string { |