예제 #1
0
        override public string ToString()
        {
            string s = "]";

            for (Node <T> curr = first; curr != null; curr = curr.GetNext())
            {
                s += " " + curr.GetValue();
                s += curr.GetNext() == null ? " ]" : ",";
            }
            return(s);
        }
예제 #2
0
        public T Pop()
        {
            if (first == null)
            {
                return(default(T));
            }
            T tmp = first.GetValue();

            first = first.GetNext();
            return(tmp);
        }
예제 #3
0
        public int Size()
        {
            Node <T> pos   = this.first;
            int      count = 0;

            while (pos != null)
            {
                count++;
                pos = pos.GetNext();
            }
            return(count);
        }
예제 #4
0
        public override string ToString()
        {
            string   st  = "[";
            Node <T> pos = this.first;

            while (pos != null)
            {
                st += pos.GetValue() + "-->";
                pos = pos.GetNext();
            }
            st += "Null]";
            return(st);
        }