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


C# System.Collections.ArrayList.RemoveAt方法代码示例

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


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

示例1: Update

        public void Update(GameTime gameTime)
        {
            if (es.EditMode)
            {
                if (es.EditType == EditorType.EntityMode)
                {
                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        if (draggedEntity != null)
                        {
                            draggedEntity.getAs<Position>().EntityPosition = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - MouseOffset;
                            draggedEntity.getAs<Position>().EntityPosition -= new Vector2(draggedEntity.getAs<Position>().EntityPosition.X % (int)es.GridType, draggedEntity.getAs<Position>().EntityPosition.Y % (int)es.GridType);

                            //draggedEntity.getAs<Position>().EntityPosition = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - MouseOffset;
                        }
                        else
                        {
                            draggedEntity = TestForTargetedDrawable(Mouse.GetState().X, Mouse.GetState().Y);
                            if (draggedEntity != null)
                            {
                                MouseOffset = RenderingSystem.camera.RealCoordsFromScreen(Mouse.GetState().X, Mouse.GetState().Y) - draggedEntity.getAs<Position>().EntityPosition;
                            }
                        }

                        selectedEntity = TestForTargetedDrawable(Mouse.GetState().X, Mouse.GetState().Y);
                    }
                    else
                    {
                        draggedEntity = null;
                    }
                }
                else if (es.EditType == EditorType.WallMode)
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.Add))
                    {
                        System.Threading.Thread.Sleep(100);

                        if (selectedEntity == null)
                        {
                            selectedEntity = new Entity(es.CreateEntityID());
                        }

                        Wall entWall = selectedEntity.getAs<Wall>();

                        if (entWall == null)
                        {
                            entWall = new Wall();
                            es.RegisterComponent(selectedEntity, entWall);
                        }

                        System.Collections.ArrayList wallPoints = new System.Collections.ArrayList();
                        if (entWall.WallPoints != null)
                        {
                            wallPoints.AddRange(entWall.WallPoints);
                        }

                        if (wallPoints.Count == 0)
                        {
                            wallPoints.Add(new Vector2(0, 0));
                        }
                        Vector2 lastPoint = (Vector2)wallPoints[wallPoints.Count - 1];
                        wallPoints.Add(new Vector2(lastPoint.X + 30, lastPoint.Y + 30));

                        entWall.WallPoints = (Vector2[])wallPoints.ToArray(typeof(Vector2));
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.Subtract))
                    {
                        if (selectedEntity != null)
                        {
                            Wall entWall = selectedEntity.getAs<Wall>();

                            if (entWall != null)
                            {
                                if (entWall.WallPoints != null)
                                {
                                    System.Collections.ArrayList wallPoints = new System.Collections.ArrayList();
                                    wallPoints.AddRange(entWall.WallPoints);

                                    for (int i = 0; i < wallPoints.Count; i++)
                                    {
                                        if (selectedVertex == i)
                                        {
                                            wallPoints.RemoveAt(i);
                                            break;
                                        }
                                    }

                                    entWall.WallPoints = (Vector2[])wallPoints.ToArray(typeof(Vector2));
                                }
                            }
                        }
                    }

                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        if (selectedEntity != null)
                        {
                            Wall entWall = selectedEntity.getAs<Wall>();
                            if (entWall != null)
//.........这里部分代码省略.........
开发者ID:ebobwright,项目名称:C-Sharp-Entity-System,代码行数:101,代码来源:EditingSystem.cs

示例2: createMinimumCycleBasis

        private void createMinimumCycleBasis()
        {
            org._3pq.jgrapht.Graph subgraph = new Subgraph(graph, null, null);

            CSGraphT.SupportClass.SetSupport remainingEdges = new CSGraphT.SupportClass.HashSetSupport(graph.edgeSet());
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            CSGraphT.SupportClass.SetSupport selectedEdges = new CSGraphT.SupportClass.HashSetSupport();

            while (!(remainingEdges.Count == 0))
            {
                //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                Edge edge = (Edge)remainingEdges.GetEnumerator().Current;

                subgraph.removeEdge(edge);

                // Compute a shortest cycle through edge
                System.Collections.IList path = BFSShortestPath.findPathBetween(subgraph, edge.Source, edge.Target);
                path.Add(edge);
                SimpleCycle cycle = new SimpleCycle(graph, path);

                subgraph.addEdge(edge);

                selectedEdges.Add(edge);

                cycles_Renamed_Field.Insert(0, cycle);
                edgeList.Insert(0, edge);

                SupportClass.ICollectionSupport.RemoveAll(remainingEdges, path);
            }

            subgraph.removeAllEdges(selectedEdges);

            // The cycles just created are already minimal, so we can start minimizing at startIndex
            int startIndex = cycles_Renamed_Field.Count;

            // Now we perform a breadth first traversal and build a fundamental tree base
            // ("Kirchhoff base") of the remaining subgraph

            System.Object currentVertex = graph.vertexSet()[0];

            // We build a spanning tree as a directed graph to easily find the parent of a
            // vertex in the tree. This means however that we have to create new Edge objects
            // for the tree and can't just use the Edge objects of the graph, since the
            // the edge in the graph might have a wrong or no direction.

            DirectedGraph spanningTree = new SimpleDirectedGraph();

            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            CSGraphT.SupportClass.SetSupport visitedEdges = new CSGraphT.SupportClass.HashSetSupport();

            // FIFO for the BFS
            //UPGRADE_TODO: Class 'java.util.LinkedList' was converted to 'System.Collections.ArrayList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilLinkedList'"
            System.Collections.ArrayList vertexQueue = new System.Collections.ArrayList();

            // currentVertex is the root of the spanning tree
            spanningTree.addVertex(currentVertex);

            vertexQueue.Insert(vertexQueue.Count, currentVertex);

            // We need to remember the tree edges so we can add them at once to the
            // index list for the incidence matrix

            System.Collections.IList treeEdges = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));

            while (!(vertexQueue.Count == 0))
            {
                System.Object tempObject;
                tempObject = vertexQueue[0];
                vertexQueue.RemoveAt(0);
                currentVertex = tempObject;

                System.Collections.IEnumerator edges = subgraph.edgesOf(currentVertex).GetEnumerator();
                //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                while (edges.MoveNext())
                {
                    // find a neighbour vertex of the current vertex 
                    //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                    Edge edge = (Edge)edges.Current;

                    if (!visitedEdges.Contains(edge))
                    {

                        // mark edge as visited
                        visitedEdges.Add(edge);

                        System.Object nextVertex = edge.oppositeVertex(currentVertex);

                        if (!spanningTree.containsVertex(nextVertex))
                        {
                            // tree edge

                            treeEdges.Add(edge);

                            spanningTree.addVertex(nextVertex);

                            // create a new (directed) Edge object (as explained above)
                            spanningTree.addEdge(currentVertex, nextVertex);

                            // add the next vertex to the BFS-FIFO
                            vertexQueue.Insert(vertexQueue.Count, nextVertex);
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:SimpleCycleBasis.cs

示例3: RetrieveDhcpMessage


//.........这里部分代码省略.........
                                {
                                    index++;
                                }
                                break;
                            case DhcpOptionCode.End:
                                {
                                    index++;
                                    endOpcodeReceived = true;
                                }
                                break;
                            case DhcpOptionCode.OptionOverload:
                                {
                                    if (optionsBlocksIndex == 0)
                                    {
                                        index++;
                                        if (dhcpFrameBuffer[index] != 1)
                                            break;
                                        index++;
                                        byte value = dhcpFrameBuffer[index];
                                        index++;
                                        int numBlocks = 1 + (((value & 0x01) == 0x01) ? 1 : 0) + (((value & 0x02) == 0x02) ? 1 : 0);
                                        optionsBlocks = new DhcpOptionsBlockRange[numBlocks];
                                        int iOptionBlock = 0;
                                        optionsBlocks[iOptionBlock++] = new DhcpOptionsBlockRange(240, DHCP_FRAME_BUFFER_LENGTH - 240 - 1);
                                        if ((value & 0x01) == 0x01)
                                        {
                                            /* use file field for extended options */
                                            optionsBlocks[iOptionBlock++] = new DhcpOptionsBlockRange(108, 235);
                                        }
                                        if ((value & 0x02) == 0x02)
                                        {
                                            /* use sname field for extended options */
                                            optionsBlocks[iOptionBlock++] = new DhcpOptionsBlockRange(44, 107);
                                        }
                                    }
                                }
                                break;
                            default:
                                {
                                    index++;
                                    byte[] value = new byte[Math.Min(dhcpFrameBuffer[index], DHCP_FRAME_BUFFER_LENGTH - index)];
                                    index++;
                                    Array.Copy(dhcpFrameBuffer, index, value, 0, value.Length);
                                    index += value.Length;

                                    // if the option already exists, append to it
                                    bool foundOption = false;
                                    for (int iExistingOption = 0; iExistingOption < optionsArrayList.Count; iExistingOption++)
                                    {
                                        if (((DhcpOption)optionsArrayList[iExistingOption]).Code == optionCode)
                                        {
                                            byte[] newValue = new byte[((DhcpOption)optionsArrayList[iExistingOption]).Value.Length + value.Length];
                                            Array.Copy(((DhcpOption)optionsArrayList[iExistingOption]).Value, 0, newValue, 0, ((DhcpOption)optionsArrayList[iExistingOption]).Value.Length);
                                            Array.Copy(value, 0, newValue, ((DhcpOption)optionsArrayList[iExistingOption]).Value.Length, value.Length);
                                            optionsArrayList.RemoveAt(iExistingOption);
                                            optionsArrayList.Add(new DhcpOption(optionCode, newValue));

                                            foundOption = true;
                                            break;
                                        }
                                    }
                                    if (!foundOption)
                                    {
                                        optionsArrayList.Add(new DhcpOption(optionCode, value));
                                    }

                                    if (optionCode == DhcpOptionCode.DhcpMessageType)
                                    {
                                        verifyMessageType = (DhcpMessageType)value[0];
                                    }
                                }
                                break;
                        }
                    }

                    optionsBlocksIndex++;
                }
                options = (DhcpOption[])optionsArrayList.ToArray(typeof(DhcpOption));

                // verify that the DHCP message type matches
                bool messageTypeMatches = false;
                for (int iMessageType = 0; iMessageType < messageTypes.Length; iMessageType++)
                {
                    if (messageTypes[iMessageType] == verifyMessageType)
                    {
                        messageTypeMatches = true;
                        break;
                    }
                }

                if (messageTypeMatches)
                    return true; /* message matches the messageTypes filter, with a valid frame; return all data to the caller  */
            }

            // if we did not receive a message before timeout, return false.
            // set default return values
            assignedIPAddress = 0;
            options = null;
            return false;
        }
