public void FirstTimeAStringArrives(Actor sender, ActorMatch address, object message)
 {
     // 4. reconfigure this actor to have the SecondTimeAStringArrives function to respond when strings are sent.
     MessageBox.Show((string)message, @"First time");
     MatchList.Clear();
     MatchList.Add(new ActorMatch(typeof(string), SecondTimeAStringArrives));
 }
Exemplo n.º 2
0
        public override void BuildMatch()
        {
            IList <ITeam> list1 = new List <ITeam>(TeamList);
            IList <ITeam> list2 = new List <ITeam>(TeamList);

            MatchList.Clear();
            foreach (var team1 in list1)
            {
                foreach (var team2 in list2)
                {
                    if (team1 == team2 ||
                        MatchList.Count(item => item.Team1 == team1 && item.Team2 == team2 ||
                                        item.Team1 == team2 && item.Team2 == team1) != 0)
                    {
                        continue;
                    }

                    CreateMatch(team1, team2);

                    if (!MatchWithRevenge)
                    {
                        continue;
                    }
                    CreateMatch(team2, team1);
                }
            }
        }
Exemplo n.º 3
0
 public void Reset()
 {
     direction = MatchDir.None;
     matchlist.Clear();
     isMatch   = false;
     matchType = MatchType.Normal;
 }
Exemplo n.º 4
0
 public override void BuildMatch()
 {
     MatchList.Clear();
     for (var i = 0; i < TeamList.Count; i += 2)
     {
         CreateMatch(TeamList[i], TeamList[i + 1]);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Function to call to re-calculate algorithm results.
        /// </summary>
        public void MatchFeatures()
        {
            MatchList.Clear();
            MatchList = FindMatches(m_observedFeatureList, m_targetFeatureList, m_matchParameters.UserTolerances, 0);

            var lengthCheck = (MatchList.Count >= MIN_MATCHES_FOR_NORMAL_ASSUMPTION);

            if (m_matchParameters.ShouldCalculateSTAC && lengthCheck)
            {
                var stacInformation = new STACInformation(m_matchParameters.UseDriftTime);

                // Attach the event handlers
                stacInformation.MessageEvent += StacInformationMessageHandler;

                ReportMessage("Performing STAC");
                PerformStac(stacInformation);

                // Add the Refined Tolerances that STAC calculated
                RefinedToleranceList.Add(stacInformation.RefinedTolerances);

                StacParameterList.Add(stacInformation);
                ReportMessage("Populating FDR table");
                StacFdrTable = PopulateStacfdrTable(MatchList);
            }
            if (m_matchParameters.ShouldCalculateHistogramFDR)
            {
                ReportMessage("Setting Mass Error Histogram FDR");
                SetMassErrorHistogramFdr();
            }
            if (m_matchParameters.ShouldCalculateShiftFDR)
            {
                ReportMessage("Calculating Shift FDR");
                foreach (var t in MatchList)
                {
                    t.InRegion(RefinedToleranceList[0], m_matchParameters.UseEllipsoid);
                }
                var count = MatchList.Count(t => t.WithinRefinedRegion);
                ShiftedMatchList.AddRange(FindMatches(m_observedFeatureList, m_targetFeatureList, RefinedToleranceList[0], m_matchParameters.ShiftAmount));
                ShiftFdr             = (1.0 * count) / ShiftedMatchList.Count;
                ShiftConservativeFdr = (2.0 * count) / ShiftedMatchList.Count;
            }

            OnProcessingComplete(new ProgressNotifierArgs("Processing Complete"));
        }
Exemplo n.º 6
0
        public List <Token> Process(string input, string fileName)
        {
            if (!finalized)
            {
                finalize();
            }

            var tokens = new List <Token>();

            var matchList1 = new MatchList(states.Count);
            var matchList2 = new MatchList(states.Count);

            foreach (var state in states)
            {
                state.lastInputPos = -1;
            }

            int line     = 1;
            int position = 1;

            for (int inputPos = 0; inputPos < input.Length;)
            {
                int startLine     = line;
                int startPosition = position;

                matchList1.Clear();
                matchList2.Clear();
                var currentMatchList = matchList1;
                var nextMatchList    = matchList2;
                currentMatchList.AddState(startState, inputPos);

                int startPos = inputPos;
                for (; inputPos < input.Length; inputPos++)
                {
                    var c = input[inputPos];

                    nextMatchList.Clear();
                    for (int i = 0; i < currentMatchList.Count; i++)
                    {
                        var currentState = currentMatchList.States[i];
                        for (int j = 0; j < currentState.NextChars.Count; j++)
                        {
                            if (currentState.NextChars[j] == c)
                            {
                                nextMatchList.AddState(currentState.NextStates[j], inputPos + 1);
                            }
                        }
                    }

                    if (nextMatchList.Count == 0)
                    {
                        break;
                    }

                    if (currentMatchList == matchList1)
                    {
                        currentMatchList = matchList2;
                        nextMatchList    = matchList1;
                    }
                    else
                    {
                        currentMatchList = matchList1;
                        nextMatchList    = matchList2;
                    }

                    if (c == '\n')
                    {
                        line++;
                        position = 1;
                    }
                    else
                    {
                        position++;
                    }
                }

                State acceptingState = null;
                for (int i = 0; i < currentMatchList.Count; i++)
                {
                    var newState = currentMatchList.States[i];
                    if (newState.Accepting)
                    {
                        if (acceptingState == null)
                        {
                            acceptingState = newState;
                        }
                        else
                        {
                            var acceptingType = acceptingState.AcceptingTokenType;
                            var newType       = newState.AcceptingTokenType;
                            if (!EqualityComparer <TTokenType> .Default.Equals(newType, acceptingType))
                            {
                                PrecedenceNode acceptingNode;
                                PrecedenceNode newNode;
                                precedenceNodes.TryGetValue(acceptingType, out acceptingNode);
                                precedenceNodes.TryGetValue(newType, out newNode);
                                if (acceptingNode == null || newNode == null || !acceptingNode.IsParentOrChild(newNode))
                                {
                                    throw new Exception("Ambiguous token definitions found with no applicable precedence rule");
                                }
                                else if (acceptingNode.IsParent(newNode))
                                {
                                    acceptingState = newState;
                                }
                            }
                        }
                    }
                }
                if (acceptingState != null)
                {
                    var source = new Source(fileName, startLine, startPosition);
                    var t      = tokenDefinitions[acceptingState.AcceptingTokenType].TokenCallback != null ? tokenDefinitions[acceptingState.AcceptingTokenType].TokenCallback(input, startPos, inputPos - startPos, source) : new Token(acceptingState.AcceptingTokenType, source);
                    if (t != null)
                    {
                        tokens.Add(t);
                    }
                }
                else
                {
                    throw new Exception("Unrecognized token");
                }
            }

            return(tokens);
        }
Exemplo n.º 7
0
 public static void ClearAll()
 {
     MatchList.Clear();
 }