feat(Kotlin): Replace value with _val (#1254)

* ci(kotlin): Add workflow file.

* Update kotlin.yml

* style(kotlin): value -> _val

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
curtishd
2024-04-10 18:09:43 +08:00
committed by GitHub
parent 39e2e1a5c1
commit 1623e3c6a8
28 changed files with 152 additions and 152 deletions
+3 -3
View File
@@ -7,7 +7,7 @@
package utils
/* 链表节点 */
class ListNode(var value: Int) {
class ListNode(var _val: Int) {
var next: ListNode? = null
companion object {
@@ -15,8 +15,8 @@ class ListNode(var value: Int) {
fun arrToLinkedList(arr: IntArray): ListNode? {
val dum = ListNode(0)
var head = dum
for (value in arr) {
head.next = ListNode(value)
for (_val in arr) {
head.next = ListNode(_val)
head = head.next!!
}
return dum.next
+2 -2
View File
@@ -33,7 +33,7 @@ fun printLinkedList(h: ListNode?) {
var head = h
val list = mutableListOf<String>()
while (head != null) {
list.add(head.value.toString())
list.add(head._val.toString())
head = head.next
}
println(list.joinToString(separator = " -> "))
@@ -70,7 +70,7 @@ fun printTree(root: TreeNode?, prev: Trunk?, isRight: Boolean) {
}
showTrunks(trunk)
println(" ${root.value}")
println(" ${root._val}")
if (prev != null) {
prev.str = prevStr
+2 -2
View File
@@ -9,7 +9,7 @@ package utils
/* 二叉树节点类 */
/* 构造方法 */
class TreeNode(
var value: Int // 节点值
var _val: Int // 节点值
) {
var height: Int = 0 // 节点高度
var left: TreeNode? = null // 左子节点引用
@@ -54,7 +54,7 @@ class TreeNode(
while (i >= res.size) {
res.add(null)
}
res[i] = root.value
res[i] = root._val
treeToListDFS(root.left, 2 * i + 1, res)
treeToListDFS(root.right, 2 * i + 2, res)
}
+2 -2
View File
@@ -7,7 +7,7 @@
package utils
/* 顶点类 */
class Vertex(val value: Int) {
class Vertex(val _val: Int) {
companion object {
/* 输入值列表 vals ,返回顶点列表 vets */
fun valsToVets(vals: IntArray): Array<Vertex?> {
@@ -22,7 +22,7 @@ class Vertex(val value: Int) {
fun vetsToVals(vets: MutableList<Vertex?>): MutableList<Int> {
val vals = mutableListOf<Int>()
for (vet in vets) {
vals.add(vet!!.value)
vals.add(vet!!._val)
}
return vals
}