package ru.job4j;

import java.util.*;

/**.
* Chapter_003
* Task 3.1.2
* Check time for other collection
*
* @author Anton Vasilyuk
* @version 1.0
* @since 0.1
*/

public class CheckTime {

	/**.
	* Method for check time for operation add
	* @param collection
	* @param line is added word
	* @param amount is number element
	* @return time
	*/
	public long add(Collection<String> collection, String line, int amount) {

		String word = "a";
		long firstTime = System.currentTimeMillis();

		for (int i = 0; i < amount; i++) {
			word += line;
			collection.add(word);
		}
		long secondTime = System.currentTimeMillis();
		return secondTime - firstTime;
	}
	public long delete(Collection<String> collection, int amount) {

		Iterator<String> iter = collection.iterator();
		int i = 0;
		long firstTime = System.currentTimeMillis();

		while (iter.hasNext() && i < amount) {
			iter.next();
			iter.remove();
			i++;
		}

		long secondTime = System.currentTimeMillis();
		return secondTime - firstTime;
	}
}
@@ -431,14 +431,23 @@
 word
- = %22a%22
+;%0A%09%09int num = 0
 ;%0A%09%09
@@ -533,16 +533,26 @@
 ) %7B%0A
+%09%09%09num++;%0A
 %09%09%09word 
 += l
@@ -551,15 +551,20 @@
 ord 
-+
 = line
+ + num
 ;%0A%09%09

add file for chapter_003_3.1.2