public function testPutAll() { // Remove the following lines when you implement this test. $hashmap = new HashMap(); $hashmap->put(87, 48); $hashmap->put(45, 98); $hashmap->put(7889, 4); $this->object->putAll($hashmap); $this->assertTrue($this->object->get(87)->toNative() == 48); $this->assertTrue($this->object->containsValue(48)); $this->assertTrue($this->object->get(45)->toNative() == 98); $this->assertTrue($this->object->containsValue(98)); $this->assertTrue($this->object->get(7889)->toNative() == 4); $this->assertTrue($this->object->containsValue(4)); }
function getid($facebook, $uid) { $HL = new HashMap(); $HC = new HashMap(); $user_profile = $facebook->api($uid . '/feed?fields=comments.fields(from,id),likes.fields(name),message,from,story_tags&limit=40'); // print_r($user_profile); $catch = json_encode($user_profile); //echo $catch; //print $de->{'data'}[$i]->{'comments'}->{'data'}[$j] $totallcount = 0; $totalccount = 0; $cidlist; $lidlist; $de = json_decode($catch); //print_r ($de); $arr = $de->{'data'}; //print_r $arr[0]; $datacount = count($arr); for ($i = 0; $i < $datacount; $i++) { //comments id $dataarr = $de->{'data'}[$i]->{'comments'}->{'data'}; $data2count = count($dataarr); $pid = new HashMap(); for ($j = 0; $j < $data2count; $j++) { //print "COMMENT:"; $cid = $de->{'data'}[$i]->{'comments'}->{'data'}[$j]->{'from'}->{'id'}; if ($pid->containsKey($cid)) { $HC->put($cid, 0.5); } else { $pid->put($cid, 0); $HC->put($cid, 1); } $totalccount++; } $dataarr = $de->{'data'}[$i]->{'likes'}->{'data'}; $data2count = count($dataarr); for ($j = 0; $j < $data2count; $j++) { //likes id $lid = $de->{'data'}[$i]->{'likes'}->{'data'}[$j]->{'id'}; $HL->put($lid, 1); $totallcount++; } $mid = $de->{'data'}[$i]->{'from'}->{'id'}; //get message fromid $HC->put($mid, 1); $totalccount++; $ka = array_keys((array) $de->{'data'}[$i]->{'story_tags'}); for ($x = 0; $x < count($ka); $x++) { //get story tagid $type = $de->{'data'}[$i]->{'story_tags'}->{$ka[$x]}[0]->{'type'}; if ($type == "user") { $sid = $de->{'data'}[$i]->{'story_tags'}->{$ka[$x]}[0]->{'id'}; $HC->put($sid, 1); } } } //echo $de; //echo ("</br>LIKES:$totallcount</br>"); //echo ("COMMENTS:$totalccount</br>"); $HC->putAll($HC); $HC->putAll($HL); // echo array_sum($HC->values()); $HL->removeAll(); $HC->remove($uid); $HC->maxAll($HC, 10); return $HC; }