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

Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top