☁️정리/❄️자료구조
[자료구조] TreeMap
뿌야._.
2023. 6. 19. 13:57
❓ TreeMap 이란?
- 이진트리를 기반으로 한 Map 컬렉션
- 객체 저장 시 자동 정렬(default : 오름차순)
- <key, value>
❓TreeMap 선언
TreeMap<Integer, Integer> map=new TreeMap<>();
❓ TreeMap 추가, 삭제
// 추가
map.put(1,1);
// 삭제
map.remove(1);
❓ TreeMap 가장 작은 값, 큰 값 구하기
// 가장 키 값이 큰 값
map.lastEntry();
// 가장 키 값이 작은 값
map.firstEntry();