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
  •  | 
  •  

Pergunta

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.

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top