public ReversePolishNotationEvaluator()
        {
            output = new Queue();
            ops = new Stack();

            postfixExpression = string.Empty;
        }
示例#2
1
        private static void Main()
        {
            string inputSentence = SampleSentence;
            string splitPattern = @"(\s+|\s*\,\s*|\s*\-\s*|\s*\!|\s*\.)";
            string[] elements = Regex.Split(inputSentence, splitPattern);

            Stack words = new Stack();
            Queue separators = new Queue();
            StringBuilder result = new StringBuilder();

            foreach (var element in elements)
            {
                if (Regex.IsMatch(element, splitPattern))
                {
                    separators.Enqueue(element);
                }
                else if (Regex.IsMatch(element, @"\S"))
                {
                    words.Push(element);
                }
            }

            while (words.Count > 0)
            {
                result.Append(words.Pop());
                result.Append(separators.Dequeue());
            }

            Console.WriteLine(result);
        }
示例#3
1
 public InputMapper(Dictionary<string, InputContext> contexts, int playerIndex)
 {
     _contexts = contexts;
     _activeContexts = new Stack<InputContext>();
     _callbacks = new List<Action<MappedInput>>();
     _currentFrameMappedInput = new MappedInput(playerIndex);
 }
    static void Main(string[] args)
    {
        bool   correct;
        string expression;

        while (!string.IsNullOrEmpty(expression = Console.ReadLine()))
        {
            System.Collections.Stack stack = new System.Collections.Stack();

            correct = true;

            foreach (char c in expression)
            {
                if (c == '(')
                {
                    stack.Push(c);
                }
                else if (c == ')')
                {
                    if (stack.Count == 0)
                    {
                        correct = false;
                    }
                    else
                    {
                        stack.Pop();
                    }
                }
            }

            Console.WriteLine((correct && stack.Count == 0) ? "correct" : "incorrect");
        }
    }
示例#5
0
 /// <summary> Protected constructor to allow for data structure population
 /// *
 /// </summary>
 /// <param name="aStack">The Stack for the call stack
 /// </param>
 /// <param name="aResults">The Map for the RuleResults
 /// </param>
 /// <param name="aFactories">The Map for the RuleFactory's
 /// </param>
 /// <param name="aOperators">The Map for the Operators
 ///
 /// </param>
 protected internal AbstractBRERuleContext(System.Collections.Stack aStack, Hashtable aFactories, Hashtable aOperators, Hashtable aResults)
 {
     internalCallStack = aStack;
     factories         = aFactories;
     operators         = aOperators;
     results           = aResults;
 }
示例#6
0
 public void PushHistory()
 {
     //if (!IsPostBack)
     {
         URLHISTORY_NODE          node      = new URLHISTORY_NODE();
         System.Collections.Stack stSession = (System.Collections.Stack)Session["URLHistoryStack"];
         node.szKey = Request.FilePath.ToLower();
         node.szURL = Request.Url.ToString();
         if (stSession != null)
         {
             if (stSession.Count > 0)
             {
                 URLHISTORY_NODE topnode = (URLHISTORY_NODE)stSession.Peek();
                 if (topnode.szKey != node.szKey)
                 {
                     stSession.Push(node);
                 }
             }
             else
             {
                 stSession.Push(node);
             }
         }
         else
         {
             System.Collections.Stack stNow = new System.Collections.Stack();
             stNow.Push(node);
             Session["URLHistoryStack"] = stNow;
         }
     }
 }
示例#7
0
    static void Main(string[] args)
    {
        short diamonds;
        int   N = Int32.Parse(Console.ReadLine());

        System.Collections.Stack stack = new System.Collections.Stack();

        for (int i = 0; i < N; i++)
        {
            diamonds = 0;

            foreach (char c in Console.ReadLine())
            {
                if (c == '<')
                {
                    stack.Push(c);
                }
                else if (c == '>' && stack.Count > 0)
                {
                    stack.Pop();
                    diamonds++;
                }
            }

            stack.Clear();

            Console.WriteLine(diamonds);
        }
    }
示例#8
0
        private void stackButton_Click(object sender, EventArgs e)
        {
            Stack pilha = new Stack();

            //Adicionando itens
            pilha.Push("banana");
            pilha.Push("laranja");
            pilha.Push("uva");

            //Exibindo os itens da coleção
            foreach (string elemento in pilha)
            {
                listBox1.Items.Add(elemento);
            }
            listBox1.Items.Add("--------------");

            //Exibindo o item do topo da pilha
            listBox1.Items.Add("topo da pilha");
            listBox1.Items.Add(pilha.Peek());
            listBox1.Items.Add("--------------");

            //Retirando um elemento da pilha (do topo)
            pilha.Pop();

            //Exibindo o item do topo da pilha
            listBox1.Items.Add("topo da pilha");
            listBox1.Items.Add(pilha.Peek());

        }
示例#9
0
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                System.Collections.Stack stack =
                    (System.Collections.Stack)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

                try
                {
                    stack.Clear();
                    returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
                    success = true;
                }
                //catch (KeyNotFoundException)
                //{
                //    success = false;
                //    stackframe.throwAneException(token, arraylist.ToString() + "没有链接到脚本");
                //}
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
            }
示例#10
0
        public Dictionary<HClusterNode,System.Drawing.Color> MarkNodes(List<string> toMark,System.Drawing.Color color)
        {
            Dictionary<HClusterNode, System.Drawing.Color> returnList = new Dictionary<HClusterNode, System.Drawing.Color>();
            Stack<HClusterNode> st = new Stack<HClusterNode>();
            HClusterNode current = null;

            st.Push(this);

            while (st.Count != 0)
            {
                current = st.Pop();
                if (current.joined == null || current.joined.Count == 0)
                {
                    foreach(var item in toMark)
                        if(current.setStruct.Contains(item))
                        {
                            returnList.Add(current,color);
                            break;
                        }
                }
                else
                    if (current.joined != null)
                        foreach (var item in current.joined)
                            st.Push(item);

            }
            return returnList;
        }
示例#11
0
        TextWriter tw; // where the output is going

        #endregion Fields

        #region Constructors

        public RenderXml(Report rep, IStreamGen sg)
        {
            r = rep;
            tw = sg.GetTextWriter();
            stkReportItem = new Stack();
            stkContainers = new Stack();
        }
示例#12
0
 public object Evaluate(params object[] parameters)
 {
     object source = parameters != null ? parameters[0] : null;
     if (source == null)
     {
         return null;
     }
     else if (source is string)
     {
         return StringUtils.Reverse((string) source);
     }
     else if (source is Array)
     {
         return CollectionUtils.Reverse((Array)source);
     }
     else if (source is IEnumerable)
     {
         Stack reversed = new Stack();
         foreach (var o in source as IEnumerable)
         {
             reversed.Push(o);
         }
         return reversed;
     }
     else
     {
         throw FunctionEvaluationException.WrongParameter(this, 0, source);
     }
 }
