Exemplo n.º 1
0
int main()
{
    std::ifstream file( __FILE__ ) ;
    const auto word_count = make_word_count(file) ;

    std::cout << "most used words\n--------------\n" ;
    copy_most_used( word_count, std::ostream_iterator<std::string>( std::cout, "\n" ) ) ;
}
Exemplo n.º 2
0
/*
Insert a key/val pair as a Wordcount struct into the GSList
@param {char *} key - key to store
@param {int} val - int to store
@param {void *} list - Pointer to a Glib Singly Linked List object in which to store the data
*/
void insert_result(char* key, int* val, void* list) { 
  Wordcount* word = make_word_count(key, *val);
  GSList* list_start = *(GSList **) list;
  GSList* new_list_start = g_slist_insert_sorted(list_start, word, (GCompareFunc) compare_word_count);
  *(GSList **)list = new_list_start;
}