<commit_before>package com.babylonhx.tools;

/**
 * ...
 * @author <NAME>
 */

@:expose('BABYLON.SmartArray') class SmartArray<T:ISmartArrayCompatible> {
	
	private static var _GlobalId:Int = 0;
	
	public var data:Array<T>;
	public var length:Int = 0;

	private var _id:Int;
	private var _duplicateId:Int = 0;
	

	public function new(capacity:Int = 256) {
		this.data = new Array<T>();
		this._id = SmartArray._GlobalId++;
	}

	inline public function push(value:T):Void {
		this.data[this.length++] = value;

		/*if (value.__smartArrayFlags == null) {
			value.__smartArrayFlags = [];
		}*/

		value.__smartArrayFlags[this._id] = this._duplicateId;
	}

	public function pushNoDuplicate(value:T) {
		if(/*value.__smartArrayFlags != null &&*/ value.__smartArrayFlags[this._id] == this._duplicateId) {
			return;
		}
		
		this.push(value);
	}

	inline public function sort(compareFn:T->T->Int) {
		this.data.sort(compareFn);
	}

	inline public function reset():Void {
		this.length = 0;
		this._duplicateId++;
	}

	inline public function concatArray(array:Array<T>) {
		//if (array.length != 0) {		
			for (index in 0...array.length) {
				this.data[this.length++] = array[index];
			}
		//}
	}
	
	inline public function concatSmartArray(array:SmartArray<T>) {
		//if (array.length != 0) {
			for (index in 0...array.length) {
				this.data[this.length++] = array.data[index];
			}
		//}
	}

	inline public function concatArrayWithNoDuplicate(array:Array<T>) {
		//if (array.length != 0) {			
			for (index in 0...array.length) {
				var item = array[index];
				this.pushNoDuplicate(item);
			}
		//}
	}
	
	inline public function concatSmartArrayWithNoDuplicate(array:SmartArray<T>) {
		//if (array.length != 0) {
			for (index in 0...array.length) {
				var item = array.data[index];
				this.pushNoDuplicate(item);
			}
		//}
	}

	inline public function indexOf(value:T):Int {
		var position = this.data.indexOf(value);
		
		return (position >= this.length) ? -1 : position;
	}

}<commit_msg>Update SmartArray.hx<commit_after>package com.babylonhx.tools;

/**
 * ...
 * @author <NAME>
 */

@:expose('BABYLON.SmartArray') class SmartArray<T:ISmartArrayCompatible> {
	
	private static var _GlobalId:Int = 0;
	
	public var data:Array<T>;
	public var length:Int = 0;

	private var _id:Int;
	private var _duplicateId:Int = 0;
	

	public function new(capacity:Int = 256) {
		this.data = new Array<T>();
		this._id = SmartArray._GlobalId++;
	}

	inline public function push(value:T):Void {
		this.data[this.length++] = value;
		value.__smartArrayFlags[this._id] = this._duplicateId;
	}

	public function pushNoDuplicate(value:T):Bool {
		if(value.__smartArrayFlags[this._id] == this._duplicateId) {
			return false;
		}
		
		this.push(value);
		
		return true;
	}

	inline public function sort(compareFn:T->T->Int) {
		this.data.sort(compareFn);
	}

	inline public function reset():Void {
		this.length = 0;
		this._duplicateId++;
	}

	inline public function concatArray(array:Array<T>) {
		for (index in 0...array.length) {
			this.data[this.length++] = array[index];
		}
	}
	
	inline public function concatSmartArray(array:SmartArray<T>) {
		for (index in 0...array.length) {
			this.data[this.length++] = array.data[index];
		}
	}

	inline public function concatArrayWithNoDuplicate(array:Array<T>) {
		for (index in 0...array.length) {
			var item = array[index];
			this.pushNoDuplicate(item);
		}
	}
	
	inline public function concatSmartArrayWithNoDuplicate(array:SmartArray<T>) {
		for (index in 0...array.length) {
			var item = array.data[index];
			this.pushNoDuplicate(item);
		}
	}

	inline public function indexOf(value:T):Int {
		var position = this.data.indexOf(value);
		
		return (position >= this.length) ? -1 : position;
	}

}
{'fraction_non_alphanumeric': 0.15409309791332262, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 3.64472049689441, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '6625100', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1302, 'n_words': 258}