开发者ID:NameOfTheDragon,项目名称:Netduino.IP,代码行数:101,代码来源:DHCPv4Client.cs

示例4: generateData

        private System.IO.Stream generateData()
        {
            int numGuests = 16;
            int numSeats = 16;
            int minHobbies = 2;
            int maxHobbies = 3;

            System.String LINE_SEPARATOR = System.Environment.NewLine;

            System.IO.StringWriter writer = new System.IO.StringWriter();

            int maxMale = numGuests / 2;
            int maxFemale = numGuests / 2;

            int maleCount = 0;
            int femaleCount = 0;

            // init hobbies
            System.Collections.IList hobbyList = new System.Collections.ArrayList();
            for (int i = 1; i <= maxHobbies; i++)
            {
                hobbyList.Add("h" + i);
            }

            System.Random rnd = new System.Random();
            for (int i = 1; i <= numGuests; i++)
            {
                //UPGRADE_ISSUE: Method 'java.util.Random.nextBoolean' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilRandomnextBoolean'"
                char sex = (rnd.Next(2) == 0)?'m':'f';
                if (sex == 'm' && maleCount == maxMale)
                {
                    sex = 'f';
                }
                if (sex == 'f' && femaleCount == maxFemale)
                {
                    sex = 'm';
                }
                if (sex == 'm')
                {
                    maleCount++;
                }
                if (sex == 'f')
                {
                    femaleCount++;
                }

                System.Collections.IList guestHobbies = new System.Collections.ArrayList(hobbyList);

                int numHobbies = minHobbies + rnd.Next(maxHobbies - minHobbies + 1);
                for (int j = 0; j < numHobbies; j++)
                {
                    int hobbyIndex = rnd.Next(guestHobbies.Count);
                    System.String hobby = (System.String) guestHobbies[hobbyIndex];
                    writer.Write("(guest (name n" + i + ") (sex " + sex + ") (hobby " + hobby + "))" + LINE_SEPARATOR);
                    guestHobbies.RemoveAt(hobbyIndex);
                }
            }
            writer.Write("(last_seat (seat " + numSeats + "))" + LINE_SEPARATOR);

            writer.Write(LINE_SEPARATOR);
            writer.Write("(context (state start))" + LINE_SEPARATOR);

            return new System.IO.MemoryStream(new UnicodeEncoding().GetBytes(writer.GetStringBuilder().ToString())); //(writer.GetStringBuilder().ToString()).ToCharArray()
        }
