<commit_before>package jascii.geom;

class Rect
{
    public var x:Int;
    public var y:Int;
    public var width:Int;
    public var height:Int;

    public function new(x:Int, y:Int, width:Int, height:Int)
    {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public function union(other:Rect):Rect
    {
        var x = other.x > this.x ? this.x : other.x;
        var y = other.y > this.y ? this.y : other.y;
        var width = other.x + other.width > this.x + this.width
                  ? other.x + other.width : this.x + this.width;
        var height = other.y + other.height > this.y + this.height
                   ? other.y + other.height : this.y + this.height;
        return new Rect(x, y, width - x, height - y);
    }

    public function intersects(other:Rect):Bool
    {
        return (
            ((this.x >= other.x && this.x < other.x + other.width)  ||
             (other.x >= this.x && other.x < this.x + this.width))  &&
            ((this.y >= other.y && this.y < other.y + other.height) ||
             (other.y >= this.y && other.y < this.y + this.height))
        );
    }

    public function toString():String
    {
        return "<Rectangle x: " + this.x + "; y: " + this.y +
               "; width: " + this.width + "; height: " + this.height + ">";
    }
}<commit_msg>Rect: Add a method to compare with another Rect.<commit_after>package jascii.geom;

class Rect
{
    public var x:Int;
    public var y:Int;
    public var width:Int;
    public var height:Int;

    public function new(x:Int, y:Int, width:Int, height:Int)
    {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public function union(other:Rect):Rect
    {
        var x = other.x > this.x ? this.x : other.x;
        var y = other.y > this.y ? this.y : other.y;
        var width = other.x + other.width > this.x + this.width
                  ? other.x + other.width : this.x + this.width;
        var height = other.y + other.height > this.y + this.height
                   ? other.y + other.height : this.y + this.height;
        return new Rect(x, y, width - x, height - y);
    }

    public function intersects(other:Rect):Bool
    {
        return (
            ((this.x >= other.x && this.x < other.x + other.width)  ||
             (other.x >= this.x && other.x < this.x + this.width))  &&
            ((this.y >= other.y && this.y < other.y + other.height) ||
             (other.y >= this.y && other.y < this.y + this.height))
        );
    }

    public function matches(other:Rect):Bool
    {
        return this.x == other.x && this.width  == other.width
            && this.y == other.y && this.height == other.height;
    }

    public function toString():String
    {
        return "<Rectangle x: " + this.x + "; y: " + this.y +
               "; width: " + this.width + "; height: " + this.height + ">";
    }
}
{'fraction_non_alphanumeric': 0.15356058049274385, 'fraction_numerical': 0.0, 'mean_word_length': 1.7118023787740164, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '7015422', 'n_tokens_mistral': 982, 'n_tokens_neox': 965, 'n_words': 240}