MCPcopy Create free account
hub / github.com/cogentcore/core / Insert

Method Insert

tensor/bitslice/bitslice.go:199–216  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
199func (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
219func (bs *Slice) String() string {

Callers 9

TestBitSlice10Function · 0.45
InsertColumnMethod · 0.45
linesInsertedMethod · 0.45
ApplyOneDiffFunction · 0.45
insertTextImplMethod · 0.45
linesInsertedMethod · 0.45
markupApplyEditsMethod · 0.45
InsertChildMethod · 0.45
MarshalJSONMethod · 0.45

Calls 4

LenMethod · 0.95
IndexMethod · 0.95
MakeFunction · 0.70
SetMethod · 0.65

Tested by 1

TestBitSlice10Function · 0.36