hallo, was macht folgender code (cluster) ich muss sagen, das ich bisher asp programmierer bin und wollte unten genannten source irgendwie umsetzen. diese cluster sachen sind doch sowas wie ein array, oder ?
gruss
function init_cluster_chain()
{
global $index_size, $clusters;
$index_size=15;
// use an array to store the bilinked list
$clusters=array();
// init start and end of chain
$cluster_start=array();
$cluster_start['bit_vector']=-1;
$cluster_start['prior']=NOT_IN_LIST;
$cluster_start['next']=1;
array_push($clusters, $cluster_start);
$cluster_end=array();
$cluster_end['bit_vector']=-2;
$cluster_end['next']=NOT_IN_LIST;
$cluster_end['prior']=0;
array_push($clusters, $cluster_end);
}
function insert_cluster(&$cluster)
{
global $clusters;
$index=crossed_bit_vector($cluster['x'],$cluster['y']);
$link_index=0;
while (($clusters[$link_index]['next'] != NOT_IN_LIST) && ($clusters[$link_index]['bit_vector'] < $index)) {
$link_index=$clusters[$link_index]['next'];
}
// first set double pointers for new element
$cluster['next']=$link_index;
$cluster['prior']=$clusters[$link_index]['prior'];
array_push($clusters, $cluster);
$new_link_index=count($clusters)-1;
// now relink the broken chain
$clusters[$clusters[$link_index]['prior']]['next']=$new_link_index;
$clusters[$link_index]['prior']=$new_link_index;
return $new_link_index;
} |