Exemple #1
0
 public bool Dequeue(out BinOpNodePair nodePair)
 {
     if (_oplist.Count == 0)
     {
         nodePair = default(BinOpNodePair);
         return(false);
     }
     nodePair = _oplist.First.Value;
     _oplist.RemoveFirst();
     return(true);
 }
Exemple #2
0
        public bool Enqueue(BinOpNodePair nodePair)
        {
            if (!nodePair.IsValid())
            {
                return(false);
            }

            for (var currentNode = _oplist.First; currentNode != null; currentNode = currentNode.Next)
            {
                if (currentNode.Value.Operator.Precedence > nodePair.Operator.Precedence)
                {
                    _oplist.AddBefore(currentNode, nodePair);
                    return(true);
                }
            }
            _oplist.AddLast(nodePair);
            return(true);
        }