Why can't you use Set or Dict?

julia> s = Set{ASCIIString}()
Set{ASCIIString}()

julia> push!(s, "hello")
Set(ASCIIString["hello"])

julia> push!(s, "world")
Set(ASCIIString["hello","world"])

julia> "hello" in s
true

julia> "nope" in s
false

--Tim

On Sunday, November 22, 2015 09:58:31 AM Leonardo wrote:
> Hello,
> I'm looking for an Hash table in Julia (or Hash Set, how is called in other
> programming languages), to efficiently check existence of an element in
> set, but I haven't found it.
> I've found ObjectIdDict as alternative, defined as:
> ObjectIdDict <: Dict{Any,Any}
> where key and value are equals, capable to store reference any object (if
> I'm not wrong).
> It has a simple constructor:
> d = ObjectIdDict()
> (no type stored is specified, cause previous definition)
> 
> But - also inspecting code of dict.jl in Base package - I haven't found a
> simple method to add element in set like:
> push!(d,obj)
> but only the form
> d[obj] = obj
> works. This is correct way to do this? (potentially key and value can be
> different ...)
> 
> Many thanks in advance
> 
> Leonardo

Reply via email to