Exemple #1
0
 private void  PushChar(int c)
 {
     nextCharCounter--;
     if (buffer == null)
     {
         buffer = new System.Collections.ArrayList();
     }
     buffer.Insert(0, (char)c);
 }
Exemple #2
0
 public void BringToFront(int index)
 {
     jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
     if (currentWidget != null)
     {
         m_ChildWidgets.RemoveAt(index);
         m_ChildWidgets.Insert(0, currentWidget);
     }
 }
Exemple #3
0
 public void BringToFront(int index)
 {
     WorldWind.NewWidgets.IWidget currentWidget = m_ChildWidgets[index] as WorldWind.NewWidgets.IWidget;
     if (currentWidget != null)
     {
         m_ChildWidgets.RemoveAt(index);
         m_ChildWidgets.Insert(0, currentWidget);
     }
 }
Exemple #4
0
        static void Main(string[] args)
        {
            System.Collections.ArrayList oList = new System.Collections.ArrayList();
            int[] x = new int[5];
            oList.Add(7);
            oList.Add(21);
            oList.Add(5);
            oList.Insert(1, 7);
            oList.Insert(2, 4);
            oList.Insert(3, 3);
            oList.Insert(4, 7);
            oList.Remove(8);

            foreach (int intCurrent in oList)
            {
                System.Console.WriteLine(intCurrent);
            }
            System.Console.ReadLine();



            while (oList.Contains(7))
            {
                oList.Remove(7);
            }

            foreach (int i in oList)
            {
                System.Console.WriteLine(i);
            }

            //for (int intIndex = 0; intIndex <= oList.Count - 1; intIndex++)
            //{

            //    if (oList.Contains(7))
            //    {
            //        oList.Remove(7);
            //    }
            //    System.Console.WriteLine(oList[intIndex]);

            //}


            System.Console.ReadLine();

            //int[] y = { 22, 3, 6, 3, 14, 2,3, 7 };
            //for (int i = 0; i < y.Length; i++)
            //{
            //    if (y[i]==3)
            //    {
            //        System.Console.WriteLine("yes");
            //    }
            //}

            //System.Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            System.Collections.ArrayList a = new System.Collections.ArrayList();
            a.Add("Welcome");
            a.Add(100);
            a.Add(true);
            a.Add(22.2);
            a.Add("Non generic collection");

            Console.WriteLine("ArrayList Count :" + a.Count);
            Console.WriteLine("ArrayList Capacity :" + a.Capacity);

            System.Collections.ArrayList b = new System.Collections.ArrayList();
            a.AddRange(b); // add arraylist b to a // add range will add in th end

            // insert elements into arraylist
            a.Insert(0, "Hello");
            a.Insert(3, 555);

            System.Collections.ArrayList c = new System.Collections.ArrayList();
            a.InsertRange(2, c); // inserting c aaraylist to 2 position in a //insert range will insert in middle



            Console.WriteLine("ArrayList Count :" + a.Count);
            Console.WriteLine("ArrayList Capacity :" + a.Capacity);

            Console.WriteLine("*********ArrayList Elements******");

            foreach (var item in a)
            {
                Console.WriteLine(item);
            }

            string msg = (string)a[0]; //access elements based on index
            float  v   = (float)a[2];

            Console.WriteLine("Element at 0 is :" + msg);
            Console.WriteLine("Element at 2 is :" + v);

            // Removing an element which is having a value 20.5f

            a.Remove(20.2f);

            // Removing an element at index 0

            a.RemoveAt(0);

            // Removing 2 elements starting from index 3

            a.RemoveRange(3, 2);
            Console.ReadKey();
        }
