void DataUtils::addEdge(int user_id1, int user_id2) { unordered_map<int, vector<int> >::iterator it; // Insert edge into user_id1's firend list it = raw_data_map.find(user_id1); if (it == raw_data_map.end()) { vector<int> friend_list(1, user_id2); raw_data_map.insert(pair<int, vector<int> >(user_id1, friend_list)); } else { it->second.push_back(user_id2); } // Insert edge into id2's firend list it = raw_data_map.find(user_id2); if (it == raw_data_map.end()) { vector<int> friend_list(1, user_id1); raw_data_map.insert(pair<int, vector<int> >(user_id2, friend_list)); } else { it->second.push_back(user_id1); } num_of_edges++; }
void do_friend( CHAR_DATA *ch, char *argument ) { char arg1[ MAX_INPUT_LENGTH ]; char arg2[ MAX_INPUT_LENGTH ]; char *notka; if ( !ch || IS_NPC( ch ) ) return; /* possible commands friend ktos friend list [ktos] friend clear all friend forget ktos friend remember ktos friend introduce ktos friend note ktos nota */ argument = one_argument( argument, arg1 ); notka = one_argument( argument, arg2 ); if ( notka == NULL ) if ( arg1[ 0 ] == '\0' ) { friend_list( ch, arg1 ); return; } if ( !str_prefix( arg1, "list" ) ) { friend_list( ch, arg2 ); return; } if ( !str_prefix( arg1, "clear" ) ) { if ( !str_cmp( "all", arg2 ) ) { friend_clear( ch ); } else { send_to_char( "Je¶li chcesz zapomnieæ wszystkich znajomych u¿yj 'CLEAR ALL'.\n\r", ch ); } return; } if ( !str_prefix( arg1, "introduce" ) ) { if ( ch->position < POS_STANDING ) { send_to_char( "By³oby nieuprzejmym przedstawiaæ siê w takiej pozycji.\n\r", ch ); return; } friend_introduce( ch, arg2 ); return; } if ( !str_prefix( arg1, "remember" ) ) { if ( arg2[0] != '\0') { if ( ch->position != POS_STANDING && ch->position != POS_RESTING ) { send_to_char( "Co¶ nie mo¿esz siê skupiæ.\n\r", ch ); } friend_remember( ch, arg2 ); } else { send_to_char( "Kogo chcia³by¶ zapamiêtaæ?\n\r", ch ); } return; } if ( !str_prefix( arg1, "forget" ) ) { if ( arg2[0] != '\0') { friend_forget( ch, arg2 ); } else { send_to_char( "O kim wola³by¶ zapomnieæ?\n\r", ch ); } return; } if ( !str_prefix( arg1, "note" ) ) { if ( arg2[0] != '\0') { friend_note( ch, arg2, notka, FALSE ); } else { send_to_char( "O kim chcesz zapamiêtaæ?\n\r", ch ); } return; } friend_list( ch, arg1 ); return; }