示例#13
0
        {           // with using stack
            // for ")" - error
            public bool IsValid(string s)
            {
                if (string.IsNullOrEmpty(s))
                {
                    return(true);
                }
                System.Collections.Stack closesbr = new System.Collections.Stack();
                for (int index = 0; index < s.Length; index++)
                {
                    switch (s[index])
                    {
                    case '(': closesbr.Push(')'); break;

                    case '{': closesbr.Push('}'); break;

                    case '[': closesbr.Push(']'); break;

                    default: {
                        if ((closesbr.Count == 0) ||
                            (s[index] != (char)closesbr.Pop()))
                        {
                            return(false);
                        }
                        break;
                    }
                    }
                }
                return(closesbr.Count == 0);
            }
 /// <summary>
 /// Initialize and create a new DnsRequestListener object
 /// </summary>
 public DnsRequestListener(DnsRecordProvider dnsRecordProvider, int port)
 {
     // Initialize the socket event pool
     this._socketAsyncEventArgsPool = new Stack<SocketAsyncEventArgs>();
     this.Port = 53;
     this.DnsRecordProvider = dnsRecordProvider;
 }
示例#15
0
文件: Core.cs 项目: Koneke/Yukkuri
        public static mysToken Evaluate(
			mysSymbol symbol,
			mysToken value,
			Stack<mysSymbolSpace> spaceStack
		)
        {
            // NOTICE THIS
            // since each function has it's own internal space
            // before grabbing our reference to the space in which
            // we want to define our symbol, we need to pop the
            // internal off, or we're going to be defining the symbol
            // in our internal space, i.e. it will scope out as soon as
            // we're done. So we pop the internal off, grab our reference
            // to the space outside of that, then push the internal back on.
            mysSymbolSpace top = spaceStack.Pop();
            mysSymbolSpace ss = spaceStack.Peek();

            if ( value.Type == typeof(mysFunction) ) {
                defineFunction(
                    symbol,
                    value.Value as mysFunction,
                    spaceStack.Peek()
                );
            } else {
                mysSymbolSpace space = symbol.DefinedIn( spaceStack );
                if ( space != null ) {
                    space.Define( symbol, value );
                } else {
                    ss.Define( symbol, value );
                }
            }

            spaceStack.Push( top );
            return null;
        }
		private string ResolveTemplate (string tag, Stack<string> resolvestack)
		{
			string template = FindTemplate(tag);
			if (template == null) return Cache(tag, tag.Trim());
			string translation = ExpandTemplate(template, tag, resolvestack).Trim();
			return Cache(tag, translation);
		}
示例#17
0
 public static string ReadPassword()
 {
     var passbits = new Stack<string>();
     //keep reading
     for (ConsoleKeyInfo cki = Console.ReadKey(true); cki.Key != ConsoleKey.Enter; cki = Console.ReadKey(true))
     {
         if (cki.Key == ConsoleKey.Backspace)
         {
             //rollback the cursor and write a space so it looks backspaced to the user
             Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
             Console.Write(" ");
             Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
             passbits.Pop();
         }
         else
         {
             Console.Write("*");
             passbits.Push(cki.KeyChar.ToString());
         }
     }
     string[] pass = passbits.ToArray();
     Array.Reverse(pass);
     Console.Write(Environment.NewLine);
     return string.Join(string.Empty, pass);
 }
示例#18
0
		public RichTextBox() {
			accepts_return = true;
			auto_size = false;
			auto_word_select = false;
			bullet_indent = 0;
			base.MaxLength = Int32.MaxValue;
			margin_right = 0;
			zoom = 1;
			base.Multiline = true;
			document.CRLFSize = 1;
			shortcuts_enabled = true;
			base.EnableLinks = true;
			richtext = true;
			
			rtf_style = new RtfSectionStyle ();
			rtf_section_stack = null;

			scrollbars = RichTextBoxScrollBars.Both;
			alignment = HorizontalAlignment.Left;
			LostFocus += new EventHandler(RichTextBox_LostFocus);
			GotFocus += new EventHandler(RichTextBox_GotFocus);
			BackColor = ThemeEngine.Current.ColorWindow;
			backcolor_set = false;
			language_option = RichTextBoxLanguageOptions.AutoFontSizeAdjust;
			rich_text_shortcuts_enabled = true;
			selection_back_color = DefaultBackColor;
			ForeColor = ThemeEngine.Current.ColorWindowText;

			base.HScrolled += new EventHandler(RichTextBox_HScrolled);
			base.VScrolled += new EventHandler(RichTextBox_VScrolled);

			SetStyle (ControlStyles.StandardDoubleClick, false);
		}
        public IList<IList<int>> LevelOrderBottom(TreeNode root)
        {
            IList<IList<int>> result = new List<IList<int>>();
            if (root == null)
                return result;

            Stack<IList<int>> stack = new Stack<IList<int>>();
            Queue<TreeNode> queue = new Queue<TreeNode>();
            queue.Enqueue(root);
            while (queue.Count > 0)
            {
                IList<int> items = new List<int>();
                int num = queue.Count;
                for (int i = 0; i < num; i++)
                {
                    TreeNode node = queue.Dequeue();
                    items.Add(node.val);

                    if (node.left != null)
                        queue.Enqueue(node.left);
                    if (node.right != null)
                        queue.Enqueue(node.right);
                }
                stack.Push(items);
            }

            while (stack.Count > 0)
                result.Add(stack.Pop());

            return result;
        }
示例#20
0
 public Student(string fname,string lname)
 {
     this.FirstName = fname;
     this.LastName = lname;
     Grades= new Stack();
     count++;
 }
        public void ZnajdzOtoczke(List<Punkt> lista)
        {
            List<Punkt> listaTmp = new List<Punkt>();
            Stack stos = new Stack();

            stos.Push(lista[0]);
            stos.Push(lista[1]);
            stos.Push(lista[2]);

            listaTmp.Add(lista[0]);
            listaTmp.Add(lista[1]);
            listaTmp.Add(lista[2]);

            for (int i = 3; i < lista.Count; i++)
            {
                int j = i;
                while (ObliczDet(listaTmp[stos.Count - 2], listaTmp[stos.Count - 1], lista[i]) < 0)
                {
                    //Console.WriteLine(ObliczDet(lista[j - 2], lista[j - 1], lista[i]));
                    stos.Pop();
                    listaTmp.RemoveRange(stos.Count, 1);
                }
                stos.Push(lista[i]);
                listaTmp.Add(lista[i]);
            }
            int ileWierz = stos.Count;
            for (int i = 0; i < ileWierz; i++)
            {
                wierzcholki.Add((Punkt)stos.Pop());
            }
            wierzcholki.Reverse();
        }
 public void Dispose()
 {
     _dataStructureStack = null;
     _dataStack = null;
     _accumulator = null;
     _unicodeAccumulator = null;
 }
示例#23
0
        public static void CalculateTime(Stack stack, int k)
        {
            // Add
            var startAdding = DateTime.Now;
            string test = "Test string";
            for (int i = 0; i < k; i++)
            {
                stack.Push(test);
            }
            var finishAdding = DateTime.Now;
            Console.WriteLine("Addition time (" + k + " elements) : " + stack.GetType() + "  " + (finishAdding - startAdding));

            // Search
            var startSearch = DateTime.Now;
            for (int i = 0; i < k; i++)
            {
                bool a = stack.Contains(test);
            }
            var finishSearch = DateTime.Now;
            Console.WriteLine("Search time (" + k + " elements) : " + stack.GetType() + "  " + (finishSearch - startSearch));

            // Remove
            k = 1000000;
            var startRemoving = DateTime.Now;
            for (int i = 0; i < k; i++)
            {
                stack.Pop();
            }
            var finishRemoving = DateTime.Now;
            Console.WriteLine("Removal time (" + k + " elements) : " + stack.GetType() + "  " + (finishRemoving - startRemoving) + "\n");
        }
示例#24
0
        public void TestToArrayBasic()
        {
            Stack stk1;
            Object[] oArr;
            Int32 iNumberOfElements;
            String strValue;

            //[] Vanila test case - this gives an object array of the values in the stack
            stk1 = new Stack();
            oArr = stk1.ToArray();

            
            Assert.Equal(0, oArr.Length);

            iNumberOfElements = 10;
            for (int i = 0; i < iNumberOfElements; i++)
                stk1.Push(i);

            oArr = stk1.ToArray();
            Array.Sort(oArr);

            for (int i = 0; i < oArr.Length; i++)
            {
                strValue = "Value_" + i;
                
            Assert.Equal((Int32)oArr[i], i);
            }
        }
		internal static String Format(Exception exception, IFormatProvider formatProvider)
		{
			if (exception == null)
				return null;

			// push all inner exceptions onto stack
			var exceptionStack = new Stack<Exception>();
			var currentException = exception;
			while (currentException != null)
			{
				exceptionStack.Push(currentException);
				currentException = currentException.InnerException;
			}

			// go through inner exceptions in reverse order
			var sb = new StringBuilder();
			for (Int32 i = 1; exceptionStack.Count > 0; i++)
			{
				currentException = exceptionStack.Pop();
				FormatSingleException(formatProvider, sb, currentException, i);
			}

			// that's it; return result
			return sb.ToString();
		}
示例#26
0
        static void Main(string[] args)
        {
            //ArrayList
            ArrayList arrayList = new ArrayList();
            arrayList.Add("First item");
            arrayList.Add(5);
            arrayList.Add('c');

            foreach (var item in arrayList) {
                Console.WriteLine("Element of arrayList: {0}", item);
            }

            //HashTable
            Hashtable hashtable = new Hashtable();
            hashtable.Add(0, "Zero item");
            hashtable[1] = "First item";
            hashtable["2"] = "Second item";
            hashtable[Guid.NewGuid()] = "Third item";

            ICollection keys = hashtable.Keys;
            foreach (var key in keys)
            {
                Console.WriteLine("Key: {0}, Value: {1}", key, hashtable[key]);
            }

            //SortedList
            SortedList sl = new SortedList();

            sl.Add("007", "Ritesh Saikia");
            sl.Add("001", "Zara Ali");
            sl.Add("002", "Abida Rehman");
            sl.Add("003", "Joe Holzner");
            sl.Add("004", "Mausam Benazir Nur");
            sl.Add("006", "M. Amlan");
            sl.Add("005", "M. Arif");

            ICollection slValues = sl.Values;
            foreach (var s in slValues) {
                Console.WriteLine("SortedList value: {0}", s);
            }
             //Queue is FIFO: First in First out
            Queue que = new Queue();
            que.Enqueue("Student_1");
            que.Enqueue(5);
            que.Enqueue("Student_2");
            que.Enqueue("Student_3");

            Console.WriteLine(que.Dequeue().ToString());
            Console.WriteLine(que.Dequeue().ToString());

            // Stack is FILO: First in Last out
            Stack StackPop = new Stack();
            StackPop.Push("Student_1");
            StackPop.Push("Student_2");
            StackPop.Push("Student_3");
            Console.WriteLine(StackPop.Pop().ToString());
            Console.WriteLine(StackPop.Pop().ToString());

            Console.ReadLine();
        }
示例#27
0
        public List<DBVHNode> BoundsQuery(Bounds bounds)
        {
            List<DBVHNode> results = new List<DBVHNode>();

            if (nodes.Count > 0){

            Stack<DBVHNode> stack = new Stack<DBVHNode>();
            stack.Push(nodes[0]);
            while(stack.Count > 0)
            {

                DBVHNode node = stack.Pop();

                if (node.content != null){ //leaf node

                    if (bounds.Intersects(node.content.bounds))
                        results.Add(node);

                }else{

                    if (NodeExists(node.Left) && bounds.Intersects(nodes[node.Left].bounds))
                        stack.Push(nodes[node.Left]);

                    if (NodeExists(node.Right) && bounds.Intersects(nodes[node.Right].bounds))
                        stack.Push(nodes[node.Right]);

                }

            }
            }

            return results;
        }
示例#28
0
		public SymbolTable()
		{
			scopes = new Stack<Dictionary<String, SequenceVariable>>();
            scopesMeta = new Stack<ScopeMetaInformation>();

            globalsImplicitlyDeclared = new Dictionary<SequenceVariable, bool>();
		}
        //Taken from http://stackoverflow.com/a/18884516 by pkuderov
        private static string TrimString(StringBuilder builder)
        {
            string initialString = builder.ToString();
            char[] s = new char[initialString.Length];
            char toRemove = '$';
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < s.Length; i++)
            {
                s[i] = initialString[i];
                if (s[i] == '(')
                    stack.Push(i);
                else if (s[i] == ')')
                {
                    int start = stack.Pop();
                    var endParanthesis = start == 0 && i == s.Length - 1;
                    var middleParanthesis = start != 0 && s[start - 1] == '(' && s[i + 1] == ')';
                    if (endParanthesis || middleParanthesis)
                    {
                        s[start] = s[i] = toRemove;
                    }
                }
            }
            var newString = new string((from c in s where c != toRemove select c).ToArray());
            return newString.Trim();
        }
