MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / projectedAfterMove

Function projectedAfterMove

app/src/API/Handlers/ProjectHandler.cpp:3489–3501  ·  view source on GitHub ↗

* @brief Compute the new ordinal for an item after a list move; mirrors std::vector reorder. */

Source from the content-addressed store, hash-verified

3487 * @brief Compute the new ordinal for an item after a list move; mirrors std::vector reorder.
3488 */
3489static int projectedAfterMove(int oldIndex, int from, int to)
3490{
3491 if (oldIndex == from)
3492 return to;
3493
3494 if (from < to && oldIndex > from && oldIndex <= to)
3495 return oldIndex - 1;
3496
3497 if (from > to && oldIndex >= to && oldIndex < from)
3498 return oldIndex + 1;
3499
3500 return oldIndex;
3501}
3502
3503/**
3504 * @brief Moves a dataset to a new position within its group.

Callers 2

datasetMoveMethod · 0.85
groupMoveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected