lib/linked/mutable.rb
def split_after_and_insert(head_a = chain_head)
      # If this is not the last item in the chain, sub chain
      # b will contain items. Use #split_before_and_insert
      # to cut the chain after this one. This will complete
      # chain b and update the item count of chain a.
      next!.split_before_and_insert unless chain_tail?

      chain_a_head = chain_head

      # If the head of sub chain a is same as the target
      # chain head
      return chain_a_head if chain_a_head.equal? head_a

      chain_a_length = chain_length

      # Set the head field of all items, starting with the
      # tail (self), moving backwards.
      item = self

      # Loop until we hit the first item.
      loop do
        item.chain_head = head_a
        item = item.prev
      end

      # Tell the target chain to grow with the number of
      # items in sub chain a.
      head_a.grow chain_a_length

      # Sub chain b is now either empty or complete. Sub
      # chain a however is only complete if the target
      # head is the same as the head of chain a. Otherwise
      # the prev field of head and the next field of tail
      # both need to be set correctly.
      chain_a_head
    end
def split_after_and_insert(head_a = chain_head)
      # If this is not the last item in the chain, sub chain
      # b will contain items. Use #split_before_and_insert
      # to cut the chain after this one. This will complete
      # chain b and update the item count of chain a.
      next!.split_before_and_insert unless chain_tail?

      chain_a_head = chain_head

      # If the head of sub chain a is same as the target
      # chain head
      return chain_a_head if chain_a_head.equal? head_a

      chain_a_length = chain_length

      # Set the head field of all items, starting with the
      # tail (self), moving backwards.
      item = self

      # Loop until we hit the first item.
      loop do
        item.chain_head = head_a
        item = item.prev
      end

      # Tell the target chain to grow with the number of
      # items in sub chain a.
      head_a.grow chain_a_length

      # Sub chain b is now either empty or complete. Sub
      # chain a however is only complete if the target
      # head is the same as the head of chain a. Otherwise
      # the prev field of head and the next field of tail
      # both need to be set correctly.
      chain_a_head
    end
def split_after_and_insert ( head_a = chain_head ) # If this is not the last item in the chain, sub chain # b will contain items. Use #split_before_and_insert # to cut the chain after this one. This will complete # chain b and update the item count of chain a. next! . split_before_and_insert unless chain_tail? chain_a_head = chain_head # If the head of sub chain a is same as the target # chain head return chain_a_head if chain_a_head . equal? head_a chain_a_length = chain_length # Set the head field of all items, starting with the # tail (self), moving backwards. item = self # Loop until we hit the first item. loop do item . chain_head = head_a item = item . prev end # Tell the target chain to grow with the number of # items in sub chain a. head_a . grow chain_a_length # Sub chain b is now either empty or complete. Sub # chain a however is only complete if the target # head is the same as the head of chain a. Otherwise # the prev field of head and the next field of tail # both need to be set correctly. chain_a_head end
rubocop:enable Metrics/AbcSize
 rubocop:enable Metrics/MethodLength
 rubocop:disable Metrics/MethodLength
 TODO
rubocop : enable Metrics / AbcSize rubocop : enable Metrics / MethodLength rubocop : disable Metrics / MethodLength TODO