From 92ca21d531701b17be250aa30172653233ea082d Mon Sep 17 00:00:00 2001 From: "alexander.nutz" Date: Thu, 28 Mar 2024 18:42:48 +0100 Subject: [PATCH] removeFirstInto() and removeLastInto(); bump to 0.7 --- README.md | 2 +- build.gradle.kts | 2 +- src/main/kotlin/blitz/collections/ListOps.kt | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a2597d..4ba1b90 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ repositories { } dependencies { - implementation("me.alex_s168:blitz:0.6") + implementation("me.alex_s168:blitz:0.7") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 7041777..180fc00 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "me.alex_s168" -version = "0.6" +version = "0.7" repositories { mavenCentral() diff --git a/src/main/kotlin/blitz/collections/ListOps.kt b/src/main/kotlin/blitz/collections/ListOps.kt index dda896f..6cd58dd 100644 --- a/src/main/kotlin/blitz/collections/ListOps.kt +++ b/src/main/kotlin/blitz/collections/ListOps.kt @@ -6,8 +6,22 @@ fun MutableList.removeFirst(count: Int) { } } +fun MutableList.removeFirstInto(count: Int, dest: MutableList = mutableListOf()): MutableList { + repeat(count) { + dest.add(removeFirst()) + } + return dest +} + fun MutableList.removeLast(count: Int) { repeat(count) { removeLast() } +} + +fun MutableList.removeLastInto(count: Int, dest: MutableList = mutableListOf()): MutableList { + repeat(count) { + dest.add(removeLast()) + } + return dest } \ No newline at end of file