package com.platform.test;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.platform.entities.CheckoutEntity;
import com.platform.entities.PreDataInfo;
import com.platform.utils.Configs;

public class FileRename {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();
		int a = total/12;
		System.out.println(a*12 == total);
		System.out.println(total);
		System.out.println(removeLastSeparator("/a/b///"));
		List<PreDataInfo> li = new ArrayList<PreDataInfo>();
		for (int i = 0; i < 89000; i++) {
			PreDataInfo a1 = new CheckoutEntity();
			a1.setId(i+1);
			a1.setAreaCode("aaa");
			li.add(a1);
		}
		Date a1= new Date();
		System.err.println("-------------------");
		List<ArrayList<PreDataInfo>> re = insertBatch(li);
		Date a2= new Date();
		System.err.println(re.size());
		System.err.println(a2.getTime() - a1.getTime());
		
		List<PreDataInfo>[] res = insertBatch2(li);
		Date a3= new Date();
		System.err.println(res.length);
		System.err.println(a3.getTime()-a2.getTime());
	}
	
	public static String removeLastSeparator(String path){
		// 递归去掉 所有 结尾 /
		if (path.length() < 1) {
			return path;
		}
		String sep = "\\"+File.separator;
		Pattern pattern2 = Pattern.compile(sep+"$");
		Matcher matcher2 = pattern2.matcher(path);
		if (matcher2.find()) {
			path = path.substring(0, path.length()-1);
			path = removeLastSeparator(path);
		}
		return path;
	}
	
	private static List<ArrayList<PreDataInfo>> insertBatch(List<PreDataInfo> allAreaInsert) {
		int listSize = allAreaInsert.size();
		int loopSize = listSize/3;
		if (loopSize * 100 != listSize) {
			loopSize++;
		}
		List<ArrayList<PreDataInfo>> list = new ArrayList<ArrayList<PreDataInfo>>();
		for (int i = 0; i < loopSize; i++) {
			list.add(new ArrayList<PreDataInfo>());
		}
		for (int i = 0; i < listSize; i++) {
			list.get(i%loopSize).add(allAreaInsert.get(i));
		}
		return list;
	}
	
	private static List<PreDataInfo>[] insertBatch2(List<PreDataInfo> allAreaInsert) {
		int listSize = allAreaInsert.size();
		int loopSize = listSize/3;
		if (loopSize * 100 != listSize) {
			loopSize++;
		}
		List<PreDataInfo>[] list = new ArrayList[loopSize];
		for (int i = 0; i < loopSize; i++) {
			list[i] = new ArrayList<PreDataInfo>();
		}
		for (int i = 0; i < listSize; i++) {
			list[i%loopSize].add(allAreaInsert.get(i));
		}
//		for (List<PreDataInfo> list2 : list) {
//			System.err.println(list2.size());
//		}
		return list;
	}

}
