예제 #1
0
 public MyDictionary(MyDictionary <K, V> mydic)
 {
     store = new List <KVP <K, V> >(mydic.Store);
 }
예제 #2
0
파일: RoomData.cs 프로젝트: julmaxi/opdtab
        void CheckOtherRounds(List <RoundDebater> rd, List <Debater> d)
        {
            int roundIndex = 0;

            foreach (RoundData roundData in Tournament.I.Rounds)
            {
                if (roundData.RoundName == roundName)
                {
                    break;
                }
                roundIndex++;
            }
            // we iterate over all (i, j) with i<j
            // and find pairs of Debaters in the same room (this is reflexive, in contrast to
            // sameRound blackList conflicts...
            // since teamMembers don't conflict each other,
            // we can start with j=3
            for (int j = 3; j < rd.Count; j++)
            {
                for (int i = 0; i < j; i++)
                {
                    if (rd[i] == null || d[i] == null)
                    {
                        goto inner;
                    }
                    if (rd[j] == null || d[j] == null)
                    {
                        goto outer;
                    }
                    // teamMembers don't conflict each other
                    if (j < 6 && i > 2)
                    {
                        continue;
                    }
                    MyDictionary <string, int> vr1 = d[i].VisitedRooms;
                    MyDictionary <string, int> vr2 = d[j].VisitedRooms;
                    // we are only interested in the intersection of roundNames
                    foreach (KVP <string, int> kvp1 in vr1.Store)
                    {
                        // skip if this room is in the round...
                        if (roundName == kvp1.Key)
                        {
                            continue;
                        }
                        // skip if debater isn't in room
                        if (kvp1.Val < 0)
                        {
                            continue;
                        }
                        KVP <string, int> kvp2;
                        if (vr2.GetKVP(kvp1.Key, out kvp2))
                        {
                            // skip if debater isn't in room
                            if (kvp2.Val < 0)
                            {
                                continue;
                            }
                            // same roomIndex?
                            if (kvp1.Val == kvp2.Val)
                            {
                                string room = RoomNameFromIndex(kvp1.Val);
                                // store it in both debaters
                                // using a lot of gets in order to prevent null pointers...
                                rd[i].GetConflict().GetPartners2(kvp1.Key).GetList(room).Add(rd[j]);
                                rd[j].GetConflict().GetPartners2(kvp1.Key).GetList(room).Add(rd[i]);
                            }
                        }
                    }

                    inner :;
                }
                outer :;
            }
        }