<commit_before>// Borrowed with great respect from this post:
// http://eloquentjavascript.net/appendix2.html

function BinaryHeap(scoreFunction){
    this.content = [];
    this.scoreFunction = scoreFunction == null ? DefaultScore : scoreFunction;
}

function DefaultScore(x) {
    return x;
}

BinaryHeap.prototype = {
    push: function(element) {
        // Add the new element to the end of the array.
        this.content.push(element);
        // Allow it to bubble up.
        this.bubbleUp(this.content.length - 1);
    },

    pop: function() {
        // Store the first element so we can return it later.
        var result = this.content[0];
        // Get the element at the end of the array.
        var end = this.content.pop();
        // If there are any elements left, put the end element at the
        // start, and let it sink down.
        if (this.content.length > 0) {
            this.content[0] = end;
            this.sinkDown(0);<commit_msg>Add contains check for heap<commit_after>// Borrowed with great respect from this post:
// http://eloquentjavascript.net/appendix2.html

function BinaryHeap(scoreFunction, equalFunction){
    this.content = [];
    this.scoreFunction = scoreFunction == null ? DefaultScore : scoreFunction;
    this.equalFunction = equalFunction == null ? DefaultEqual : equalFunction;
}

function DefaultScore(x) {
    return x;
}

function DefaultEqual(x, y) {
    console.log(x, y, x == y);
    return x == y;
}

BinaryHeap.prototype = {
    contains: function(desired) {
        for (var i = 0; i < this.content.length; i++) {
            if (this.equalFunction(this.content[i], desired)) {
                return true;
            }
        }
        return false;
    },

    push: function(element) {
        // Add the new element to the end of the array.
        this.content.push(element);
        // Allow it to bubble up.
        this.bubbleUp(this.content.length - 1);
    },

    pop: function() {
        // Store the first element so we can return it later.
        var result = this.content[0];
        // Get the element at the end of the array.
        var end = this.content.pop();
        // If there are any elements left, put the end element at the
        // start, and let it sink down.
        if (this.content.length > 0) {
            this.content[0] = end;
            this.sinkDown(0);
{'fraction_non_alphanumeric': 0.11190878378378379, 'fraction_numerical': 0.005489864864864865, 'mean_word_length': 2.1713520749665327, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2320896', 'n_tokens_mistral': 684, 'n_tokens_neox': 674, 'n_words': 221}