public static MyQueue Task(MyQueue mq) { int x = mq.Out(); MyQueue queue = new MyQueue(); queue.InQueue(x); while (mq.head != null) { var tmp = mq.Out(); if (tmp != x) { x = tmp; queue.InQueue(x); } } return(queue); }
public MyQueue Read() { FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); MyQueue mq = new MyQueue(); while (!sr.EndOfStream) { string p = sr.ReadLine(); mq.InQueue(Convert.ToInt32(p)); } sr.Close(); fs.Close(); return(mq); }