<commit_before>
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var container = document.getElementById("canvasContainer");

canvas.width = container.clientWidth;
canvas.height = container.clientHeight;



function Quadtree(width, height){

	/*
		+------+------+
		| NW,0 | NE,1 |
		+------+------+
		| SW,2 | SE,3 |
		+------+------+
	*/

	var root = {
		 internal: true
		,centerX: width/2
		,centerY: height/2
		,level: 0
		,parent: null
	};

	root.children = [
		{
			 parent: root
			,level: 1
			,centerX: root.centerX - width /4
			,centerY: root.centerY - height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX + width /4
			,centerY: root.centerY - height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX - width /4
			,centerY: root.centerY + height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX + width /4
			,centerY: root.centerY + height/4
		}
	];

	function insert(value){
		insertTo(value, root);
	}

	function insertTo(value, node){
		if(node.internal){
			if(value.x > node.centerX){
				if(value.y > node.centerY){
					// SE
					insertTo(value, node.children[3]);
				} else {
					// NE
					insertTo(value, node.children[1]);
				}
			} else {
				if(value.y > node.centerY){
					// SW
					insertTo(value, node.children[2]);
				} else {
					// NW
					insertTo(value, node.children[0]);
				}
			}
		} else {
			if(!node.leaf){
				node.leaf = true;
				node.content = value;
			} else {
				node.leaf = false;
				node.internal = true;
				node.children = [
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX - width /Math.pow(2, node.level+2)
						,centerY: node.centerY - height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX + width /Math.pow(2, node.level+2)
						,centerY: node.centerY - height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX - width /Math.pow(2, node.level+2)
						,centerY: node.centerY + height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX + width /Math.pow(2, node.level+2)<commit_msg>Don't insert node if another one of the same coordinates exists<commit_after>
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var container = document.getElementById("canvasContainer");

canvas.width = container.clientWidth;
canvas.height = container.clientHeight;



function Quadtree(width, height){

	/*
		+------+------+
		| NW,0 | NE,1 |
		+------+------+
		| SW,2 | SE,3 |
		+------+------+
	*/

	var root = {
		 internal: true
		,centerX: width/2
		,centerY: height/2
		,level: 0
		,parent: null
	};

	root.children = [
		{
			 parent: root
			,level: 1
			,centerX: root.centerX - width /4
			,centerY: root.centerY - height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX + width /4
			,centerY: root.centerY - height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX - width /4
			,centerY: root.centerY + height/4
		},
		{
			 parent: root
			,level: 1
			,centerX: root.centerX + width /4
			,centerY: root.centerY + height/4
		}
	];

	function insert(value){
		insertTo(value, root);
	}

	function insertTo(value, node){
		if(node.internal){
			if(value.x > node.centerX){
				if(value.y > node.centerY){
					// SE
					insertTo(value, node.children[3]);
				} else {
					// NE
					insertTo(value, node.children[1]);
				}
			} else {
				if(value.y > node.centerY){
					// SW
					insertTo(value, node.children[2]);
				} else {
					// NW
					insertTo(value, node.children[0]);
				}
			}
		} else {
			if(!node.leaf){
				node.leaf = true;
				node.content = value;
			} else {
				if(node.content.x == value.x && node.content.y == value.y){
					return false;
				}
				node.leaf = false;
				node.internal = true;
				node.children = [
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX - width /Math.pow(2, node.level+2)
						,centerY: node.centerY - height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX + width /Math.pow(2, node.level+2)
						,centerY: node.centerY - height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX - width /Math.pow(2, node.level+2)
						,centerY: node.centerY + height/Math.pow(2, node.level+2)
					},
					{
						 parent: node
						,level: node.level + 1
						,centerX: node.centerX + width /Math.pow(2, node.level+2)
{'fraction_non_alphanumeric': 0.16825598643780462, 'fraction_numerical': 0.017800381436745075, 'mean_word_length': 2.1763122476446837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5468143', 'n_tokens_mistral': 2225, 'n_tokens_neox': 1696, 'n_words': 357}