강의

멘토링

로드맵

Inflearn Community Q&A

suewoonryu1870's profile image
suewoonryu1870

asked

Effective Java Complete Guide Part 1

Item 1. Complete Guide 1 - Enum Type

[과제] EnumMap, EnumSet

Written on

·

865

8

## EnumMap

Javadoc에 따르면 

"when the map is created. Enum maps are represented internally as arrays. This representation is extremely compact and efficient." 

-> hashmap 은 key를 bucket에 저장하고각 bucket이 linked list를 참조 하고 있음. (linkedlist에는 hash(key)가 같은 element가 들어감) 그런데 enummap 의 경우 key로 사용할 값이 제한되어 있으므로, 그 갯수만큼 길이를 가진 array를 선언하고. 해당 index에 값을 넣으면 됨. 

 ## EnumSet

Javadoc에 따르면 

"when the set is created. Enum sets are represented internally as bit vectors."

-> hashset은 hashmap 과 같은데 map의 value가 있다 없다를 표현하는 지시자 같은 값이 들어감. enumset은 값이 있다 없다만 표시하면 되니까 enummap 처럼 array로 구현하지 않고 10101011 같은 bitvector로 구현이 가능.

java

Answer 1

0

whiteship님의 프로필 이미지
whiteship
Instructor

귿!

suewoonryu1870's profile image
suewoonryu1870

asked

Ask a question