开发者ID:happy280684,项目名称:droolsdotnet,代码行数:64,代码来源:MannersBenchmark.cs

示例5: tbBlacklistLeave

 void tbBlacklistLeave(object sender,System.EventArgs e)
 {
     ArrayList lines=new ArrayList(tbBlacklist.Lines);
     for(int i=0;i<lines.Count;i++) {
         string s=(string)lines[i];
         if(s.Length!=8) {
             lines.RemoveAt(i--);
         } else {
             for(int a=0;a<8;a++) {
                 if(Array.IndexOf(Hex2,s[a])==-1) {
                     lines.RemoveAt(i--);
                     break;
                 }
             }
         }
     }
     tbBlacklist.Lines=(string[])lines.ToArray(typeof(string));
 }
开发者ID:jrfl,项目名称:exeopt,代码行数:18,代码来源:MainForm.cs

示例6: BFolderClick

 void BFolderClick(object sender,System.EventArgs e)
 {
     if(PatchInProgress) {
         MessageBox.Show("Can only patch one file at a time.","Error");
         return;
     }
     if(OpenFolder.ShowDialog()==DialogResult.OK) {
         ArrayList files=new ArrayList(Directory.GetFiles(OpenFolder.SelectedPath));
         for(int i=0;i<files.Count;i++) {
             if(Array.IndexOf(ExecutableExtensions,Path.GetExtension((string)files[i]))==-1) {
                 files.RemoveAt(i--);
             }
         }
         new PatchDialog((string[])files.ToArray(typeof(string)));
     }
 }
