示例#1
0
文件: List.cs 项目: 0x0all/MyProgram
        // return true or false - exist element value in stack.
        public bool Exist(ElementType value)
        {
            if (head == null)
            {
                return(false);
            }
            ListElement temp = head;

            for (temp = head; temp.Next() != null && temp.Value() != value; temp = temp.Next())
            {
                ;
            }
            return(temp.Value() == value);
        }
示例#2
0
文件: List.cs 项目: 0x0all/MyProgram
        //return position element with vale value.
        public Position PositionElement(ElementType value)
        {
            ListElement temp = head;
            int         i    = 0;

            for (temp = head; temp != null && temp.Value() != value; temp = temp.Next(), i++)
            {
                ;
            }
            if (temp.Value() == value)
            {
                return(i);
            }
            return(-1);
        }
示例#3
0
        /// <summary>
        /// Print stack.
        /// </summary>
        public void Print()
        {
            if (head == null)
            {
                Console.WriteLine("Stack is empty");
                return;
            }
            ListElement pos = head;

            for (pos = head; pos.Next() != null; pos = pos.Next())
            {
                Console.Write("{0} -> ", pos.Value());
            }
            Console.Write("{0}", pos.Value());
            Console.WriteLine();
        }
示例#4
0
文件: List.cs 项目: 0x0all/MyProgram
        // print stack.
        public void Print()
        {
            Console.WriteLine();
            if (head == null)
            {
                Console.WriteLine("List is Empty");
                return;
            }
            ListElement temp = head;

            for (temp = head; temp.Next() != null; temp = temp.Next())
            {
                Console.Write("{0}, ", temp.Value());
            }
            Console.WriteLine("{0}", temp.Value());
        }