示例#1
0
 private static void printParenth(int left, int right, System.Collections.ArrayList arr)
 {
     if (left == 0 && right == 0)
     {
         foreach (var item in arr)
         {
             System.Console.Write(item + " ");
         }
         System.Console.WriteLine();
         //return arr;
     }
     if (left > 0)
     {
         System.Collections.ArrayList new_arr = (System.Collections.ArrayList)arr.Clone();
         new_arr.Add("(");
         //return
         printParenth(left - 1, right, new_arr);
     }
     if (left < right)
     {
         System.Collections.ArrayList new_arr = (System.Collections.ArrayList)arr.Clone();
         new_arr.Add(")");
         //return
         printParenth(left, right - 1, new_arr);
     }
     //return null;
 }
示例#2
0
        private static void go(System.Collections.ArrayList path, int X, int Y, bool[,] limits, bool[,] cache, short direct = 0)
        {
            if (!cache[X, Y])
            {
                cache[X, Y] = true;
            }
            else
            {
                //RETURN LIST ALREADY VISITED
            }

            if (direct > 0)
            {
                path.Add(direct);
            }
            if (X == 0 && Y == 0)
            {
                paths.Add(path);
                return;
            }

            if (X > 0 && verifyImpediment(limits, X - 1, Y))
            {
                go((System.Collections.ArrayList)path.Clone(), X - 1, Y, limits, cache, 1);
            }
            if (Y > 0 && verifyImpediment(limits, X, Y - 1))
            {
                go((System.Collections.ArrayList)path.Clone(), X, Y - 1, limits, cache, 2);
            }
        }
示例#3
0
        private static void printParenth(int RemainingLeft, int RemainingRight, System.Collections.ArrayList arr)
        {
            if (RemainingLeft == 0 && RemainingRight == 0)
            {
                for (int i = 0; i < arr.Count; i++)
                {
                    System.Console.Write(arr[i] + " ");
                }
                System.Console.WriteLine();
            }

            if (RemainingLeft > 0)
            {
                System.Collections.ArrayList arr2 = (System.Collections.ArrayList)arr.Clone();
                arr2.Add("[");
                printParenth(RemainingLeft - 1, RemainingRight, arr2);
            }

            if (RemainingLeft < RemainingRight)
            {
                System.Collections.ArrayList arr2 = (System.Collections.ArrayList)arr.Clone();
                arr2.Add("]");
                printParenth(RemainingLeft, RemainingRight - 1, arr2);
            }
        }
示例#4
0
        public System.Collections.ArrayList GetStepResult()
        {
            var temp = BaseListOfResItems.Clone();

            BaseListOfResItems.Clear();
            return((System.Collections.ArrayList)temp);
        }
示例#5
0
        /// <summary>
        /// The actual implementation
        /// </summary>
        /// <param name="primary"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="compare"></param>
        protected void InternalSort(
            ref System.Collections.ArrayList primary,
            int left,
            int right,
            System.Collections.IComparer compare)
        {
            if (secondaryList == null || secondaryList.Count != primary.Count)
            {
                secondaryList = (System.Collections.ArrayList)primary.Clone();
            }

            if (right > left)
            {
                int middle = (left + right) / 2;
                InternalSort(ref primary, left, middle, compare);
                InternalSort(ref primary, middle + 1, right, compare);

                int i, j, k;
                for (i = middle + 1; i > left; i--)
                {
                    secondaryList[i - 1] = primary[i - 1];
                }
                for (j = middle; j < right; j++)
                {
                    secondaryList[right + middle - j] = primary[j + 1];
                }
                for (k = left; k <= right; k++)
                {
                    primary[k] = (compare.Compare(secondaryList[i], secondaryList[j]) < 0) ?
                                 secondaryList[i++] : secondaryList[j--];
                }
            }
        }
