Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with PriorityQueue #337

Open
felipensp opened this issue Mar 31, 2013 · 1 comment
Open

Crash with PriorityQueue #337

felipensp opened this issue Mar 31, 2013 · 1 comment

Comments

@felipensp
Copy link
Member

The following code reproduces a crash:

import std.collection.*;
import std.io.*;

function test(x, y) {
    return x > y;
}

var pq = PriorityQueue.new(test);

pq.push(1);
pq.push(1);
pq.push(1);
@gogo40
Copy link
Member

gogo40 commented Apr 3, 2013

And there are a "leak" in this code

import std.collection.*;
import std.io.*;


class Pair {
    var x, y, d;

    function Pair(x, y, d) {
        this.x = x;
        this.y = y;
        this.d = d;
    }
}


function cmp(a, b) {
    return a.d < b.d;
}

var v = [];

for (var i = 0; i < 10; ++i) {
    for (var j = 0; j < 10; ++j) {
        for (var d = 0; d < 10; ++d) {
            v += [Pair.new(i, j, d)];
        }
    }
}


for (var n = 0; n < 10; ++n) {
    var pq = PriorityQueue.new(cmp);
    //var set = Set.new(cmp);

    for (var i in v) {
        pq.push(Pair.new(i.x, i.y, i.d));
        //set.insert(Pair.new(i.x, i.y, i.d));
    }

    while (!pq.empty()) {
        var p = pq.top();
        pq.pop();
    }
}




Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants