示例#1
0
        public string getNext()
        {
            CDNode oldCurrent = current;

            current = current.Previous;
            return(oldCurrent.Artist);
        }
示例#2
0
        private void btnPush_Click(object sender, EventArgs e)
        {
            CDNode cd = new CDNode();

            cd.Artist   = txtData.Text;
            cd.Duration = Convert.ToInt32(nudMinutes.Value);

            myst.push(cd);
        }
        }//push

        public CDNode pop()
        {
            if (isEmpty())
            {
                return(null);
            }
            CDNode removed = top;

            top = removed.Previous;
            size--;
            return(removed);
        }//pop
        }//pop

        public String list()
        {
            if (isEmpty())
            {
                return("Stack is empty\n");
            }
            string output = "Contents of stack\n Nodes:     " + size +
                            "\n";
            CDNode current = top;

            while (current != null)
            {
                output += "Artist:   " + current.Artist + " Duration: " + current.Duration + "\n";
                current = current.Previous;
            }
            return(output);
        }//list
示例#5
0
 public StackIterator(SpindleStack collection)
 {
     this.collection = collection;
     size            = collection.getSize;
     current         = collection.peek();
 }
        }//is empty

        public void push(CDNode sn)
        {
            sn.Previous = top;
            top         = sn;
            size++;
        }//push
 public SpindleStack()
 {
     top  = null;
     size = 0;
 }