小编Aru*_*abu的帖子

如何显示1分钟的进度条?

我在android中有一个水平进度条.我需要在60秒内完成它.

为什么以下代码不起作用?

int progress = 0;
progressBarHorizontal.setMax(60);
while(progress < 60) {
     progressHandler.postDelayed((new Runnable() {
        public void run() {                     
           progressBarHorizontal.setProgress(progress);                    
        }                   
     }),progress * 1000);
     progress++;
}
Run Code Online (Sandbox Code Playgroud)

请提出一些其他方法.我试过这个:

new Thread(new Runnable() {
                int progress = 0;       
                public void run() {
                    long timerEnd = System.currentTimeMillis() + 60 * 1000;

                    while (timerEnd >  System.currentTimeMillis() ) {

                        progress = (int) (timerEnd - System.currentTimeMillis()) / 1000;
                        // Update the progress bar
                        progressHandler.post(new Runnable() {
                            public void run() {
                                progressBarHorizontal.setProgress(progress);
                            }
                        });                         
                        try {
                            Thread.sleep(500);
                        } catch …
Run Code Online (Sandbox Code Playgroud)

android handler

5
推荐指数
2
解决办法
9668
查看次数

二次探测哈希表的限制

我正在做一个程序来比较线性探测,二次探测和哈希表中单独链接所需的平均和最大访问.

我已经为3个案例完成了元素插入部分.在从哈希表中找到元素时,我需要限制结束搜索.在单独链接的情况下,我可以在下一个指针为空时停止.对于线性探测,我可以在探测整个表时停止(即表的大小).在二次探测中我应该使用什么作为限制?表大小会吗?

我的二次探测函数是这样的

newKey = (key + i*i) % size;
Run Code Online (Sandbox Code Playgroud)

其中我从0变为无穷大.请帮我..

algorithm hashtable quadratic probing data-structures

4
推荐指数
1
解决办法
3140
查看次数