All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.weicoder.common.queue.OnlyQueue Maven / Gradle / Ivy

package com.weicoder.common.queue;

import java.util.Collection;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * 唯一队列值 基础并发队列ConcurrentLinkedQueue 确保元素唯一
 * @author WD
 */
public class OnlyQueue extends ConcurrentLinkedQueue {
	private static final long serialVersionUID = -790216735906542874L;

	@Override
	public boolean add(E e) {
		if (contains(e))
			return remove(e);
		return super.add(e);
	}

	@Override
	public boolean addAll(Collection c) {
		if (containsAll(c))
			return removeAll(c);
		return super.addAll(c);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy