删除并返回头节点中的首个值 @return 头节点的首个值,null if empty
()
| 252 | * @return 头节点的首个值,null if empty |
| 253 | */ |
| 254 | public V poll() { |
| 255 | var root = getRoot(); |
| 256 | if (root == null) |
| 257 | return null; |
| 258 | |
| 259 | var headKey = root.getHeadNodeKey(); |
| 260 | if (headKey.getNodeId() == 0) |
| 261 | return null; |
| 262 | |
| 263 | var head = getNode(headKey); |
| 264 | if (head == null) |
| 265 | return null; |
| 266 | |
| 267 | var nodeValues = head.getValues(); |
| 268 | var nodeValue = nodeValues.remove(0); |
| 269 | root.setCount(root.getCount() - 1); |
| 270 | if (nodeValues.isEmpty()) { |
| 271 | root.setHeadNodeKey(head.getNextNodeKey()); |
| 272 | module._tQueueNodes.remove(headKey); |
| 273 | } |
| 274 | |
| 275 | @SuppressWarnings("unchecked") |
| 276 | var value = (V)nodeValue.getValue().getBean(); |
| 277 | return value; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @return 头节点的首个值,null if empty |