package org.gallery3.utils {
	public class ArrayUtils {
		public static function intersect(array1:Array, array2:Array): Array {
			var intersection:Array = new Array();
        	var n:int = array1.length;
        	for (var i:int = 0; i < n; i++) {
				if (array2.indexOf(array1[i]) != -1) {
					intersection[intersection.length] = array1[i];
				}
        	}
        	return intersection;
		}

		public static function union(array1:Array, array2:Array): Array {
			var union:Array = new Array();
       		var n:int = array1.length;
         	for (var i:int = 0; i < n; i++) {
         		union[i] = array1[i];
         	}
       		n = array2.length;
        	for (i = 0; i < n; i++) {
				if (array1.indexOf(array2[i]) == -1) {
					union[union.length] = array2[i];
				}
        	}
        	return union;
		}
	}
}