0
|
1 package treeVnc;
|
|
2
|
|
3 import java.util.LinkedList;
|
|
4
|
|
5
|
|
6 public class MostRecentMultiCast<T> extends MulticastQueue<T> {
|
|
7
|
|
8 LinkedList<Node<T>> alive;
|
|
9 int count = 0;
|
|
10 MostRecentMultiCast(int limit) {
|
|
11 count = limit;
|
|
12 this.alive = new LinkedList<Node<T>>();
|
|
13 }
|
|
14
|
|
15 @Override
|
|
16 public synchronized void put(T item)
|
|
17 {
|
|
18 Node<T> next = new Node<T>(item);
|
|
19 tail.set(next);
|
|
20 tail = next;
|
|
21 alive.addLast(next);
|
|
22 if (alive.size()>count) {
|
|
23 Node<T> old = alive.getFirst();
|
|
24 old.clear();
|
|
25 }
|
|
26 }
|
|
27 }
|