예제 #1
0
 public override void FillFromFile(string fileDir)
 {
     using (System.IO.StreamReader file =
                new System.IO.StreamReader(fileDir))
     {
         if (!file.EndOfStream)
         {
             root = new Node(new DatePrice(file.ReadLine()));
             size++;
         }
         for (int i = 1; !file.EndOfStream; i++)
         {
             DatePrice left = new DatePrice(file.ReadLine());
             if (!file.EndOfStream)
             {
                 DatePrice right = new DatePrice(file.ReadLine());
                 new Node(GetNodeByIndex(i), left, right);
                 size += 2;
             }
             else
             {
                 new Node(GetNodeByIndex(i), left);
                 size++;
             }
         }
     }
 }
예제 #2
0
 public void add(DatePrice obj)
 {
     fileStreamData.Seek(size * 20, SeekOrigin.Begin);
     writerData.Write(obj.date);                       //writes data of element
     writerData.Write(obj.price);
     fileStreamTree.Seek(size * 12, SeekOrigin.Begin); //creates node
     writerTree.Write(size * 20);
     writerTree.Write(0);
     writerTree.Write(0);
     size++;
 }
예제 #3
0
 public void add(int parentNodeAddress, DatePrice left)
 {
     fileStreamData.Seek(size * 20, SeekOrigin.Begin);
     writerData.Write(left.date); //writes data of left element
     writerData.Write(left.price);
     fileStreamTree.Seek(parentNodeAddress + 4, SeekOrigin.Begin);
     writerTree.Write(size * 12); //writes address of left node
     fileStreamTree.Seek(size * 12, SeekOrigin.Begin);
     writerTree.Write(size * 20); //creates left node
     writerTree.Write(0);
     writerTree.Write(0);
     size++;
 }
예제 #4
0
 public override void FillFromFile(string fileDir)
 {
     using (System.IO.StreamReader file =
                new System.IO.StreamReader(fileDir))
     {
         if (!file.EndOfStream)
         {
             add(new DatePrice(file.ReadLine()));
         }
         for (int i = 1; !file.EndOfStream; i++)
         {
             DatePrice left = new DatePrice(file.ReadLine());
             if (!file.EndOfStream)
             {
                 DatePrice right = new DatePrice(file.ReadLine());
                 add(GetNodeAdress(i), left, right);
             }
             else
             {
                 add(GetNodeAdress(i), left);
             }
         }
     }
 }
예제 #5
0
        public int CompareTo(object obj)
        {
            DatePrice dp = (DatePrice)obj;

            return(price.CompareTo(dp.price));
        }
예제 #6
0
 public Node(Node parent, DatePrice left)
 {
     parent.left = new Node(left);
 }
예제 #7
0
 public Node(Node parent, DatePrice left, DatePrice right)
 {
     parent.left  = new Node(left);
     parent.right = new Node(right);
 }
예제 #8
0
 public Node(DatePrice Obj)
 {
     obj = Obj;
 }