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

📄 make_table.php

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

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

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

$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] = '<span class="g">' . $max[$key] . '</span>';
   }
   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 with green color
       if(isset($cur_col))
           select_best($time[$cur_col]);
       
       # Check number of rows
       //if(isset($cur_row) && $cur_row != count($rows))
       //   die($columns[count($columns)-1] . ': should be ' . count($rows) . " columns, found {$cur_row}");
       
       $cur_row = 0;
       array_push($columns, rtrim($line));
       array_push($time, array());
       $cur_col = array_push($collisions, array()) - 1;
    }
}

select_best($time[$cur_col]);

echo '<style>.g {color:green} td{border:1px solid #336699; padding:5px} table{border:1px solid #336699; border-collapse:collapse}</style>';
echo '<table>';
echo '<tr><td></td><td colspan="2"><b>' . implode('</b></td><td colspan="2"><b>', $columns) . "</b></td></tr>\r\n";
for($i = 0; $i < count($rows); $i++) {
    echo '<tr><td>' . $rows[$i] . '</td>';
    for($j = 0; $j < count($columns); $j++) {
        echo '<td style="text-align:right;border-right:0px">' . $time[$j][$i] . '</td>'.
             '<td style="text-align:right;border-left:0px"><small>[' . $collisions[$j][$i] . ']</small></td>';
    }
    echo "</tr>\r\n";
}
echo '</table>';

?>

⌨️ 快捷键说明

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