public void CopyTo(BigListItem <V>[] array, int arrayIndex)
 {
     for (BigListItem <V> item = _bigList.FirstItem; item != null; item = item.Next)
     {
         array[arrayIndex++] = item;
     }
 }
Exemple #2
0
 public static void MakeNodeBlack <V>(this BigListItem <V> node)
 {
     if (node != null)
     {
         node.Color = RedBlackTreeNodeColor.Black;
     }
 }
Exemple #3
0
        /// <summary>
        /// The maximum subnode of the subtree rooted by this node.  O(lg n).
        /// This cannot be null.
        /// </summary>
        internal BigListItem <V> MaximumSubnode()
        {
            BigListItem <V> node = this;

            while (node.Right != null)
            {
                node = node.Right;
            }
            return(node);
        }
Exemple #4
0
        /// <summary>
        /// The minimum subnode of the subtree rooted by this node.  O(lg n).
        /// This cannot be null.
        /// </summary>
        internal BigListItem <V> MinimumSubnode()
        {
            BigListItem <V> node = this;

            while (node.Left != null)
            {
                node = node.Left;
            }
            return(node);
        }
Exemple #5
0
        public V First()
        {
            BigListItem <V> item = FirstItem;

            if (item == null)
            {
                throw new InvalidOperationException("BigList is empty.");
            }
            return(item.Value);
        }
 public bool MoveNext()
 {
     if (!_isStarted)
     {
         Current    = _bigList.FirstItem;
         _isStarted = true;
     }
     else
     {
         Current = _next;
     }
     _next = Current?.Next;
     return(Current != null);
 }
 public void Reset()
 {
     _isStarted = false;
     Current    = null;
 }
Exemple #8
0
 public static bool IsBlack <V>(this BigListItem <V> node)
 => node == null || node.Color == RedBlackTreeNodeColor.Black;
Exemple #9
0
 public static bool IsRed <V>(this BigListItem <V> node)
 => node != null && node.Color == RedBlackTreeNodeColor.Red;
 public bool Remove(BigListItem <V> item)
 => _bigList.DeleteItem(item);
 public bool Contains(BigListItem <V> item)
 => _bigList.ContainsItem(item);
 public void Add(BigListItem <V> item)
 => _bigList.Add(item.Value);
Exemple #13
0
        public V FirstOrDefault()
        {
            BigListItem <V> item = FirstItem;

            return(item != null ? item.Value : default);