@@ -175,6 +175,8 @@ func (u *unaryNode) DecidedPrefix() int {
175
175
return u .decidedPrefix
176
176
}
177
177
178
+ //nolint:gci,gofmt,gofumpt // this comment is formatted as intended
179
+ //
178
180
// This is by far the most complicated function in this algorithm.
179
181
// The intuition is that this instance represents a series of consecutive unary
180
182
// snowball instances, and this function's purpose is convert one of these unary
@@ -186,23 +188,23 @@ func (u *unaryNode) DecidedPrefix() int {
186
188
//
187
189
// For example, attempting to insert the value "00001" in this node:
188
190
//
189
- // +-------------------+ <-- This node will not be split
190
- // | |
191
- // | 0 0 0 |
192
- // | |
193
- // +-------------------+ <-- Pass the add to the child
194
- // ^
195
- // |
191
+ // +-------------------+ <-- This node will not be split
192
+ // | |
193
+ // | 0 0 0 |
194
+ // | |
195
+ // +-------------------+ <-- Pass the add to the child
196
+ // ^
197
+ // |
196
198
//
197
199
// Results in:
198
200
//
199
- // +-------------------+
200
- // | |
201
- // | 0 0 0 |
202
- // | |
203
- // +-------------------+ <-- With the modified child
204
- // ^
205
- // |
201
+ // +-------------------+
202
+ // | |
203
+ // | 0 0 0 |
204
+ // | |
205
+ // +-------------------+ <-- With the modified child
206
+ // ^
207
+ // |
206
208
//
207
209
// 2. This instance represents a series of only one unary instance and it must
208
210
// be split.
@@ -213,19 +215,19 @@ func (u *unaryNode) DecidedPrefix() int {
213
215
//
214
216
// For example, attempting to insert the value "1" in this tree:
215
217
//
216
- // +-------------------+
217
- // | |
218
- // | 0 |
219
- // | |
220
- // +-------------------+
218
+ // +-------------------+
219
+ // | |
220
+ // | 0 |
221
+ // | |
222
+ // +-------------------+
221
223
//
222
224
// Results in:
223
225
//
224
- // +-------------------+
225
- // | | |
226
- // | 0 | 1 |
227
- // | | |
228
- // +-------------------+
226
+ // +-------------------+
227
+ // | | |
228
+ // | 0 | 1 |
229
+ // | | |
230
+ // +-------------------+
229
231
//
230
232
// 3. This instance must be split on the first bit
231
233
//
@@ -235,26 +237,26 @@ func (u *unaryNode) DecidedPrefix() int {
235
237
//
236
238
// For example, attempting to insert the value "10" in this tree:
237
239
//
238
- // +-------------------+
239
- // | |
240
- // | 0 0 |
241
- // | |
242
- // +-------------------+
240
+ // +-------------------+
241
+ // | |
242
+ // | 0 0 |
243
+ // | |
244
+ // +-------------------+
243
245
//
244
246
// Results in:
245
247
//
246
- // +-------------------+
247
- // | | |
248
- // | 0 | 1 |
249
- // | | |
250
- // +-------------------+
251
- // ^ ^
252
- // / \
253
- // +-------------------+ +-------------------+
254
- // | | | |
255
- // | 0 | | 0 |
256
- // | | | |
257
- // +-------------------+ +-------------------+
248
+ // +-------------------+
249
+ // | | |
250
+ // | 0 | 1 |
251
+ // | | |
252
+ // +-------------------+
253
+ // ^ ^
254
+ // / \
255
+ // +-------------------+ +-------------------+
256
+ // | | | |
257
+ // | 0 | | 0 |
258
+ // | | | |
259
+ // +-------------------+ +-------------------+
258
260
//
259
261
// 4. This instance must be split on the last bit
260
262
//
@@ -265,26 +267,26 @@ func (u *unaryNode) DecidedPrefix() int {
265
267
//
266
268
// For example, attempting to insert the value "01" in this tree:
267
269
//
268
- // +-------------------+
269
- // | |
270
- // | 0 0 |
271
- // | |
272
- // +-------------------+
270
+ // +-------------------+
271
+ // | |
272
+ // | 0 0 |
273
+ // | |
274
+ // +-------------------+
273
275
//
274
276
// Results in:
275
277
//
276
- // +-------------------+
277
- // | |
278
- // | 0 |
279
- // | |
280
- // +-------------------+
281
- // ^
282
- // |
283
- // +-------------------+
284
- // | | |
285
- // | 0 | 1 |
286
- // | | |
287
- // +-------------------+
278
+ // +-------------------+
279
+ // | |
280
+ // | 0 |
281
+ // | |
282
+ // +-------------------+
283
+ // ^
284
+ // |
285
+ // +-------------------+
286
+ // | | |
287
+ // | 0 | 1 |
288
+ // | | |
289
+ // +-------------------+
288
290
//
289
291
// 5. This instance must be split on an interior bit
290
292
//
@@ -296,33 +298,33 @@ func (u *unaryNode) DecidedPrefix() int {
296
298
//
297
299
// For example, attempting to insert the value "010" in this tree:
298
300
//
299
- // +-------------------+
300
- // | |
301
- // | 0 0 0 |
302
- // | |
303
- // +-------------------+
301
+ // +-------------------+
302
+ // | |
303
+ // | 0 0 0 |
304
+ // | |
305
+ // +-------------------+
304
306
//
305
307
// Results in:
306
308
//
307
- // +-------------------+
308
- // | |
309
- // | 0 |
310
- // | |
311
- // +-------------------+
312
- // ^
313
- // |
314
- // +-------------------+
315
- // | | |
316
- // | 0 | 1 |
317
- // | | |
318
- // +-------------------+
319
- // ^ ^
320
- // / \
321
- // +-------------------+ +-------------------+
322
- // | | | |
323
- // | 0 | | 0 |
324
- // | | | |
325
- // +-------------------+ +-------------------+
309
+ // +-------------------+
310
+ // | |
311
+ // | 0 |
312
+ // | |
313
+ // +-------------------+
314
+ // ^
315
+ // |
316
+ // +-------------------+
317
+ // | | |
318
+ // | 0 | 1 |
319
+ // | | |
320
+ // +-------------------+
321
+ // ^ ^
322
+ // / \
323
+ // +-------------------+ +-------------------+
324
+ // | | | |
325
+ // | 0 | | 0 |
326
+ // | | | |
327
+ // +-------------------+ +-------------------+
326
328
func (u * unaryNode ) Add (newChoice ids.ID ) node {
327
329
if u .Finalized () {
328
330
return u // Only happens if the tree is finalized, or it's a leaf node
0 commit comments