• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

[과제] EnumMap, EnumSet

22.07.22 16:18 작성 조회수 707

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로 구현이 가능.

답변 1

답변을 작성해보세요.

0

귿!