Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/bits-and-blooms/bitset
/ functions
Functions
266 in github.com/bits-and-blooms/bitset
⨍
Functions
266
◇
Types & classes
4
↓ 292 callers
Method
Set
Set bit i to 1, the capacity of the bitset is automatically increased accordingly. Warning: using a very large value for 'i' may lead to a memory shor
bitset.go:263
↓ 222 callers
Function
New
New creates a new BitSet with a hint that length bits will be required. The memory usage is at least length/8 bytes. In case of allocation failure, th
bitset.go:165
↓ 116 callers
Method
Test
Test whether bit i is set.
bitset.go:230
↓ 89 callers
Method
Count
Count (number of set bits). Also known as "popcount" or "population count".
bitset.go:845
↓ 43 callers
Method
Len
Len returns the number of bits in the BitSet. Note that it differ from Count function.
bitset.go:207
↓ 37 callers
Function
panicIfNull
(b *BitSet)
bitset.go:880
↓ 36 callers
Method
Equal
Equal tests the equivalence of two BitSets. False if they are of different sizes, otherwise true only if all the same bits are set
bitset.go:855
↓ 30 callers
Method
NextSet
NextSet returns the next bit set from the specified index, including possibly the current index along with an error code (true = valid, false = no set
bitset.go:574
↓ 24 callers
Method
wordCount
wordCount returns the number of words used in a bit set
bitset.go:787
↓ 20 callers
Method
Clone
Clone this BitSet, returning a new BitSet that has the same bits set. In case of allocation failure, the function will return an empty BitSet.
bitset.go:793
↓ 19 callers
Function
wordsIndex
wordsIndex calculates the index of words in a `uint64`
bitset.go:157
↓ 18 callers
Method
DumpAsBits
DumpAsBits dumps a bit set as a string of bits. Following the usual convention in Go, the least significant bits are printed last (index 0 is at the e
bitset.go:1196
↓ 16 callers
Method
SetTo
SetTo sets bit i to value. Warning: using a very large value for 'i' may lead to a memory shortage and a panic: the caller is responsible for providin
bitset.go:284
↓ 14 callers
Function
From
From is a constructor used to create a BitSet from an array of words
bitset.go:109
↓ 13 callers
Method
Clear
Clear bit i to 0. This never cause a memory allocation. It is always safe.
bitset.go:272
↓ 13 callers
Method
NextClear
NextClear returns the next clear bit from the specified index, including possibly the current index along with an error code (true = valid, false = no
bitset.go:674
↓ 12 callers
Method
NextSetMany
NextSetMany returns many next bit sets from the specified index, including possibly the current index and up to cap(buffer). If the returned slice has
bitset.go:622
↓ 10 callers
Method
Shrink
Shrink shrinks BitSet so that the provided value is the last possible set value. It clears all bits > the provided index and reduces the size and leng
bitset.go:377
↓ 10 callers
Function
wordsNeeded
wordsNeeded calculates the number of words needed for i bits
bitset.go:143
↓ 9 callers
Method
Bytes
Bytes returns the bitset as array of 64-bit words, giving direct access to the internal representation. It is not a copy, so changes to the returned s
bitset.go:131
↓ 9 callers
Method
FlipRange
FlipRange bit in [start, end). Warning: using a very large value for 'end' may lead to a memory shortage and a panic: the caller is responsible for pr
bitset.go:307
↓ 8 callers
Function
Cap
Cap returns the total possible capacity, or number of bits that can be stored in the BitSet theoretically. Under 32-bit system, it is 4294967295 and u
bitset.go:201
↓ 8 callers
Method
DifferenceCardinality
DifferenceCardinality computes the cardinality of the difference
bitset.go:903
↓ 8 callers
Method
IntersectionCardinality
IntersectionCardinality computes the cardinality of the intersection
bitset.go:965
↓ 8 callers
Function
popcntSlice
(s []uint64)
popcnt.go:5
↓ 7 callers
Method
Intersection
Intersection of base set and other set This is the BitSet equivalent of & (and) In case of allocation failure, the function will return an empty BitSe
bitset.go:953
↓ 7 callers
Method
None
None returns true if no bit is set, false otherwise. Returns true for empty sets.
bitset.go:1156
↓ 7 callers
Method
String
String creates a string representation of the BitSet. It is only intended for human-readable output and not for serialization.
bitset.go:462
↓ 7 callers
Method
SymmetricDifferenceCardinality
SymmetricDifferenceCardinality computes the cardinality of the symmetric difference
bitset.go:1081
↓ 7 callers
Method
UnionCardinality
UnionCardinality computes the cardinality of the uniton of the base set and the compare set.
bitset.go:1023
↓ 6 callers
Method
Copy
Copy into a destination BitSet using the Go array copy semantics: the number of bits copied is the minimum of the number of bits in the current BitSet
bitset.go:805
↓ 6 callers
Method
ExtractTo
ExtractTo copies bits from the BitSet using positions specified in mask into a compacted form in dst. The number of set bits in mask determines the nu
bitset.go:1625
↓ 6 callers
Method
Select
Select returns the index of the jth set bit, where j is the argument. The caller is responsible to ensure that 0 <= j < Count(): when j is out of rang
bitset.go:1441
↓ 6 callers
Method
extendSet
extendSet adds additional words to incorporate new bits if needed
bitset.go:212
↓ 6 callers
Function
sortByLength
Convenience function: return two bitsets ordered by increasing length. Note: neither can be nil
bitset.go:941
↓ 5 callers
Method
All
All returns true if all bits are set, false otherwise. Returns true for empty sets.
bitset.go:1149
↓ 5 callers
Method
BinaryStorageSize
BinaryStorageSize returns the binary storage requirements (see WriteTo) in bytes.
bitset.go:1209
↓ 5 callers
Method
ClearAll
ClearAll clears the entire BitSet. It does not free the memory.
bitset.go:765
↓ 5 callers
Method
DepositTo
DepositTo spreads bits from a compacted form in the BitSet into positions specified by mask in dst. This is the inverse operation of Extract. For exa
bitset.go:1684
↓ 5 callers
Method
Difference
Difference of base set and other set This is the BitSet equivalent of &^ (and not)
bitset.go:888
↓ 5 callers
Method
PreviousSet
PreviousSet returns the previous set bit from the specified index, including possibly the current index along with an error code (true = valid, false
bitset.go:711
↓ 5 callers
Method
ReadFrom
ReadFrom reads a BitSet from a stream written using WriteTo The format is: 1. uint64 length 2. []uint64 set See WriteTo for details. Upon success, the
bitset.go:1310
↓ 5 callers
Method
SymmetricDifference
SymmetricDifference of base set and other set This is the BitSet equivalent of ^ (xor)
bitset.go:1068
↓ 5 callers
Method
Union
Union of base set and other set This is the BitSet equivalent of | (or)
bitset.go:1010
↓ 4 callers
Method
DeleteAt
DeleteAt deletes the bit at the given index position from within the bitset All the bits residing on the left of the deleted bit get shifted right by
bitset.go:492
↓ 4 callers
Method
Flip
Flip bit at i. Warning: using a very large value for 'i' may lead to a memory shortage and a panic: the caller is responsible for providing sensible p
bitset.go:295
↓ 4 callers
Method
InPlaceIntersection
InPlaceIntersection destructively computes the intersection of base set and the compare set. This is the BitSet equivalent of & (and)
bitset.go:979
↓ 4 callers
Method
MarshalBinary
MarshalBinary encodes a BitSet into a binary form and returns the result. Please see WriteTo for details.
bitset.go:1350
↓ 4 callers
Method
PreviousClear
PreviousClear returns the previous clear bit from the specified index, including possibly the current index along with an error code (true = valid, fa
bitset.go:736
↓ 4 callers
Method
Rank
Rank returns the number of set bits up to and including the index that are set in the bitset. See https://en.wikipedia.org/wiki/Ranking#Ranking_in_sta
bitset.go:1402
↓ 4 callers
Method
WriteTo
WriteTo writes a BitSet to a stream. The format is: 1. uint64 length 2. []uint64 set The length is the number of bits in the BitSet. The set is a sli
bitset.go:1275
↓ 4 callers
Function
good
function provided by FlorianUekermann
bitset_benchmark_test.go:330
↓ 4 callers
Function
pext
go:generate go run cmd/pextgen/main.go -pkg=bitset
bitset.go:1730
↓ 3 callers
Method
AsSlice
AsSlice returns all set bits as slice. It panics if the capacity of buf is < b.Count() See also [BitSet.AppendTo] and [BitSet.NextSetMany].
bitset.go:547
↓ 3 callers
Method
Compact
Compact shrinks BitSet to so that we preserve all set bits, while minimizing memory usage. Compact calls Shrink. A new slice is allocated to store the
bitset.go:401
↓ 3 callers
Method
Complement
Complement computes the (local) complement of a bitset (up to length bits) In case of allocation failure, the function will return an empty BitSet.
bitset.go:1137
↓ 3 callers
Function
FromWithLength
FromWithLength constructs from an array of words and length in bits. This function is for advanced users, most users should prefer the From function.
bitset.go:119
↓ 3 callers
Method
InPlaceDifference
InPlaceDifference computes the difference of base set and other set This is the BitSet equivalent of &^ (and not)
bitset.go:920
↓ 3 callers
Method
InPlaceSymmetricDifference
InPlaceSymmetricDifference creates the destructive SymmetricDifference of base set and other set This is the BitSet equivalent of ^ (xor)
bitset.go:1097
↓ 3 callers
Method
InPlaceUnion
InPlaceUnion creates the destructive union of base set and compare set. This is the BitSet equivalent of | (or).
bitset.go:1039
↓ 3 callers
Method
InsertAt
InsertAt takes an index which indicates where a bit should be inserted. Then it shifts all the bits in the set to the left by 1, starting from the giv
bitset.go:423
↓ 3 callers
Method
IsSuperSet
IsSuperSet returns true if this is a superset of the other set
bitset.go:1175
↓ 3 callers
Method
OnesBetween
OnesBetween returns the number of set bits in the range [from, to). The range is inclusive of 'from' and exclusive of 'to'. Returns 0 if from >= to.
bitset.go:1569
↓ 3 callers
Method
ShiftRight
ShiftRight shifts the bitset like >> operation would do.
bitset.go:1525
↓ 3 callers
Method
cleanLastWord
Clean last word by setting unused bits to 0
bitset.go:1129
↓ 3 callers
Function
copyBinary
(t *testing.T, from encoding.BinaryMarshaler, to encoding.BinaryUnmarshaler)
bitset_test.go:1656
↓ 3 callers
Function
max
Helper function for max
bitset_fuzz_test.go:488
↓ 3 callers
Function
pdep
(w, m uint64)
bitset.go:1749
↓ 3 callers
Function
setRnd
(bits []uint64, halfings int)
bitset_benchmark_test.go:281
↓ 2 callers
Method
AppendTo
AppendTo appends all set bits to buf and returns the (maybe extended) buf. In case of allocation failure, the function will panic. See also [BitSet.A
bitset.go:527
↓ 2 callers
Method
CopyFull
CopyFull copies into a destination BitSet such that the destination is identical to the source after the operation, allocating memory if necessary.
bitset.go:824
↓ 2 callers
Method
EachSet
()
bitset_iter.go:11
↓ 2 callers
Method
IsStrictSuperSet
IsStrictSuperSet returns true if this is a strict superset of the other set
bitset.go:1189
↓ 2 callers
Function
MustNew
MustNew creates a new BitSet with the given length bits. It panics if length exceeds the possible capacity or by a lack of memory.
bitset.go:185
↓ 2 callers
Method
SetAll
SetAll sets the entire BitSet
bitset.go:775
↓ 2 callers
Method
ShiftLeft
ShiftLeft shifts the bitset like << operation would do. Left shift may require bitset size extension. We try to avoid the unnecessary memory operatio
bitset.go:1469
↓ 2 callers
Method
UnmarshalBinary
UnmarshalBinary decodes the binary form generated by MarshalBinary. Please see WriteTo for details.
bitset.go:1362
↓ 2 callers
Function
generatePextTestCases
(n int)
bitset_test.go:2715
↓ 2 callers
Method
isLenExactMultiple
Is the length an exact multiple of word sizes?
bitset.go:1124
↓ 2 callers
Function
popcntAndSlice
popcntAndSlice computes the population count of the AND of two slices. It assumes that len(m) >= len(s) > 0.
popcnt.go:48
↓ 2 callers
Function
popcntMaskSlice
(s, m []uint64)
popcnt.go:25
↓ 2 callers
Function
popcntOrSlice
popcntOrSlice computes the population count of the OR of two slices. It assumes that len(m) >= len(s) > 0.
popcnt.go:59
↓ 2 callers
Function
popcntXorSlice
popcntXorSlice computes the population count of the XOR of two slices. It assumes that len(m) >= len(s) > 0.
popcnt.go:70
↓ 2 callers
Method
top
top detects the top bit set
bitset.go:1454
↓ 1 callers
Method
Any
Any returns true if any bit is set, false otherwise
bitset.go:1169
↓ 1 callers
Function
Base64StdEncoding
Base64StdEncoding Marshal/Unmarshal BitSet with base64.StdEncoding(Default: base64.URLEncoding)
bitset.go:73
↓ 1 callers
Method
GetWord64AtBit
GetWord64AtBit retrieves bits i through i+63 as a single uint64 value
bitset.go:238
↓ 1 callers
Function
LittleEndian
LittleEndian sets Marshal/Unmarshal Binary as Little Endian (Default: binary.BigEndian)
bitset.go:76
↓ 1 callers
Method
MarshalJSON
MarshalJSON marshals a BitSet as a JSON structure
bitset.go:1369
↓ 1 callers
Method
Read
(b []byte)
bitset_test.go:2246
↓ 1 callers
Method
SetBitsetFrom
SetBitsetFrom fills the bitset with an array of integers without creating a new BitSet instance
bitset.go:103
↓ 1 callers
Method
UnmarshalJSON
UnmarshalJSON unmarshals a BitSet from JSON created using MarshalJSON
bitset.go:1381
↓ 1 callers
Method
Words
Words returns the bitset as array of 64-bit words, giving direct access to the internal representation. It is not a copy, so changes to the returned s
bitset.go:138
↓ 1 callers
Function
generateTable
(name string, data interface{}, comment string)
cmd/pextgen/main.go:40
↓ 1 callers
Function
onScroll
()
docs/main.js:50
↓ 1 callers
Function
pdepByte
pdepByte handles single-byte PDEP operation
cmd/pextgen/main.go:27
↓ 1 callers
Function
pextByte
pextByte handles single-byte PEXT operation
cmd/pextgen/main.go:13
↓ 1 callers
Function
readUint64Array
(reader io.Reader, data []uint64)
bitset.go:1213
↓ 1 callers
Method
safeSet
safeSet will fixup b.set to be non-nil and return the field value
bitset.go:95
↓ 1 callers
Function
select64
(w uint64, j uint)
select.go:5
next →
1–100 of 266, ranked by callers