开发者ID:jrfl,项目名称:exeopt,代码行数:16,代码来源:MainForm.cs

示例7: calSim2

        /// <summary>
        /// 计算其他独立义原描述式的相似度 
        /// </summary>
        /// <param name="line1"></param>
        /// <param name="line2"></param>
        /// <returns></returns>
        private double calSim2(string line1, string line2)
        {
            if (line1 == "" && line2 == "")
            {
                return 1d;
            }

            if (line1 == "" || line2 == "")
            {
                return 0d;
            }

            string[] sems1 = this.splitSemanetes(line1);
            System.Collections.ArrayList array_sems1 = new System.Collections.ArrayList();
            for (int i = 0; i < sems1.Length; i++)
            {
                array_sems1.Add(sems1[i]);
            }

            string[] sems2 = this.splitSemanetes(line2);
            System.Collections.ArrayList array_sems2 = new System.Collections.ArrayList();
            for (int j = 0; j < sems2.Length; j++)
            {
                array_sems2.Add(sems2[j]);
            }

            Stack<double> stk_max_sim = new Stack<double>();

            int len1 = array_sems1.Count;
            int len2 = array_sems2.Count;

            while (len1 != 0 && len2 != 0)
            {
                int m = -1, n = -1;
                double max_sim = 0d;
                for (int i = 0; i < len1; i++)
                {
                    for (int j = 0; j < len2; j++)
                    {
                        double simil = calSimBase((string)array_sems1[i], (string)array_sems2[j]);
                        if (simil > max_sim)
                        {
                            m = i;
                            n = j;
                            max_sim = simil;
                        }
                    }
                }

                if (max_sim == 0d)
                {
                    break;
                }

                stk_max_sim.Push(max_sim);

                if (m != -1)
                {
                    array_sems1.RemoveAt(m);
                }

                if (n != -1)
                {
                    array_sems2.RemoveAt(n);
                }

                len1 = array_sems1.Count;
                len2 = array_sems2.Count;
            }

            //把整体相似度还原为部分相似度的加权平均,这里权值取一样,即计算算术平均
            if (stk_max_sim.Count == 0)
            {
                return 0d;
            }

            double sum = 0.0;
            int count = stk_max_sim.Count;
            while (stk_max_sim.Count > 0)
            {
                sum += stk_max_sim.Pop();
            }

            return sum / count;
        }
