Debian Codegraph @

container/intsets/sparse.go

raw symbols SCIP
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package intsets provides Sparse, a compact and fast representation
6 // for sparse sets of int values.
7 //
8 // The time complexity of the operations Len, Insert, Remove and Has
9 // is in O(n) but in practice those methods are faster and more
10 // space-efficient than equivalent operations on sets based on the Go
11 // map type. The IsEmpty, Min, Max, Clear and TakeMin operations
12 // require constant time.
13 package intsetsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/ // import "golang.org/x/tools/container/intsets"
14
15 // TODO(adonovan):
16 // - Add InsertAll(...int), RemoveAll(...int)
17 // - Add 'bool changed' results for {Intersection,Difference}With too.
18 //
19 // TODO(adonovan): implement Dense, a dense bit vector with a similar API.
20 // The space usage would be proportional to Max(), not Len(), and the
21 // implementation would be based upon big.Int.
22 //
23 // TODO(adonovan): opt: make UnionWith and Difference faster.
24 // These are the hot-spots for go/pointer.
25
26 import (
27 "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/"
28 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
29 "math/bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/"
30 )
31
32 // A Sparse is a set of int values.
33 // Sparse operations (even queries) are not concurrency-safe.
34 //
35 // The zero value for Sparse is a valid empty set.
36 //
37 // Sparse sets must be copied using the Copy method, not by assigning
38 // a Sparse value.
39 type Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse# struct {
40 // An uninitialized Sparse represents an empty set.
41 // An empty set may also be represented by
42 // root.next == root.prev == &root.
43 //
44 // The root is always the block with the smallest offset.
45 // It can be empty, but only if it is the only block; in that case, offset is
46 // MaxInt (which is not a valid offset).
47 rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#
48 }
49
50 type wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word# uintptr
51
52 const (
53 _mscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/_m. = ^wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#(0)
54 bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord. = 8 << (_mscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/_m.>>8&1 + _mscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/_m.>>16&1 + _mscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/_m.>>32&1)
55 bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock. = 256 // optimal value for go/pointer solver performance
56 wordsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordsPerBlock. = bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock. / bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
57 )
58
59 // Limit values of implementation-specific int type.
60 const (
61 MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt. = int(^uint(0) >> 1)
62 MinIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MinInt. = -MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt. - 1
63 )
64
65 // popcount returns the number of set bits in w.
66 func popcountscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/popcount().(x wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#) int {
67 // Avoid OnesCount(uint): don't assume uint = uintptr.
68 if bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord. == 32 {
69 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.OnesCount32scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/OnesCount32().(uint32(x))
70 } else {
71 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.OnesCount64scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/OnesCount64().(uint64(x))
72 }
73 }
74
75 // nlz returns the number of leading zeros of x.
76 func nlzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/nlz().(x wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#) int {
77 // Avoid LeadingZeros(uint): don't assume uint = uintptr.
78 if bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord. == 32 {
79 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.LeadingZeros32scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/LeadingZeros32().(uint32(x))
80 } else {
81 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.LeadingZeros64scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/LeadingZeros64().(uint64(x))
82 }
83 }
84
85 // ntz returns the number of trailing zeros of x.
86 func ntzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/ntz().(x wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#) int {
87 // Avoid TrailingZeros(uint): don't assume uint = uintptr.
88 if bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord. == 32 {
89 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.TrailingZeros32scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/TrailingZeros32().(uint32(x))
90 } else {
91 return bitsscip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/.TrailingZeros64scip-go gomod github.com/golang/go/src go1.25.0 `math/bits`/TrailingZeros64().(uint64(x))
92 }
93 }
94
95 // -- block ------------------------------------------------------------
96
97 // A set is represented as a circular doubly-linked list of blocks,
98 // each containing an offset and a bit array of fixed size
99 // bitsPerBlock; the blocks are ordered by increasing offset.
100 //
101 // The set contains an element x iff the block whose offset is x - (x
102 // mod bitsPerBlock) has the bit (x mod bitsPerBlock) set, where mod
103 // is the Euclidean remainder.
104 //
105 // A block may only be empty transiently.
106 type blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# struct {
107 offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. int // offset mod bitsPerBlock == 0
108 bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. [wordsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordsPerBlock.]wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word# // contains at least one set bit
109 nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next., prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# // doubly-linked list of blocks
110 }
111
112 // wordMask returns the word index (in block.bits)
113 // and single-bit mask for the block's ith bit.
114 func wordMaskscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordMask().(i uint) (w uint, mask wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#) {
115 w = i / bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
116 mask = 1 << (i % bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.)
117 return
118 }
119
120 // insert sets the block b's ith bit and
121 // returns true if it was not already set.
122 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#insert().(i uint) bool {
123 w, mask := wordMaskscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordMask().(i)
124 if b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w]&mask == 0 {
125 b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w] |= mask
126 return true
127 }
128 return false
129 }
130
131 // remove clears the block's ith bit and
132 // returns true if the bit was previously set.
133 // NB: may leave the block empty.
134 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) removescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#remove().(i uint) bool {
135 w, mask := wordMaskscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordMask().(i)
136 if b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w]&mask != 0 {
137 b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w] &^= mask
138 return true
139 }
140 return false
141 }
142
143 // has reports whether the block's ith bit is set.
144 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) hasscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#has().(i uint) bool {
145 w, mask := wordMaskscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordMask().(i)
146 return b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w]&mask != 0
147 }
148
149 // empty reports whether b.len()==0, but more efficiently.
150 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#empty().() bool {
151 for _, w := range b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
152 if w != 0 {
153 return false
154 }
155 }
156 return true
157 }
158
159 // len returns the number of set bits in block b.
160 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) lenscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#len().() int {
161 var l int
162 for _, w := range b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
163 l += popcountscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/popcount().(w)
164 }
165 return l
166 }
167
168 // max returns the maximum element of the block.
169 // The block must not be empty.
170 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) maxscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#max().() int {
171 bi := b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. + bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock.
172 // Decrement bi by number of high zeros in last.bits.
173 for i := len(b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.) - 1; i >= 0; i-- {
174 if w := b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]; w != 0 {
175 return bi - nlzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/nlz().(w) - 1
176 }
177 bi -= bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
178 }
179 panic("BUG: empty block")
180 }
181
182 // min returns the minimum element of the block,
183 // and also removes it if take is set.
184 // The block must not be initially empty.
185 // NB: may leave the block empty.
186 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#min().(take bool) int {
187 for i, w := range b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
188 if w != 0 {
189 tz := ntzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/ntz().(w)
190 if take {
191 b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = w &^ (1 << uint(tz))
192 }
193 return b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. + i*bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord. + tz
194 }
195 }
196 panic("BUG: empty block")
197 }
198
199 // lowerBound returns the smallest element of the block that is greater than or
200 // equal to the element corresponding to the ith bit. If there is no such
201 // element, the second return value is false.
202 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) lowerBoundscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#lowerBound().(i uint) (int, bool) {
203 w := i / bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
204 bit := i % bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
205
206 if val := b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w] >> bit; val != 0 {
207 return b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. + int(i) + ntzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/ntz().(val), true
208 }
209
210 for w++; w < wordsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/wordsPerBlock.; w++ {
211 if val := b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[w]; val != 0 {
212 return b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. + int(w*bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.) + ntzscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/ntz().(val), true
213 }
214 }
215
216 return 0, false
217 }
218
219 // forEach calls f for each element of block b.
220 // f must not mutate b's enclosing Sparse.
221 func (b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#forEach().(f func(int)) {
222 for i, w := range b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
223 offset := b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. + i*bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.
224 for bi := 0; w != 0 && bi < bitsPerWordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerWord.; bi++ {
225 if w&1 != 0 {
226 f(offset)
227 }
228 offset++
229 w >>= 1
230 }
231 }
232 }
233
234 // offsetAndBitIndex returns the offset of the block that would
235 // contain x and the bit index of x within that block.
236 func offsetAndBitIndexscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/offsetAndBitIndex().(x int) (int, uint) {
237 mod := x % bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock.
238 if mod < 0 {
239 // Euclidean (non-negative) remainder
240 mod += bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock.
241 }
242 return x - mod, uint(mod)
243 }
244
245 // -- Sparse --------------------------------------------------------------
246
247 // none is a shared, empty, sentinel block that indicates the end of a block
248 // list.
249 var nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#
250
251 // Dummy type used to generate an implicit panic. This must be defined at the
252 // package level; if it is defined inside a function, it prevents the inlining
253 // of that function.
254 type to_copy_a_sparse_you_must_call_its_Copy_methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/to_copy_a_sparse_you_must_call_its_Copy_method# struct{}
255
256 // init ensures s is properly initialized.
257 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) initscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#init().() {
258 root := &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
259 if root.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == nil {
260 root.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt.
261 root.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = root
262 root.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = root
263 } else if root.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. != root {
264 // Copying a Sparse x leads to pernicious corruption: the
265 // new Sparse y shares the old linked list, but iteration
266 // on y will never encounter &y.root so it goes into a
267 // loop. Fail fast before this occurs.
268 // We don't want to call panic here because it prevents the
269 // inlining of this function.
270 _ = (any(nil)).(to_copy_a_sparse_you_must_call_its_Copy_methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/to_copy_a_sparse_you_must_call_its_Copy_method#)
271 }
272 }
273
274 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().() *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# {
275 s.initscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#init().()
276 if s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt. {
277 return &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.
278 }
279 return &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
280 }
281
282 // next returns the next block in the list, or end if b is the last block.
283 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# {
284 if b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
285 return &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.
286 }
287 return b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.
288 }
289
290 // IsEmpty reports whether the set s is empty.
291 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() bool {
292 return s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == nil || s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt.
293 }
294
295 // Len returns the number of elements in the set s.
296 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Lenscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Len().() int {
297 var l int
298 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
299 l += b.lenscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#len().()
300 }
301 return l
302 }
303
304 // Max returns the maximum element of the set s, or MinInt if s is empty.
305 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Maxscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Max().() int {
306 if s.IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() {
307 return MinIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MinInt.
308 }
309 return s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev..maxscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#max().()
310 }
311
312 // Min returns the minimum element of the set s, or MaxInt if s is empty.
313 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Min().() int {
314 if s.IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() {
315 return MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt.
316 }
317 return s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#min().(false)
318 }
319
320 // LowerBound returns the smallest element >= x, or MaxInt if there is no such
321 // element.
322 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) LowerBoundscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#LowerBound().(x int) int {
323 offset, i := offsetAndBitIndexscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/offsetAndBitIndex().(x)
324 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
325 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > offset {
326 return b.minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#min().(false)
327 }
328 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == offset {
329 if y, ok := b.lowerBoundscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#lowerBound().(i); ok {
330 return y
331 }
332 }
333 }
334 return MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt.
335 }
336
337 // block returns the block that would contain offset,
338 // or nil if s contains no such block.
339 // Precondition: offset is a multiple of bitsPerBlock.
340 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#block().(offset int) *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# {
341 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. <= offset; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
342 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == offset {
343 return b
344 }
345 }
346 return nil
347 }
348
349 // Insert adds x to the set s, and reports whether the set grew.
350 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Insert().(x int) bool {
351 offset, i := offsetAndBitIndexscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/offsetAndBitIndex().(x)
352
353 b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
354 for ; b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. <= offset; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
355 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == offset {
356 return b.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#insert().(i)
357 }
358 }
359
360 // Insert new block before b.
361 new := s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(b)
362 new.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = offset
363 return new.insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#insert().(i)
364 }
365
366 // removeBlock removes a block and returns the block that followed it (or end if
367 // it was the last block).
368 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# {
369 if b != &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
370 b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.
371 b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.
372 if b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
373 return &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.
374 }
375 return b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.
376 }
377
378 first := s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.
379 if first == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
380 // This was the only block.
381 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
382 return &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.
383 }
384 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = first.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
385 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = first.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
386 if first.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
387 // Single block remaining.
388 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
389 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
390 } else {
391 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = first.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.
392 first.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
393 }
394 return &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
395 }
396
397 // Remove removes x from the set s, and reports whether the set shrank.
398 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Remove().(x int) bool {
399 offset, i := offsetAndBitIndexscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/offsetAndBitIndex().(x)
400 if b := s.blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#block().(offset); b != nil {
401 if !b.removescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#remove().(i) {
402 return false
403 }
404 if b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#empty().() {
405 s.removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(b)
406 }
407 return true
408 }
409 return false
410 }
411
412 // Clear removes all elements from the set s.
413 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().() {
414 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. = blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#{
415 offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.: MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt.,
416 nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.: &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.,
417 prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.: &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.,
418 }
419 }
420
421 // If set s is non-empty, TakeMin sets *p to the minimum element of
422 // the set s, removes that element from the set and returns true.
423 // Otherwise, it returns false and *p is undefined.
424 //
425 // This method may be used for iteration over a worklist like so:
426 //
427 // var x int
428 // for worklist.TakeMin(&x) { use(x) }
429 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) TakeMinscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#TakeMin().(p *int) bool {
430 if s.IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() {
431 return false
432 }
433 *p = s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#min().(true)
434 if s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#empty().() {
435 s.removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(&s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.)
436 }
437 return true
438 }
439
440 // Has reports whether x is an element of the set s.
441 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Hasscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Has().(x int) bool {
442 offset, i := offsetAndBitIndexscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/offsetAndBitIndex().(x)
443 if b := s.blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#block().(offset); b != nil {
444 return b.hasscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#has().(i)
445 }
446 return false
447 }
448
449 // forEach applies function f to each element of the set s in order.
450 //
451 // f must not mutate s. Consequently, forEach is not safe to expose
452 // to clients. In any case, using "range s.AppendTo()" allows more
453 // natural control flow with continue/break/return.
454 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#forEach().(f func(int)) {
455 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
456 b.forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#forEach().(f)
457 }
458 }
459
460 // Copy sets s to the value of x.
461 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Copyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Copy().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
462 if s == x {
463 return
464 }
465
466 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
467 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
468 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
469 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
470 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
471 }
472 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
473 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
474 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
475 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
476 }
477 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
478 }
479
480 // insertBlockBefore returns a new block, inserting it before next.
481 // If next is the root, the root is replaced. If next is end, the block is
482 // inserted at the end.
483 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(next *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block# {
484 if s.IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() {
485 if next != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
486 panic("BUG: passed block with empty set")
487 }
488 return &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
489 }
490
491 if next == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
492 // Special case: we need to create a new block that will become the root
493 // block.The old root block becomes the second block.
494 second := s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
495 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. = blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#{
496 nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next.: &second,
497 }
498 if second.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
499 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = &second
500 } else {
501 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = second.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.
502 second.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = &second
503 second.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
504 }
505 return &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
506 }
507 if next == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
508 // Insert before root.
509 next = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
510 }
511 b := new(blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#)
512 b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = next
513 b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = next.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.
514 b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = b
515 next.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = b
516 return b
517 }
518
519 // discardTail removes block b and all its successors from s.
520 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(b *blockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#) {
521 if b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
522 if b == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
523 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
524 } else {
525 b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. = &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root.
526 s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. = b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.
527 }
528 }
529 }
530
531 // IntersectionWith sets s to the intersection s ∩ x.
532 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) IntersectionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IntersectionWith().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
533 if s == x {
534 return
535 }
536
537 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
538 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
539 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
540 switch {
541 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
542 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
543
544 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
545 sb = s.removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(sb)
546
547 default:
548 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
549 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
550 r := xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] & sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
551 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
552 sum |= r
553 }
554 if sum != 0 {
555 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
556 } else {
557 // sb will be overwritten or removed
558 }
559
560 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
561 }
562 }
563
564 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
565 }
566
567 // Intersection sets s to the intersection x ∩ y.
568 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Intersectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Intersection().(x, y *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
569 switch {
570 case s == x:
571 s.IntersectionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IntersectionWith().(y)
572 return
573 case s == y:
574 s.IntersectionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IntersectionWith().(x)
575 return
576 case x == y:
577 s.Copyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Copy().(x)
578 return
579 }
580
581 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
582 yb := y.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
583 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
584 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
585 switch {
586 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
587 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
588 continue
589 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
590 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
591 continue
592 }
593
594 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
595 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
596 }
597 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
598
599 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
600 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
601 r := xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] & yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
602 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
603 sum |= r
604 }
605 if sum != 0 {
606 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
607 } else {
608 // sb will be overwritten or removed
609 }
610
611 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
612 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
613 }
614
615 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
616 }
617
618 // Intersects reports whether s ∩ x ≠ ∅.
619 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Intersectsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Intersects().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) bool {
620 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
621 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
622 for sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
623 switch {
624 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
625 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
626 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
627 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
628 default:
629 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
630 if sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]&xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] != 0 {
631 return true
632 }
633 }
634 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
635 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
636 }
637 }
638 return false
639 }
640
641 // UnionWith sets s to the union s ∪ x, and reports whether s grew.
642 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) UnionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#UnionWith().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) bool {
643 if s == x {
644 return false
645 }
646
647 var changed bool
648 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
649 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
650 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
651 if sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. == xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. {
652 for i := range xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
653 union := sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] | xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
654 if sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] != union {
655 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = union
656 changed = true
657 }
658 }
659 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
660 } else if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. {
661 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
662 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
663 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
664 changed = true
665
666 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
667 }
668 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
669 }
670 return changed
671 }
672
673 // Union sets s to the union x ∪ y.
674 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Unionscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Union().(x, y *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
675 switch {
676 case x == y:
677 s.Copyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Copy().(x)
678 return
679 case s == x:
680 s.UnionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#UnionWith().(y)
681 return
682 case s == y:
683 s.UnionWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#UnionWith().(x)
684 return
685 }
686
687 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
688 yb := y.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
689 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
690 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
691 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
692 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
693 }
694 switch {
695 case yb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || (xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.):
696 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
697 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
698 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
699
700 case xb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || (yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.):
701 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
702 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
703 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
704
705 default:
706 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
707 for i := range xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
708 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] | yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
709 }
710 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
711 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
712 }
713 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
714 }
715
716 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
717 }
718
719 // DifferenceWith sets s to the difference s ∖ x.
720 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) DifferenceWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#DifferenceWith().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
721 if s == x {
722 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
723 return
724 }
725
726 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
727 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
728 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
729 switch {
730 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
731 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
732
733 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
734 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
735
736 default:
737 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
738 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
739 r := sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] & ^xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
740 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
741 sum |= r
742 }
743 if sum == 0 {
744 sb = s.removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(sb)
745 } else {
746 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
747 }
748 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
749 }
750 }
751 }
752
753 // Difference sets s to the difference x ∖ y.
754 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Differencescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Difference().(x, y *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
755 switch {
756 case x == y:
757 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
758 return
759 case s == x:
760 s.DifferenceWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#DifferenceWith().(y)
761 return
762 case s == y:
763 var y2 Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#
764 y2.Copyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Copy().(y)
765 s.Differencescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Difference().(x, &y2)
766 return
767 }
768
769 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
770 yb := y.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
771 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
772 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
773 if xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. {
774 // y has block, x has &none
775 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
776 continue
777 }
778
779 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
780 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
781 }
782 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
783
784 switch {
785 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
786 // x has block, y has &none
787 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
788
789 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
790
791 default:
792 // x and y have corresponding blocks
793 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
794 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
795 r := xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] & ^yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
796 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
797 sum |= r
798 }
799 if sum != 0 {
800 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
801 } else {
802 // sb will be overwritten or removed
803 }
804
805 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
806 }
807 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
808 }
809
810 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
811 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
812 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
813 }
814 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
815 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
816 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
817
818 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
819 }
820
821 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
822 }
823
824 // SymmetricDifferenceWith sets s to the symmetric difference s ∆ x.
825 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) SymmetricDifferenceWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#SymmetricDifferenceWith().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
826 if s == x {
827 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
828 return
829 }
830
831 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
832 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
833 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
834 switch {
835 case sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
836 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
837 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
838 nb := s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
839 nb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
840 nb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
841 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
842 default:
843 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
844 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
845 r := sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] ^ xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
846 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
847 sum |= r
848 }
849 if sum == 0 {
850 sb = s.removeBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#removeBlock().(sb)
851 } else {
852 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
853 }
854 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
855 }
856 }
857
858 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. { // append the tail of x to s
859 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
860 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
861 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
862 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
863 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
864 }
865 }
866
867 // SymmetricDifference sets s to the symmetric difference x ∆ y.
868 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) SymmetricDifferencescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#SymmetricDifference().(x, y *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) {
869 switch {
870 case x == y:
871 s.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Clear().()
872 return
873 case s == x:
874 s.SymmetricDifferenceWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#SymmetricDifferenceWith().(y)
875 return
876 case s == y:
877 s.SymmetricDifferenceWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#SymmetricDifferenceWith().(x)
878 return
879 }
880
881 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
882 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
883 yb := y.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
884 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
885 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
886 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
887 }
888 switch {
889 case yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
890 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
891 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
892 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
893 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
894 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
895 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
896 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
897 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
898 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
899 default:
900 var sum wordscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/word#
901 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
902 r := xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] ^ yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]
903 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] = r
904 sum |= r
905 }
906 if sum != 0 {
907 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
908 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
909 }
910 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
911 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
912 }
913 }
914
915 for xb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. { // append the tail of x to s
916 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
917 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
918 }
919 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
920 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
921 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
922 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
923 }
924
925 for yb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. { // append the tail of y to s
926 if sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
927 sb = s.insertBlockBeforescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#insertBlockBefore().(sb)
928 }
929 sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. = yb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.
930 sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. = yb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.
931 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
932 yb = y.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(yb)
933 }
934
935 s.discardTailscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#discardTail().(sb)
936 }
937
938 // SubsetOf reports whether s ∖ x = ∅.
939 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) SubsetOfscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#SubsetOf().(x *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) bool {
940 if s == x {
941 return true
942 }
943
944 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
945 xb := x.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
946 for sb != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. {
947 switch {
948 case xb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. > sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
949 return false
950 case xb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. < sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
951 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
952 default:
953 for i := range sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
954 if sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i]&^xb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.[i] != 0 {
955 return false
956 }
957 }
958 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
959 xb = x.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(xb)
960 }
961 }
962 return true
963 }
964
965 // Equals reports whether the sets s and t have the same elements.
966 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Equals().(t *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) bool {
967 if s == t {
968 return true
969 }
970 sb := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
971 tb := t.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().()
972 for {
973 switch {
974 case sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. && tb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.:
975 return true
976 case sb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none. || tb == &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.:
977 return false
978 case sb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. != tb.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.:
979 return false
980 case sb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. != tb.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits.:
981 return false
982 }
983
984 sb = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(sb)
985 tb = t.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(tb)
986 }
987 }
988
989 // String returns a human-readable description of the set s.
990 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) Stringscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#String().() string {
991 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
992 buf.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteByte().('{')
993 s.forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#forEach().(func(x int) {
994 if buf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().() > 1 {
995 buf.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteByte().(' ')
996 }
997 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(&buf, "%d", x)
998 })
999 buf.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteByte().('}')
1000 return buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().()
1001 }
1002
1003 // BitString returns the set as a string of 1s and 0s denoting the sum
1004 // of the i'th powers of 2, for each i in s. A radix point, always
1005 // preceded by a digit, appears if the sum is non-integral.
1006 //
1007 // Examples:
1008 //
1009 // {}.BitString() = "0"
1010 // {4,5}.BitString() = "110000"
1011 // {-3}.BitString() = "0.001"
1012 // {-3,0,4,5}.BitString() = "110001.001"
1013 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) BitStringscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#BitString().() string {
1014 if s.IsEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#IsEmpty().() {
1015 return "0"
1016 }
1017
1018 min, max := s.Minscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Min().(), s.Maxscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#Max().()
1019 var nbytes int
1020 if max > 0 {
1021 nbytes = max
1022 }
1023 nbytes++ // zero bit
1024 radix := nbytes
1025 if min < 0 {
1026 nbytes += len(".") - min
1027 }
1028
1029 b := make([]byte, nbytes)
1030 for i := range b {
1031 b[i] = '0'
1032 }
1033 if radix < nbytes {
1034 b[radix] = '.'
1035 }
1036 s.forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#forEach().(func(x int) {
1037 if x >= 0 {
1038 x += len(".")
1039 }
1040 b[radix-x] = '1'
1041 })
1042 return string(b)
1043 }
1044
1045 // GoString returns a string showing the internal representation of
1046 // the set s.
1047 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) GoStringscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#GoString().() string {
1048 var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
1049 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); b != &nonescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/none.; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
1050 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(&buf, "block %p {offset=%d next=%p prev=%p",
1051 b, b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset., b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next., b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev.)
1052 for _, w := range b.bitsscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#bits. {
1053 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(&buf, " 0%016x", w)
1054 }
1055 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(&buf, "}\n")
1056 }
1057 return buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().()
1058 }
1059
1060 // AppendTo returns the result of appending the elements of s to slice
1061 // in order.
1062 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) AppendToscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#AppendTo().(slice []int) []int {
1063 s.forEachscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#forEach().(func(x int) {
1064 slice = append(slice, x)
1065 })
1066 return slice
1067 }
1068
1069 // -- Testing/debugging ------------------------------------------------
1070
1071 // check returns an error if the representation invariants of s are violated.
1072 // (unused; retained for debugging)
1073 func (s *Sparsescip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#) checkscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#check().() error {
1074 s.initscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#init().()
1075 if s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#empty().() {
1076 // An empty set must have only the root block with offset MaxInt.
1077 if s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. != &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
1078 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("multiple blocks with empty root block")
1079 }
1080 if s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. != MaxIntscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/MaxInt. {
1081 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("empty set has offset %d, should be MaxInt", s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.)
1082 }
1083 return nil
1084 }
1085 for b := s.firstscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#first().(); ; b = s.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#next().(b) {
1086 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.%bitsPerBlockscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/bitsPerBlock. != 0 {
1087 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad offset modulo: %d", b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.)
1088 }
1089 if b.emptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#empty().() {
1090 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("empty block")
1091 }
1092 if b.prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev..nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. != b {
1093 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad prev.next link")
1094 }
1095 if b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..prevscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#prev. != b {
1096 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad next.prev link")
1097 }
1098 if b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next. == &s.rootscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/Sparse#root. {
1099 break
1100 }
1101 if b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. >= b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset. {
1102 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad offset order: b.offset=%d, b.next.offset=%d",
1103 b.offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset., b.nextscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#next..offsetscip-go gomod golang.org/x/tools . `golang.org/x/tools/container/intsets`/block#offset.)
1104 }
1105 }
1106 return nil
1107 }