Exemplo n.º 1
0
        void PlaceinTheList(Mochila x)
        {
            if (x.Position().Equals(0))
            {
                listBox1.Items.Clear();
            }
            if (x.Next() != null)
            {
                if (x.Previous() != null)
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem a " +
                                       x.Next().Index() +
                                       " e está dentro da " + x.Previous().Index());
                }
                else
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem a " +
                                       x.Next().Index() + " e não está dentro de nenhuma");
                }

                PlaceinTheList(x.Next());
            }
            else
            {
                if (x.Previous() != null)
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem nada e está dentro da " + x.Previous().Index());
                }
                else
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem nada e não está dentro de nenhuma");
                }
                textBox4.Text = (x.Position() + 1).ToString();
            }
        }
Exemplo n.º 2
0
 void GoToIndex(Mochila x, int index)
 {
     if (x.Previous().Index() != index)
     {
         ChangePosition(x, x.Previous());
         GoToIndex(x.Previous(), index);
     }
 }
Exemplo n.º 3
0
 void GoToPosition(Mochila x, int position)
 {
     if (x.Position() != position)
     {
         ChangePosition(x, x.Previous());
         GoToPosition(x.Previous(), position);
     }
 }
Exemplo n.º 4
0
 Mochila GoToEnd(Mochila x)
 {
     if (x.Next() != null)
     {
         x = GoToEnd(x.Next());
     }
     return(x);
 }
Exemplo n.º 5
0
 Mochila GetByPositon(Mochila x, float position)
 {
     if (x.Position() != position)
     {
         x = GetByPositon(x.Next(), position);
     }
     return(x);
 }
Exemplo n.º 6
0
        void ChangePosition(Mochila x, Mochila y)
        {
            Mochila w = new Mochila();

            w = x;
            int ew = w.Index();

            x = y;
            y = w;
            y.Index(x.Index());
            x.Index(ew);
        }
Exemplo n.º 7
0
 private void AddElement(object sender, EventArgs e)
 {
     if (element != null)
     {
         element = AddEnd(element, 1, 1);
     }
     else
     {
         element = new Mochila();
         element.Index(1);
     }
     PlaceinTheList(element);
 }
Exemplo n.º 8
0
 private void AddElement(object sender, EventArgs e)
 {
     if (m != null)
     {
         m = AddEnd(m, 1, 1);
     }
     else
     {
         m = new Mochila();
         m.Index(1);
     }
     PlaceinTheList(m);
 }
Exemplo n.º 9
0
 Mochila AddEnd(Mochila x, int posicao, int tamanho)
 {
     if (x.Index() >= tamanho)
     {
         tamanho = x.Index() + 1;
     }
     if (x.Next() != null)
     {
         x.Next(AddEnd(x.Next(), posicao + 1, tamanho));
     }
     else
     {
         x.Next(new Mochila());
         x.Next().Previous(x);
         x.Next().Position(posicao);
         x.Next().Index(tamanho);
     }
     return(x);
 }
Exemplo n.º 10
0
 Mochila AddEnd(Mochila x, int position, int index)
 {
     if (x.Index() >= index)
     {
         index = x.Index() + 1;
     }
     if (x.Next() != null)
     {
         x.Next(AddEnd(x.Next(), position + 1, index));
     }
     else
     {
         x.Next(new Mochila());
         x.Next().Previous(x);
         x.Next().Position(position);
         x.Next().Index(index);
     }
     return(x);
 }
Exemplo n.º 11
0
 private void AddElementToPosition(object sender, EventArgs e)
 {
     if (newInPosition.Text != null && newInPosition.Text != "")
     {
         try
         {
             element = AddEnd(element, 1, 1);
             GoToPosition(GoToEnd(element), int.Parse(newInPosition.Text));
             PlaceinTheList(element);
         }
         catch
         {
             MessageBox.Show("Choose a Position that is on the List");
         }
     }
     else
     {
         MessageBox.Show("Choose a Position");
     }
 }
Exemplo n.º 12
0
 private void AddElementToValue(object sender, EventArgs e)
 {
     if (textBox6.Text != null && textBox6.Text != "")
     {
         try
         {
             m = AddEnd(m, 1, 1);
             GoToIndex(GoToEnd(m), int.Parse(textBox6.Text));
             PlaceinTheList(m);
         }
         catch
         {
             MessageBox.Show("Choose a Value that is on the List");
         }
     }
     else
     {
         MessageBox.Show("Choose a Value");
     }
 }
Exemplo n.º 13
0
 private void AddElementToValue(object sender, EventArgs e)
 {
     if (newAfterValue.Text != null && newAfterValue.Text != "")
     {
         try
         {
             element = AddEnd(element, 1, 1);
             GoToIndex(GoToEnd(element), int.Parse(newAfterValue.Text));
             PlaceinTheList(element);
         }
         catch
         {
             MessageBox.Show("Choose a Value that is on the List");
         }
     }
     else
     {
         MessageBox.Show("Choose a Value");
     }
 }
Exemplo n.º 14
0
        void AllBackToPosition(Mochila x, int first)
        {
            if (x.Next() != null)
            {
                if (first.Equals(0))
                {
                    if (x.Previous() != null)
                    {
                        x.Previous().Next(x.Next());
                        x.Next().Previous(x.Previous());
                        x.Next().Position(x.Position());
                    }
                    else
                    {
                        m = x.Next();
                        m.Previous(null);
                        m.Position(0);
                        m.Next().Position(1);
                    }
                }
                else
                {
                    x.Next().Position(x.Position() + 1);
                }

                AllBackToPosition(x.Next(), first + 1);
            }
            else if (first.Equals(0))
            {
                if (x.Previous() != null)
                {
                    x.Previous().Next(null);
                }
                else
                {
                    x = new Mochila();
                }
            }
        }
Exemplo n.º 15
0
 public void Previous(Mochila i)
 {
     mochilona = i;
 }
Exemplo n.º 16
0
 public void Next(Mochila i)
 {
     mochilinha = i;
 }
Exemplo n.º 17
0
 public void Previous(Mochila i)
 {
     previous = i;
 }
Exemplo n.º 18
0
 public void Next(Mochila i)
 {
     next = i;
 }