<commit_before>'use strict';

class Set {

    constructor() {
        this.init();
    }

    /**
     * @private
     * inits the set properties
     */
    init() {
        this.elements = {};
        this.count = 0;        
    }

    /**
     * @public
     * adds an element to the set
     * @param {(string|number|boolean)} element
     */
    add(element) {
        if (!this.elements[element]) {
            this.elements[element] = true;
            this.count++;
        }
    }

    /**
     * @public
     * removes an element from the set
     * @param {(string|number|boolean)} element
     */
    remove(element){ 
        if (this.elements[element]) {
            this.elements[element] = false;
            this.count--;
        }
    }

    /**
     * @public
     * checks if the set is empty
     * @returns {boolean}
     */
    isEmpty() {
        return this.count === 0;
    }

    /**
     * @public
     * gets the size of the set
     * @returns {number}
     */
    size() {
        return this.count;
    }

    /**
     * @public
     * checks if the set contains an element
     * @param {(string|number|boolean)} element
     * @returns {number}
     */
    contains(element) {
        return this.elements[element] === true;
    }

    /**
     * @public
     * joins the actual set with a given set
     * @param {Set} s
     * @returns {Set}
     */
    union(s) {
        if (s instanceof Set) {
            let union = new Set();
            for (let el1 in this.elements) {
                if (this.contains(el1)) {
                    union.add(el1);
                }
            }
            for (let el2 of s.toArray()) {
                union.add(el2);
            }
            return union;
        }
        else {
            throw new Error('.union expects a set as a param');
        }
    }

    /**
     * @public
     * intersects the actual set with a given set
     * @param {Set} s
     * @returns {Set}
     */
    intersect(s) {
        if (s instanceof Set) {
            let intersect = new Set();
            for (let el in this.elements) {
                if (this.contains(el) && s.contains(el)) {
                    intersect.add(el);
                }
            }
            return intersect;
        }
        else {
            throw new Error('.intersect expects a set as a param');
        }
    }

    /**
     * @public
     * returns a set with elements that exists 
     * in the actual set but not in the given set
     * @param {Set} s
     * @returns {Set}
     */
    diff(s) {
        if (s instanceof Set) {
            let diffSet = new Set();
            for (let el in this.elements) {
                if (this.contains(el) && !s.contains(el)) {
                    diffSet.add(el);
                }  
            }
            return diffSet;
        }
        else {
            throw new Error('.diff expects a set as a param');
        }
    }

    /**
     * @private
     * checks if the actual set is a subset of another set
     * @param {Set} s
     * @returns {boolean}
     */
    isSetSubsetOf(s) {
        for (let el in this.elements) {
            if (this.contains(el) && !s.contains(el)) {
                return false;
            }
        }
        return true;
    }

    /**
     * @public
     * checks if the actual set is a subset of a given set
     * @param {Set} s
     * @returns {boolean}<commit_msg>refactor<commit_after>'use strict';

class Set {

    constructor() {
        this.init();
    }

    /**
     * @private
     * inits the set properties
     */
    init() {
        this.elements = {};
        this.count = 0;        
    }

    /**
     * @public
     * adds an element to the set
     * @param {(string|number|boolean)} element
     */
    add(element) {
        if (!this.elements[element]) {
            this.elements[element] = true;
            this.count++;
        }
    }

    /**
     * @public
     * removes an element from the set
     * @param {(string|number|boolean)} element
     */
    remove(element){ 
        if (this.elements[element]) {
            this.elements[element] = false;
            this.count--;
        }
    }

    /**
     * @public
     * checks if the set is empty
     * @returns {boolean}
     */
    isEmpty() {
        return this.count === 0;
    }

    /**
     * @public
     * gets the size of the set
     * @returns {number}
     */
    size() {
        return this.count;
    }

    /**
     * @public
     * checks if the set contains an element
     * @param {(string|number|boolean)} element
     * @returns {number}
     */
    contains(element) {
        return this.elements[element] === true;
    }

    /**
     * @private
     * @param {Set} s
     * @returns {Set}
     */
    unionSet(s) {
        let union = new Set();
        for (let el1 in this.elements) {
            if (this.contains(el1)) {
                union.add(el1);
            }
        }
        for (let el2 of s.toArray()) {
            union.add(el2);
        }
        return union;
    }  

    /**
     * @public
     * joins the actual set with a given set
     * @param {Set} s
     * @returns {Set|Error}
     */
    union(s) {
        if (s instanceof Set) {
            return this.unionSet(s);
        }
        else {
            throw new Error('.union expects a set as a param');
        }
    }

    /**
     * @private
     * @param {Set} s
     * @returns {Set}
     */
    intersectSet(s) {
        let intersect = new Set();
        for (let el in this.elements) {
            if (this.contains(el) && s.contains(el)) {
                intersect.add(el);
            }
        }
        return intersect;
    }    

    /**
     * @public
     * intersects the actual set with a given set
     * @param {Set} s
     * @returns {Set|Error}
     */
    intersect(s) {
        if (s instanceof Set) {
            return this.intersectSet(s);
        }
        else {
            throw new Error('.intersect expects a set as a param');
        }
    }

    /**
     * @private
     * @param {Set} s
     * @returns {Set}
     */
    diffSet(s) {
        let diffSet = new Set();
        for (let el in this.elements) {
            if (this.contains(el) && !s.contains(el)) {
                diffSet.add(el);
            }  
        }
        return diffSet;
    }

    /**
     * @public
     * returns a set with elements that exists 
     * in the actual set but not in the given set
     * @param {Set} s
     * @returns {Set|Error}
     */
    diff(s) {
        if (s instanceof Set) {
            return this.diffSet(s);
        }
        else {
            throw new Error('.diff expects a set as a param');
        }
    }

    /**
     * @private
     * @param {Set} s
     * @returns {boolean}
     */
    isSetSubsetOf(s) {
        for (let el in this.elements) {
            if (this.contains(el) && !s.contains(el)) {
                return false;
            }
        }
        return true;
    }

    /**
     * @public
     * checks if the actual set is a subset of a given set
     * @param {Set} s
     * @returns {boolean|Error}
{'fraction_non_alphanumeric': 0.12626262626262627, 'fraction_numerical': 0.001964085297418631, 'mean_word_length': 1.2646124523506987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2786860', 'n_tokens_mistral': 2165, 'n_tokens_neox': 2095, 'n_words': 581}