MCPcopy
hub / github.com/RoaringBitmap/roaring / String

Method String

roaring64/roaring64.go:243–266  ·  view source on GitHub ↗

String creates a string representation of the Bitmap

()

Source from the content-addressed store, hash-verified

241
242// String creates a string representation of the Bitmap
243func (rb *Bitmap) String() string {
244 // inspired by https://github.com/fzandona/goroar/
245 var buffer bytes.Buffer
246 start := []byte("{")
247 buffer.Write(start)
248 i := rb.Iterator()
249 counter := 0
250 if i.HasNext() {
251 counter = counter + 1
252 buffer.WriteString(strconv.FormatUint(i.Next(), 10))
253 }
254 for i.HasNext() {
255 buffer.WriteString(",")
256 counter = counter + 1
257 // to avoid exhausting the memory
258 if counter > 0x40000 {
259 buffer.WriteString("...")
260 break
261 }
262 buffer.WriteString(strconv.FormatUint(i.Next(), 10))
263 }
264 buffer.WriteString("}")
265 return buffer.String()
266}
267
268// Iterator creates a new IntPeekable to iterate over the integers contained in the bitmap, in sorted order;
269// the iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).

Callers 2

TestStringerCOWFunction · 0.95
TestStringerFunction · 0.95

Calls 4

IteratorMethod · 0.95
HasNextMethod · 0.65
NextMethod · 0.65
StringMethod · 0.65

Tested by 2

TestStringerCOWFunction · 0.76
TestStringerFunction · 0.76