Ejemplo n.º 1
0
 public void InsertPolymerAtBack(Polymer polymerData)
 {
     PolymerCount++;
     if (IsEmpty())
     {
         FirstPolymer = LastPolymer = polymerData;
     }
     else
     {
         LastPolymer.Next     = polymerData;
         polymerData.Previous = LastPolymer;
         LastPolymer          = polymerData;
     }
 }
Ejemplo n.º 2
0
 public void InsertPolymerAtFront(Polymer polymerData)
 {
     PolymerCount++;
     if (IsEmpty())
     {
         FirstPolymer = LastPolymer = polymerData;
     }
     else
     {
         FirstPolymer.Previous = polymerData;
         polymerData.Next      = FirstPolymer;
         FirstPolymer          = polymerData;
     }
 }
Ejemplo n.º 3
0
 public void InsertPolymerAtBack(char polymerData)
 {
     PolymerCount++;
     if (IsEmpty())
     {
         FirstPolymer = LastPolymer = new Polymer(polymerData);
     }
     else
     {
         var newPoly = new Polymer(polymerData);
         LastPolymer.Next = newPoly;
         newPoly.Previous = LastPolymer;
         LastPolymer      = newPoly;
     }
 }
Ejemplo n.º 4
0
        public bool Delete(Polymer polymer)
        {
            if (IsEmpty())
            {
                Console.WriteLine("Empty chain", Color.Red);
                return(false);
            }

            if (polymer == FirstPolymer)
            {
                FirstPolymer = polymer.Next;
            }
            if (polymer == LastPolymer)
            {
                LastPolymer = polymer.Previous;
            }
            polymer.Destroy();
            PolymerCount--;
            return(true);
        }