You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Determines whether [this] list contains a sublist such that at least one element in each list of said sublist is contained in a parallel sublist of [other].
1043
-
* This is a direct adaptation of [CharSequence.contains(CharSequence)].
1044
-
* For example the following returns true:
1045
-
val x = listOf( listOf('a', 'b', 'c'), listOf('d', 'e', 'f') )
1046
-
val y = listOf(listOf('x' ,'y' ,'z'), listOf('1', '2', 'a'), listOf('3', 'f', '4'), listOf('9'))
1047
-
val z = listOf( listOf('1', '2', 'a'), listOf('3', 'f', '4') )
1048
-
println(x in y) //prints true
1049
-
println(x in z) //prints true
1050
-
*/
1041
+
1042
+
/**
1043
+
* Returns index of the first element after [offset] matching the given [predicate], or -1 if the list does not contain such element.
1044
+
*/
1045
+
publicinlinefun <T> List<T>.indexOf(predicate: (T) ->Boolean, offset:Int): Int {
1046
+
var index =0
1047
+
for (item inthis.subList(offset, this.size)) {
1048
+
if (predicate(item))
1049
+
return index
1050
+
index++
1051
+
}
1052
+
return-1
1053
+
}
1054
+
1055
+
/**
1056
+
* Splits a list by a predicate. List analog to [String.split]
1057
+
* */
1058
+
fun <E> List<E>.split(includeDelimiter:Boolean = false, predicate: (E) ->Boolean): List<List<E>> {
* Determines whether [this] list contains a sublist such that at least one element in each list of said sublist is contained in a parallel sublist of [other].
1071
+
* This is a direct adaptation of [CharSequence.contains(CharSequence)].
1072
+
* For example the following returns true:
1073
+
* val x = listOf( listOf('a', 'b', 'c'), listOf('d', 'e', 'f') )
1074
+
* val y = listOf(listOf('x' ,'y' ,'z'), listOf('1', '2', 'a'), listOf('3', 'f', '4'), listOf('9'))
1075
+
* val z = listOf( listOf('1', '2', 'a'), listOf('3', 'f', '4') )
1076
+
* println(x in y) //prints true
1077
+
* println(x in z) //prints true
1078
+
*/
1051
1079
operatorfun <T> List<Iterable<T>>.contains(other:List<Iterable<T>>): Boolean= contains(other) { thisList, otherList -> thisList.any { it in otherList } }
0 commit comments