MCPcopy
hub / github.com/skip2/go-qrcode / Substr

Method Substr

bitset/bitset.go:56–72  ·  view source on GitHub ↗

Substr returns a substring, consisting of the bits from indexes start to end.

(start int, end int)

Source from the content-addressed store, hash-verified

54
55// Substr returns a substring, consisting of the bits from indexes start to end.
56func (b *Bitset) Substr(start int, end int) *Bitset {
57 if start > end || end > b.numBits {
58 log.Panicf("Out of range start=%d end=%d numBits=%d", start, end, b.numBits)
59 }
60
61 result := New()
62 result.ensureCapacity(end - start)
63
64 for i := start; i < end; i++ {
65 if b.At(i) {
66 result.bits[result.numBits/8] |= 0x80 >> uint(result.numBits%8)
67 }
68 result.numBits++
69 }
70
71 return result
72}
73
74// NewFromBase2String constructs and returns a Bitset from a string. The string
75// consists of '1', '0' or ' ' characters, e.g. "1010 0101". The '1' and '0'

Callers 2

encodeBlocksMethod · 0.80
TestSubstrFunction · 0.80

Calls 3

AtMethod · 0.95
ensureCapacityMethod · 0.80
NewFunction · 0.70

Tested by 1

TestSubstrFunction · 0.64