Exemplo n.º 1
0
 public IEnumerator <T> GetEnumerator()
 {
     _currentNode         = new LeafLinkedNode <T>(Factor);
     _currentNode.Next    = _root?.GetFirstLeaf();
     _currentNodePosition = 0;
     return(this);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Слияние двух узлов.
        /// </summary>
        /// <param name="sibling">Брат, с которым происходит слияние.</param>
        public override void Merge(LinkedNode <T> sibling)
        {
            LeafLinkedNode <T> node = (LeafLinkedNode <T>)sibling;

            Keys.AddRange(node.Keys);
            Next = node.Next;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Деление узла.
        /// </summary>
        /// <returns>Появившийся в результате деления узел.</returns>
        public override LinkedNode <T> Split()
        {
            int from  = Keys.Count / 2;
            int count = Keys.Count - from;
            LeafLinkedNode <T> sibling = new LeafLinkedNode <T>(Factor);

            sibling.Keys.AddRange(Keys.GetRange(from, count));
            Keys         = Keys.GetRange(0, from);
            sibling.Next = Next;
            Next         = sibling;
            return(sibling);
        }
Exemplo n.º 4
0
        bool IEnumerator.MoveNext()
        {
            if (_currentNodePosition >= _currentNode.Keys.Count - 1)
            {
                _currentNode         = _currentNode.Next;
                _currentNodePosition = 0;
            }
            else
            {
                _currentNodePosition++;
            }

            return(_currentNode != null);
        }
Exemplo n.º 5
0
 void IEnumerator.Reset()
 {
     _currentNode = _root?.GetFirstLeaf();
 }