@@ -251,20 +251,17 @@ type sequencePosition struct {
251
251
}
252
252
253
253
func updateSimulatedIdxMap (idxMap * map [Movable ]int , moved Movable , startingIdx int , targetIdx int ) {
254
- slog .Debug ("updateSimulatedIdxMap" , "entries" , idxMap )
255
254
for entry , idx := range * idxMap {
256
255
if entry == moved {
257
256
continue
258
257
}
259
258
260
- slog .Debug ("updateSimulatedIdxMap" , "entry" , entry , "idx" , idx , "startingIdx" , startingIdx , "targetIdx" , targetIdx )
261
259
if startingIdx > targetIdx && idx >= targetIdx {
262
260
(* idxMap )[entry ] = idx + 1
263
261
} else if startingIdx < targetIdx && idx >= startingIdx && idx <= targetIdx {
264
262
(* idxMap )[entry ] = idx - 1
265
263
}
266
264
}
267
- slog .Debug ("updateSimulatedIdxMap" , "entries" , idxMap )
268
265
}
269
266
270
267
func OptimizeMovements (existing []Movable , expected []Movable , entries []Movable , actions []MoveAction , position any ) []MoveAction {
@@ -277,10 +274,7 @@ func OptimizeMovements(existing []Movable, expected []Movable, entries []Movable
277
274
var optimized []MoveAction
278
275
279
276
switch position .(type ) {
280
- case PositionBefore :
281
- slog .Debug ("OptimizeMovements()" , "position" , position , "type" , fmt .Sprintf ("%T" , position ))
282
- case PositionAfter :
283
- slog .Debug ("OptimizeMovements()" , "position" , position , "type" , fmt .Sprintf ("%T" , position ))
277
+ case PositionBefore , PositionAfter :
284
278
default :
285
279
return actions
286
280
}
@@ -298,22 +292,19 @@ func OptimizeMovements(existing []Movable, expected []Movable, entries []Movable
298
292
case ActionWhereBottom :
299
293
targetIdx = len (simulated ) - 1
300
294
case ActionWhereBefore :
301
- slog .Debug ("OptimizeMovements()" , "dest" , action .Destination , "destIdx" , simulatedIdxMap [action .Destination ])
302
295
targetIdx = simulatedIdxMap [action .Destination ] - 1
303
296
case ActionWhereAfter :
304
297
targetIdx = simulatedIdxMap [action .Destination ] + 1
305
298
}
306
299
307
- slog .Debug ("OptimizeMovements()" , "action" , action , "currentIdx" , currentIdx , "targetIdx" , targetIdx )
308
300
if targetIdx != currentIdx {
309
301
optimized = append (optimized , action )
310
302
simulatedIdxMap [action .Movable ] = targetIdx
311
303
updateSimulatedIdxMap (& simulatedIdxMap , action .Movable , currentIdx , targetIdx )
312
304
}
313
305
}
314
306
315
- slog .Debug ("OptimizeMovements()" , "optimized" , optimized )
316
-
307
+ slog .Debug ("OptimiveMovements()" , "optimized" , optimized )
317
308
return optimized
318
309
}
319
310
@@ -348,50 +339,35 @@ func GenerateMovements(existing []Movable, expected []Movable, entries []Movable
348
339
349
340
var movements []MoveAction
350
341
351
- var commonStartIdx , commonEndIdx int
352
- if commonLen > 0 {
353
- commonStartIdx = expectedIdxMap [common [0 ]]
354
- commonEndIdx = expectedIdxMap [common [commonLen - 1 ]]
355
- }
356
-
357
- slog .Debug ("GenerateMovements()" , "expected" , expected )
358
- slog .Debug ("GenerateMovements()" , "existing" , existing )
359
- slog .Debug ("GenerateMovements()" , "common" , common , "commonStartIdx" , commonStartIdx , "commonEndIdx" , commonEndIdx )
360
342
var previous Movable
361
343
for _ , elt := range entries {
362
- slog .Debug ("GenerateMovements()" , "elt" , elt , "existing" , existingIdxMap [elt ], "expected" , expectedIdxMap [elt ])
363
344
// If existing index for the element matches the expected one, skip it over
364
345
if existingIdxMap [elt ] == expectedIdxMap [elt ] {
365
346
continue
366
347
}
367
348
368
349
if expectedIdxMap [elt ] == 0 {
369
- slog .Debug ("HELP1" )
370
350
movements = append (movements , MoveAction {
371
351
Movable : elt ,
372
352
Destination : nil ,
373
353
Where : ActionWhereTop ,
374
354
})
375
355
previous = elt
376
356
} else if expectedIdxMap [elt ] == len (expectedIdxMap ) {
377
- slog .Debug ("HELP2" )
378
357
movements = append (movements , MoveAction {
379
358
Movable : elt ,
380
359
Destination : nil ,
381
360
Where : ActionWhereBottom ,
382
361
})
383
362
previous = elt
384
363
} else if previous != nil {
385
- slog .Debug ("HELP3" )
386
-
387
364
movements = append (movements , MoveAction {
388
365
Movable : elt ,
389
366
Destination : previous ,
390
367
Where : ActionWhereAfter ,
391
368
})
392
369
previous = elt
393
370
} else {
394
- slog .Debug ("HELP4" )
395
371
var where ActionWhereType
396
372
397
373
switch movement {
0 commit comments