import "golang.org/x/tools/container/intsets"
Package intsets provides Sparse, a compact and fast representation for sparse sets of int values.
The time complexity of the operations Len, Insert, Remove and Has is in O(n) but in practice those methods are faster and more space-efficient than equivalent operations on sets based on the Go map type. The IsEmpty, Min, Max, Clear and TakeMin operations require constant time.
popcnt_amd64.go sparse.go util.go
Limit values of implementation-specific int type.
type Sparse struct {
// contains filtered or unexported fields
}
A Sparse is a set of int values. Sparse operations (even queries) are not concurrency-safe.
The zero value for Sparse is a valid empty set.
Sparse sets must be copied using the Copy method, not by assigning a Sparse value.
AppendTo returns the result of appending the elements of s to slice in order.
BitString returns the set as a string of 1s and 0s denoting the sum of the i'th powers of 2, for each i in s. A radix point, always preceded by a digit, appears if the sum is non-integral.
Examples:
{}.BitString() = "0" {4,5}.BitString() = "110000" {-3}.BitString() = "0.001" {-3,0,4,5}.BitString() = "110001.001"
Clear removes all elements from the set s.
Copy sets s to the value of x.
Difference sets s to the difference x ∖ y.
DifferenceWith sets s to the difference s ∖ x.
Equals reports whether the sets s and t have the same elements.
GoString returns a string showing the internal representation of the set s.
Has reports whether x is an element of the set s.
Insert adds x to the set s, and reports whether the set grew.
Intersection sets s to the intersection x ∩ y.
IntersectionWith sets s to the intersection s ∩ x.
Intersects reports whether s ∩ x ≠ ∅.
IsEmpty reports whether the set s is empty.
Len returns the number of elements in the set s.
Max returns the maximum element of the set s, or MinInt if s is empty.
Min returns the minimum element of the set s, or MaxInt if s is empty.
Remove removes x from the set s, and reports whether the set shrank.
String returns a human-readable description of the set s.
SubsetOf reports whether s ∖ x = ∅.
SymmetricDifference sets s to the symmetric difference x ∆ y.
SymmetricDifferenceWith sets s to the symmetric difference s ∆ x.
If set s is non-empty, TakeMin sets *p to the minimum element of the set s, removes that element from the set and returns true. Otherwise, it returns false and *p is undefined.
This method may be used for iteration over a worklist like so:
var x int for worklist.TakeMin(&x) { use(x) }
Union sets s to the union x ∪ y.
UnionWith sets s to the union s ∪ x, and reports whether s grew.
Package intsets imports 2 packages (graph) and is imported by 12 packages. Updated 2 days ago. Refresh now. Tools for package owners.