Exemple #6
0
        /// <summary>Insert a FITS object into the list of HDUs.</summary>
        /// <param name="myHDU">The HDU to be inserted into the list of HDUs.</param>
        /// <param name="n">The location at which the HDU is to be inserted.</param>
        public virtual void InsertHDU(BasicHDU myHDU, int n)
        {
            if (myHDU == null)
            {
                return;
            }

            if (n < 0 || n > NumberOfHDUs)
            {
                throw new FitsException("Attempt to insert HDU at invalid location: " + n);
            }

            try
            {
                if (n == 0)
                {
                    // Note that the previous initial HDU is no longer the first.
                    // If we were to insert tables backwards from last to first,
                    // we could get a lot of extraneous DummyHDUs but we currently
                    // do not worry about that.

                    if (NumberOfHDUs > 0)
                    {
                        ((BasicHDU)hduList[0]).PrimaryHDU = false;
                    }

                    if (myHDU.CanBePrimary)
                    {
                        myHDU.PrimaryHDU = true;
                        hduList.Insert(0, myHDU);
                    }
                    else
                    {
                        InsertHDU(BasicHDU.DummyHDU, 0);
                        myHDU.PrimaryHDU = false;
                        hduList.Insert(1, (Object)myHDU);
                    }
                }
                else
                {
                    myHDU.PrimaryHDU = false;
                    hduList.Insert(n, myHDU);
                }
            }
            catch (Exception e)
            {
                throw new FitsException("hduList inconsistency in insertHDU: " + e);
            }
        }
Exemple #7
0
 public static void Insert <T>(ref T[] array, int index, T item)
 {
     System.Collections.ArrayList list = new System.Collections.ArrayList();
     list.AddRange(array);
     list.Insert(index, item);
     array = list.ToArray(typeof(T)) as T[];
 }
Exemple #8
0
		/// <summary>
		/// Put a pane into the visible pane ordering at the specified index
		/// -- Might throw a System.ArgumentOutOfRangeException
		/// </summary>
		/// <param name="pane">a TabStop representing the specified pane</param>
		/// <param name="index">the index to insert the pane at</param>
		public static void ReorderPane (RemovablePane pane, int index) 
		{
			// Do not add WaitForHolodeck, since this method might be called before the Holodeck process started

			RemovePaneFromOrdering (pane);
			paneOrdering.Insert (index, pane);
		}
        private void ucPhaGetTotBill_Load(object sender, EventArgs e)
        {
            Neusoft.FrameWork.Models.NeuObject obj = new Neusoft.FrameWork.Models.NeuObject();
            obj.ID   = "all";
            obj.Name = "全部";

            System.Collections.ArrayList alDrugQuality = new System.Collections.ArrayList();

            alDrugQuality = consManager.GetList(Neusoft.HISFC.Models.Base.EnumConstant.DRUGQUALITY);
            alDrugQuality.Insert(0, obj);
            this.cmbQuality.AddItems(alDrugQuality);

            this.cmbQuality.SelectedIndex = 0;
            //}
            //private void ucPhaGetTotBill_OnLoad(object sender, EventArgs e)
            //{

            //加药品类别查找 add jlj

            Neusoft.FrameWork.Models.NeuObject obj1 = new Neusoft.FrameWork.Models.NeuObject();
            obj1.ID   = "all";
            obj1.Name = "全部";

            System.Collections.ArrayList alDrugType = new System.Collections.ArrayList();

            alDrugType = consManager.GetList(Neusoft.HISFC.Models.Base.EnumConstant.ITEMTYPE);
            alDrugType.Insert(0, obj1);
            this.cmbType.AddItems(alDrugType);

            this.cmbType.SelectedIndex = 0;
        }
Exemple #10
0
        protected override void OnLoad()
        {
            this.Init();

            base.OnLoad();
            //设置时间范围
            DateTime now = DateTime.Now;
            DateTime dt  = new DateTime(DateTime.Now.Year, 1, 1);

            this.dtpBeginTime.Value = dt;

            //填充数据
            Neusoft.HISFC.BizProcess.Integrate.Manager manager = new Neusoft.HISFC.BizProcess.Integrate.Manager();
            constantList = manager.QueryEmployeeAll();


            Neusoft.HISFC.Models.Base.Employee allPerson = new Neusoft.HISFC.Models.Base.Employee();
            allPerson.ID        = "%%";
            allPerson.Name      = "全部";
            allPerson.SpellCode = "QB";
            //cboPersonCode.Items.Insert(0, allPerson);
            constantList.Insert(0, allPerson);
            this.cboPersonCode.AddItems(constantList);
            cboPersonCode.SelectedIndex = 0;
        }
