求反交集算法

来源:互联网 发布:mac app原型设计工具 编辑:程序博客网 时间:2024/05/20 05:10

package data.BitSet;

import java.io.IOException;
import java.util.Random;

public class Data {

 
 public static void main(String[] args)throws Exception {
  test();
 }
 
 /**
  * 求反交集
  * @throws IOException
  */
 public   static void test() throws IOException {
        int[] randomNums = new int[10000000];
        Random random = new Random();
        for (int i = 0, length = randomNums.length; i < length; i++) {
            randomNums[i] = random.nextInt(10000000);
        }
        long start = System.currentTimeMillis();
        boolean[] bitArray = new boolean[10000000];
        for (int i = 0, length = randomNums.length; i < length; i++) {
            bitArray[randomNums[i]] = true;
        }
        for (int i = 0, length = bitArray.length; i < length; i++) {
            if (bitArray[i]) {
                continue;
            }
             //System.out.println(i);
        }
        long end = System.currentTimeMillis();
        System.out.println("Spend milliseconds: " + (end - start));
    }

}

本文来自网络转载itoyo

 
 

0 0
原创粉丝点击