• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ sortList函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sortList函数的典型用法代码示例。如果您正苦于以下问题:C++ sortList函数的具体用法?C++ sortList怎么用?C++ sortList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sortList函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: h1

 ListNode *sortList(ListNode *head) {
     if (head == NULL) return NULL;
     int val = head->val;
     ListNode h1(0), h2(0), h3(0), *t1 = &h1, *t2 = &h2, *t3 = &h3;
     for (auto p = head; p; p = p->next){
         if (p->val == val){
             t2 = t2->next = p;
         }else if (p->val < val){
             t1 = t1->next = p;
         }else{
             t3 = t3->next = p;
         }
     }
     t1->next = t2->next = t3->next = NULL;
     h1.next = sortList(h1.next);
     for (t1 = &h1; t1->next; t1 = t1->next);
     t1->next = h2.next;
     t2->next = sortList(h3.next);
     return h1.next;
 }
开发者ID:Anchor89,项目名称:leetcode-2,代码行数:20,代码来源:Sort+List.cpp


示例2: while

ListNode* Solution148::sortList(ListNode *head)
{
    if(head == NULL)
        return NULL;
    if(head->next == NULL)
        return head;
    ListNode* fast = head->next;
    ListNode* slow = head;
    while(fast != NULL && fast->next != NULL)
    {
        fast = fast->next->next;
        slow = slow->next;
    }
    fast = slow->next;
    slow->next = NULL;
    slow = fast;
    ListNode* l = sortList(head);
    ListNode* r = sortList(slow);
    return merge(l,r);
}
开发者ID:zhangxiaoya,项目名称:LeetCodeCPP,代码行数:20,代码来源:solution148.cpp


示例3: while

    ListNode *sortList(ListNode *head) {
        if(!head || head->next==NULL) return head;

        ListNode* pA = head, *pB = head;

        while( pA && pB && pB->next && pB->next->next )
        {
            pA = pA->next;
            pB = pB->next->next;
        }        
        pB= pA->next;
        pA->next = NULL;
        pA = head;


        pA = sortList(pA);
        pB = sortList(pB);       
        return MergeSortedList(pA, pB);

    }
开发者ID:668,项目名称:LeetCode,代码行数:20,代码来源:SortList.cpp


示例4: redrawButtons

    void MultiListBox::sortByColumn(size_t _column, bool _backward)
    {
        mSortColumnIndex = _column;
        if (_backward)
        {
            mSortUp = !mSortUp;
            redrawButtons();
            // если было недосортированно то сортируем
            if (mFrameAdvise)
                sortList();

            flipList();
        }
        else
        {
            mSortUp = true;
            redrawButtons();
            sortList();
        }
    }
开发者ID:redkaras,项目名称:Demi3D,代码行数:20,代码来源:MyGUI_MultiListBox.cpp


示例5: sortList

    ListNode* sortList(ListNode* head) {
        if (head == NULL || head->next == NULL) {
            return head;
        }
        ListNode *slow = head;
        ListNode *fast = head;

        //Get the middle index of list
        while (fast->next && fast->next->next) {
            slow  = slow->next;
            fast = fast->next->next;
        }
        fast = slow->next;
        slow->next = NULL;

        ListNode *p1 = sortList(head);
        ListNode *p2 = sortList(fast);

        return merge(p1, p2);
    }
开发者ID:byhj,项目名称:OJ-LeetCode,代码行数:20,代码来源:148.+Sort+List.cpp


示例6: sortList

 ListNode * sortList(ListNode * head)
 {
     int iNodeCount = 0;
     
     for (ListNode * pstCount = head; pstCount != NULL; pstCount = pstCount -> next)
     {
         iNodeCount ++;
     }
     
     return sortList(head, iNodeCount);
 }
开发者ID:earnestzhao,项目名称:LeetCode,代码行数:11,代码来源:LeetCode_148_MergeSort.cpp


示例7: executeChoice

void executeChoice(int choice, Node ** head)
{

    char * fn = NULL;
    char * fName = NULL;
    char * lName = NULL;
    char * position = NULL;

    switch(choice)
    {
    case 1:
        printList(*head);
        break;
    case 2:
        fn = getFileName();
        FILE* fout = openKnownFile(fn,"w");
        printListToFile(*head,fout);
        fclose(fout);
        break;
    case 3:
        getPositionUser(&position);
        printSpecificPlayers(*head, position);
        free(position);
        break;
    case 4:
        *head = sortList(*head, 1);
        break;
    case 5:
        *head = sortList(*head, 2);
        break;
    case 6:
        getPlayerName(&fName,&lName);
        removeNode(head,fName,lName);
        free(fName);
        free(lName);
        break;
    default:
        printf("Sorry incorrect input");
    }

}
开发者ID:kepler27,项目名称:HW1,代码行数:41,代码来源:hw1.c


