This commit is contained in:
krahets
2024-04-11 01:11:20 +08:00
parent a6adc8e20a
commit 739f8a31bb
85 changed files with 1555 additions and 979 deletions

View File

@ -1958,10 +1958,10 @@ comments: true
fun pop(isFront: Boolean): Int {
if (isEmpty())
throw IndexOutOfBoundsException()
val value: Int
val _val: Int
// 队首出队操作
if (isFront) {
value = front!!._val // 暂存头节点值
_val = front!!._val // 暂存头节点值
// 删除头节点
val fNext = front!!.next
if (fNext != null) {
@ -1971,7 +1971,7 @@ comments: true
front = fNext // 更新头节点
// 队尾出队操作
} else {
value = rear!!._val // 暂存尾节点值
_val = rear!!._val // 暂存尾节点值
// 删除尾节点
val rPrev = rear!!.prev
if (rPrev != null) {
@ -1981,7 +1981,7 @@ comments: true
rear = rPrev // 更新尾节点
}
queSize-- // 更新队列长度
return value
return _val
}
/* 队首出队 */