示例#30
0
        public IEnumerable<IPath> Map(object data)
        {
            JToken jToken = JToken.Parse(data.ToString());
            var propertyStack = new Stack<Tuple<JProperty, bool>>();

            return BuildPaths(jToken, propertyStack, jToken);
        }
示例#31
0
        static void Main(string[] args)
        {
            string frase; //string que contendra la frase digitada por el usuario
            Stack mipila = new Stack(); //Pila que contendra la frase por partes
            int contadorPalabrasIguales = 0; //contador que contara la cantidad de palabras iguales
            string valor;

            Console.WriteLine("Digite una frase: "); //Le indico que necesito que digite una frase
            frase = Console.ReadLine(); //Guardo la frase en la variable "frase"

            for (int i = 0; i < frase.Length; i++) //para i = 0 hasta que i sea menor al tamaño de la frase
            {
                mipila.Push(frase.Substring(i,1)); //Enviar a la pila una subcadena de la frase
            }
            for (int i = 0; i < frase.Length; i++)
            {
                valor = mipila.Pop().ToString();
                if (valor == frase.Substring(i,1))
                {
                    contadorPalabrasIguales++;
                }
            }
            if (contadorPalabrasIguales == frase.Length)
            {
                Console.WriteLine("La frase es palindromo");
            }
            else
            {
                Console.WriteLine("La frase no es palindromo");
            }
            Console.WriteLine("Presione una tecla para salir...");
            Console.ReadKey();
        }
        /// <summary>
        /// returns true if path exists from startVertex to endVertex
        /// </summary>
        private bool depthFirstSearch(object startVertex, object endVertex)
        {
            var stack = new Stack();
            var vertextQueue = new Queue();
            bool found = false;

            graph.clearMarks();
            stack.Push(startVertex);
            do
            {
                object vertex = stack.Pop();

                if (vertex == endVertex) // general case when path is found
                    found = true;
                else
                {
                    if (!graph.isMarked(vertex)) // if not marked
                    {
                        graph.markVertex(vertex); // then mark that vertex
                        vertextQueue = graph.getToVertices(vertex); //get all adjecent vertexes

                        while (vertextQueue.Count > 0) // then for each of those adjecent vertexes
                        {
                            object item = vertextQueue.Dequeue();

                            if (!graph.isMarked(item))
                                stack.Push(item);
                        }
                    }
                }
            } while (stack.Count > 0 && !found);

            return found;
        }
