Пример #1
0
// Implementation of multiSearch()
void Engine::multiSearch(vector<string> words) {
    
    if(freqTable.count(words[0]) == 0) {
        cout << words[0] << " is not in any movie. Sorry" << endl << endl ;
        return;
    }
    else if(freqTable.count(words[1]) == 0) {
        cout << words[1] << " is not in any movie. Sorry" << endl << endl ;
        return;
    }
    
    // Map for the movies in the intersection
    std::tr1::unordered_map<string, unsigned int>intersection;
    
    std::tr1::unordered_map<string, unsigned int>::iterator it1 ;
    
    // Iterate through all movies that contain both words and save the ones that
    // intersect with the sum of frequencies in the intersection map.
    for(it1 = freqTable[words[0]].begin() ; it1 != freqTable[words[0]].end() ; ++it1) {
        if(freqTable[words[1]].find(it1->first) != freqTable[words[1]].end())
            intersection[it1->first] = (it1->second)+(freqTable[words[1]][it1->first]) ;
    }
    
    // Call displayMulti to finish the job!
    displayMulti(intersection) ;
}
Пример #2
0
// Implementation of singleSearch()
void Engine::singleSearch(vector<string> word) {
    
    // If the movie is not in the frequency table, then break
    if(freqTable.count(word[0]) == 0) {
        cout << word[0] << " is not in any movie. Sorry" << endl << endl ;
        return;
    }
    
    std::tr1::unordered_map<string, unsigned int>single = freqTable[word[0]];
    
    // Call displayMulti to finish the job!
    displayMulti(single) ;
}
Пример #3
0
uint8_t getPeople(void){
  char c;
  char buf[MAX_PEEPS];
  uint8_t buf_count = 0;
  while(1){
    displayMulti(atoi(buf),'P');
    if(c = waitKeyPress()){
      usb_debug_putchar(c);
      if(c == '*'){
        memset(buf, 0, MAX_PEEPS);
        buf_count = 0;
      } else if(c == '#'){
        return atoi(buf);
      } else {
        buf[buf_count] = c;
        buf_count++;
        if (buf_count == MAX_PEEPS){
          return atoi(buf);
        }
      }
    }
  }
}