File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/utils Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ internal inline fun <reified T> Array<out T>.value() = if (isNotEmpty()) {
7373 " [${value.trim().let { it.substring(0 , it.lastIndex) }} ]"
7474} else " []"
7575
76+ /* *
77+ * 通过 [conditions] 查找符合条件的最后一个元素的下标
78+ * @return [Int] 没有找到符合条件的下标将返回 -1
79+ */
80+ internal inline fun <reified T > Sequence<T>.findLastIndex (conditions : (T ) -> Boolean ) =
81+ withIndex().findLast { conditions(it.value) }?.index ? : - 1
82+
83+ /* *
84+ * 返回最后一个元素的下标
85+ * @return [Int] 如果 [Sequence] 为空将返回 -1
86+ */
87+ internal inline fun <reified T > Sequence<T>.lastIndex () = foldIndexed(- 1 ) { index, _, _ -> index }.takeIf { it >= 0 } ? : - 1
88+
7689/* *
7790 * 满足条件判断方法体 - 对 [kotlin.takeIf] 进行封装
7891 * @param other 需要满足不为空的对象 - 仅用于判断是否为 null
You can’t perform that action at this time.
0 commit comments