⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_table_wiki.php

📁 散列函数源代码,散列表通常是关键字和值对应的数据结构,散列函数用于把关键字映射到相应的数组索引号,由于散列表中每个元素访问到的概率不同,所以应该选用不同的散列函数,以提高程序的查找效率.
💻 PHP
字号:
<?php

// Make results table
// (c) Peter Kankowski, 2008

$columns = array();
$rows = array(
  '[[http://www.cse.yorku.ca/~oz/hash.html#djb2|Bernstein]]',
  'K&R',
  'x17 unrolled',
  '[[http://www.cse.yorku.ca/~oz/hash.html#sdbm|x65599]]',
  '[[http://isthe.com/chongo/tech/comp/fnv/|FNV-1a]]',
  'Sedgewick',
  'Weinberger',
  '[[http://research.microsoft.com/~PALARSON/|Paul Larson]]',
  
  '[[http://www.azillionmonkeys.com/qed/hash.html|Paul Hsieh]]',
  '[[http://www.burtleburtle.net/bob/hash/doobs.html|One At Time]]',
  '[[http://www.burtleburtle.net/bob/hash/doobs.html|lookup3]]',
  '[[http://www.partow.net/programming/hashfunctions/|Arash Partow]]',
  'CRC-32',
  'Ramakrishna',
  '[[http://en.wikipedia.org/wiki/Fletcher\'s_checksum|Fletcher]]',
  '[[http://murmurhash.googlepages.com/MurmurHash2.cpp|Murmur2]]'
);

$time = array();
$collisions = array();

$lines = file('test_results.txt');

function select_best(&$max) {
   if(!isset($max))
     return;
   asort($max);
   $i = 0;
   reset($max);
   foreach($max as $key => $value) {
     if( $i++ >= 3 )
        break;
     $max[$key] = '**' . $max[$key] . '**';
   }
   return $max;
}

foreach($lines as $line) {
    if(preg_match('/\| +(\d+) \[ *(\d+)\]/', $line, $match)) {
       array_push($time[$cur_col], $match[1]);
       array_push($collisions[$cur_col], $match[2]);
       $cur_row++;
    } else if(0 == strspn($line, "1234567890")) {
       # Mark the best results
       if(isset($cur_col))
           select_best($time[$cur_col]);
       
       $cur_row = 0;
       array_push($columns, rtrim($line));
       array_push($time, array());
       $cur_col = array_push($collisions, array()) - 1;
    }
}

select_best($time[$cur_col]);

// Print the table
echo '^ ^' . implode('^^', $columns) . "^^\r\n";
for($i = 0; $i < count($rows); $i++) {
    echo '|' . $rows[$i];
    for($j = 0; $j < count($columns); $j++) {
        echo '|  ' . $time[$j][$i] . '| <color #CCCCCC>[' . $collisions[$j][$i] . ']</color>';
    }
    echo "|\r\n";
}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -