예제 #1
0
        public override String ToString()
        {
            QueueElement iterator = first;

            StringBuilder builder = new StringBuilder();

            builder.Append("[");

            if (iterator != null)
            {
                builder.Append(" ");
                builder.Append(iterator.GetPriority());
                builder.Append(". ");
                builder.Append(iterator.GetData());

                iterator = iterator.GetPrev();

                while (iterator != null)
                {
                    builder.Append(", ");
                    builder.Append(iterator.GetPriority());
                    builder.Append(". ");
                    builder.Append(iterator.GetData());

                    iterator = iterator.GetPrev();
                }
                builder.Append(" ");
            }

            builder.Append("]");

            return(builder.ToString());
        }
예제 #2
0
        public ICollection <T> ToList()
        {
            LinkedList <T> list     = new LinkedList <T> ();
            QueueElement   iterator = first;

            while (iterator != null)
            {
                list.AddLast(iterator.GetData());
                iterator = iterator.GetPrev();
            }

            return(list);
        }