开发者ID:rokii,项目名称:context_analyzer,代码行数:91,代码来源:Similarity.cs

示例8: calSim4

        /// <summary>
        /// 计算符号义原描述式的相似度 
        /// </summary>
        /// <param name="line1"></param>
        /// <param name="line2"></param>
        /// <returns></returns>
        private double calSim4(string line1, string line2)
        {
            if (line1 == "" && line2 == "")
            {
                return 1d;
            }

            if (line1 == "" || line2 == "")
            {
                return 0d;
            }

            string[] sems1 = splitSemanetes(line1);
            System.Collections.ArrayList array_sems1 = new System.Collections.ArrayList();
            for (int i = 0; i < sems1.Length; i++)
            {
                array_sems1.Add(sems1[i]);
            }

            string[] sems2 = splitSemanetes(line2);
            System.Collections.ArrayList array_sems2 = new System.Collections.ArrayList();
            for (int j = 0; j < sems2.Length; j++)
            {
                array_sems2.Add(sems2[j]);
            }

            Stack<double> stk_sim = new Stack<double>();

            int len1 = array_sems1.Count;
            int len2 = array_sems2.Count;

            while (len1 != 0 && len2 != 0)
            {
                char sym1 = ((string)array_sems1[len1 - 1])[0];
                for (int j = 0; j < len2; j++)
                {
                    char sym2 = ((string)array_sems2[j])[0];
                    if (sym1 == sym2)
                    {
                        string base1 = ((string)array_sems1[len1 - 1]).Substring(1);
                        string base2 = ((string)array_sems2[j]).Substring(1);
                        double ss = calSimBase(base1, base2);
                        stk_sim.Push(ss);
                        array_sems2.RemoveAt(j);
                        break;
                    }
                }

                array_sems1.RemoveAt(len1 - 1);

                len1 = array_sems1.Count;
                len2 = array_sems2.Count;
            }

            if (stk_sim.Count == 0)
            {
                return 0d;
            }

            double sum = 0d;

            int count = stk_sim.Count;
            while (stk_sim.Count > 0)
            {
                sum += stk_sim.Pop();
            }
            return sum / count;
        }
开发者ID:rokii,项目名称:context_analyzer,代码行数:74,代码来源:Similarity.cs

