Collections

java core 2015. 8. 12. 17:53

(Sometiems ArrayList is better when no synchronize, Sometimes Vector is better because of Size doubling )

 

ArrayList : Resizable Array - fast because of index.  Add/Delete is Slow for data Copy. ==> 50% increase its array size

Vector : Similar to ArryList..  a little heavy because of synchronize processing. ==> doubles its array size

 

LinkedList: Fast for ADD/Delete.  But No Index so sequential search is slow.

 

HashSet, SortedSet,

HashMap

DelayQueue,  - - - |> BlockingQueue

Stack

 

several I/F like:

  Queue, - 보통  new LinkedList<T>();

  Deque, - 상동.    

  BlockingQueue : (waiting in some cases)

put은 queue가 꽉 차 있을 경우, take

는 queue가 비어있을 경우가 블로킹 조건이다. 

  TransferQueue

 

 

<class> 

  ConcurrentXX  Collections : thread-Safe

-ConcurrentHashMap : synchronize detail이 HashTable과 약간 다름.

   

  - SynchronousQueue: 초기 size가 0이고.. 다른Thread에서 빼려고 할때만 삽입이 가능한 놈이므로 peek도 안됨..

      

 

TreeMap -  red-black Tree 기반의 sorted NavigableMap

 

TreeSet   -  TreeMap기반.

 

PriorityQueue - Heap자료구조 기반..

PriorityQueue 클래스는 기본적으로 작은 값이 우선순위가 높은 것으로 취급합니다. 따라서, 1에서 100까지의 숫자를 PriorityQueue에 추가하면, 1이 가장 높은 우선순위를 갖게 되고, 100이 가장 낮은 우선순위를 갖게 됩니다. 따라서 poll() 메서드를 호출하면, 가장 높은 우선순위를 갖는 1이 먼저 반환됩니다.  => 체육복 코딩테스트에 사용 됨.

 

 

Posted by yongary
,