i trying return index of selected element of my Vector collection
type Node
name::AbstractString
value::Int
left::Nullable{Node}
right::Nullable{Node}
Node(name::AbstractString, value::Int) = new(name, value, Nullable{Node}(), Nullable{Node}())
end
function minimal(nodes::Vector{Node})
minnode=Nullable{Node}()
minval = nodes[1].value
for f in nodes
if f.value< minval
minval= f.value
minnode = f
end
end
return find(nodes .== minnode)
end
Problem is of course find(nodes .== minnode)
, how can I return index of this element
The function seems to be overkill, wouldn't it be sufficient to do:
e.g. for
this returns
3
, the index of the smallest node in the node list.