protected short[] union(short[] itemSet1, short[] itemSet2) {
        // check for null sets
        if (itemSet1 == null) {
            if (itemSet2 == null) return(null);
            else return(itemSet2);
            }
        if (itemSet2 == null) return(itemSet1);

        // determine size of union and dimension return itemSet
        short[] newItemSet = new short[sizeOfUnion(itemSet1,itemSet2)];

        // Loop through itemSets
        int index1=0, index2=0, index3=0;
        while (index1<itemSet1.length) {
            // Check for end of itemSet2
            if (index2>=itemSet2.length) {
            	for (int index=index1;index<itemSet1.length;index++,index3++)
            	    			newItemSet[index3] = itemSet1[index];
            	break;
            	}
            // Before	
            if (itemSet1[index1] < itemSet2[index2]) {
            	newItemSet[index3] = itemSet1[index1];
            	index1++;
            	}
            else {
                // Equals
                if (itemSet1[index1] == itemSet2[index2]) {
                    newItemSet[index3] = itemSet1[index1];
            	    index1++;
            	    index2++;
            	    }
            	// After
                else {
            	    newItemSet[index3] = itemSet2[index2];
            	    index2++;
                    }	
                }
            index3++;
            }

        // add remainder of itemSet2
        for (int index=index2;index<itemSet2.length;index++,index3++)
    				newItemSet[index3] = itemSet2[index];

        // Return
        return(newItemSet);
        }