Exemple #11
0
        static void Main(string[] args)
        {
            System.Collections.ArrayList lst1 = new System.Collections.ArrayList();
            lst1.Add("a");
            lst1.Add("b");
            lst1.Insert(1, "c");
            foreach (var item in lst1)
            {
                Console.WriteLine(item);
            }
            for (int i = 0; i < lst1.Count; i++)
            {
                Console.WriteLine(lst1[i]);
            }

            System.Collections.Hashtable lst2 = new System.Collections.Hashtable();
            lst2.Add("123", "anders");
            lst2.Add("124", "lene");
            Console.WriteLine(lst2["124"]);

            //System.Collections.Queue
            System.Collections.Stack s = new System.Collections.Stack();
            s.Push("1");
            s.Push("2");
            s.Push("3");
            var o = s.Pop();

            Garage g = new Garage();

            g.SætBilIGarage(new Bil()
            {
                Mærke = "Volvo"
            });
            g.SætBilIGarage(new Bil()
            {
                Mærke = "BMW"
            });


            System.Collections.Generic.List <string> lst3 = new List <string>();
            lst3.Add("1");
            string r = lst3[0];

            System.Collections.Generic.List <Bil> lst4 = new List <Bil>();
            lst4.Add(new Bil());

            System.Collections.Generic.Queue <int>              lst5 = new Queue <int>();
            System.Collections.Generic.Stack <string>           lst6 = new Stack <string>();
            System.Collections.Generic.Dictionary <string, int> lst7 = new Dictionary <string, int>();
            lst7.Add("123", 5);
            lst7.Add("125", 6);

            List <int> lst8 = new List <int>();

            lst8.Add(3);
            lst8.Add(6);
            lst8.Add(6);
            Test2(lst8.ToArray());
        }
Exemple #12
0
 /// <summary>
 /// Adiciona dados para a instancia.
 /// </summary>
 /// <param name="dataChunk"></param>
 public void AddDataChunk(byte[] dataChunk)
 {
     if (_data != null && _index < _noOfChunks)
     {
         _data.Insert(_index, dataChunk);
         _index++;
     }
 }
Exemple #13
0
        private void btnItem_Click(object sender, EventArgs e)
        {
            System.Collections.ArrayList employee =
                new System.Collections.ArrayList();

            employee.Insert(0, "許清榮");
            employee.Insert(1, "吳宜隆");
            employee.Insert(2, "林建亨");
            employee.Insert(3, "買大誠");
            employee.Insert(4, "廖健宇");

            var item = employee[2];

            string msg = "employee陣列第三個元素:" + item;

            MessageBox.Show(msg, "Item屬性");
        }
Exemple #14
0
        private void btnCount_Click(object sender, EventArgs e)
        {
            System.Collections.ArrayList employee =
                new System.Collections.ArrayList();

            employee.Insert(0, "許清榮");
            employee.Insert(1, "吳宜隆");
            employee.Insert(2, "林建亨");
            employee.Insert(3, "買大誠");
            employee.Insert(4, "廖健宇");

            int nums = employee.Count;

            string msg = "employee實際陣列元素個數:" + nums;

            MessageBox.Show(msg, "Count屬性");
        }
Exemple #15
0
 /// <summary>
 /// Adds a project file path to the recent projects list.
 /// </summary>
 /// <param name="projectName">
 /// Path of the project file.
 /// </param>
 public static void AddToRecentProjects(string projectName)
 {
     for (int index = 0; index < recentProjectsList.Count; index++)
     {
         if (projectName.ToLower() == ((string)recentProjectsList[index]).ToLower())
         {
             recentProjectsList.RemoveAt(index);
             recentProjectsList.Insert(0, projectName);
             return;
         }
     }
     if (recentProjectsList.Count >= 4)
     {
         recentProjectsList.RemoveAt(3);
     }
     recentProjectsList.Insert(0, projectName);
 }
        /// <summary>
        /// Inserts an element into the ActivityCollection at the specified index
        /// </summary>
        /// <param name="index">
        /// The index at which the IActivity is to be inserted.
        /// </param>
        /// <param name="value">
        /// The IActivity to insert.
        /// </param>
        public virtual void Insert(int index, IActivity value)
        {
            CheckParent();

            mList.Insert(index, value);

            value.Parent = mParentActivity;
        }
Exemple #17
0
 public static void AddRecentProject(string projectName)
 {
     if (recentProjects.Count == 4)
     {
         recentProjects.RemoveAt(3);
     }
     recentProjects.Insert(0, projectName);
 }
 //remove children from [start,end) and replace with node n
 public virtual void  condense(ASTNode node, int start, int end)
 {
     for (int i = end - 1; i >= start; i--)
     {
         content.RemoveAt(i);
     }
     content.Insert(start, node);
 }
