public CircList(ICollection <CircListBeg> col) // { CircListBeg help = new CircListBeg(); First = help; foreach (CircListBeg entry in col) { help.Value = entry.Value; help.Key = entry.Key; help.Next = new CircListBeg(); help = help.Next; } //help = First; }
public void Add(CircListBeg entry) { if (First != null) { CircListBeg help = this.SearchKey(Count - 1); help.Next = entry; entry.Next = First; entry.Key = help.Key + 1; } else { First = entry; First.Key = 0; First.Next = First; } }
public override string ToString() { if (First != null) { string ans = ""; CircListBeg help = First; ans += First.ToString() + " "; help = help.Next; while (help.Key != First.Key) { ans += help.ToString() + " "; help = help.Next; } return(ans); } else { return("Список пуст"); } }
public void Remove(CircListBeg entry) { if (First != null) { CircListBeg help = First; if (help.Value != entry.Value) { CircListBeg last = help; help = help.Next; while (help.Key != First.Key) { if (help.Value == entry.Value) { last.Next = help.Next; for (int i = help.Key; i < Count - 1; i++) { help = help.Next; help.Key = i; } break; } else { last = help; help = help.Next; } } } else { SearchKey(Count - 1).Next = help.Next; First = help.Next; First.Key = 0; for (int i = 0; i < Count - 1; i++) { help = help.Next; help.Key = i; } } } }
public CircListBeg SearchKey(int key) { CircListBeg help = First; if (key == help.Key) { return(help); } help = help.Next; while (help.Key != First.Key) { if (key == help.Key) { return(help); } else { help = help.Next; } } return(null); }
public CircList(CircListBeg first) //с парам. { First = first; }
public CircListBeg(int value) { Value = value; Next = null; }
public CircListBeg() { Key = 0; Value = 0; Next = null; }