core :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Library for simple interning of strings
module symbol
redef class String
# Get the unique corresponding to the string
fun to_symbol: Symbol
do
var symbol_dictionary = once new HashMap[String, Symbol]
if symbol_dictionary.has_key(self) then
return symbol_dictionary[self]
else
var symbol = new Symbol(self)
symbol_dictionary[self] = symbol
return symbol
end
end
end
# A symbol is a unique immutable string
class Symbol
private var string: String
redef fun to_s do return string.to_s
end
lib/symbol/symbol.nit:13,1--35,3