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

Method String

roaring.go:946–969  ·  view source on GitHub ↗

String creates a string representation of the Bitmap

()

Source from the content-addressed store, hash-verified

944
945// String creates a string representation of the Bitmap
946func (rb *Bitmap) String() string {
947 // inspired by https://github.com/fzandona/goroar/
948 var buffer bytes.Buffer
949 start := []byte("{")
950 buffer.Write(start)
951 i := rb.Iterator()
952 counter := 0
953 if i.HasNext() {
954 counter = counter + 1
955 buffer.WriteString(strconv.FormatInt(int64(i.Next()), 10))
956 }
957 for i.HasNext() {
958 buffer.WriteString(",")
959 counter = counter + 1
960 // to avoid exhausting the memory
961 if counter > 0x40000 {
962 buffer.WriteString("...")
963 break
964 }
965 buffer.WriteString(strconv.FormatInt(int64(i.Next()), 10))
966 }
967 buffer.WriteString("}")
968 return buffer.String()
969}
970
971// Iterate iterates over the bitmap, calling the given callback with each value in the bitmap. If the callback returns
972// false, the iteration is halted.

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