public abstract class LinkedAbstract<K,V> extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private NodeAbstract<K,V> |
headNode
头节点
|
private Map<K,NodeAbstract<K,V>> |
searchMap
用于查找链表节点的map
使得查找节点的时间为O(1)
|
private NodeAbstract<K,V> |
tailNode
尾节点
|
| 构造器和说明 |
|---|
LinkedAbstract() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
deleteFromSearchMap(NodeAbstract<K,V> node)
将节点从查找map中移除
|
NodeAbstract<K,V> |
get(K key)
根据key获取某个节点
|
NodeAbstract<K,V> |
insertAfter(NodeAbstract<K,V> targetNode,
NodeAbstract<K,V> node)
某节点后插入节点
|
NodeAbstract<K,V> |
insertBefore(NodeAbstract<K,V> targetNode,
NodeAbstract<K,V> node)
某节点前插入节点
|
NodeAbstract<K,V> |
pop()
从链表尾删除一个节点
|
NodeAbstract<K,V> |
push(NodeAbstract<K,V> node)
尾部插入节点
|
void |
remove(K key)
删除某个节点
|
void |
remove(NodeAbstract<K,V> node)
删除某个节点
|
protected void |
saveToSearchMap(NodeAbstract<K,V> node)
将节点存入查找map
|
NodeAbstract<K,V> |
shift()
从链表头删除一个节点
|
int |
size()
链表元素个数
|
NodeAbstract<K,V> |
unshift(NodeAbstract<K,V> node)
头部插入节点
|
private NodeAbstract<K,V> headNode
private NodeAbstract<K,V> tailNode
private Map<K,NodeAbstract<K,V>> searchMap
public NodeAbstract<K,V> unshift(NodeAbstract<K,V> node)
node - public NodeAbstract<K,V> push(NodeAbstract<K,V> node)
node - public NodeAbstract<K,V> insertBefore(NodeAbstract<K,V> targetNode, NodeAbstract<K,V> node)
targetNode - 目标节点node - 要插入的节点public NodeAbstract<K,V> insertAfter(NodeAbstract<K,V> targetNode, NodeAbstract<K,V> node)
targetNode - 目标节点node - 要插入的节点public NodeAbstract<K,V> get(K key)
key - public void remove(NodeAbstract<K,V> node)
node - 节点对象public void remove(K key)
key - 节点keypublic NodeAbstract<K,V> shift()
public NodeAbstract<K,V> pop()
public int size()
protected void saveToSearchMap(NodeAbstract<K,V> node)
node - protected void deleteFromSearchMap(NodeAbstract<K,V> node)
node - Copyright © 2023. All rights reserved.