forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e03fa5
commit 8201d9e
Showing
4 changed files
with
48 additions
and
3 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
20 changes: 20 additions & 0 deletions
20
multitask/src/main/java/dev/aether/collaborative_multitasking/Extensions.kt
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,20 @@ | ||
package dev.aether.collaborative_multitasking | ||
|
||
fun <K, V> MutableMap<K, V>.filterInPlace(predicate: (Map.Entry<K, V>) -> Boolean): List<K> { | ||
val collected: MutableList<K> = mutableListOf() | ||
for (pair in this.entries) { | ||
if (!predicate(pair)) { | ||
collected.add(pair.key) | ||
} | ||
} | ||
val deleted: MutableList<K> = mutableListOf() | ||
for (delete in collected) { | ||
val del = this.remove(delete) | ||
if (del != null) deleted.add(delete) | ||
} | ||
return deleted | ||
} | ||
|
||
fun <K, V> MutableMap<K, V>.filterInPlace(predicate: (K, V) -> Boolean) = filterInPlace { pair -> | ||
predicate(pair.key, pair.value) | ||
} |
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