我的算法使用了一个庞大的布尔数组,正如我所教导的,每个布尔变量需要1个字节.无论如何都要声明一个布尔数组并减少内存使用量,因为我正在处理手机环境.
编辑:我的朋友和我正在讨论BitSet是否比普通布尔数组慢.请澄清一下.该算法仍然需要性能作为最佳需求.
解决方法
BitSet
This class implements a vector of bits that grows as needed. Each
component of the bit set has a boolean value. The bits of a BitSet are
indexed by nonnegative integers. Individual indexed bits can be
examined,set,or cleared. One BitSet may be used to modify the
contents of another BitSet through logical AND,logical inclusive OR,
and logical exclusive OR operations.
Link to benchmark使用布尔与BitSet之间