示例#33
0
    void InvokeEstablish()
    {
      var types = new Stack<Type>();
      var type = GetType();

      do
      {
        types.Push(type);
#if NET_STANDARD
        type = type.GetTypeInfo().BaseType;
#else
        type = type.BaseType;
#endif

      } while (type != typeof (ContextSpecification));

      foreach (var t in types)
      {
        var fieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

        FieldInfo establishFieldInfo = null;
        foreach (var info in fieldInfos)
        {
          if (info.FieldType.Name.Equals("Establish"))
            establishFieldInfo = info;
        }

        Delegate establish = null;

        if (establishFieldInfo != null) establish = establishFieldInfo.GetValue(this) as Delegate;
        if (establish != null) Exception = Catch.Exception(() => establish.DynamicInvoke(null));
      }
    }
        internal static TreeViewItemViewModel Expand(TreeViewItemModelItemViewModel rootTreeViewItem, ModelItem modelItemToExpandTo)
        {
            Fx.Assert(modelItemToExpandTo != null && rootTreeViewItem != null, "rootTreeViewItem and modelItemToExpand should not have null value");

            // ModelItems with HidePropertyInOutlineViewAttribute are invisible in the designerTree.
            if (ExtensibilityAccessor.GetAttribute<HidePropertyInOutlineViewAttribute>(modelItemToExpandTo) != null)
            {
                return null;
            }

            Stack pathStack = new Stack();

            TreeViewItemViewModel itemToBeSelected = null;

            if (GetExpandingPath(modelItemToExpandTo, pathStack, new HashSet<ModelItem>()))
            {
                // If the root of modelItemToExpandTo differs from the root of the designerTree, it means modelItemToExpandTo doesn't belong to the designerTree.
                if (pathStack.Pop() != rootTreeViewItem.VisualValue)
                {
                    return null;
                }

                object item = null;
                TreeViewItemViewModel treeViewItem = rootTreeViewItem;
                TreeViewItemViewModel tempTreeViewItem = rootTreeViewItem;

                // Using the path to the root, expand the corresponding tree node. Ignore the items which is not visible on the designerTree.
                while (pathStack.Count > 0)
                {
                    if (tempTreeViewItem != null)
                    {
                        treeViewItem = tempTreeViewItem;
                        treeViewItem.IsExpanded = true;
                    }

                    item = pathStack.Pop();
                    tempTreeViewItem = (from child in treeViewItem.Children
                                        where (child is TreeViewItemModelItemViewModel && ((TreeViewItemModelItemViewModel)child).VisualValue == item as ModelItem)
                                        || (child is TreeViewItemModelPropertyViewModel && ((TreeViewItemModelPropertyViewModel)child).VisualValue == item as ModelProperty)
                                        || (child is TreeViewItemKeyValuePairModelItemViewModel && ((TreeViewItemKeyValuePairModelItemViewModel)child).VisualValue.Value == item as ModelItem)
                                        select child).FirstOrDefault();

                    // For TreeViewItemKeyValuePairModelItemViewModel, its path to the children is very complicated.
                    // Take Switch as example: Switch(ModelItem) -> Cases(ModelProperty) -> KeyDictionaryCollection(ModelItem) -> ItemsCollection(ModelProperty) -> ModelItemKeyValuePair<T, Activity>(ModelItem) -> Value(ModelProperty) -> Children
                    // All the path nodes except Switch and Children are invisible and can be ignored, the child node in the path is used twice to search for TreeViewItemKeyValuePairModelItemViewModel and its children in designerTree.
                    if (tempTreeViewItem is TreeViewItemKeyValuePairModelItemViewModel)
                    {
                        // For further searching
                        pathStack.Push(item);
                    }

                    if (pathStack.Count == 0)
                    {
                        itemToBeSelected = tempTreeViewItem;
                    }
                }
            }

            return itemToBeSelected;
        }
 protected virtual void ClearFlowVariables()
 {
     _callingModuleDriverStack = new System.Collections.Stack();
     _callingModuleStack       = new System.Collections.Stack();
     _driver          = string.Empty;
     _moduleBeginName = string.Empty;
     _moduleEndName   = string.Empty;
     _selection       = string.Empty;
 }