示例8: sortList

    ListNode* sortList(ListNode* head) {
        if(!head || !(head->next)) return head;
        
        ListNode *fast = head;
        ListNode *slow = head;
        ListNode *pre = NULL;
        while(fast && fast->next)
        {
            fast = fast->next->next;
            pre = slow;
            slow = slow->next;
        }
        

        pre->next = NULL;
        
        head = sortList(head);
        slow = sortList(slow);
        
        return mergeTwoLists(head,slow);
    }
开发者ID:FeibHwang,项目名称:OJ-Leetcode,代码行数:21,代码来源:148_Sort_List.cpp


示例9: sortList

    ListNode* sortList(ListNode* head) {
        if (!head || !head->next)
            return head;

        // Find the middle
        ListNode *slow = head, *fast = head;
        while (fast->next && fast->next->next)
        {
            fast = fast->next->next;
            slow = slow->next;
        }

        // Cut at middle
        ListNode *p = slow;
        slow = slow->next;
        p->next = NULL;

        ListNode *l1 = sortList(head);
        ListNode *l2 = sortList(slow);
        return mergeTwoLists(l1, l2);
    }
开发者ID:insaneyilin,项目名称:leetcode,代码行数:21,代码来源:sort_list.hpp


示例10: sortList

/************************************************************************
    Set sort mode
************************************************************************/
void ItemListBase::setSortMode(SortMode mode)
{
    if (d_sortMode != mode)
    {
        d_sortMode = mode;
        if (d_sortEnabled && !d_initialising)
            sortList();

        WindowEventArgs e(this);
        onSortModeChanged(e);
    }
}
开发者ID:Ocerus,项目名称:Ocerus,代码行数:15,代码来源:CEGUIItemListBase.cpp


示例11: request

/*
    Start the request (and complete it)
 */
static void startDir(HttpQueue *q)
{
    HttpConn        *conn;
    HttpTx          *tx;
    HttpRx          *rx;
    MprList         *list;
    MprDirEntry     *dp;
    Dir             *dir;
    cchar           *path;
    uint            nameSize;
    int             next;

    conn = q->conn;
    rx = conn->rx;
    tx = conn->tx;
    dir = conn->data;
    assert(tx->filename);

    if (!(rx->flags & (HTTP_GET | HTTP_HEAD))) {
        httpError(conn, HTTP_CODE_BAD_METHOD, "Bad method");
        return;
    }
    httpSetHeaderString(conn, "Cache-Control", "no-cache");
    httpSetHeaderString(conn, "Last-Modified", conn->http->currentDate);
    httpSetHeaderString(conn, "Content-Type", "text/html");
    parseQuery(conn);

    if ((list = mprGetPathFiles(tx->filename, MPR_PATH_RELATIVE)) == 0) {
        httpWrite(q, "<h2>Cannot get file list</h2>\r\n");
        outputFooter(q);
        return;
    }
    if (dir->pattern) {
        filterDirList(conn, list);
    }
    sortList(conn, list);
    /*
        Get max filename size
     */
    nameSize = 0;
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        nameSize = max((int) strlen(dp->name), nameSize);
    }
    nameSize = max(nameSize, 22);

    path = rx->route->prefix ? sjoin(rx->route->prefix, rx->pathInfo, NULL) : rx->pathInfo;
    outputHeader(q, path, nameSize);
    for (next = 0; (dp = mprGetNextItem(list, &next)) != 0; ) {
        outputLine(q, dp, tx->filename, nameSize);
    }
    outputFooter(q);
    httpFinalize(conn);
}
开发者ID:yodamaster,项目名称:appweb,代码行数:56,代码来源:dirHandler.c


示例12: while

	ListNode *sortList(ListNode *head){
		if (head==NULL||head->next==NULL){
			return head;
		}
		ListNode *slow=head,*fast=head;
		//假定head存放数据

		while (fast->next!=NULL&&fast->next->next!=NULL){
			fast=fast->next->next;
			slow=slow->next;
		}

		ListNode *head1=slow->next;
		ListNode *head2=head;
		slow->next=NULL;//slow指向null

		head1=sortList(head1);
		head2=sortList(head2);

		return merge(head1,head2);
	}
开发者ID:JSRGFJZ,项目名称:LeetCode,代码行数:21,代码来源:Sort+List.cpp


示例13: sortList