示例9: CreateObject

        protected override Object CreateObject(NonterminalToken token)
        {
            string name;
               int bytes, inx, value;
               CmdItem cmdItem;
               TestValue testval;
               try
               {
               switch (token.Rule.Id)
               {

                   case (int)RuleConstants.RULE_TESTGROUPEXPRESS_TESTEQ:
                       CanTest = false;
                       break;
                   case (int)RuleConstants.RULE_VERSION_VERSIONEQ_FLOAT:
                       this.version = token.Tokens[1].UserObject.ToString();
                       break;
                   case (int)RuleConstants.RULE_TESTGROUPEXPRESS_TESTEQ2:
                       CanTest = true;
                       break;
                   case (int)RuleConstants.RULE_TESTEXPRESS_ATCMD:
                       tmpTestExpress.Add(tmpTestValues);
                       tmpTestValues = new System.Collections.ArrayList(10);
                       break;
                   case (int)RuleConstants.RULE_TESTREPEATITEMS_LBRACE_RBRACE:

                       testval = (TestValue)token.Tokens[0].UserObject;
                       inx = tmpTestValues.IndexOf(testval);
                       for (int i = inx + 1; i < tmpTestValues.Count; i++)
                           testval.subValues.Add(tmpTestValues[i]);
                       for (int i = tmpTestValues.Count - 1; i > inx; i--)
                           tmpTestValues.RemoveAt(i);
                       break;
                   case (int)RuleConstants.RULE_TESTSELECTVALUE_NUMBER:

                       return token.Tokens[0].ToString();
                   case (int)RuleConstants.RULE_TESTSELECTVALUES:
                       return token.Tokens[0].UserObject;

                   case (int)RuleConstants.RULE_TESTSELECTITEM_IDENTIFIER_LPARAN_RPARAN:

                       name = token.Tokens[0].UserObject.ToString();
                       value = Convert.ToInt32(token.Tokens[2].UserObject.ToString());
                       tmpTestValues.Add(testval = new TestValue(name, value));
                       return testval;

                   case (int)RuleConstants.RULE_TESTITEM2:

                       return token.Tokens[0].UserObject;

                   case (int)RuleConstants.RULE_RANGEITEM_IDENTIFIER_LPARAN_RPARAN:
                       NonterminalToken ntok;
                       name = token.Tokens[getTokenInx(token, "Identifier")].UserObject.ToString();
                       ntok = findToken(token, "Bytes");
                       bytes = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString());
                       ntok = findToken(token, "LValue");
                       int lval = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString());
                       ntok = findToken(token, "HValue");
                       int hval = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString());
                       TmpCmdItems.Add(cmdItem = new CmdItem(name, bytes, lval, hval));
                       return cmdItem;

                   case (int)RuleConstants.RULE_SELECTITEM_IDENTIFIER_LPARAN_RPARAN:
                       SelectValue[] selectvalues;
                       name = token.Tokens[0].UserObject.ToString();
                       bytes = Convert.ToInt32(findToken(token, "Bytes").Tokens[0].UserObject.ToString());
                       selectvalues = new SelectValue[TmpSelectValues.Count];
                       for (int i = 0; i < TmpSelectValues.Count; i++)
                       {
                           selectvalues[i] = (SelectValue)TmpSelectValues[i];
                       }
                       TmpCmdItems.Add(cmdItem = new CmdItem(name, bytes, selectvalues));
                       TmpSelectValues.Clear();
                       return cmdItem;

                   case (int)RuleConstants.RULE_SELECTVALUE_NUMBER:
                       SelectValue sVal = new SelectValue();
                       sVal.value = Convert.ToInt32(token.Tokens[0].UserObject.ToString());
                       sVal.valueName = findToken(token, "ValueDescription").Tokens[0].UserObject.ToString();
                       TmpSelectValues.Add(sVal);

                       break;
                   case (int)RuleConstants.RULE_EXPRESSITEM:
                       return token.Tokens[0].UserObject;

                   case (int)RuleConstants.RULE_REPEATEXPRESS_LBRACE_RBRACE:
                       inx = TmpCmdItems.IndexOf(token.Tokens[0].UserObject);
                       for (int i = inx + 1; i < TmpCmdItems.Count; i++)
                           ((CmdItem)TmpCmdItems[inx]).AddSubItems((CmdItem)TmpCmdItems[i]);//reduce repeat item
                       for (int i = TmpCmdItems.Count - 1; i > inx; i--)
                           TmpCmdItems.RemoveAt(i);
                       return TmpCmdItems[inx];
                   case (int)RuleConstants.RULE_SENDEXPRESS_SENDEQ:  //send express
                       tmpSendExpress.Clear();
                       break;
                   case (int)RuleConstants.RULE_SENDEXPRESS_SENDEQ2: //sendexpress
                       tmpSendExpress = (System.Collections.ArrayList)TmpCmdItems.Clone();
                       TmpCmdItems.Clear();
                       break;
                   case (int)RuleConstants.RULE_RETURNEXPRESS_RETURNEQ:
//.........这里部分代码省略.........
开发者ID:ufjl0683,项目名称:sshmc,代码行数:101,代码来源:Protocol.cs

