예제 #1
0
 public static bool ContainsEventPair(this List<EventPair> collection, EventPair toMatch)
 {
     if (toMatch.Left.Count == 1 && toMatch.Right.Count == 1)
     {
         foreach (var pair in collection)
         {
             if (pair.Left.Contains(toMatch.Left.First()) && pair.Right.Contains(toMatch.Right.First()))
                 return true;
         }
         return false;
     }
     else
     {
         foreach (var pair in collection)
         {
             if (pair.Left.Intersect(toMatch.Left).Count() == toMatch.Left.Count() && pair.Right.Intersect(toMatch.Right).Count() == toMatch.Right.Count())
                 return true;
         }
         return false;
     }
 }
예제 #2
0
        private List<EventPair> GetNormalizedPairs(List<EventPair> Hashes, List<EventPair> Forwards)
        {
            var x_w = Forwards.ToList();
            var X_Temp = Forwards.ToList();
            //Check if Hashes come with others
            foreach (var hash in Hashes)
            {
                var eventsToMatch = T_W.Where(t => t.Id != hash.Left.First().Id && t.Id != hash.Right.First().Id).ToList();
                foreach (var matchEvent in eventsToMatch)
                {
                    var pairToMatch1 = new EventPair { Left = new List<Event> { matchEvent }, Right = new List<Event> { hash.Left.First() } };
                    var pairToMatch2 = new EventPair { Left = new List<Event> { matchEvent }, Right = new List<Event> { hash.Right.First() } };
                    if (X_Temp.ContainsEventPair(pairToMatch1) && X_Temp.ContainsEventPair(pairToMatch2))
                    {
                        var eventPair = new EventPair { Left = new List<Event> { matchEvent }, Right = new List<Event> { pairToMatch1.Right.First(), pairToMatch2.Right.First() } };
                        if (!x_w.ContainsEventPair(eventPair))
                            x_w.Add(eventPair);
                    }

                    pairToMatch1 = new EventPair { Right = new List<Event> { matchEvent }, Left = new List<Event> { hash.Left.First() } };
                    pairToMatch2 = new EventPair { Right = new List<Event> { matchEvent }, Left = new List<Event> { hash.Right.First() } };
                    if (X_Temp.ContainsEventPair(pairToMatch1) && X_Temp.ContainsEventPair(pairToMatch2))
                    {
                        var eventPair = new EventPair { Left = new List<Event> { pairToMatch1.Left.First(), pairToMatch2.Left.First() }, Right = new List<Event> { matchEvent } };
                        if (!x_w.ContainsEventPair(eventPair))
                            x_w.Add(eventPair);
                    }
                }
            }
            return x_w;
        }