57 foreach ( $suggestions as $suggestion ) {
58 $pageID = $suggestion->getSuggestedTitleID();
59 if ( $pageID && empty( $this->pageMap[$pageID] ) ) {
60 $this->pageMap[$pageID] =
true;
62 $this->suggestions[] = $suggestion;
86 public function map( $callback ) {
87 return array_map( $callback, $this->suggestions );
96 public function filter( $callback ) {
97 $before = count( $this->suggestions );
98 $this->suggestions = array_values( array_filter( $this->suggestions, $callback ) );
99 return $before - count( $this->suggestions );
111 if ( $pageID && isset( $this->pageMap[$pageID] ) ) {
117 $this->suggestions[] = $suggestion;
119 $this->pageMap[$pageID] =
true;
138 $removed = array_splice( $this->suggestions, $key, 1 );
139 unset( $this->pageMap[$removed[0]->getSuggestedTitleID()] );
150 if ( $pageID && isset( $this->pageMap[$pageID] ) ) {
156 array_unshift( $this->suggestions, $suggestion );
158 $this->pageMap[$pageID] =
true;
166 if ( empty( $this->suggestions ) ) {
169 return $this->suggestions[0]->getScore();
176 if ( empty( $this->suggestions ) ) {
179 return end( $this->suggestions )->getScore();
186 return count( $this->suggestions );
194 if ( count( $this->suggestions ) > $limit ) {
195 $this->suggestions = array_slice( $this->suggestions, 0, $limit );
211 $score = count( $titles );
228 $score = count( $titles );