不知道 lz 你想干嘛 ,上面写得 不是很明确了

解决方案 »

  1.   

    条件说完了? 问题是什么?
      

  2.   

    偶去摆摊算命了!楼主来试试!
      

  3.   

    无非是实现一个有效性的检测,然后对数据库操作而已啊
      

  4.   

    BitSet 应该效率比较高。
    package com;import java.util.BitSet;public class Test5 { private static BitSet bset;
    private static Test5 t = null;
    private Test5()
    {
    bset = new BitSet(7);
    }
    //单例
    public static Test5 getInstance()
    {
    if(t==null)
    t = new Test5();
    return t;
    }
    //插入
    public boolean insert(int x)
    {
    if(!find(x))
    {
    bset.set(x);
    return true;
    }else
    {
    return false;
    }
    }
    //查找
    public boolean find(int x)
    {
    return bset.get(x);
    }

    //删除
    public boolean delete(int x)
    {
    if(find(x))
    {
    bset.clear(x);
    }
    return true;
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
    Test5 t = Test5.getInstance();
    long start = System.currentTimeMillis();
    for(int i=1000000;i<8999999;i++)
    {
    t.insert(i);
    }
    long end = System.currentTimeMillis();
    System.out.println("插入全部[1000000,8999999]耗时:"+(end-start)+" 毫秒");
    int x = 1000001;
    System.out.println(t.find(x));
    t.insert(x);
    System.out.println(t.find(x));
    t.delete(x);
    System.out.println(t.find(x));


    }}