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


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

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


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

示例1: DeleteObjects

        private void DeleteObjects(System.Collections.ArrayList objectNames, bool doingFiles)
        {
            // Indices of successfully deleted objects (so we can remove their names in reverse order)
            System.Collections.ArrayList deletedIndices = new System.Collections.ArrayList(objectNames.Count);
            int index = 0;
            foreach (string objectName in objectNames)
            {
                bool exists = (doingFiles ? File.Exists(objectName) : Directory.Exists(objectName));
                if (!exists)
                {
                    // It's already gone: remove its name
                    deletedIndices.Insert(0, index);
                }
                else
                {
                    try
                    {
                        if (doingFiles)
                        {
							ForceDeleteFile(objectName);
                        }
                        else
                        {
                            // Delete the files in the directory
                            DirectoryInfo dirInfo = new DirectoryInfo(objectName);
                            foreach (FileInfo file in dirInfo.GetFiles())
                            {
								ForceDeleteFile(file.FullName);
                            }
                            Directory.Delete(objectName);
                        }
                        deletedIndices.Insert(0, index);
                    }
                    catch
                    {
                    }
                }
                ++index;
            }
            foreach (int i in deletedIndices)
            {
                objectNames.RemoveAt(i);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:44,代码来源:TempFileController.cs

示例2: GetAncestors

	    /// <summary>
	    /// Return a list of all ancestors of this node.  The first node of
	    /// list is the root and the last is the parent of this node.
	    /// </summary>
	    public IList GetAncestors() {
	        if ( Parent==null ) return null;
	        IList ancestors = new ArrayList();
	        ITree t = this;
	        t = t.Parent;
	        while ( t!=null ) {
	            ancestors.Insert(0, t); // insert at start
	            t = t.Parent;
	        }
	        return ancestors;
	    }
开发者ID:sebasjm,项目名称:antlr,代码行数:15,代码来源:BaseTree.cs

示例3: 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

示例4: ToString

		/// <summary>
		/// Converts the numeric value of this instance to its equivalent string representation in specified base.
		/// </summary>
		/// <param name="radix">Int radix between 2 and 36</param>
		/// <returns>A string.</returns>
		public string ToString(int radix)
		{
			if (radix < 2 || radix > 36)
			{
				throw new ArgumentOutOfRangeException("radix");
			}

			if (IsZero)
			{
				return "0";
			}

			BigInteger a = this;
			bool negative = a.IsNegative;
			a = Abs(this);

			BigInteger quotient;
			BigInteger remainder;
			BigInteger biRadix = new BigInteger(radix);

			const string charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
			System.Collections.ArrayList al = new System.Collections.ArrayList();
			while (a.m_digits.DataUsed > 1 || (a.m_digits.DataUsed == 1 && a.m_digits[0] != 0))
			{
				Divide(a, biRadix, out quotient, out remainder);
				al.Insert(0, charSet[(int)remainder.m_digits[0]]);
				a = quotient;
			}

			string result = new String((char[])al.ToArray(typeof(char)));
			if (radix == 10 && negative)
			{
				return "-" + result;
			}

			return result;
		}
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:42,代码来源:BigInteger.cs

示例5: GetReturnHistory

        /// <summary>
        /// Trata o histórico de retorno para pastas pai, conforme fonte e tamanho máximo do texto a ser renderizado.
        /// </summary>
        /// <returns>Vetor de histórico de retorno.</returns>
        /// <param name="p_overflow">.</param>
        public System.Collections.ArrayList GetReturnHistory(out bool p_overflow, out int p_start)
        {
            System.Collections.ArrayList v_handledhistory;
            Spartacus.Utils.File v_directory;
            string v_text;
            int k;

            v_handledhistory = new System.Collections.ArrayList();

            p_overflow = false;
            k = this.v_returnhistory.Count - 1;
            v_text = "";

            while (k > 0 && !p_overflow)
            {
                v_directory = new Spartacus.Utils.File(1, 1, Spartacus.Utils.FileType.DIRECTORY, (string)this.v_returnhistory [k]);

                v_text += this.v_returnhistory_sep + (v_directory.v_name);

                if (this.v_returnhistory_font.StringWidth(this.v_returnhistory_root + v_text) > this.v_returnhistory_maxwidth)
                {
                    v_handledhistory.Insert(0, this.v_returnhistory_first);
                    p_overflow = true;
                }
                else
                {
                    v_handledhistory.Insert(0, v_directory.v_name);
                    k--;
                }
            }

            v_handledhistory.Insert(0, this.v_returnhistory_root);
            p_start = k - 1;

            return v_handledhistory;
        }
开发者ID:lubota,项目名称:spartacus,代码行数:41,代码来源:Spartacus.Utils.FileExplorer.cs

示例6: fringeSearch

       /* Fringe Search 
        * Fringe search is a memory enchanced version of IDA* */
       public bool fringeSearch()
       {
           //initialize:
           System.Collections.ArrayList nowList = new System.Collections.ArrayList();
           System.Collections.ArrayList laterList = new System.Collections.ArrayList();
           System.Collections.ArrayList rejectedList = new System.Collections.ArrayList();
           int limit = calcHvalue(startNode);
           
           #if DEBUG
                Globals.l2net_home.Add_Debug("start limit:" + limit);
           #endif

           bool found = false;

           Globals.debugPath = nowList;
           nowList.Add(startNode);
           
           while (!found)
           {
              // Globals.l2net_home.Add_Debug("big loop...");
               
               int fmin = INFINITY;
               while (nowList.Count != 0)
               {
                   AstarNode head = ((AstarNode)nowList[0]);
                   head.fvalue = calcFvalue(head);
                   

                   #region check for goal
                   if (isNodeTarget(head, targetNode.x, targetNode.y))
                   {
                       found = true;
                       break;
                   }
                   #endregion

                   //check if head is over the limit
                   if (head.fvalue > limit)
                   {
                       
                       //transfer head from nowlist to laterlist.
                       nowList.Remove(head);
                       laterList.Add(head);

                       //find the minimum of the nodes we will look at 'later'
                       fmin = Util.MIN(fmin, head.fvalue);

                      
                   }           
                   else
                   {
                       #region expand head's children on to now list
                       expand(head); //nodes are sorted by insert sort in this function

                       bool addedChildren = false;
                       foreach (AstarNode child in head.adjacentNodes)
                       {
                           //dont allow children already on path or adjacent to path or walls...

                           if (!isNodeIn(nowList, child) && !isNodeIn(laterList, child) && !isNodeIn(rejectedList, child))
                           {
                               if (child.passable == true)
                               {
                                   //add child of head to front of nowlist 
                                   nowList.Insert(0, child);
                                   addedChildren = true;
                               }
                           }

                       }
                       if (!addedChildren)
                       {                        
                           nowList.Remove(head);
                           rejectedList.Add(head);

                       }
                       #endregion
                   }

               }
               if (found == true)
                   break;

               //set new limit
              // Globals.l2net_home.Add_Debug("new limit:" + fmin);
               limit = fmin;

               //set now list to later list.
               nowList = (System.Collections.ArrayList)laterList.Clone();
               nowList.Sort();
               Globals.debugPath = nowList;
               laterList.Clear();

           
           }

           if (found == true)
           {
//.........这里部分代码省略.........
开发者ID:stephenZh,项目名称:l2net,代码行数:101,代码来源:Astar.cs

示例7: GetValue

        private static object GetValue(Range cell, Domain domain, InfoCell infoCell)
        {
            var childDomain = domain.GetChildDomain(infoCell.DomainId);

            if (childDomain != null)
            {
                SetFormat(cell, childDomain);

                if (childDomain.Value != null)
                {
                    if (childDomain is EntityDomain)
                    {
                        return childDomain.ObjectValue.ToString();
                    }
                    if (childDomain.Type.IsEnum)
                    {
                        return childDomain.Value.ToString();
                    }
                    if (childDomain.IsNumeric && childDomain.Format != null && childDomain.Value != null)
                        return string.Format(string.Concat("{0:", childDomain.Format.GetFirstExpressionFormat(childDomain), "}"), childDomain.Value);

                    return childDomain.Value;
                }
                if (childDomain.Format != null)
                {
                    var arrayList = new System.Collections.ArrayList(childDomain.Format.GetEvaluatedParameters(childDomain));
                    arrayList.Insert(0, !(childDomain is EntityDomain) ? childDomain.Value : string.Empty);
                    return string.Format(childDomain.Format.Expression, arrayList.ToArray());
                }
            }

            return string.Empty;
        }
开发者ID:timbooker,项目名称:dotObjects,代码行数:33,代码来源:HybridRenderer.cs

示例8: PutLineAt

        /// <summary>
        /// inserts line into a file at given position (line number)
        /// </summary>
        /// <param name="fName"></param>
        /// <param name="lineNumber"></param>
        /// <param name="lineX"></param>
        public static void PutLineAt(string fName, int lineNumber, string lineX)
        {
            string strTextFileName = fName;
            int iInsertAtLineNumber = lineNumber;
            string strTextToInsert = lineX;
            System.Collections.ArrayList lines = new System.Collections.ArrayList();
            StreamReader rdr = new StreamReader(
                strTextFileName);
            string line;
            while ((line = rdr.ReadLine()) != null)
            {
                lines.Add(line);
            }

            rdr.Close();
            if (lines.Count > iInsertAtLineNumber)
            {
                lines.Insert(iInsertAtLineNumber,
                   strTextToInsert);
            }
            else
            {
                lines.Add(strTextToInsert);
            }
            StreamWriter wrtr = new StreamWriter(
                strTextFileName);
            foreach (string strNewLine in lines)
                wrtr.WriteLine(strNewLine);
            wrtr.Close();
        }
开发者ID:jurehr,项目名称:JureHrHelperClass,代码行数:36,代码来源:Files.cs

示例9: 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

示例10: Main

        static void Main(string[] args)
        {
            System.Collections.ArrayList M = new System.Collections.ArrayList();
            string s = System.Console.ReadLine();
            int N = int.Parse(s);
            char c;
            Int64 L;
            int x;
            for(int i=0;i<N;i++) {
                s = System.Console.ReadLine();
                c = s[0];
                L = Int64.Parse(s.Substring(2));
                M.Sort();
                switch (c) {
                    case 'I':
                        if (!M.Contains(L))
                        {
                            M.Insert(0, L);
                        }
                        break;
                    case 'D':
                        x = Array.BinarySearch(M.ToArray(), L);
                        if(x < 0) {
                             System.Console.WriteLine("BRAK");
                        } else {
                            System.Console.WriteLine("OK");
                            M.Remove(L);
                        }
                        break;
                    case 'U':
                        x = Array.BinarySearch(M.ToArray(), L);
                        if (x >= 0) {
                            System.Console.WriteLine(M[x]);
                        } else if (~x < 0) {
                            System.Console.WriteLine("BRAK");
                        } else if ((~x) >= M.ToArray().Length)
                        {
                            System.Console.WriteLine("BRAK");
                        }
                        else {
                            System.Console.WriteLine(M[~x].ToString());
                        }
                        break;
                    case 'L':
                        x = Array.BinarySearch(M.ToArray(), L);
                        if (x >= 0)
                        {
                            System.Console.WriteLine(M[x]);
                        }
                        else if (~x <= 0)
                        {
                            System.Console.WriteLine("BRAK");
                        }
                        else if ((~x) > M.ToArray().Length)
                        {
                            System.Console.WriteLine("BRAK");
                        }
                        else
                        {
                            System.Console.WriteLine(M[~x-1].ToString());
                        }

                        break;
                }
            }
        }
开发者ID:krzysztofp,项目名称:Algo-n-Datas-in-C,代码行数:66,代码来源:Program.cs


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