Mercurial > hg > Applications > TightVNC_orginal
diff src/main/java/ac/ryukyu/treevnc/MostRecentMultiCast.java @ 3:e7ce2b2ffed8
add and modify files
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Jul 2012 15:46:36 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/ac/ryukyu/treevnc/MostRecentMultiCast.java Tue Jul 24 15:46:36 2012 +0900 @@ -0,0 +1,27 @@ +package ac.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(); + } + } +}