Ejemplo n.º 1
0
        /// <summary>
        /// Inserts the specified bucket as the new head in the list.
        /// </summary>
        /// <param name="toInsert">To insert.</param>
        public void InsertHead(ListBucket <T> toInsert)
        {
            if (toInsert == null)
            {
                return;
            }

            if (_tail == null)
            {
                _tail = toInsert;
            }
            else
            {
                _head.InsertBefore(toInsert);
            }
            _head = toInsert;
            _count++;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Inserts the specified node toInsert before the node toInsertBefore.
 /// </summary>
 /// <param name="toInsert">To insert into the list.</param>
 /// <param name="toInsertBefore">the node to insert before. Has to be in the list</param>
 public void InsertBefore(ListBucket <T> toInsert, ListBucket <T> toInsertBefore)
 {
     if (toInsert == null)
     {
         return;
     }
     if (toInsertBefore == null)
     {
         if (_count > 0)
         {
             throw new ArgumentException("toInsertBefore can't be null when this LinkedBucketList has 1 or more elements");
         }
         InsertHead(toInsert);
     }
     else
     {
         toInsertBefore.InsertBefore(toInsert);
         _count++;
         if (toInsertBefore == _head)
         {
             _head = toInsert;
         }
     }
 }