我正在嘗試插入一個(gè)請(qǐng)求并通過優(yōu)先級(jí)對(duì)其進(jìn)行排序,因此最高(1)是列表中的第一個(gè)。public Node addByPriority(Object request, int priority) { size++; //creates a new node with a priority, owner and creator and sets its next node to the root Node newNode = new Node(request, priority); //node to store prev Node prevNode = null; //node to store current Node currNode = first; //cycle thru the nodes til either the priority is higher or current is null while (currNode != null && priority >= currNode.getPriority()) { prevNode = currNode; currNode = currNode.getNext(); } if (prevNode == null) { newNode.setNext(first); first = newNode; } else { prevNode.setNext(newNode); newNode.setNext(currNode); } // what would be the return statement??} 它說我需要一個(gè)退貨聲明,但不確定必須放什么,或者是否有其他方法。
添加回答
舉報(bào)
0/150
提交
取消