[julia-users] Re: membership checking in heap

2016-10-03 Thread Athul George Appadan
As a follow up question, is there a way to check if a particular key is 
present in the priority queue? That is, to check if `HeapEntry` with k=5 is 
there in a heap..? Does julia has any wildcards..? 

On Saturday, October 1, 2016 at 10:47:48 PM UTC+5:30, Athul George Appadan 
wrote:
>
> I am trying to find a way to check the membership of a user defined type 
> object in a heap. This is the code I have written:
>
> type HeapEntry
> k::Int
> dist::Float64
> end
>
> isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>
> heap1 = []
> Collection.heappush!(heap1, HeapEntry(1, 10.0))
>
>
> But HeapEntry(1, 10.0) is returning false. Can anyone explain how to do it 
> correctly?
>


[julia-users] Re: membership checking in heap

2016-10-02 Thread Athul George Appadan
Thanks a lot..

On Monday, October 3, 2016 at 2:41:13 AM UTC+5:30, Steven G. Johnson wrote:
>
>
>
> On Saturday, October 1, 2016 at 1:17:48 PM UTC-4, Athul George Appadan 
> wrote:
>>
>> I am trying to find a way to check the membership of a user defined type 
>> object in a heap. This is the code I have written:
>>
>> type HeapEntry
>> k::Int
>> dist::Float64
>> end
>>
>> isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>>
>> heap1 = []
>> Collection.heappush!(heap1, HeapEntry(1, 10.0))
>>
>>
>> But HeapEntry(1, 10.0) is returning false. Can anyone explain how to do 
>> it correctly?
>>
>
> == defaults to object equality, so HeapEntry(1, 10.0) == HeapEntry(1, 
> 10.0) returns false unless you define your own == operation.
>
> However, I'm guessing that in this case you want to define an immutable 
> type, rather than a mutable type.  Not only will storage etc be more 
> efficient, but also the default == will do what you want in that case.
>
> immutable HeapEntry
>
>k::Int
>
>dist::Float64
>
> end
>
> Base.isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>
> heap1 = HeapEntry[]
>
> Collections.heappush!(heap1, HeapEntry(1, 10.0))
>
>
> At that point, HeapEntry(1, 10.0) in heap1 returns true.
>
>
> However, note that a heap data structure is not designed for fast 
> membership testing.  It is designed for quickly popping the minimum 
> element.   If you want "x in data" operations to be fast, you should use 
> some other data structure.
>


[julia-users] membership checking in heap

2016-10-01 Thread Athul George Appadan
I am trying to find a way to check the membership of a user defined type 
object in a heap. This is the code I have written:

type HeapEntry
k::Int
dist::Float64
end

isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist

heap1 = []
Collection.heappush!(heap1, HeapEntry(1, 10.0))


But HeapEntry(1, 10.0) is returning false. Can anyone explain how to do it 
correctly?


[julia-users] Unable to add packages

2016-04-23 Thread Athul George Appadan
I am unable to install packages in my system. Whenever I am trying, the 
following error is thrown up.

julia> Pkg.add("JSON")
INFO: Initializing package repository /home/fossee/.julia/v0.2
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
fatal: unable to connect to github.com:
github.com[0: 192.30.252.123]: errno=Connection timed out

ERROR: failed process: Process(`git clone -q -b metadata-v2 
git://github.com/JuliaLang/METADATA.jl METADATA`, ProcessExited(128)) [128]
 in pipeline_error at process.jl:476
 in run at process.jl:453
 in anonymous at no file:43
 in cd at file.jl:22
 in init at pkg/dir.jl:41
 in cd at pkg/dir.jl:25
 in add at pkg.jl:19

julia>