<commit_before>var PROCED = PROCED || {};
PROCED.wrappingArray = function(size) {
	var zonesX = [],
		zonesY = [],
		zonesZ = [];
	var centerIdx = ~~(size / 2),
		maxIdx =  size - 1,
		zoneFunctions = [];
	function constructor() {
		if(size % 2 === 0) {
			throw new Error('size should not be dividable by two');
		}
		var count = 0;
		for(var i = centerIdx; i < size; i++) {
			zonesX[count] = {
				max: centerIdx + count,
				min: centerIdx - count
			};
			zonesY[count] = {
				max: centerIdx + count,
				min: centerIdx - count
			};
			zonesZ[count] = {
				max: centerIdx + count,
				min: centerIdx - count
			};
			count++;
		}
	}
	function getNextWrap(num) {
		if(num === maxIdx) {
			return 0;
		}
		else {
			return num + 1;	
		}
	}
	function getPrevWrap(num) {
		if(num === 0) {
			return maxIdx;
		}
		else {
			return num - 1;	
		}
	}
	constructor();
	var pub = {};
	pub.setZoneFunction = function(zone, fnForward, fnBackward) {
		zoneFunctions[zone] = {
			forward: fnForward,
			backward: fnBackward
		};
	};
	pub.moveXPlus = function(worldCoords) {
		for(var i = 0; i < zonesX.length; i++) {
			zonesX[i].max = getNextWrap(zonesX[i].max);
			zonesX[i].min = getNextWrap(zonesX[i].min);

			var x = zonesX[i].max,
				y, z, wrappedIdx;
			for(y = zonesY[i].min; y != zonesY[i].max; y = getNextWrap(y)) {
				for(z = zonesZ[i].min; z != zonesZ[i].max; z = getNextWrap(z)) {
					wrappedIdx = getIdx(x,y,z);
					zoneFunctions[i].forward(wrappedIdx, worldCoords);
					//keep track of world coordinates somewhere else
					//example zone function:
					//zoneFnForDrawing(wrappedIdx, worldCoords) {
					//	array[wrappedIdx] = loadIfNotLoaded(worldCoords);
					//	array[wrappedIdx].draw()
					//}
				}
			}

			x = zonesX[i].min;
			for(y = zonesY[i].min; y != zonesY[i].max; y = getNextWrap(y)) {
				for(z = zonesZ[i].min; z != zonesZ[i].max; z = getNextWrap(z)) {
					wrappedIdx = getIdx(x,y,z);
					zoneFunctions[i].backward(wrappedIdx, worldCoords);
				}
			}

		}

	};

	pub.size = size;
<commit_msg>Updated wrapping-array with world coordinates bookkeeping...<commit_after>var PROCED = PROCED || {};
PROCED.wrappingArray = function(size) {
	var zonesX = [],
		zonesY = [],
		zonesZ = [];
	var centerIdx = ~~(size / 2),
		maxIdx =  size - 1,
		zoneFunctions = [];
	function constructor() {
		if(size % 2 === 0) {
			throw new Error('size should not be dividable by two');
		}
		var count = 0;
		for(var i = centerIdx; i < size; i++) {
			zonesX[count] = {
				max: centerIdx + count,
				min: centerIdx - count,
				worldMax: centerIdx + count,
				worldMin: centerIdx - count
			};
			zonesY[count] = {
				max: centerIdx + count,
				min: centerIdx - count,
				worldMax: centerIdx + count,
				worldMin: centerIdx - count
			};
			zonesZ[count] = {
				max: centerIdx + count,
				min: centerIdx - count,
				worldMax: centerIdx + count,
				worldMin: centerIdx - count
			};
			count++;
		}
	}
	function getNextWrap(num) {
		if(num === maxIdx) {
			return 0;
		}
		else {
			return num + 1;	
		}
	}
	/*
	function getPrevWrap(num) {
		if(num === 0) {
			return maxIdx;
		}
		else {
			return num - 1;	
		}
	}
	*/
	constructor();
	var pub = {};
	pub.setZoneFunction = function(zone, fnForward, fnBackward) {
		zoneFunctions[zone] = {
			forward: fnForward,
			backward: fnBackward
		};
	};
	pub.dirXPlus = function() {
		for(var i = 0; i < zonesX.length; i++) {
			zonesX[i].max = getNextWrap(zonesX[i].max);
			zonesX[i].min = getNextWrap(zonesX[i].min);
			zonesX[i].worldMax++;
			zonesX[i].worldMin++;

			var x = zonesX[i].max,
				y, z, wrappedIdx;
			for(y = zonesY[i].min; y != zonesY[i].max; y = getNextWrap(y)) {
				for(z = zonesZ[i].min; z != zonesZ[i].max; z = getNextWrap(z)) {
					wrappedIdx = getIdx(x,y,z);
					zoneFunctions[i].forward(
					wrappedIdx, {
						x: zonesX[i].worldMax,
						y: y,
						z: z
					});
				}
			}

			x = zonesX[i].min;
			for(y = zonesY[i].min; y != zonesY[i].max; y = getNextWrap(y)) {
				for(z = zonesZ[i].min; z != zonesZ[i].max; z = getNextWrap(z)) {
					wrappedIdx = getIdx(x,y,z);
					zoneFunctions[i].backward(wrappedIdx, {
						x: zonesX[i].worldMin,
						y: y,
						z: z
					});
				}
			}

		}
	};

	pub.size = size;

{'fraction_non_alphanumeric': 0.16963226571767498, 'fraction_numerical': 0.004744958481613286, 'mean_word_length': 2.669277632724108, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6298518', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1645, 'n_words': 347}