示例#36
0
        /// <summary>
        /// Wizard control with designer support
        /// </summary>
        public Wizard()
        {
            //Empty collection of Pages
            vPages     = new PageCollection(this);
            mPageStack = new Stack();

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
        }
示例#37
0
        /** Invoke a user supplied parse action. */
        public override TUVienna.CS_CUP.Runtime.Symbol do_action(
            int act_num,
            TUVienna.CS_CUP.Runtime.lr_parser parser,
            System.Collections.Stack xstack1,
            int top)
        {
            mStack CUP_parser_stack = new mStack(xstack1);

            /* call code in generated class */
            return(action_obj.CUP_TinyParser_do_action(act_num, parser, stack, top));
        }
示例#38
0
        public int solution2(int[] A, int[] B)
        {
            // 37%
            // Correctness 50%
            // Performance 25%
            var count = 0;

            System.Collections.Stack list = new System.Collections.Stack();

            for (int i = 0; i < A.Length; i++)
            {
                var current = new fishObj()
                {
                    Size = A[i], Direction = B[i]
                };

                if (list.Count == 0 && current.Direction == 0)
                {
                    count++;
                    continue;
                }

                if (current.Direction == 1)
                {
                    list.Push(current);
                }
                else
                {
                    for (int x = 0; x < list.Count; x++)
                    {
                        var compare = (fishObj)list.Pop();

                        if (compare.Size > current.Size)
                        {
                            list.Push(compare);
                            break;
                        }
                        else if (x == list.Count)
                        {
                            count++; // bug aqui
                        }
                        else
                        {
                            current = compare;
                        }
                    }
                }
            }
            //Console.WriteLine($"{solution2(new int[]{2,6,4,3,1,5}, new int[]{0,1,0,1,0,0})} - 2");
            //0 - esquerda, 1 - direita)
            count = count + list.Count; // ou aqui

            return(count);
        }
 static public int Clear(IntPtr l)
 {
     try {
         System.Collections.Stack self = (System.Collections.Stack)checkSelf(l);
         self.Clear();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#40
0
 private void InitializeNavigationStack()
 {
     if (navigationStacks.ContainsKey(SceneManager.GetActiveScene().name) == false)
     {
         navigationStack = new Stack();
     }
     else
     {
         navigationStack = navigationStacks[SceneManager.GetActiveScene().name];
         navigationStacks.Remove(SceneManager.GetActiveScene().name);
     }
 }
 static public int get_SyncRoot(IntPtr l)
 {
     try {
         System.Collections.Stack self = (System.Collections.Stack)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.SyncRoot);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#42
0
        public void Stack_ReturnsCount()
        {
            System.Collections.Stack st = new System.Collections.Stack();
            var rand  = new Random();
            int count = rand.Next(0, 5);

            for (int i = 0; i < count; i++)
            {
                Stack.push(ref st, i);
            }

            Assert.AreEqual(count, Stack.size(st));
        }
        public MainWindow()
        {
            InitializeComponent();
            applnames   = new Stack();
            applhash    = new Hashtable();
            mainWindow1 = new MainWindow();

            timer1       = new System.Windows.Forms.Timer();
            timer1.Tick += Timer1_Tick;

            Loaded            += MainWindow_Loaded;
            notifyIcon1.Click += NotifyIcon1_Click;
        }
 static public int ctor_s(IntPtr l)
 {
     try {
         System.Collections.Stack o;
         o = new System.Collections.Stack();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#45
0
        public void Stack_Push_Adds5Items()
        {
            System.Collections.Stack st = new System.Collections.Stack();

            Stack.push(ref st, 0);

            for (int i = 0; i < 5; i++)
            {
                Stack.push(ref st, i);
            }

            Assert.AreEqual(6, Stack.size(st));
        }
示例#46
0
        public void Stack_Pop_RemovesItem()
        {
            System.Collections.Stack st = new System.Collections.Stack();

            for (int i = 0; i < 5; i++)
            {
                Stack.push(ref st, i);
            }

            Stack.pop(ref st);

            Assert.AreEqual(4, Stack.size(st));
        }
 static public int ToArray(IntPtr l)
 {
     try {
         System.Collections.Stack self = (System.Collections.Stack)checkSelf(l);
         var ret = self.ToArray();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#48
0
 public string PopHistory()
 {
     System.Collections.Stack stSession = (System.Collections.Stack)Session["URLHistoryStack"];
     if (stSession != null)
     {
         if (stSession.Count > 1)
         {
             stSession.Pop();
             URLHISTORY_NODE topnode = (URLHISTORY_NODE)stSession.Pop();
             return(topnode.szURL);
         }
     }
     return(null);
 }
示例#49
0
        static void Main(string[] args)
        {
            System.Collections.Stack st = new System.Collections.Stack();
            st.Push(10);
            st.Push(20);
            st.Push(30);
            var top = st.Pop();

            foreach (var c in st)
            {
                Console.WriteLine(c);
            }
            Console.WriteLine(top);
        }
 static int Clear(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Stack obj = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         obj.Clear();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static public int Push(IntPtr l)
 {
     try {
         System.Collections.Stack self = (System.Collections.Stack)checkSelf(l);
         System.Object            a1;
         checkType(l, 2, out a1);
         self.Push(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int Push(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         System.Collections.Stack obj = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         object arg0 = ToLua.ToVarObject(L, 2);
         obj.Push(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static public int ctor__ICollection_s(IntPtr l)
 {
     try {
         System.Collections.Stack       o;
         System.Collections.ICollection a1;
         checkType(l, 1, out a1);
         o = new System.Collections.Stack(a1);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int GetEnumerator(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Stack       obj = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         System.Collections.IEnumerator o   = obj.GetEnumerator();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#55
0
        public void Stack_Peek_GetsItem()
        {
            System.Collections.Stack st = new System.Collections.Stack();

            Stack.push(ref st, 0);

            for (int i = 0; i < 5; i++)
            {
                Stack.push(ref st, i);
            }

            Stack.peek(st);

            Assert.AreEqual(4, Stack.peek(st));
        }
 static int ToArray(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Stack obj = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         object[] o = obj.ToArray();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Synchronized(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Stack arg0 = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         System.Collections.Stack o    = System.Collections.Stack.Synchronized(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int CopyTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         System.Collections.Stack obj  = (System.Collections.Stack)ToLua.CheckObject(L, 1, typeof(System.Collections.Stack));
         System.Array             arg0 = (System.Array)ToLua.CheckObject(L, 2, typeof(System.Array));
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.CopyTo(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#59
-1
        public SetTimeSpanGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_Property = prop;
            m_Mobile = mobile;
            m_Object = o;
            m_Stack = stack;
            m_Page = page;
            m_List = list;

            TimeSpan ts = (TimeSpan)prop.GetValue( o, null );

            AddPage( 0 );

            AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
            AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );

            AddRect( 0, prop.Name, 0, -1 );
            AddRect( 1, ts.ToString(), 0, -1 );
            AddRect( 2, "Zero", 1, -1 );
            AddRect( 3, "From H:M:S", 2, -1 );
            AddRect( 4, "H:", 3, 0 );
            AddRect( 5, "M:", 4, 1 );
            AddRect( 6, "S:", 5, 2 );
        }
示例#60
-1
 public TagListViewProcessor(ListView listview)
 {
     _TagTable = new Hashtable(1023);
     _Tags = new Stack<string>();
     _Item_LV = listview;
     _Item_LV.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this._Item_LV_ItemCheck);
 }