Hi Steve,

sorry the delay, I was out... I think the dictionary questions were
answered by Kevin.

> With regard to the inner and outer constructor both needed, can you give me 
> a reference?  I have read the manual section you mentioned; the constructor 
> for the Point example in the manual takes arguments and so it doesn't seem 
> to cover my case.

This is a long thread about this
https://groups.google.com/forum/#!searchin/julia-users/constructor/julia-users/LWgATl9Pd64/50aEPb8UAfUJ
probably the best bit is here by Stefan
https://groups.google.com/d/msg/julia-users/LWgATl9Pd64/Zp2JvfKhK48J

Try this one too:
https://groups.google.com/forum/#!searchin/julia-users/constructor/julia-users/lk3WcbDJOJo/QqkNzsNMUXQJ

> With regard to default key values, I'm still not getting it, so let me ask 
> the question in more detail.  A data node in my structure looks like this:
>
>    immutable TreeLeaf{K,D}
>        k::K 
>        d::D
>        parent::Int
>     end
>
> To initialize a map, I need to create an Array{TreeLeaf{K,D},2).  The two 
> initial entries are markers for the start and end of the data.  The k and d 
> fields of these two nodes don't matter, but the parent values do matter. 
>  So apparently I need something like this:
>
>     data = Array{TreeLeaf{K,D}, 2}

I think here you want to construct an instance
   data = Array(TreeLeaf{K,D}, 2)
what you wrote gives you back a datatype:
   data = Array{TreeLeaf{K,D}, 2}

>     data[1] = TreeLeaf(undefinedK, undefinedD, 1)
>     data[2] = TreeLeaf(undefinedK, undefinedD, 1)
>
> What should I put for 'undefinedK' and 'undefinedD' here?  After seeing 
> your post, I tried this:  u = Array{K,1}, and then I used u[1] for 
> undefinedK, but this gave an error ("access to undefined reference"). 
>  There are some other places in my code where I have a similar problem.

Hmm, I'm not sure and I don't have quite enough time to ponder it.  But
one way could be to leave the fields of TreeLeaf uninitialised:

immutable A
    a
    A() = new()
    A(x) = new(x)
end

a = A()
b = A(5)

Then you can check whether the field is defined:
julia> isdefined(a, :a)
false

julia> isdefined(b, :a)
true

But your probably better of with just leaving the `data`-array entries
undefined.  Again, check with `isdefined`, accessing them is an error.

This probably doesn't answer your questions.  Maybe have a look at some
other trees:

https://groups.google.com/forum/?fromgroups=#!searchin/julia-dev/AVL$20tree/julia-dev/KPpLattsEpc/PhGu0a8l-RQJ
https://groups.google.com/forum/?fromgroups=#!searchin/julia-dev/tree/julia-dev/dDaUEqHKVCk/zBBIQBAn7jMJ
red-black tree https://gist.github.com/SirVer/3371829

Reply via email to