@@ -1052,8 +1052,18 @@ println(x in z) //prints true
10521052
10531053 inline fun <T > List<T>.contains (other : List <T >, predicate : (thisElement: T , otherElement: T ) -> Boolean ): Boolean = indexOf(other, 0 , this .size, predicate) >= 0
10541054
1055- inline fun <T > List<T>.indexOf (other : List <T >, startIndex : Int , endIndex : Int , predicate : (thisElement: T , otherElement: T ) -> Boolean ): Int {
1056- fun <T > List<T>.regionMatches (thisOffset : Int , other : List <T >, otherOffset : Int , size : Int , predicate : (thisElement: T , otherElement: T ) -> Boolean ): Boolean {
1055+ fun <T > List<T>.indexOf (other : List <T >, startIndex : Int , endIndex : Int , predicate : (thisElement: T , otherElement: T ) -> Boolean ): Int {
1056+
1057+ val indices = startIndex.coerceAtLeast(0 ).. endIndex.coerceAtMost(this .size)
1058+
1059+ for (index in indices) {
1060+ if (other.regionMatches(0 , this , index, other.size, predicate))
1061+ return index
1062+ }
1063+ return - 1
1064+ }
1065+
1066+ inline fun <T > List<T>.regionMatches (thisOffset : Int , other : List <T >, otherOffset : Int , size : Int , predicate : (thisElement: T , otherElement: T ) -> Boolean ): Boolean {
10571067 if ((otherOffset < 0 ) || (thisOffset < 0 ) || (thisOffset > this .size - size) || (otherOffset > other.size - size)) {
10581068 return false
10591069 }
@@ -1064,15 +1074,6 @@ println(x in z) //prints true
10641074 }
10651075 return true
10661076 }
1067- val indices = startIndex.coerceAtLeast(0 ).. endIndex.coerceAtMost(this .size)
1068-
1069- for (index in indices) {
1070- if (other.regionMatches(0 , this , index, other.size, predicate))
1071- return index
1072- }
1073- return - 1
1074- }
1075-
10761077
10771078 fun <T > Iterable<T>.collectionSizeOrDefault (default : Int ): Int = if (this is Collection <* >) this .size else default
10781079
0 commit comments