当前位置: 首页>>代码示例>>C#>>正文


C# StringDictionary.GetContainsKey方法代码示例

本文整理汇总了C#中StringDictionary.GetContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary.GetContainsKey方法的具体用法?C# StringDictionary.GetContainsKey怎么用?C# StringDictionary.GetContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringDictionary的用法示例。


在下文中一共展示了StringDictionary.GetContainsKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TarjanModelChecking

        public void TarjanModelChecking()
        {
            OutgoingTransitionTable = new Dictionary<string, List<string>>(Ultility.Ultility.MC_INITIAL_SIZE);
            TaskStack = new Stack<LocalPair>(Ultility.Ultility.MC_INITIAL_SIZE);
            DFSData = new StringDictionary<int[]>(Ultility.Ultility.MC_INITIAL_SIZE);

            List<LocalPair> initials = LocalPair.GetInitialPairsLocal(BA, initialStep);

            if (initials.Count == 0 || !BA.HasAcceptState)
            {
                VerificationResult = VerificationResultType.VALID;
                return;
            }

            for (int z = 0; z < initials.Count; z++)
            {
                LocalPair initState = initials[z];
                TaskStack.Push(initState);
                string ID = initState.GetCompressedState();
                DFSData.Add(ID, new int[] { VISITED_NOPREORDER, 0 });
                OutgoingTransitionTable.Add(ID, new List<string>(8));
            }

            Dictionary<string, LocalPair> SCCPairs = new Dictionary<string, LocalPair>(1024);
            Stack<LocalPair> stepStack = new Stack<LocalPair>(1024);

            //# Preorder counter
            int i = 0;

            //store the expended event step of a node to avoid multiple invocation of the make one move.
            Dictionary<string, List<LocalPair>> ExpendedNode = new Dictionary<string, List<LocalPair>>(1024);

            //PrintMessage("Start to find the Strongly Connected Component of graph.");

            do
            {
                if (SearchedDepth < TaskStack.Count)
                {
                    SearchedDepth = TaskStack.Count;
                }

                if (JobFinished)
                {
                    return;
                }

                LocalPair pair = TaskStack.Peek();
                ConfigurationBase evt = pair.configuration;
                string BAState = pair.state;

                string v = pair.GetCompressedState();

                List<string> outgoing = OutgoingTransitionTable[v];

                int[] nodeData = DFSData.GetContainsKey(v);

                if (nodeData[0] == VISITED_NOPREORDER)
                {
                    nodeData[0] = i;
                    i++;
                }

                bool done = true;

                if (ExpendedNode.ContainsKey(v))
                {
                    List<LocalPair> list = ExpendedNode[v];
                    if (list.Count > 0)
                    {
                        //transverse all steps
                        for (int k = list.Count - 1; k >= 0; k--)
                        {
                            LocalPair step = list[k];

                            string tmp = step.GetCompressedState();

                            //if the step is a unvisited step
                            if (DFSData.GetContainsKey(tmp)[0] == VISITED_NOPREORDER)
                            {
                                //only add the first unvisited step
                                //for the second or more unvisited steps, ignore at the monent
                                if (done)
                                {
                                    TaskStack.Push(step);
                                    done = false;
                                    list.RemoveAt(k);
                                }
                            }
                            else
                            {
                                list.RemoveAt(k);
                            }
                        }
                    }
                }
                else
                {
                    //ConfigurationBase[] list = evt.MakeOneMove().ToArray();
                    IEnumerable<ConfigurationBase> list = evt.MakeOneMove();
                    pair.SetEnabled(list, FairnessType);
//.........这里部分代码省略.........
开发者ID:nhannhan159,项目名称:PAT,代码行数:101,代码来源:TarjanThread.cs

示例2: ModelCheckingLivenessWithFairness

        /// <summary>
        /// Run the verification and get the result.
        /// </summary>
        /// <returns></returns>
        public void ModelCheckingLivenessWithFairness()
        {
            Dictionary<string, List<string>> OutgoingTransitionTable = new Dictionary<string, List<string>>(Ultility.Ultility.MC_INITIAL_SIZE);
            LocalTaskStack = new Stack<LocalPair>(5000);
            VerificationOutput.CounterExampleTrace = null;

            List<LocalPair> initials = LocalPair.GetInitialPairsLocal(BA, InitialStep);
            StringDictionary<int[]> DFSData = new StringDictionary<int[]>();

            if (initials.Count == 0)
            {
                VerificationOutput.VerificationResult = VerificationResultType.VALID;
                return;
            }

            for (int z = 0; z < initials.Count; z++)
            {
                LocalPair initState = initials[z];
                LocalTaskStack.Push(initState);
                string ID = initState.GetCompressedState(FairnessType);
                DFSData.Add(ID, new int[] { VISITED_NOPREORDER, 0 });
                OutgoingTransitionTable.Add(ID, new List<string>(8));
            }

            Dictionary<string, LocalPair> SCCPairs = new Dictionary<string, LocalPair>(1024);
            Stack<LocalPair> stepStack = new Stack<LocalPair>(1024);

            int i = 0;

            //store the expended event step of a node to avoid multiple invocation of the make one move.
            Dictionary<string, List<LocalPair>> ExpendedNode = new Dictionary<string, List<LocalPair>>(1024);

            do
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = DFSData.Count; // VisitedWithID.Count;
                    return;
                }

                LocalPair pair = LocalTaskStack.Peek();
                ConfigurationBase evt = pair.configuration;
                string BAState = pair.state;

                string v = pair.GetCompressedState(FairnessType);

                List<string> outgoing = OutgoingTransitionTable[v];

                int[] nodeData = DFSData.GetContainsKey(v);

                if (nodeData[0] == VISITED_NOPREORDER)
                {
                    nodeData[0] = i;
                    i++;
                }

                bool done = true;

                if (ExpendedNode.ContainsKey(v))
                {
                    List<LocalPair> list = ExpendedNode[v];
                    if (list.Count > 0)
                    {
                        //transverse all steps
                        for (int k = list.Count - 1; k >= 0; k--)
                        {
                            LocalPair step = list[k];

                            //if the step is a unvisited step
                            string tmp = step.GetCompressedState(FairnessType);
                            if (DFSData.GetContainsKey(tmp)[0] == VISITED_NOPREORDER)
                            //if (!preorder.ContainsKey(step.GetCompressedState()))
                            {
                                //only add the first unvisited step
                                //for the second or more unvisited steps, ignore at the monent
                                if (done)
                                {
                                    LocalTaskStack.Push(step);
                                    done = false;
                                    list.RemoveAt(k);
                                }
                            }
                            else
                            {
                                list.RemoveAt(k);
                            }
                        }
                    }
                }
                else
                {
                    //ConfigurationBase[] list = evt.MakeOneMove().ToArray();
                    IEnumerable<ConfigurationBase> list = evt.MakeOneMove();
                    pair.SetEnabled(list, FairnessType);
                    List<LocalPair> product = LocalPair.NextLocal(BA, list, BAState);

//.........这里部分代码省略.........
开发者ID:nhannhan159,项目名称:PAT,代码行数:101,代码来源:AssertionLTLwithFairness.cs

示例3: TarjanModelChecking


//.........这里部分代码省略.........
            }

            for (int z = 0; z < initials.Count; z++)
            {
                KeyValuePair<ConfigurationBase, string> initState = initials[z];
                TaskStack.Push(initState);
                string ID = initState.Key.GetIDWithEvent() + Constants.SEPARATOR + initState.Value;
                DFSData.Add(ID, new int[] { VISITED_NOPREORDER, 0 });
                OutgoingTransitionTable.Add(ID, new List<string>(8));
            }

            List<string> StronglyConnectedComponets = new List<string>(1024);
            Stack<KeyValuePair<ConfigurationBase, string>> stepStack = new Stack<KeyValuePair<ConfigurationBase, string>>(1024);

            //# Preorder counter
            int i = 0;

            //store the expended event step of a node to avoid multiple invocation of the make one move.
            Dictionary<string, List<KeyValuePair<ConfigurationBase, string>>> ExpendedNode = new Dictionary<string, List<KeyValuePair<ConfigurationBase, string>>>(1024);

            do
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = DFSData.Count; // VisitedWithID.Count;
                    return;
                }

                KeyValuePair<ConfigurationBase, string> pair = TaskStack.Peek();
                ConfigurationBase config = pair.Key;
                string v = pair.Key.GetIDWithEvent() + Constants.SEPARATOR + pair.Value;
                List<string> outgoing = OutgoingTransitionTable[v];

                int[] nodeData = DFSData.GetContainsKey(v);

                if (nodeData[0] == VISITED_NOPREORDER)
                {
                    nodeData[0] = i;
                    i++;
                }

                bool done = true;

                if (ExpendedNode.ContainsKey(v))
                {
                    List<KeyValuePair<ConfigurationBase, string>> list = ExpendedNode[v];
                    if (list.Count > 0)
                    {
                        //transverse all steps
                        for (int k = list.Count - 1; k >= 0; k--)
                        {
                            KeyValuePair<ConfigurationBase, string> step = list[k];

                            //if the step is a unvisited step
                            string tmp = step.Key.GetIDWithEvent() + Constants.SEPARATOR + step.Value;
                            if(DFSData.GetContainsKey(tmp)[0] == VISITED_NOPREORDER)
                            {
                                if (done)
                                {
                                    TaskStack.Push(step);
                                    done = false;
                                    list.RemoveAt(k);
                                }
                            }
                            else
                            {
开发者ID:nhannhan159,项目名称:PAT,代码行数:67,代码来源:AssertionLTL.cs

示例4: BuildQuotientMDP

        public MDP BuildQuotientMDP(VerificationOutput VerificationOutput)
        {
            //return this;

            MDP toReturn = new MDP(Precision, MAX_DIFFERENCE);

            //todo change to set
            List<KeyValuePair<string, string>> BoundaryOneTransition = new List<KeyValuePair<string, string>>();

            //todo change to set
            List<Distribution> ProbTransitions = new List<Distribution>();

            Dictionary<string, List<Distribution>> GlobalProbTransitions = new Dictionary<string, List<Distribution>>();

            StringDictionary<bool> visited = new StringDictionary<bool>(States.Count);
            List<KeyValuePair<HashSet<string>, MDPState>> sccs = new List<KeyValuePair<HashSet<string>, MDPState>>();

            Dictionary<string, int> preorder = new Dictionary<string, int>();
            Dictionary<string, int> lowlink = new Dictionary<string, int>();
            //HashSet<string> scc_found = new HashSet<string>();
            Stack<MDPState> TaskStack = new Stack<MDPState>();

            //Dictionary<string, List<string>> OutgoingTransitionTable = new Dictionary<string, List<string>>();
            Stack<MDPState> stepStack = new Stack<MDPState>(1024);

            visited.Add(InitState.ID, false);
            TaskStack.Push(InitState);

            //# Preorder counter
            int preor = 0;

            do
            {
                while (TaskStack.Count > 0)
                {
                    MDPState pair = TaskStack.Peek();
                    string v = pair.ID;

                    if (visited.GetContainsKey(v) && visited.GetContainsKey(v))
                    {
                        TaskStack.Pop();
                        continue;
                    }

                    if (!preorder.ContainsKey(v))
                    {
                        preorder.Add(v, preor);
                        preor++;
                    }

                    bool done = true;

                    List<Distribution> list = pair.Distributions;
                    List<MDPState> nonProbTrans = new List<MDPState>();
                    List<Distribution> ProbTrans = new List<Distribution>();

                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].IsTrivial())
                        {
                            nonProbTrans.Add(list[i].States[0].Value);
                        }
                        else
                        {
                            ProbTrans.Add(list[i]);
                        }
                    }

                    if (ProbTrans.Count > 0 && !GlobalProbTransitions.ContainsKey(v))
                    {
                        GlobalProbTransitions.Add(v, ProbTrans);
                        ProbTransitions.AddRange(ProbTrans);
                    }

                    for (int k = nonProbTrans.Count - 1; k >= 0; k--)
                    {
                        MDPState step = nonProbTrans[k];
                        string tmp = step.ID;

                        if (visited.ContainsKey(tmp))
                        {
                            //if this node is still not visited
                            if (!preorder.ContainsKey(tmp))
                            {
                                //only put the first one to the work list stack.
                                //if there are more than one node to be visited,
                                //simply ignore them and keep its event step in the list.
                                if (done)
                                {
                                    TaskStack.Push(step);
                                    done = false;
                                }
                            }
                        }
                        else
                        {
                            visited.Add(tmp, false);
                            //OutgoingTransitionTable.Add(tmp, new List<string>(8));

                            //only put the first one into the stack.
//.........这里部分代码省略.........
开发者ID:nhannhan159,项目名称:PAT,代码行数:101,代码来源:MDP.cs

示例5: localImprovedTarjanGeldenhuysValmari

        /// <summary>
        /// The local function of each process running Improved MultiCore Tarjan algorithm
        /// </summary>
        /// <returns></returns>        
        public void localImprovedTarjanGeldenhuysValmari()
        {
            //local data for on-the-fly and Tarjan algorithm
            Dictionary<string, List<string>> outgoingTransitionTable = new Dictionary<string, List<string>>(Ultility.Ultility.MC_INITIAL_SIZE);
            StringDictionary<int[]> dfsData = new StringDictionary<int[]>(5000);
            Dictionary<string, List<LocalPair>> expendedNodes = new Dictionary<string, List<LocalPair>>(1024);
            Stack<LocalPair> callStack = new Stack<LocalPair>(5000);
            Stack<LocalPair> currentStack = new Stack<LocalPair>(1024);
            int counter = 0;
            string goal = null;
            int[] goalData = new int[2] { -2, 0 };
            //--------------------------

            //create initial states
            List<LocalPair> initialStates = LocalPair.GetInitialPairsLocal(BA, InitialStep);
            if (initialStates.Count == 0 || !BA.HasAcceptState)
            {
                VerificationOutput.VerificationResult = VerificationResultType.VALID;
                return;
            }

            //create random variable for each process
            Random rand = null;
            lock (MultiCoreLock)
            {
                rand = new Random(MultiCoreSeed);
                MultiCoreSeed++;
            }

            //put all initial states to callStack in different order & init data
            int[] initPermutation = generatePermutation(initialStates.Count, rand);
            for (int i = 0; i < initPermutation.Length; i++)
            {
                //get data from initialStates
                LocalPair tmp = initialStates[initPermutation[i]];
                callStack.Push(tmp);
                string tmpID = tmp.GetCompressedState();
                dfsData.Add(tmpID, new int[] { VISITED_NOPREORDER, 0 });
                outgoingTransitionTable.Add(tmpID, new List<string>(8));
            }

            //start loop
            while (callStack.Count > 0)
            {
                //cancel if too long action
                if (CancelRequested || StopMutliCoreThreads)
                {
                    return;
                }

                //get the top of callStack
                LocalPair pair = callStack.Peek();
                ConfigurationBase LTSState = pair.configuration;
                string BAState = pair.state;
                string v = pair.GetCompressedState();

                //get local data of the top
                List<string> outgoing = outgoingTransitionTable[v];
                int[] vData = dfsData.GetContainsKey(v);

                //if not expended then expend to next states from v
                if (!expendedNodes.ContainsKey(v))
                {
                    //create next states of v
                    //ConfigurationBase[] nextLTSStates = LTSState.MakeOneMove().ToArray();
                    IEnumerable<ConfigurationBase> nextLTSStates = LTSState.MakeOneMove(); //.ToArray()
                    pair.SetEnabled(nextLTSStates, FairnessType);
                    List<LocalPair> nextStates = LocalPair.NextLocal(BA, nextLTSStates, BAState);
                    expendedNodes.Add(v, nextStates);

                    //update outgoing of v and set initial data for successors
                    //no need to use inverse for statement and use nextStates
                    foreach (LocalPair next in nextStates)
                    {
                        string w = next.GetCompressedState();
                        outgoing.Add(w);
                        if (!dfsData.ContainsKey(w))
                        {
                            dfsData.Add(w, new int[] { VISITED_NOPREORDER, 0 });
                            outgoingTransitionTable.Add(w, new List<string>(8));
                        }
                    }
                }

                //get successors of v
                List<LocalPair> successors = expendedNodes[v];

                //process if v is not numbered yet
                if (vData[0] == VISITED_NOPREORDER)
                {
                    vData[0] = counter;
                    vData[1] = counter;
                    counter = counter + 1;

                    //push to currentStack
                    currentStack.Push(pair);
//.........这里部分代码省略.........
开发者ID:nhannhan159,项目名称:PAT,代码行数:101,代码来源:AssertionLTLMultiCoreTarjanGeldenhuysValmari.cs


注:本文中的StringDictionary.GetContainsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。