@Override
	public T[] next() {

		if (!firstElemntOut) {
			firstElemntOut = true;
			return objList.clone();
		}

		// see the wiki page for detailed explanation.
		// http://en.wikipedia.org/wiki/Permutation#Systematic_generation_of_all_permutations

		// find the least significant reversed order
		int k = n - 2;
		for (; k >= 0; k--) {
			if (objList[k].compareTo(objList[k + 1]) < 0) {
				break;
			}
		}

		int l = n - 1;
		for (; objList[k].compareTo(objList[l]) >= 0; l--) {
			;
		}

		// swap it.
		swap(k, l);

		// make k+1..n-1 to be in ascending order. That is, the next smallest
		// permutation in dictionary order.
		for (int i = k + 1, j = n - 1; i < j; i++, j--) {
			swap(i, j);
		}

		return objList;
	}