import java.util.Random;

public abstract class CollectionTimer
{
   public static final int[] DEFAULT_MUTATIONS = {10000, -10000};
   private Random elemGen = new Random();

   public CollectionTimer() {}
   public CollectionTimer(long elemGenSeed)
   {
	   elemGen.setSeed( elemGenSeed );
   }

   public abstract void addElement(Integer elem);
   public abstract void removeElement();
   public abstract int getSize();
   public abstract boolean isEmpty(); 

   public void insert(int amount)
   {
	   Integer elem;
	   for ( int i = 0; i <  amount; i++ )
	   {
              elem = elemGen.nextInt();
	      addElement(elem);
	   }
   }

   public boolean extract(int amount)
   {
	   for ( int i = 0; i <  amount; i++ )
	   {
	       removeElement();
	   }
	   return true;
   }

   public long time()
  {
    long begin = System.currentTimeMillis();
    insert(DEFAULT_MUTATIONS[0]);
    extract(-DEFAULT_MUTATIONS[1]);
    return System.currentTimeMillis() - begin;
  }

   public long time(int[] mutations)
   {
     long begin = System.currentTimeMillis();
     for (int a : mutations) {
       if (a < 0) {
         extract(-a); 
       }
       else {
         insert(a);
       }
     }
     return System.currentTimeMillis() - begin;
   }
}
