I think this is the fastest.  Unless you rewrite it in C and you get a bit faster.  But the technique itself is the fastest.To improve speed, you might want to look at your problem domain again.  What is the purpose of reading this array randomly for so many times?  Can you reduce the number of reads?  Can you parition the array into smaller arrays and do the reading in parallel using threads?  etc.

解决方案 »

  1.   

    你的意思是改写算法,把大数组拆分成若干小数组
    这些应该都有所帮助,但速度提高不是很多另外也有人说把int改成byte也会好些,以上办法都有些效果但效果不是特别明显
      

  2.   

    查找最快的应该是B+树,搂主可以把你的数组按照B+数的格式分拆n个节点。然后可以查找分叉直接定位。当然,定多少个节点,多少层,楼主要仔细分析自己的数据了。不过,java不支持自己操作内存,你拆开优化之后所需要的时间是否比java的数租查找优化快,那就不清楚了
      

  3.   

    楼上的不太对吧。再快的查找也没有数组快啊,直接一步定位。
    之所以有查找树的各种算法,主要是因为定位过程中需要比较一个KEY,
    而数组是不需要的。
      

  4.   

    你的意思是改写算法,把大数组拆分成若干小数组
    这些应该都有所帮助,但速度提高不是很多If you do 把大数组拆分成若干小数组 and then do parallel access, and if you have a multi-processor system, it will definetly help.  Even the new Pentium processor that supports hyper threading will show a difference.