Exemple #19
0
 public static void AddRecentFile(string fileName)
 {
     if (recentFiles.Count == 4)
     {
         recentFiles.RemoveAt(3);
     }
     recentFiles.Insert(0, fileName);
 }
        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);
            }
        }
Exemple #21
0
        private void font_up_Click(object sender, EventArgs e)
        {
            int idx = fontlist.SelectedIndex;

            if (idx <= 0)
            {
                return;
            }
            FontInfo info = mFonts[idx] as FontInfo;

            mFonts.RemoveAt(idx);
            --idx;
            mFonts.Insert(idx, info);
            for (int i = idx; i < mFonts.Count; ++i)
            {
                setListName(i, mFonts[i] as FontInfo);
            }
            fontlist.SelectedIndex = idx;
        }
Exemple #22
0
        public System.Collections.ArrayList ExecRowsWithBlank(string sql)
        {
            WUZH.DATA.DBFactory.mydb = WorkDB();

            System.Collections.ArrayList al = WUZH.DATA.DBFactory.Instance.ExecRows(sql);

            al.Insert(0, "");

            return(al);
        }
Exemple #23
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            System.Collections.ArrayList student =
                new System.Collections.ArrayList();
            student.Add("Ryu");

            student.Insert(1, "Candy");

            student.Add("Ven");

            student.Insert(0, "Karen");

            string msg = "陣列清單內容:\n";

            for (int i = 0; i < student.Count; i++)
            {
                msg = msg + student[i] + "\n";
            }
            MessageBox.Show(msg, "Insert()方法");
        }
Exemple #24
0
        //索引器
        public object this[int index]
        {
            get
            {
                return(_items[index]);
            }

            set
            {
                _items.Insert(index, value);
            }
        }
Exemple #25
0
 /// <summary>
 /// Deserializa os dados na instancia.
 /// </summary>
 /// <param name="reader"></param>
 public void Deserialize(CompactReader reader)
 {
     _noOfChunks = reader.ReadInt32();
     _index      = reader.ReadInt32();
     if (_noOfChunks > 0)
     {
         _data = new System.Collections.ArrayList(_noOfChunks);
         for (int i = 0; i < _noOfChunks; i++)
         {
             _data.Insert(i, reader.ReadObject() as byte[]);
         }
     }
 }
Exemple #26
0
        /// <summary> Decrements the in-degree of a vertex.
        ///
        /// </summary>
        /// <param name="vertex">the vertex whose in-degree will be decremented.
        /// </param>
        private void  decrementInDegree(System.Object vertex)
        {
            ModifiableInteger inDegree = (ModifiableInteger)m_inDegreeMap[vertex];

            if (inDegree.value_Renamed > 0)
            {
                inDegree.value_Renamed--;

                if (inDegree.value_Renamed == 0)
                {
                    m_queue.Insert(m_queue.Count, vertex);
                }
            }
        }
Exemple #27
0
 static void Main(string[] args)
 {
     System.Collections.ArrayList arrList = new System.Collections.ArrayList(5);
     for (int i = 0; i < 4; i++)
     {
         arrList.Add(i);
     }
     Console.WriteLine("arrList的元素个数:{0} 容量:{1}", arrList.Count, arrList.Capacity);
     arrList.Insert(1, "a");             //在索引为1的位置插入字符串a
     arrList.Insert(3, "b");             //在索引为3的位置插入字符串b
     Console.WriteLine("添加两个元素后,arrList的元素个数:{0} 容量:{1}", arrList.Count, arrList.Capacity);
     Console.WriteLine("用foreach语句输出arrList中的所有元素:");
     foreach (object o in arrList)
     {
         Console.Write("{0} ", o);
     }
     Console.WriteLine("\n用for语句输出arrList中的所有元素:");
     for (int i = 0; i < arrList.Count; i++)
     {
         Console.Write("{0} ", arrList[i]);
     }
     Console.WriteLine();
 }