示例#6
0
        public Chain get_last_chain(int last_index)
        {
            Chain temp = new Chain();

            temp.chain_s_moves = chain_s_moves.Clone() as System.Collections.ArrayList;
            temp.chain_s_moves.RemoveRange(last_index + 1, temp.chain_s_moves.Count - last_index - 1);
            return(temp);
        }
示例#7
0
        public ArrayList GetindexofArrayfromassignmentStatement(string statement)
        {
            ArrayList index     = new ArrayList();
            ArrayList index1    = new ArrayList();
            ArrayList indextemp = new ArrayList();
            int       i;
            bool      flag = false, flagagain = false;

            for (i = 0; i <= statement.Length - 1; i++)
            {
                if (statement[i] == '[')
                {
                    flag = true;
                    i    = i + 1;
                }
                if (statement[i] == ']')
                {
                    flag      = false;
                    flagagain = true;
                }
                if (flag)
                {
                    index.Add(statement[i]);
                }
                if (flagagain)
                {
                    if (index1.Count < index.Count)
                    {
                        if (index.Count >= indextemp.Count)
                        {
                            index1 = (ArrayList)index.Clone();
                        }
                        else
                        {
                            index1 = (ArrayList)indextemp.Clone();
                        }
                    }
                    indextemp = (ArrayList)index.Clone();
                    index.Clear();
                    flagagain = false;
                }
            }

            return(index1);
        }
示例#8
0
        public System.Collections.ArrayList GetInventoryListBySQLID(int SqlID)
        {
            System.Collections.ArrayList InventorySQLIDList = new System.Collections.ArrayList();

            foreach (inventory_item MyInventoryItem in GetInventoryList())
            {
                if (MyInventoryItem.SqlID == SqlID)
                {
                    InventorySQLIDList.Add(MyInventoryItem);
                }
            }

            return((System.Collections.ArrayList)InventorySQLIDList.Clone());
        }
示例#9
0
 /// <summary>
 /// Checks the execution status of all batches.
 /// </summary>
 protected void MonitorBatches()
 {
     System.Collections.ArrayList l_ExeList = (System.Collections.ArrayList)m_ExeList.Clone();
     foreach (ExeBatch exe in l_ExeList)
     {
         try
         {
             if (exe.DPSW.DoneWith(exe.MappedDesc.Id))
             {
                 try
                 {
                     exe.MappedDesc = exe.DPSW.Result(exe.MappedDesc.Id);
                     lock (m_Queue)
                     {
                         m_ResultList.Add(new DataProcessingResult(exe.Desc, null, MainForm.ResultLiveTime));
                         m_Queue.Remove(exe.Desc);
                         m_ExeList.Remove(exe);
                     }
                 }
                 catch (SySal.DAQSystem.DataProcessingException retx)
                 {
                     lock (m_Queue)
                     {
                         m_ResultList.Add(new DataProcessingResult(exe.Desc, retx, MainForm.ResultLiveTime));
                         m_Queue.Remove(exe.Desc);
                         m_ExeList.Remove(exe);
                     }
                 }
                 catch (Exception x)
                 {
                     m_ExeList.Remove(exe);
                     try
                     {
                         EventLog.WriteEntry("Error handling batch " + exe.Desc.Id.ToString("X16") + "\r\n" + x.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                     }
                     catch (Exception) { }
                 }
             }
         }
         catch (Exception x)
         {
             m_ExeList.Remove(exe);
             try
             {
                 EventLog.WriteEntry("Error handling batch " + exe.Desc.Id.ToString("X16") + "\r\n" + x.ToString(), System.Diagnostics.EventLogEntryType.Warning);
             }
             catch (Exception) { }
         }
     }
 }
示例#10
0
        protected internal virtual void  refresh(ArrayList listeners)
        {
            ArrayList v;

            lock (listeners)
            {
                v = (ArrayList)listeners.Clone();
            }
            if (v != null)
            {
                for (int i = 0; i < v.Count; i++)
                {
                    ((Listener)v[i]).refresh();
                }
            }
        }
示例#11
0
		public virtual void  fireEvents(int type, ArrayList listeners)
		{
			ArrayList targets = null;
			Listener l = null;
			
			lock(this)
			{
				if (listeners == null)
					return ;
				targets = (ArrayList) listeners.Clone();
			}
			
			if (targets != null)
				 for (int i = 0; i < targets.Count; i++)
				{
					l = (Listener) targets[i];
					fireEvent(type, l);
				}
		}
示例#12
0
        /// <summary> Selects a random subset of members according to subset_percentage and returns them.
        /// Picks no member twice from the same membership. If the percentage is smaller than 1 -> picks 1 member.
        /// </summary>
        public static System.Collections.ArrayList pickSubset(System.Collections.ArrayList members, double subset_percentage)
        {
            System.Collections.ArrayList ret = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)), tmp_mbrs;
            int num_mbrs = members.Count, subset_size, index;

            if (num_mbrs == 0)
            {
                return(ret);
            }
            subset_size = (int)System.Math.Ceiling(num_mbrs * subset_percentage);

            tmp_mbrs = (System.Collections.ArrayList)members.Clone();

            for (int i = subset_size; i > 0 && tmp_mbrs.Count > 0; i--)
            {
                index = (int)((Global.Random.NextDouble() * num_mbrs) % tmp_mbrs.Count);
                ret.Add(tmp_mbrs[index]);
                tmp_mbrs.RemoveAt(index);
            }

            return(ret);
        }
