public static function get_bst_for_assoc($assoc, $shuffle_before_insert = TRUE) { $bst = new DataStructures_BinarySearchTree(); $bst->insert_assoc($assoc, $shuffle_before_insert); return $bst; }
/** * @return DataStructures_BinarySearchTree */ public function get_tag_popularity_css_classes_with_popularities() { if (!isset($this->tag_popularity_css_classes_with_popularities)) { $t_p_c_cs_w_ps = array(); $t_p_c_cs = self::get_tag_popularity_css_classes(); #print_r($t_p_c_cs); $min_popularity = $this->get_min_tag_popularity(); #echo "\$min_popularity: $min_popularity\n"; $max_popularity = $this->get_max_tag_popularity(); #echo "\$max_popularity: $max_popularity\n"; $range = $max_popularity - $min_popularity + 1; $number_of_popularities = count($t_p_c_cs); #$popularity_step = floor($range / $number_of_popularities); $popularity_step = $range / $number_of_popularities; #echo "\$popularity_step: $popularity_step\n"; $previous = 0; foreach ($t_p_c_cs as $popularity) { $current = $previous + $popularity_step; $t_p_c_cs_w_ps[$popularity] = $current; $previous = $current; } #$current = 0; #foreach ($t_p_c_cs as $popularity) { # $this->tag_popularity_css_classes_with_popularities[$popularity] # #= floor($current); # = $current; # # $current += $popularity_step; #} $this->tag_popularity_css_classes_with_popularities = DataStructures_BinarySearchTree::get_bst_for_assoc($t_p_c_cs_w_ps); } return $this->tag_popularity_css_classes_with_popularities; }