Exemple #28
0
        //add new value; return index inserted at if value was not already present, -1 if it was
        public virtual int add(int n)
        {
            int i = indexOf(n, false);

            if (i != -1 && get_Renamed(i) == n)
            {
                return(-1);
            }
            else
            {
                v.Insert(i + 1, (System.Int32)n);
                return(i + 1);
            }
        }
 /// <summary> Allow outside entities to listen for incoming DMessages.  We
 /// make no presumptions about the ordering and do not filter
 /// anything at this level
 /// </summary>
 public virtual bool addListener(DProtocolNotifierIF n)
 {
     if (m_listeners.Count == 0)
     {
         m_listeners.Add(n);
     }
     else
     {
         // The DMessageCounter must always be the LAST listener, so that the message has
         // been fully processed before we wake up any threads that were waiting until a
         // message comes in.  So, insert this listener at the second-to-last position in
         // the list of listeners.
         m_listeners.Insert(m_listeners.Count - 1, n);
     }
     return(true);
 }
 private static void UnblockAddr(System.Net.IPAddress addr)
 {
     lock (BLOCKED_ADDR_TO_TIME.SyncRoot)
     {
         int addrCount = ((System.Int32)THREADS_PER_HOST_COUNT[addr]);
         if (addrCount == 1)
         {
             THREADS_PER_HOST_COUNT.Remove(addr);
             BLOCKED_ADDR_QUEUE.Insert(0, addr);
             BLOCKED_ADDR_TO_TIME[addr] = (long)((System.DateTime.Now.Ticks - 621355968000000000) / 10000 + SERVER_DELAY);
         }
         else
         {
             THREADS_PER_HOST_COUNT[addr] = (System.Int32)(addrCount - 1);
         }
     }
 }
Exemple #31
0
        /// <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);
        }
Exemple #32
0
        /// <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;
        }
        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);
                        }
                        else
                        {
                            // non-tree edge

                            // This edge defines a cycle together with the edges of the spanning tree
                            // along the path to the root of the tree. We create a new cycle containing 
                            // these edges (not the tree edges, but the corresponding edges in the graph)

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

                            // follow the path to the root of the tree

                            System.Object vertex = currentVertex;

                            // get parent of vertex
                            System.Collections.IList incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                            System.Object parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);

                            while (parent != null)
                            {
                                // add the corresponding edge to the cycle
                                edgesOfCycle.Add(subgraph.getEdge(vertex, parent));

                                // go up the tree
                                vertex = parent;

                                // get parent of vertex
                                incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                                parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);
                            }

                            // do the same thing for nextVertex
                            vertex = nextVertex;

                            // get parent of vertex
                            incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                            parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);

                            while (parent != null)
                            {
                                edgesOfCycle.Add(subgraph.getEdge(vertex, parent));
                                vertex = parent;

                                // get parent of vertex
                                incomingEdgesOfVertex = spanningTree.incomingEdgesOf(vertex);
                                parent = (incomingEdgesOfVertex.Count == 0) ? null : ((Edge)incomingEdgesOfVertex[0]).oppositeVertex(vertex);
                            }

                            // finally, add the non-tree edge to the cycle
                            edgesOfCycle.Add(edge);

                            // add the edge to the index list for the incidence matrix
                            edgeList.Add(edge);

                            SimpleCycle newCycle = new SimpleCycle(graph, edgesOfCycle);

                            cycles_Renamed_Field.Add(newCycle);
                        }
                    }
                }
            }

            // Add all the tree edges to the index list for the incidence matrix
            SupportClass.ICollectionSupport.AddAll(edgeList, treeEdges);

            edgeIndexMap = createEdgeIndexMap(edgeList);

            // Now the index list is ordered: first the non-tree edges, then the tree edge.
            // Moreover, since the cycles and the corresponding non-tree edge have been added
            // to their lists in the same order, the incidence matrix is in upper triangular form.

            // Now we can minimize the cycles created from the tree base
            minimize(startIndex);
        }
		/// <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;
		}
Exemple #35
0
        /// <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();
        }
        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;
        }
Exemple #37
0
       /* 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)
           {
#if DEBUG
               Globals.l2net_home.Add_Debug("found a path... building...");
#endif
               buildPathFromParents(((AstarNode)nowList[0]));
               return true;
           }

           return false;

       }
        /// <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;
        }
Exemple #39
0
	    /// <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;
	    }
        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;
                }
            }
        }