package br.ufrj.cos.redes.delayLossSimulator;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import br.ufrj.cos.redes.fileAccess.Chunk;

public class ChunkList {

	private Map<Long, Chunk> chunkList;
	
	public ChunkList() {
		chunkList = Collections.synchronizedMap(new HashMap<Long, Chunk>());
	}
	
	public void add(long tn, Chunk chunk) {
		chunkList.put(tn, chunk);
	}
	
	public Chunk getChunk(long tn) {
		Chunk chunk = chunkList.get(tn);	
		chunkList.remove(tn);
		
		return chunk;		
	}
		
	public boolean isOver() {
		return chunkList.isEmpty();
	}	
	
	public void print() {
		Iterator iterator = chunkList.entrySet().iterator(); 
		System.out.println("List of chunks passed in simulator:");
		while(iterator.hasNext()) {
			Map.Entry entry = (Map.Entry) iterator.next();
			System.out.println("(tn = " + entry.getKey() + ", seqNum = " + ((Chunk) entry.getValue()).getSeqNum() + ")");
		}		
	}
	
	
}




@@ -572,19 +572,16 @@
 %09%09%0D%0A%09%7D%0D%0A
-%09%09%0D
 %0A%09public
@@ -634,17 +634,103 @@
 y();%0D%0A%09%7D
-%09
+%0D%0A%09%0D%0A%09public boolean hasChunkWithTn(Long tn) %7B%0D%0A%09%09return chunkList.containsKey(tn);%0D%0A%09%7D
 %0D%0A%09%0D%0A%09pu

add method hasChunkWithTn to ChunkList class