请帮助我理解此代码段

问题描述 投票:-2回答:1
template<class Type>
void linkedQueueType<Type>:: mergeSort()
{
  mergeSort(queueFront);
  if (queueFront == NULL) 
    queueRear = NULL;
  else
  {
    queueRear = queueFront;
    while(queueRear->link != NULL)
      queueRear = queueRear->link;
  }
  return;
}

请说明此代码段,而不是了解这种合并方式。

c++ mergesort
1个回答
0
投票

看来此功能是主要的mergeStort入口点。它调用一个辅助函数(也称为mergeSort)进行实际的排序。但是看来辅助函数没有正确设置queueRear,因此在调用辅助函数后,该函数必须将queueRear设置为指向队列中的最后一个条目(如果队列为空,则为NULL) )。

© www.soinside.com 2019 - 2024. All rights reserved.