//добавление случайного элемента в коллекцию public void AddDefault(int nom, string Name) { if (nom > Length) { Console.WriteLine("Номер элемента находится за перделами границ списка"); } else { Factory Fact = new Factory(); Fact = (Factory)Fact.Init(); NewDoublePointConnection <Organization> p1 = beg; NewDoublePointConnection <Organization> temp1 = new NewDoublePointConnection <Organization>(Fact); NewDoublePointConnection <Organization> vr1; NewDoublePointConnection <Organization> vr2; NewDoublePointConnection <Organization> p2 = beg; for (int i = 1; i < nom; i++) { p2 = p2.next; } vr2 = p2; for (int i = 1; i < nom - 1; i++) { p1 = p1.next; } vr1 = p1; p1.next = temp1; p1 = p1.next; p1.pred = vr1; p1.next = vr2; ChanAdd(nom, Name); OnCollectionCountChanged(this, new CollectionHandlerEventArgs(NameColl, "Дабавление случайного элемента", p2)); } }
public void Add(int nom, Organization org, string Name, params Organization[] mas)//добавление введенного элемента в коллекцию { if (nom > Length) { Console.WriteLine("Номер элемента находится за перделами границ списка"); } else { NewDoublePointConnection <Organization> p1 = beg; NewDoublePointConnection <Organization> temp1 = new NewDoublePointConnection <Organization>(org); NewDoublePointConnection <Organization> vr1; NewDoublePointConnection <Organization> vr2; NewDoublePointConnection <Organization> p2 = beg; for (int i = 1; i < nom; i++) { p2 = p2.next; } vr2 = p2; for (int i = 1; i < nom - 1; i++) { p1 = p1.next; } vr1 = p1; p1.next = temp1; p1 = p1.next; p1.pred = vr1; p1.next = vr2; ChanAdd(nom, Name); OnCollectionCountChanged(this, new CollectionHandlerEventArgs(NameColl, "Дабавление", p2)); } }
public bool MoveNext() { if (current == null) { current = beg; } else { current = current.next; } return(current != null); }
public void FindInColl(T beg1, int employee) { NewDoublePointConnection <Organization> p = beg; while (p != null) { if (p.data.Number_of_employees == employee) { Console.WriteLine(p.ToString()); } } p = p.next; }
public void Delete(int nom, string Name) { if (nom > Length) { Console.WriteLine("Номер элемента находится за пределами границ списка"); } else { NewDoublePointConnection <Organization> dp1; NewDoublePointConnection <Organization> dp = beg; for (int t = 0; t < nom; t++) { dp = dp.next; } dp.next = dp.next.next; dp1 = dp; dp = dp.next.next; dp.pred = dp1; ChanDel(nom, Name); OnCollectionCountChanged(this, new CollectionHandlerEventArgs(NameColl, "Удаление", dp1)); } }
public NewDoubleListConnection(string Name, params Organization[] mas)//передаем элемененты коллекции и ее имя { name = Name; NewDoublePointConnection <Organization> r; beg = new NewDoublePointConnection <Organization>(mas[0]); NewDoublePointConnection <Organization> p = beg; for (int i = 1; i < mas.Length; i++) { NewDoublePointConnection <Organization> temp = new NewDoublePointConnection <Organization>(mas[i]); NewDoublePointConnection <Organization> vr = new NewDoublePointConnection <Organization>(mas[i - 1]); p.next = temp; p = temp; p.pred = vr; if (i == mas.Length - 1) { r = p; p.next = beg; p = beg; p.pred = r; } } }
public void Reset() { current = this.beg; }
public void DeleteCollection(T beg)//нужно передать корень коллекции { this.beg = null; }
public MyNumerator(NewDoubleListConnection <T> collection) { //beg = collection.beg; current = null; }
public NewDoublePointConnection(T data, NewDoublePointConnection <T> next, NewDoublePointConnection <T> pred) { this.data = data; this.next = next; this.pred = pred; }
public NewDoublePointConnection(T d) { next = null; data = d; pred = null; }
public NewDoublePointConnection() { data = default; next = null; pred = null; }