view src/main/java/jp/ac/u_ryukyu/treevnc/MostRecentMultiCast.java @ 34:f70008073a03

add TreeViewer.java
author one
date Tue, 04 Sep 2012 19:02:04 +0900
parents 12c3a73be47f
children
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc;

import java.util.LinkedList;


public class MostRecentMultiCast<T> extends MulticastQueue<T> {

	LinkedList<Node<T>> alive;
	int count = 0;
	MostRecentMultiCast(int limit) {
		count = limit;
		this.alive = new LinkedList<Node<T>>();
	}

	@Override
	public synchronized void put(T item)
	{
		Node<T> next = new Node<T>(item);
		tail.set(next);
		tail = next;
		alive.addLast(next);
		if (alive.size()>count) {
			Node<T> old = alive.getFirst();
			old.clear();
		}
	}
}