示例10: RecordStack

        //Create a Set command for the identifier on top of the stack
        //NOTE: unlike GET, the last value on the SET stack is assumed to be the new value
        private void RecordStack(Type ExpectedDataType)
        {
            string total = "";
            //Add the dot notation
            System.Collections.ArrayList thiscommand = new System.Collections.ArrayList();
            foreach (string i in stack)
            {
                thiscommand.Add(i);
                thiscommand.Add(".");
            }

            //some string fixup
            thiscommand.Reverse();
            thiscommand.RemoveAt(thiscommand.Count - 2);
            string value = (string)thiscommand[thiscommand.Count - 1];
            thiscommand.RemoveAt(thiscommand.Count - 1);

            foreach (string i in thiscommand)
            {
                total += i;
            }
            //Total is not the name of the identifier
            //value is the value
            total = total.Substring(1);

            // add cmi. to all data model identifiers
            total = "cmi." + total;

            ScormSet ss = new ScormSet(total, value, ExpectedDataType);

            //set this on the serilization list
            //NOTE: we could just call the wrapper here directly
            wrapper.Set(ss);
        }
开发者ID:AntoineOctarina,项目名称:scorm4unity,代码行数:36,代码来源:ScormSerialization.cs

示例11: GeneratePath

        public System.Collections.ArrayList GeneratePath(Point start, Point dest)
        {
            System.Collections.ArrayList my_path = new System.Collections.ArrayList();

            Point intersect = new Point();
            int index = 0;

            if (FindIntersect(start, dest, ref intersect, ref index))
            {
                my_path.Add(intersect);

                //need to trace the left and right paths
                double left_dist = 0;
                double right_dist = 0;

                System.Collections.ArrayList left_path = new System.Collections.ArrayList();
                System.Collections.ArrayList right_path = new System.Collections.ArrayList();

                Point t1 = new Point();
                Point t2 = new Point();
                Point tp = new Point();
                int ti = 0;

                //generate left path
                t1 = (Point)PointList[index];
                left_path.Add(t1);
                left_dist += Get_Dist(intersect, t1);

                while (FindIntersect(t1, dest, ref tp, ref ti))
                {
                    t2.X = t1.X;
                    t2.Y = t1.Y;
                    t2.Z = t1.Z;

                    index = Get_Left_Point(index);
                    t1 = (Point)PointList[index];
                    left_path.Add(t1);
                    left_dist += Get_Dist(t1, t2);
                }
                left_dist += Get_Dist(t1, dest);
                left_path.Add(dest);

                //generate right path
                index = Get_Right_Point(index);
                t1 = (Point)PointList[index];
                right_path.Add(t1);
                right_dist += Get_Dist(intersect, t1);

                while (FindIntersect(t1, dest, ref tp, ref ti))
                {
                    t2.X = t1.X;
                    t2.Y = t1.Y;
                    t2.Z = t1.Z;

                    index = Get_Right_Point(index);
                    t1 = (Point)PointList[index];
                    right_path.Add(t1);
                    right_dist += Get_Dist(t1, t2);

                }
                right_dist += Get_Dist(t1, dest);
                right_path.Add(dest);

                if (left_dist > right_dist)
                {
                    //use our right path
                    for (int i = 0; i < right_path.Count; i++)
                    {
                        my_path.Add(right_path[i]);
                    }
                }
                else
                {
                    //use our left path
                    for (int i = 0; i < left_path.Count; i++)
                    {
                        my_path.Add(left_path[i]);
                    }
                }

                //clean up our pathing
                bool cleaned = false;

                do
                {
                    for (int i = 0; i < my_path.Count - 2; i++)
                    {
                        if (!FindIntersect((Point)my_path[i], (Point)my_path[i + 2], ref tp, ref ti))
                        {
                            my_path.RemoveAt(i + 1);
                            cleaned = true;
                            break;
                        }
                    }
                } while (cleaned);
            }
            else
            {
                //no intersection...
                //straight shot to the destination
//.........这里部分代码省略.........
开发者ID:stephenZh,项目名称:l2net,代码行数:101,代码来源:PathValues.cs

示例12: BenergyTest

        public bool BenergyTest(ArrayList index1, ArrayList index2)
        {
            int i,j;
            int count = 0;
            string te = ArraytoString(index1);
            if (string.Compare(ArraytoString(index1), ArraytoString(index2)) == 0)
            {
                return false;
            }

            if (index1.Count >= index2.Count)
            {
                for (i = 0; i < index1.Count; i++)
                {
                    for (j = 0; j < index2.Count; j++)
                    {
                        if ((index1[i].ToString() == "+") || (index1[i].ToString() == "-") || (index1[i].ToString() == "["))
                        {
                            index1.RemoveAt(i);
                        }
                        if (String.Compare(index1[i].ToString() ,index2[j].ToString()) == 0)
                        {
                            index1.RemoveAt(i);
                            index2.RemoveAt(j);
                        }
                        else
                        {
                            count++;
                        }

                    }
                }
                if (index1.Count == 0)
                {
                    return false;
                }
            }
            else
            {
                for (i = 0; i < index2.Count; i++)
                {
                    for (j = 0; j < index1.Count; j++)
                    {
                        if ((index2[i].ToString() == "+") || (index2[i].ToString() == "-") || (index2[i].ToString() == "["))
                        {
                            index2.RemoveAt(i);
                        }
                        if (String.Compare(index2[i].ToString(), index1[j].ToString())==0)
                        {
                            index2.RemoveAt(i);
                            index1.RemoveAt(j);
                        }
                        else
                        {
                            count++;
                        }

                    }
                }
                if (index2.Count == 0)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:prem30488,项目名称:C2CUDATranslator,代码行数:67,代码来源:Analysis.cs

示例13: getShortestPath

        /// <summary> Returns a list of atoms in the shortest path between two atoms.
        /// 
        /// This method uses the Djikstra algorithm to find all the atoms in the shortest
        /// path between the two specified atoms. The start and end atoms are also included
        /// in the path returned
        /// 
        /// </summary>
        /// <param name="atomContainer">The molecule to search in
        /// </param>
        /// <param name="start">The starting atom
        /// </param>
        /// <param name="end">The ending atom
        /// </param>
        /// <returns> A <code>List</code> containing the atoms in the shortest path between <code>start</code> and
        /// <code>end</code> inclusive
        /// </returns>
        public static System.Collections.IList getShortestPath(IAtomContainer atomContainer, IAtom start, IAtom end)
        {
            int natom = atomContainer.AtomCount;
            int endNumber = atomContainer.getAtomNumber(end);
            int startNumber = atomContainer.getAtomNumber(start);
            int[] d = new int[natom];
            int[] previous = new int[natom];
            for (int i = 0; i < natom; i++)
            {
                d[i] = 99999999;
                previous[i] = -1;
            }
            d[atomContainer.getAtomNumber(start)] = 0;

            System.Collections.ArrayList S = new System.Collections.ArrayList();
            System.Collections.ArrayList Q = new System.Collections.ArrayList();
            for (int i = 0; i < natom; i++)
                Q.Add((System.Int32)i);

            while (true)
            {
                if (Q.Count == 0)
                    break;

                // extract min
                int u = 999999;
                int index = 0;
                for (int i = 0; i < Q.Count; i++)
                {
                    int tmp = ((System.Int32)Q[i]);
                    if (d[tmp] < u)
                    {
                        u = d[tmp];
                        index = i;
                    }
                }
                Q.RemoveAt(index);
                S.Add(atomContainer.getAtomAt(u));
                if (u == endNumber)
                    break;

                // relaxation
                IAtom[] connected = atomContainer.getConnectedAtoms(atomContainer.getAtomAt(u));
                for (int i = 0; i < connected.Length; i++)
                {
                    int anum = atomContainer.getAtomNumber(connected[i]);
                    if (d[anum] > d[u] + 1)
                    {
                        // all edges have equals weights
                        d[anum] = d[u] + 1;
                        previous[anum] = u;
                    }
                }
            }

            System.Collections.ArrayList tmp2 = new System.Collections.ArrayList();
            int u2 = endNumber;
            while (true)
            {
                tmp2.Insert(0, atomContainer.getAtomAt(u2));
                u2 = previous[u2];
                if (u2 == startNumber)
                {
                    tmp2.Insert(0, atomContainer.getAtomAt(u2));
                    break;
                }
            }
            return tmp2;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:85,代码来源:PathTools.cs


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