0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

[Kotlin Migration] CollectionUtils

Package: com.ichi2.utils
This commit is contained in:
codingtosh 2021-11-06 23:20:32 +05:30 committed by David Allison
parent 1992752643
commit 3c176046ec
2 changed files with 13 additions and 14 deletions

View File

@ -43,7 +43,7 @@ permission notice:
// Example of class name: "/com/ichi2/anki/UIUtils.kt"
// Ensure that it starts with '/' (slash)
def source = Source.MAIN
def className = "/com/ichi2/utils/CollectionUtils.kt"
def className = ""
enum Source {
MAIN("/src/main/java"),

View File

@ -13,25 +13,24 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ichi2.utils
package com.ichi2.utils;
import java.util.Collection;
import java.util.List;
public class CollectionUtils {
/** Throws IndexOutOfBoundsException on empty list*/
public static <T> T getLastListElement(List<T> l) {
return l.get(l.size()-1);
object CollectionUtils {
/** Throws IndexOutOfBoundsException on empty list */
@JvmStatic
fun <T> getLastListElement(l: List<T>): T {
return l[l.size - 1]
}
/**
* @param c A collection in which to add elements of it
* @param it An iterator returning things to add to C
* @param <T> Type of elements to copy from iterator to collection
*/
public static <T> void addAll(Collection<T> c, Iterable<T> it) {
for (T elt : it) {
c.add(elt);
</T> */
@JvmStatic
fun <T> addAll(c: MutableCollection<T>, it: Iterable<T>) {
for (elt in it) {
c.add(elt)
}
}
}