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(); } }
void GoToIndex(Mochila x, int index) { if (x.Previous().Index() != index) { ChangePosition(x, x.Previous()); GoToIndex(x.Previous(), index); } }
void GoToPosition(Mochila x, int position) { if (x.Position() != position) { ChangePosition(x, x.Previous()); GoToPosition(x.Previous(), position); } }
Mochila GoToEnd(Mochila x) { if (x.Next() != null) { x = GoToEnd(x.Next()); } return(x); }
Mochila GetByPositon(Mochila x, float position) { if (x.Position() != position) { x = GetByPositon(x.Next(), position); } return(x); }
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); }
private void AddElement(object sender, EventArgs e) { if (element != null) { element = AddEnd(element, 1, 1); } else { element = new Mochila(); element.Index(1); } PlaceinTheList(element); }
private void AddElement(object sender, EventArgs e) { if (m != null) { m = AddEnd(m, 1, 1); } else { m = new Mochila(); m.Index(1); } PlaceinTheList(m); }
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); }
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); }
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"); } }
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"); } }
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"); } }
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(); } } }
public void Previous(Mochila i) { mochilona = i; }
public void Next(Mochila i) { mochilinha = i; }
public void Previous(Mochila i) { previous = i; }
public void Next(Mochila i) { next = i; }