Java 常用集合笔记
自增数组
ArrayList<Integer>G[]=new ArrayList[N]
栈
Stack<Integer> stack=new Stack<Integer>();
boolean empty()
Object peek( )
Object pop( )
Object push(Object element)
int search(Object element)
返回对象在堆栈中的位置,以 1 为基数。
队列
Queue<Integer>que=new LinkedList<Integer>();
add
offer
poll
pollFirst
poolLast
优先队列
默认小根堆,有需要自行设置比较器
PriorityQueue<Integer>que=new PriorityQueue<Integer>();
堆
HashSet<Integer>set=new HashSet<Integer>
add(Object)
remove(object)
size()
clear()
isEmpty()
contain(object)
map
HashMap<Integer,Integer>map=new HashMap<Integer,Integer>
void clear( )
Object clone( )
boolean contains(Object value)
boolean containsKey(Object key)
boolean containsValue(Object value)
Object get(Object key)
Object put(Object key, Object value)
双端队列
LinkedList qmax=new LinkedList<Integer>();
void clear( )
int peekFirst();
int peekLast();
int pollFirst();
int pollLast();
int addFirst(Object o);
int addLast(Object o);