void RobotDecoder::DelayTime::endTiming() {
	const int timeDelta = _decoder->getTickCount() - _startTime;
	for (uint i = 0; i < kDelayListSize; ++i) {
		if (_timestamps[i] == _oldestTimestamp) {
			_timestamps[i] = ++_newestTimestamp;
			_delays[i] = timeDelta;
			break;
		}
	}
	++_newestTimestamp;
	_startTime = 0;
	sortList();
}
开发者ID:DrItanium,项目名称:scummvm,代码行数:13,代码来源:robot_decoder.cpp


示例14: findSingleOccurenceNumber

int findSingleOccurenceNumber(int *A, int len) 
{
	int index;
	if (A == NULL)
		return -1;
	sortList(A, 0, len - 1);
	for (index = 0; index < len; index += 3)
	{
		if (A[index] != A[index + 2])
			return A[index];
	}

}
开发者ID:chirag0103,项目名称:MissionRnD-C-Arrays2-Worksheet,代码行数:13,代码来源:findSingleOccurenceNumber.cpp


示例15: sortList

 ListNode* sortList(ListNode* head)
 {
     int n = getLength(head);
     if (n == 0 || n == 1)
     {
         return head;
     }
     n /= 2;
     ListNode* pl = head;
     ListNode* pr = head;
     while (n)
     {
         --n;
         pl = pr;
         pr = pr->next;
     }
     pl->next = NULL;
     pl = sortList(head);
     pr = sortList(pr);
     head = mergeList(pl, pr);
     return head;
 }
开发者ID:CWang24,项目名称:LeetCode,代码行数:22,代码来源:sortList.cpp


示例16: getCandidateMoves

/*Not implemented - Return possible Moves for Color sorted according to heuristic value*/
ListNode *getCandidateMovesOrd(Game *game, Color col){
	ListNode *tmp = getCandidateMoves(game, col);
	return tmp;
	ListNode *head = tmp;
	while (head != NULL){
		if (head->move == NULL)break;
		if (isEmpty(game->board[head->move->dest->column][head->move->dest->row])) head->value = -1000;
		else head->value = scoreChar(game->board[head->move->dest->column][head->move->dest->row], oppositeCol(col)) - scoreChar(game->board[head->move->source->column][head->move->source->row], col);
		head = head->next;
	}
	tmp = sortList(tmp);
	return tmp;
}
开发者ID:orrshilon,项目名称:chessprog,代码行数:14,代码来源:Logic.c


示例17: TestsortList1

int TestsortList1(){
  START_TEST_CASE;

  DocumentNode *d;
  d = NULL;
  d = sortList(d);
  
  SHOULD_BE( d == NULL );
  
  freeDocNodeList(d);
  
  END_TEST_CASE;
}
开发者ID:ChrisHoder,项目名称:Projects,代码行数:13,代码来源:query_test.c


示例18: sortList

	void Armature::updateSlotsZOrder(){
		std::vector<Slot*> sortList(_slotList.size());
		for(Slot* slot : _slotList)
		{
			sortList[(int)slot->getZOrder()] = slot;
			if(slot->_isDisplayOnStage)
			{
				slot->_displayBridge->addDisplay(_display);
			}
		}
			
		_slotsZOrderChanged = false;
	}
开发者ID:KingNormac,项目名称:CPlusPlus-Opengl-Dragonbones,代码行数:13,代码来源:Armature.cpp


示例19: if

 ListNode *sortList(ListNode *head){
     if (head == NULL)
         return head;
     else if (head->next == NULL) 
         return head;
     
     ListNode *slow = head, *fast = head;
     while (fast->next != NULL && fast->next->next != NULL)
     {
         slow = slow->next;
         fast = fast->next->next;
     }
     fast = slow;
     slow = slow->next;
     fast->next = NULL;
     
     fast = sortList(head);
     slow = sortList(slow);
     
     return mergeList(fast,slow);
     
 }
开发者ID:vinctzh,项目名称:leetcode_problems,代码行数:22,代码来源:sortList.hpp


示例20: while

    ListNode *sortList(ListNode *head) {
        // IMPORTANT: Please reset any member data you declared, as
        // the same Solution instance will be reused for each test case.
		
		if(!head || !head->next)
			return head;
		ListNode* slow, *fast;
		slow = head;
		fast = slow->next;
		while(fast){
			if(!fast->next || !fast->next->next)
				break;
			slow = slow->next;
			fast = fast->next->next;
		}

		fast = slow->next;
		slow->next = NULL;
		head = sortList(head);
		fast = sortList(fast);
		return merge(head, fast);
    }
开发者ID:elsucai,项目名称:LC,代码行数:22,代码来源:sort-list.cpp



注:本文中的sortList函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sorted函数代码示例发布时间:2022-05-30
下一篇:
C++ sortAllChildren函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap