package me.nallar.tickthreading.collections;

import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;

import me.nallar.tickthreading.Log;

public class TreeHashSet<T> extends TreeSet<T> {
	private final Set internalHashSet = Collections.newSetFromMap(new ConcurrentHashMap());

	public Iterator concurrentIterator() {
		return internalHashSet.iterator();
	}

	@Override
	public boolean contains(Object o) {
		return internalHashSet.contains(o);
	}

	@Override
	public synchronized boolean add(T o) {
		if (internalHashSet.add(o)) {
			super.add(o);
			if (size() > 5000 && size() % 64 == 0) {
				Log.info("Spammy TickNextTickList updates", new Throwable());
			}
			return true;
		}
		return false;
	}

	@Override
	public synchronized boolean remove(Object o) {
		if (internalHashSet.remove(o)) {
			super.remove(o);
			return true;
		}
		return false;
	}

	@Override
	public synchronized void clear() {
		super.clear();
		internalHashSet.clear();
	}
}

@@ -669,126 +669,8 @@
 );%0D%0A
-%09%09%09if (size() %3E 5000 && size() %25 64 == 0) %7B%0D%0A%09%09%09%09Log.info(%22Spammy TickNextTickList updates%22, new Throwable());%0D%0A%09%09%09%7D%0D%0A
 %09%09%09r

Remove spammy debug log.