Beispiel #1
0
        public static MyQueue StringToMyQueue(string s)
        {
            MyQueue queue = new MyQueue();

            string[] arr  = s.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            int[]    mass = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                queue.InQueue(Convert.ToDouble(arr[i]));
            }
            return(queue);
        }
Beispiel #2
0
        public void MyQueueToFile(MyQueue q)
        {
            FileStream   f3     = new FileStream(PathFileInput, FileMode.Create);
            StreamWriter writer = new StreamWriter(f3);

            while (!q.QueueIsEmpty())
            {
                writer.WriteLine(Convert.ToString(q.OutQueue()));
            }
            writer.Close();
            f3.Close();
        }
Beispiel #3
0
        public static MyQueue FileToMyQueue(string pathFileInput)
        {
            FileStream   f           = new FileStream(pathFileInput, FileMode.Open);
            StreamReader r           = new StreamReader(f);
            MyQueue      DecFromFile = new MyQueue();
            string       str         = r.ReadLine();

            while (str != null)
            {
                double v = Convert.ToDouble(str);
                DecFromFile.InQueue(v);
                str = r.ReadLine();
            }
            f.Close();
            r.Close();
            return(DecFromFile);
        }
Beispiel #4
0
 public bool FileToMyQueue(MyQueue DecFromFile)
 {
     try
     {
         FileStream   f = new FileStream(PathFileInput, FileMode.Open);
         StreamReader r = new StreamReader(f);
         // DecFromFile = new MyQueue();
         string str = r.ReadLine();
         while (str != null)
         {
             double v = Convert.ToDouble(str);
             DecFromFile.InQueue(v);
             str = r.ReadLine();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }