当前位置: 首页>>代码示例>>C++>>正文


C++ LinkList::InsertSort方法代码示例

本文整理汇总了C++中LinkList::InsertSort方法的典型用法代码示例。如果您正苦于以下问题:C++ LinkList::InsertSort方法的具体用法?C++ LinkList::InsertSort怎么用?C++ LinkList::InsertSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkList的用法示例。


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

示例1: main


//.........这里部分代码省略.........
    }

    idx = 7;
    val = ll.Get(idx);
    if (idx == ll.Locate(val))
    {
        cout << val << " is at " << idx << "." << endl;
    }

    idx = ll.Count();
    val = ll.Get(idx);
    if (idx == ll.Locate(val))
    {
        cout << val << " is at " << idx << "." << endl;
    }

    val = 9999999;
    if (-1 == ll.Locate(val))
    {
        cout << "Unable to locate " << val << "." << endl;
    }

    cout << "Inserting 3 at 3 ..." << endl;
    ll.Insert(3, 3);
    Display(ll);
    cout << "Deleting 3 ..." << endl;
    ll.Delete(3);
    Display(ll);

    cout << "Inserting 0 at 1 ..." << endl;
    ll.Insert(0, 1);
    Display(ll);
    cout << "Deleting 0 ..." << endl;
    ll.Delete(1);
    Display(ll);

    cout << "Inserting 11 at 12 ..." << endl;
    ll.Insert(11, 11);
    Display(ll);
    cout << "Deleting 11 ..." << endl;
    ll.Delete(11);
    Display(ll);
    try
    {
        cout << "call LinkList<int> lla = ll ..." << endl;
        LinkList<int> lla = ll;
        cout << "lla.length = " << lla.Count() << endl;

        cout << "call LinkList<int> llb(ll) ..." << endl;
        LinkList<int> llb(ll);
        cout << "llb.length = " << llb.Count() << endl;
        llb.Insert(77, 7);
        cout << "llb.length = " << llb.Count() << endl;

        cout << "call llb = lla ..." << endl;
        llb = lla;
        cout << "llb.length = " << llb.Count() << endl;
        cout << "lla.length = " << lla.Count() << endl;

        cout << "Splitting llb ..." << endl;
        llb.Insert(88, 8);
        cout << "llb.length = " << llb.Count() << endl;
        LinkList<int> llb2 = llb.Split();
        Display(llb);
        Display(llb2);

        cout << "Splitting ll ..." << endl;
        LinkList<int> llc = ll.Split();
        Display(ll);
        Display(llc);

        cout << "Sorting llc ..." << endl;
        llc.Insert(33, 6);
        llc.Insert(11, 1);
        llc.Insert(20, 2);
        llc.Insert(17, 3);
        llc.Insert(1, 6);
        Display(llc);
        llc.InsertSort();
        Display(llc);

        cout << "Intersecting on llb and llc ..." << endl;
        Display(llb);
        Display(llc);
        LinkList<int> lld = llb.Intersect(llc);
        Display(lld);

        cout << "Merging llc into ll ..." << endl;
        ll.Merge(llc);
        Display(ll);
        Display(llc);
    }
    catch (const char *&ex)
    {
        cout << "Error: " << ex << endl;
    }

    cout << "End." << endl;
    return 0;
}
开发者ID:fanjeffrey,项目名称:axiom.master,代码行数:101,代码来源:test_linklist.cpp


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