假设分配和释放需要常量时间,这个扩容动作花费O (n)时间,这里的n是当前数组的大小。
Assuming allocates and frees run in constant time, this enlargement process takes o (n) time where nis the current size of the array.
当对当前类启用跟踪时,清单7就创建了这些对象和数组。
Listing 7 creates these objects and arrays when trace is enabled for the current class.
与之前一样,可以用一个3d数组保存当前的这些几何分布。
As before, a 3d array is used to maintain the current and working geometries.
But if, at any point, I get to a place in the list where the thing I'm looking for is smaller than the element in the list, I know everything else in the rest of the list has to be bigger than that, I don't have to bother looking anymore.
比当前位置数组的元素要小,我也就知道后面的数肯定,也都比我的目标数要大了,我就不用再继续进行下去了,这意味着目标数不在这个数组中,我就可以退出了。
If it's there, I'm done, if not, I keep walking down, and I only stop when I get to a place where the element I'm looking for is smaller than the value in the list., in which case I know the rest of this is too big and I can stop.
并且保持遍历,我只在当当前位置的数组元素,大于目标数时停止,这意味着剩下的元素都比目标元素大,但是其他的情况,我还是要遍历完整个数组。
I'll look at the rest of that big chunk of the list, and that's a pain.
因为这样每一步,都可以保证,排除当前数组的。
应用推荐