Пример #1
0
 /*public void Sort() {
  *  for (LinkedListNode<Sweet> firstIter = this.Sweets.First; firstIter != null; firstIter = firstIter.Next)
  *  {
  *      for (LinkedListNode<Sweet> secondIter = firstIter; secondIter != null; secondIter = secondIter.Next)
  *      {
  *          if (firstIter.Value.CaloriesContent>secondIter.Value.CaloriesContent)
  *          {
  *              Sweet buf = firstIter.Value;
  *              firstIter.Value = secondIter.Value;
  *              secondIter.Value = buf;
  *          }
  *      }
  *  }
  * }*/
 public void SortComparator(Comparator comparator)
 {
     for (LinkedListNode <Sweet> firstIter = this.Sweets.First; firstIter != null; firstIter = firstIter.Next)
     {
         for (LinkedListNode <Sweet> secondIter = firstIter; secondIter != null; secondIter = secondIter.Next)
         {
             if (comparator(firstIter.Value, secondIter.Value))
             {
                 Sweet buf = firstIter.Value;
                 firstIter.Value  = secondIter.Value;
                 secondIter.Value = buf;
             }
         }
     }
 }
Пример #2
0
 public void removeSweet(Sweet a)
 {
     Sweets.Remove(a);
 }
Пример #3
0
 public void addSweet(Sweet a)
 {
     Sweets.AddLast(a);
 }