forked from Read-Write/Submariner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRY the move returning new IndexSet code
Unfortunately Foundation doesn't do this. Also remove an unused extension on NSIndexSet.
- Loading branch information
1 parent
4b705f8
commit e1459d5
Showing
7 changed files
with
41 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// MutableCollection+Move.swift | ||
// Submariner | ||
// | ||
// Created by Calvin Buckley on 2024-06-20. | ||
// | ||
// Copyright (c) 2024 Calvin Buckley | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import Foundation | ||
|
||
extension MutableCollection { | ||
mutating func moveReturningNewIndices(fromOffsets offsets: IndexSet, toOffset offset: Int) -> IndexSet { | ||
self.move(fromOffsets: offsets, toOffset: offset) | ||
|
||
var newRow = offset | ||
for index in offsets { | ||
if index < newRow { | ||
newRow -= 1 | ||
} | ||
} | ||
let lastRow = newRow + offsets.count - 1 | ||
let newRange = newRow...lastRow | ||
let newIndexSet = IndexSet(integersIn: newRange) | ||
|
||
return newIndexSet | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters