I need a dictionary-like mapping between characters and other kinds of objects. Which class would be best?

StackOverflow https://stackoverflow.com/questions/2979140

  •  24-10-2019
  •  | 
  •  

문제

This is in Squeak/Pharo. If I want to have a mapping between Character objects like $a and $b to other kinds of objects, and want to look up those other objects based on the Character, what is the best class to use? Dictionary is an obvious choice, but seems wasteful to be hashing character objects which are basically already numbers. I guess what I want is a kind of array where the character value (number) is used as an index/offset, but I am not sure if this is possible with Unicode.

도움이 되었습니까?

해결책

At least the hashing's cheap: Character hash just says "^value".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top