示例#13
0
        public virtual void  fireEvents(int type, ArrayList listeners)
        {
            ArrayList targets = null;
            Listener  l       = null;

            lock (this)
            {
                if (listeners == null)
                {
                    return;
                }
                targets = (ArrayList)listeners.Clone();
            }

            if (targets != null)
            {
                for (int i = 0; i < targets.Count; i++)
                {
                    l = (Listener)targets[i];
                    fireEvent(type, l);
                }
            }
        }
示例#14
0
        //Iterate
        public static System.Collections.ArrayList getSubSet(System.Collections.ArrayList set)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();

            System.Collections.ArrayList empty = new System.Collections.ArrayList();
            empty.Add('@');
            result.Add(empty);
            for (int i = 0; i < set.Count; i++)
            {
                int result_count = result.Count;
                for (int j = 0; j < result_count; j++)
                {
                    System.Collections.ArrayList subset       = (System.Collections.ArrayList)result[j];
                    System.Collections.ArrayList subset_clone = (System.Collections.ArrayList)subset.Clone();
                    subset_clone.Add(set[i]);
                    result.Add(subset_clone);
                }
                System.Collections.ArrayList subset_new_elem = new System.Collections.ArrayList();
                subset_new_elem.Add(set[i]);
                result.Add(subset_new_elem);
            }

            return(result);
        }
示例#15
0
        public System.Collections.ArrayList GetInventoryListBySQLID(int SqlID, System.Collections.ArrayList InventoryList)
        {
            System.Collections.ArrayList InventorySQLIDList = new System.Collections.ArrayList();

            foreach (inventory_item MyInventoryItem in InventoryList)
            {
                if (MyInventoryItem.SqlID == SqlID)
                {
                    InventorySQLIDList.Add(MyInventoryItem);
                }
            }

            return (System.Collections.ArrayList)InventorySQLIDList.Clone();
        }
示例#16
0
		protected internal virtual void  refresh(ArrayList listeners)
		{
			ArrayList v;
			lock(listeners)
			{
				v = (ArrayList) listeners.Clone();
			}
			if (v != null)
				 for (int i = 0; i < v.Count; i++)
					((Listener) v[i]).refresh();
		}
示例#17
0
 public System.Collections.ArrayList GetInventoryList()
 {
     return((System.Collections.ArrayList)TheInventory.Clone());
 }
