public class IntLinkedListMultiSet implements IntMultiSet, Cloneable {

	private IntLinkedList list;

	public IntLinkedListMultiSet() {
		list = new IntLinkedList();
	}

	public void add(int element) {
		list.insertFront(element);
	}

	public void addMany(int... elements) {
		for (int elem : elements) {
			list.insertBack(elem);
		}
	}

	public void addAll(IntMultiSet o) {
		IntLinkedListMultiSet other = (IntLinkedListMultiSet) o;
		list.addAll(other.list);
	}

	public boolean remove(int target) {
		return list.remove(target);
	}

	public int size() {
		return this.list.size();
	}

	public int countOccurrences(int target) {
		return list.countOccurences(target);
	}

	/**
	 * Generate a copy of this set.
	 *
	 * @return The return value is a copy of this set. Subsequent changes to the
	 *         copy will not affect the original, nor vice versa.
	 * @exception OutOfMemoryError Indicates insufficient memory for creating the
	 *                             clone.
	 **/
	public IntLinkedListMultiSet clone() {
		IntLinkedListMultiSet set = null;
		try {
			set = (IntLinkedListMultiSet) super.clone();
			set.list = this.list.clone();
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException("IntLinkedListMultiSet somehow isn't cloneable");
		}
		return set;
	}
}