示例#18
0
文件: Astar.cs 项目: stephenZh/l2net
       /* 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;

       }
示例#19
0
        /// <summary>  remove all redundant solution
        ///
        /// </summary>
        /// <param name="graphList"> the list of structure to clean
        /// </param>
        /// <returns>            the list cleaned
        /// </returns>
        private static System.Collections.ArrayList getMaximum(System.Collections.ArrayList graphList)
        {
            System.Collections.ArrayList reducedGraphList = (System.Collections.ArrayList)graphList.Clone();

            for (int i = 0; i < graphList.Count; i++)
            {
                IAtomContainer gi = (IAtomContainer)graphList[i];

                for (int j = i + 1; j < graphList.Count; j++)
                {
                    IAtomContainer gj = (IAtomContainer)graphList[j];

                    // Gi included in Gj or Gj included in Gi then
                    // reduce the irrelevant solution
                    if (isSubgraph(gj, gi))
                    {
                        SupportClass.ICollectionSupport.Remove(reducedGraphList, gi);
                    }
                    else if (isSubgraph(gi, gj))
                    {
                        SupportClass.ICollectionSupport.Remove(reducedGraphList, gj);
                    }
                }
            }
            return(reducedGraphList);
        }
示例#20
0
        public ArrayList GetindexofArrayfromassignmentStatement(string statement)
        {
            ArrayList index = new ArrayList();
            ArrayList index1 = new ArrayList();
            ArrayList indextemp = new ArrayList();
            int i;
            bool flag=false,flagagain=false ;

            for (i = 0; i <= statement.Length -1; i++)
            {
                if (statement[i]=='[')
                {
                    flag = true;
                    i = i + 1;
                }
                if (statement[i] == ']')
                {
                    flag = false;
                    flagagain = true;
                }
                if (flag)
                {
                    index.Add(statement[i]);

                }
                if (flagagain)
                {
                    if (index1.Count < index.Count)
                    {

                        if (index.Count >= indextemp.Count)
                        {
                            index1 = (ArrayList)index.Clone();
                        }
                        else
                        {
                            index1 = (ArrayList)indextemp.Clone();
                        }
                    }
                    indextemp = (ArrayList)index.Clone();
                    index.Clear();
                    flagagain = false;
                }
            }

            return index1;
        }
示例#21
0
 public System.Collections.ArrayList GetStorageList()
 {
     return((System.Collections.ArrayList)TheStorage.Clone());
 }
示例#22
0
        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:
                       tmpReturnExpress.Clear();
                       break;
                   case (int)RuleConstants.RULE_RETURNEXPRESS_RETURNEQ2:
                       tmpReturnExpress = (System.Collections.ArrayList)TmpCmdItems.Clone();
                       TmpCmdItems.Clear();
                       break;
                   case (int)RuleConstants.RULE_DEVICETYPE_DEVICETYPEEQ_IDENTIFIER:
                       this.DeviceType = token.Tokens[1].UserObject.ToString();
                       break;
                   case (int)RuleConstants.RULE_IP_IPEQ_IP:
                       ip = token.Tokens[1].UserObject.ToString();
                       break;
                   case (int)RuleConstants.RULE_PORT_PORTEQ_NUMBER:
                       port = int.Parse(token.Tokens[1].UserObject.ToString());
                       break;
                   case (int)RuleConstants.RULE_DEVICEID_DEVICEIDEQ_DEVICEID:
                       deviceId = Convert.ToInt32(token.Tokens[1].ToString(), 16);
                       break;
                   case (int)RuleConstants.RULE_CMD_CMDEQ_CMD:
                       //Cmd cmd;
                       //if(token.Tokens[2].UserObject==null)
                       //  cmd=new Cmd(Convert.ToByte(token.Tokens[1].UserObject.ToString(),16));
                       //else
                       //cmd=new Cmd(Convert.ToByte(token.Tokens[1].UserObject.ToString(),16),
                       //    Convert.ToByte(token.Tokens[2].UserObject.ToString(),16));
                       //  return cmd;

                       break;
                   case (int)RuleConstants.RULE_COMMAND:

                       //CmdClass cls;
                       //CmdType type;
                       //string desc;
                       //string func_name;
                       //byte cmdcode;
                       Cmd cmd = new Cmd(this);

                       // inx  = getTokenInx(token, "Description");

                       for (int i = 0; i < token.Tokens.Length; i++)
                       {
                           NonterminalToken ttok;
                           ttok = (NonterminalToken)token.Tokens[i];
                           if (token.Rule.Rhs[i].Name == "Description")
                           {
                               cmd.description = ((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString().Trim(new char[] { '\"' });
                           }
                           else if (token.Rule.Rhs[i].Name == "FuncName")
                           {
                               cmd.cmdName = ((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString().Trim(new char[] { '\"' });
                           }
                           else if (token.Rule.Rhs[i].Name == "CmdClass")
                           {
                               switch (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString()[0])
                               {
                                   case 'A':
                                       cmd.cmdClass = CmdClass.A;
                                       break;
                                   case 'B':
                                       cmd.cmdClass = CmdClass.B;
                                       break;
                                   case 'C':
                                       cmd.cmdClass = CmdClass.C;
                                       break;
                                   case 'D':
                                       cmd.cmdClass = CmdClass.D;
                                       break;
                               }
                           }
                           else if (token.Rule.Rhs[i].Name == "CmdType")
                           {
                               if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Set")
                                   cmd.cmdType = CmdType.CmdSet;
                               else if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Query")
                                   cmd.cmdType = CmdType.CmdQuery;
                               else if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Report")
                                   cmd.cmdType = CmdType.CmdReport;
                               else
                                   cmd.cmdType = CmdType.CmdUnkonwn;
                           }
                           else if (token.Rule.Rhs[i].Name == "Cmd")
                           {
                               cmd.cmd = Convert.ToByte(ttok.Tokens[1].UserObject.ToString(), 16);  //cmd
                               if (((NonterminalToken)ttok.Tokens[2]).Tokens.Length > 0)
                                   cmd.subCmd = Convert.ToByte(((NonterminalToken)ttok.Tokens[2]).Tokens[0].UserObject.ToString(), 16); //subCmd
                           }

                       } //for
                       cmd.SendCmdItems = (System.Collections.ArrayList)tmpSendExpress.Clone();
                       cmd.ReturnCmdItems = (System.Collections.ArrayList)tmpReturnExpress.Clone();
                       cmd.TestGroupValues = tmpTestExpress;
                       cmd.CanTest = CanTest;
                       tmpReturnExpress.Clear();
                       tmpSendExpress.Clear();
                       tmpTestValues.Clear();
                       tmpTestExpress = new System.Collections.ArrayList(5);
                       //try
                       //{
                       if (cmd.cmdType != CmdType.CmdReport)
                           cmd.CheckTestValue();
                       cmd.GenerateCmdDataSet();

                       //}
                       //catch (Exception ex)
                       //{
                       //    Console.WriteLine(ex.StackTrace);
                       //}
                       this.AddCmd(cmd);
                       break;

               }
               }
               catch (Exception ex)
               {
               Console.WriteLine(ex.StackTrace);
               throw ex;
               }

               return null;
        }
示例#23
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);
        }
示例#24
0
        /// <summary> creates a copy of this view</summary>
        /// <returns> a copy of this view
        /// </returns>
        public override object Clone()
        {
            ViewId vid2 = Vid != null ? (ViewId)Vid.Clone() : null;

            System.Collections.ArrayList members2   = Members != null?(System.Collections.ArrayList)Members.Clone():null;
            System.Collections.ArrayList subgroups2 = subgroups != null?(System.Collections.ArrayList)subgroups.Clone():null;
            return(new MergeView(vid2, members2, subgroups2));
        }