C++ STL容器操作:6種常用場景算法

C++ STL容器操作:6種常用場景算法

[TOC]

引言

? 在日常軟件開發(fā)工作中,容器操作如查找眠菇、排序袱衷、和元素替換等任務(wù)極為常見致燥。幸運(yùn)的是,C++的標(biāo)準(zhǔn)化利器——STL(Standard Template Library断傲,標(biāo)準(zhǔn)模板庫)為我們封裝了一系列高效且靈活的算法认罩,極大簡化了這些操作续捂。特別是自C++11版本以來牙瓢,STL引入了一批新晉的通用算法矾克,它們不僅功能強(qiáng)大,而且設(shè)計(jì)得更加人性化差购,旨在進(jìn)一步提升我們的編碼效率與程序性能欲逃。本文列舉一些常用到的方法稳析,便于日后回顧和查閱彰居。

概述

? 日常開發(fā)中的容器操作撰筷,如查找毕籽、刪除关筒、排序蒸播、分割萍肆、拷貝和合并塘揣,均可借助STL中的精選算法高效完成勿负。本文將概覽這些核心STL算法,助力開發(fā)流程優(yōu)化铁孵。

查找與計(jì)數(shù)

std::find

  • 作用: 找容器中第一個(gè)匹配給定值的元素
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    DumpVector("testArrgs", testArrgs);

    auto find = std::find(testArrgs.begin(), testArrgs.end(), "XiaoMing");
    if (find != testArrgs.end()) {
        SPR_LOGD("find: dest = \"XiaoMing\", result = %s, index = %ld\n", find->c_str(), find - testArrgs.begin());
    }
  • 結(jié)果
D: find: dest = "XiaoMing", result = XiaoMing, index = 2

std::find_if

  • 作用: 查找容器中第一個(gè)滿足謂詞條件的元素
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    auto findIf = std::find_if(testArrgs.begin(), testArrgs.end(),  [](const std::string &str) { return str.find("Ming") != std::string::npos; });
    if (findIf != testArrgs.end()) {
        SPR_LOGD("find_if: dest = \"Ming\", result = %s, index = %ld\n", findIf->c_str(), findIf - testArrgs.begin());
    }

③ 結(jié)果

D: find_if: dest = "Ming", result = XiaoMing, index = 2

std::find_if_not

  • 作用: 尋找第一個(gè)不符合指定條件的元素
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    auto findIfNot = std::find_if_not(testArrgs.begin(), testArrgs.end(),  [](const std::string &str) { return str.find("Xiao") != std::string::npos; });
    if (findIfNot != testArrgs.end()) {
        SPR_LOGD("find_if_not: dest = \"Xiao\", result = %s, index = %ld\n", findIfNot->c_str(), findIfNot - testArrgs.begin());
    }
  • 結(jié)果
D: find_if_not: dest = "Xiao", result = LiHua, index = 1

std::find_end

  • 作用: 查找一個(gè)子序列最后一次出現(xiàn)的位置
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    vector<std::string> subArrgs1 = {"XiaoMing", "XiaoHong"};
    auto findEnd = std::find_end(testArrgs.begin(), testArrgs.end(), subArrgs1.begin(), subArrgs1.end());
    if (findEnd != testArrgs.end()) {
        SPR_LOGD("find_end: dest = {\"XiaoMing\", \"XiaoHong\"}, result = %s, index = %ld\n", findEnd->c_str(), findEnd - testArrgs.begin());
    }
  • 結(jié)果
D: find_end: dest = {"XiaoMing", "XiaoHong"}, result = XiaoMing, index = 3

std::find_first_of

  • 作用: 查找序列中任何一個(gè)元素首次出現(xiàn)的位置
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    vector<std::string> subArrgs2 = {"JianGuo"};
    auto findFirstOf = std::find_first_of(testArrgs.begin(), testArrgs.end(), subArrgs2.begin(), subArrgs2.end());
    if (findFirstOf != testArrgs.end()) {
        SPR_LOGD("find_first_of: dest = {\"JianGuo\"}, result = %s, index = %ld\n", findFirstOf->c_str(), findFirstOf - testArrgs.begin());
    }
  • 結(jié)果
D: find_first_of: dest = {"JianGuo"}, result = JianGuo, index = 5

std::adjacent_find

  • 作用: 查找相鄰重復(fù)的元素
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    auto adjacentFind = std::adjacent_find(testArrgs.begin(), testArrgs.end(), [](const std::string &str1, const std::string &str2) { return str1 == str2; });
    if (adjacentFind != testArrgs.end()) {
        SPR_LOGD("adjacent_find: result = %s, index = %ld\n", adjacentFind->c_str(), adjacentFind - testArrgs.begin());
    }
  • 結(jié)果
D: adjacent_find: result = XiaoMing, index = 2

std::count

  • 作用: 計(jì)算容器中指定值出現(xiàn)的次數(shù)
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    auto cnt = std::count(testArrgs.begin(), testArrgs.end(), "XiaoFang");
    if (cnt > 0) {
        SPR_LOGD("count: dest = \"XiaoFang\", result = %ld\n", cnt);
    }
  • 結(jié)果
D: count: dest = "XiaoFang", result = 1

std::count_if

  • 作用: 計(jì)算滿足謂詞條件的元素?cái)?shù)量
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    auto cntIf = std::count_if(testArrgs.begin(), testArrgs.end(), [](const std::string &str) { return str.find("Xiao") != std::string::npos; });
    if (cntIf > 0) {
        SPR_LOGD("count_if: dest = \"Xiao\", result = %ld\n", cntIf);
    }
  • 結(jié)果
D: count_if: dest = "Xiao", result = 6

移除與替換

std::remove

  • 作用: 重新排列容器元素岖沛,使得所有不匹配特定值的元素被放置在容器的前端婴削。配合earse實(shí)現(xiàn)移除不匹配元素唉俗。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    vector<std::string> rmArrgs(testArrgs);
    auto remove = std::remove(rmArrgs.begin(), rmArrgs.end(), "XiaoMing");
    if (remove != rmArrgs.end()) {
        rmArrgs.erase(remove, rmArrgs.end());
        DumpVector("rmArrgs", rmArrgs);
    }
  • 結(jié)果
D: rmArrgs: "XiaoFang", "LiHua", "XiaoHong", "JianGuo", "XiaoFangFang",

std::remove_if

  • 作用: 重新排列容器元素虫溜,使得所有不滿足謂詞條件的元素被放置在容器的前端衡楞。配合earse實(shí)現(xiàn)移除不匹配元素敦姻。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> rmIfArrgs(testArrgs);
    auto removeIf = std::remove_if(rmIfArrgs.begin(), rmIfArrgs.end(), [](const std::string &str) { return str.find("Xiao") != std::string::npos; });
    if (removeIf != rmIfArrgs.end()) {
        rmIfArrgs.erase(removeIf, rmIfArrgs.end());
        DumpVector("rmArrgs", rmArrgs);
    }
  • 結(jié)果
D: rmIfArrgs: "XiaoFang", "LiHua", "XiaoHong", "JianGuo", "XiaoFangFang"

std::remove_copy

  • 作用: 從源序列拷貝元素到目標(biāo)序列寄雀,排除滿足條件的元素陨献。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> dstArrgs;
    vector<std::string> rcArrgs(testArrgs);
    std::remove_copy(rcArrgs.begin(), rcArrgs.end(), std::back_inserter(dstArrgs), "XiaoMing");
    DumpVector("dstArrgs", dstArrgs);
  • 結(jié)果
D: dstArrgs: "XiaoFang", "LiHua", "XiaoHong", "JianGuo", "XiaoFangFang"

std::replace

  • 作用: 將所有出現(xiàn)的指定元素替換為新值。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> rpArrgs(testArrgs);
    std::replace(rpArrgs.begin(), rpArrgs.end(), "XiaoMing", "MingMing");
    DumpVector("rpArrgs", rpArrgs);
  • 結(jié)果
D: rpArrgs: "XiaoFang", "LiHua", "MingMing", "MingMing", "XiaoHong", "JianGuo", "XiaoFangFang", "MingMing",

std::replace_if

  • 作用: 滿足謂詞條件的元素,替換為指定的替換值慷暂。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> rpIfArrgs(testArrgs);
    std::replace_if(rpIfArrgs.begin(), rpIfArrgs.end(), [](const std::string &str) { return (str == "XiaoFang"); }, "FangFang");
    DumpVector("rpIfArrgs", rpIfArrgs);
  • 結(jié)果
 D: rpIfArrgs: "FangFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing",

std::replace_copy

  • 作用:用于在指定范圍內(nèi)將所有匹配某個(gè)值的元素替換為另一個(gè)值行瑞,拷貝到另一個(gè)的容器中餐禁。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> rpCpDstArrgs;
    vector<std::string> rpCopyArrgs(testArrgs);
    std::replace_copy(rpCopyArrgs.begin(), rpCopyArrgs.end(), std::back_inserter(rpCpDstArrgs), "XiaoMing", "MingMing");
    DumpVector("rpCpDstArrgs", rpCpDstArrgs);
  • 結(jié)果
D: rpCpDstArrgs: "XiaoFang", "LiHua", "MingMing", "MingMing", "XiaoHong", "JianGuo", "XiaoFangFang", "MingMing"

std::swap

  • 作用:交換兩個(gè)變量的值氧吐。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};
    
    vector<std::string> swapSrcArrgs(testArrgs);
    vector<std::string> swapDstArrgs = {"Vince Carter", "Rose", "James"};
    std::swap(swapSrcArrgs, swapDstArrgs);
    DumpVector("swapSrcArrgs", swapSrcArrgs);
    DumpVector("swapDstArrgs", swapDstArrgs);
  • 結(jié)果
  D: swapSrcArrgs: "Vince Carter", "Rose", "James", 
  D: swapDstArrgs: "XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing", 

排序與組織

std::sort

  • 作用:對容器元素進(jìn)行排序筑舅。
  • 示例
    vector<std::string> testArrgs = {"XiaoFang", "LiHua", "XiaoMing", "XiaoMing", "XiaoHong", "JianGuo", "XiaoFangFang", "XiaoMing"};

    // sort
    vector<std::string> sortArrgs(testArrgs);
    std::sort(sortArrgs.begin(), sortArrgs.end());
    DumpVector("sortArrgs", sortArrgs);
    std::sort(sortArrgs.begin(), sortArrgs.end(), [](const std::string &str1, const std::string &str2) { return str1.size() > str2.size(); });
    DumpVector("sortArrgs", sortArrgs);

  • 結(jié)果
  D: sortArrgs: "JianGuo", "LiHua", "XiaoFang", "XiaoFangFang", "XiaoHong", "XiaoMing", "XiaoMing", "XiaoMing", 
  D: sortArrgs: "XiaoFangFang", "XiaoFang", "XiaoHong", "XiaoMing", "XiaoMing", "XiaoMing", "JianGuo", "LiHua", 

std::stable_sort

  • 作用:穩(wěn)定排序翠拣,保持相等元素的原有順序心剥。
  • 示例
    // stable_sort
    vector<Persion> srcPersions = {{"LiWei", 18}, {"LiHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhenHua", 20}, {"JianGuo", 18}, {"ZhiGuo", 19}, {"JianHua", 19}};
    vector<Persion> sPersions(srcPersions);
    std::stable_sort(sPersions.begin(), sPersions.end(), [](const Persion &p1, const Persion &p2) { return p1.age > p2.age; });
    DumpVector("sPersions", sPersions);
    std::stable_sort(sPersions.begin(), sPersions.end(), [](const Persion &p1, const Persion &p2) { return p1.age < p2.age; });
    DumpVector("sPersions", sPersions);
  • 結(jié)果
  D: sPersions = { {"LiHua", 20}, {"ZhenHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhiGuo", 19}, {"JianHua", 19}, {"LiWei", 18}, {"JianGuo", 18}, }
  D: sPersions = { {"LiWei", 18}, {"JianGuo", 18}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhiGuo", 19}, {"JianHua", 19}, {"LiHua", 20}, {"ZhenHua", 20}, }

std::partial_sort

  • 作用:對部分區(qū)間排序优烧。
  • 示例
    vector<Persion> srcPersions = {{"LiWei", 18}, {"LiHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhenHua", 20}, {"JianGuo", 18}, {"ZhiGuo", 19}, {"JianHua", 19}};

    // partial_sort
    vector<Persion> prtPersions(srcPersions);
    vector<Persion> sortPersions(srcPersions);
    std::partial_sort(prtPersions.begin(), prtPersions.begin() + 5, prtPersions.end(), [](const Persion &p1, const Persion &p2) { return p1.age > p2.age; });
    std::sort(sortPersions.begin(), sortPersions.begin() + 5, [](const Persion &p1, const Persion &p2) { return p1.age > p2.age; });
    DumpVector("prtPersions", prtPersions);
    DumpVector("sortPersions", sortPersions);
  • 結(jié)果
  D: prtPersions = { {"ZhenHua", 20}, {"LiHua", 20}, {"WeiGuo", 19}, {"ZhiGuo", 19}, {"ZhangLei", 19}, {"JianGuo", 18}, {"LiWei", 18}, {"JianHua", 19}, }
  D: sortPersions = { {"LiHua", 20}, {"ZhenHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"LiWei", 18}, {"JianGuo", 18}, {"ZhiGuo", 19}, {"JianHua", 19}, }

std::reverse

  • 作用:對部分區(qū)間排序。
  • 示例
    vector<Persion> srcPersions = {{"LiWei", 18}, {"LiHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhenHua", 20}, {"JianGuo", 18}, {"ZhiGuo", 19}, {"JianHua", 19}};

    // reverse
    vector<Persion> rPersions(srcPersions);
    std::reverse(rPersions.begin(), rPersions.end());
    DumpVector("rPersions", rPersions);
  • 結(jié)果
  D: rPersions = { {"JianHua", 19}, {"ZhiGuo", 19}, {"JianGuo", 18}, {"ZhenHua", 20}, {"WeiGuo", 19}, {"ZhangLei", 19}, {"LiHua", 20}, {"LiWei", 18}, }

std::rotate

  • 作用:對部分區(qū)間排序熙卡。
  • 示例
    vector<Persion> srcPersions = {{"LiWei", 18}, {"LiHua", 20}, {"ZhangLei", 19}, {"WeiGuo", 19}, {"ZhenHua", 20}, {"JianGuo", 18}, {"ZhiGuo", 19}, {"JianHua", 19}};

    // rotate
    vector<Persion> rtPersions(srcPersions);
    std::rotate(rtPersions.begin(), rtPersions.begin() + 3, rtPersions.end());
    DumpVector("rtPersions", rtPersions);
  • 結(jié)果
  D: rPersions = { {"JianHua", 19}, {"ZhiGuo", 19}, {"JianGuo", 18}, {"ZhenHua", 20}, {"WeiGuo", 19}, {"ZhangLei", 19}, {"LiHua", 20}, {"LiWei", 18}, }

分割

std::partition

  • 作用:分割容器驳癌,使?jié)M足謂詞的元素在前颓鲜,不滿足的在后甜滨。
  • 示例
    vector<std::string> testArrgs = {"LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua"};

    // partition
    vector<std::string> partArrgs(testArrgs);
    std::partition(partArrgs.begin(), partArrgs.end(), [](const std::string& str) { return (str.compare(0, 5, "Zhang") == 0); });
    DumpVector("partArrgs", partArrgs);
  • 結(jié)果
  D: partArrgs: "ZhangLei", "ZhangHong", "HeDa", "LiWei", "LiHua", "WeiGuo", "ZhenHua",

std::stable_partition

  • 作用:類似partition衣摩,但保持相同元素的相對順序不變艾扮。
  • 示例
    vector<std::string> testArrgs = {"LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua"};

    // stable_partition
    vector<std::string> stPartArrgs(testArrgs);
    std::stable_partition(stPartArrgs.begin(), stPartArrgs.end(), [](const std::string& str) { return (str.compare(0, 5, "Zhang") == 0); });
    DumpVector("stPartArrgs", stPartArrgs);
  • 結(jié)果
  D: stPartArrgs: "ZhangHong", "ZhangLei", "LiHua", "HeDa", "LiWei", "WeiGuo", "ZhenHua", 

拷貝與生成

std::copy

  • 作用:拷貝容器或范圍內(nèi)的元素到另一位置栏渺。
  • 示例
    vector<std::string> srcArrgs = {"LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua"};

    // copy
    vector<std::string> dstCopyArrgs;
    std::copy(srcArrgs.begin(), srcArrgs.end(), std::back_inserter(dstCopyArrgs));
    DumpVector("dstCopyArrgs", dstCopyArrgs);
  • 結(jié)果
  D: dstCopyArrgs: "LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua",

std::copy_if

  • 作用:根據(jù)謂詞條件拷貝元素磕诊。
  • 示例
    vector<std::string> srcArrgs = {"LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua"};

    // copy_if
    vector<std::string> dstCopyIfArrgs;
    std::copy_if(srcArrgs.begin(), srcArrgs.end(), std::back_inserter(dstCopyIfArrgs), [](const std::string& str) { return (str.compare(0, 5, "Zhang") == 0); });
    DumpVector("dstCopyIfArrgs", dstCopyIfArrgs);
  • 結(jié)果
  D: dstCopyIfArrgs: "ZhangHong", "ZhangLei", 

std::copy_n

  • 作用:拷貝指定數(shù)量的元素霎终。
  • 示例
    vector<std::string> srcArrgs = {"LiHua", "ZhangHong", "HeDa", "LiWei", "ZhangLei", "WeiGuo", "ZhenHua"};

    // copy_n
    vector<std::string> dstCopyNArrgs;
    std::copy_n(srcArrgs.begin(), 3, std::back_inserter(dstCopyNArrgs));
    DumpVector("dstCopyNArrgs", dstCopyNArrgs);
  • 結(jié)果
  D: dstCopyNArrgs: "LiHua", "ZhangHong", "HeDa",

std::generate

  • 作用:使用生成器函數(shù)填充容器莱褒。
  • 示例
    // generate
    vector<std::string> genArrgs(5);
    std::generate(genArrgs.begin(), genArrgs.end(), [](){ return "Hello"; });
    DumpVector("genArrgs", genArrgs);
  • 結(jié)果
  D: genArrgs: "Hello", "Hello", "Hello", "Hello", "Hello", 

std::generate_n

  • 作用:生成指定數(shù)量的元素填充容器广凸。
  • 示例
    // generate_n
    vector<std::string> genNArrgs;
    std::generate_n(std::back_inserter(genNArrgs), 3, [](){ return "Hello"; });
    DumpVector("genNArrgs", genNArrgs);
  • 結(jié)果
  D: genNArrgs: "Hello", "Hello", "Hello", 

集合操作

std::merge

  • 作用:生成指定數(shù)量的元素填充容器谅海。
  • 示例
    vector<std::string> srcArrgs = {"Vince Carter", "Rose", "James"};

    // merge
    vector<std::string> mergeArrgs;
    vector<std::string> tmpArrgs = {"Irving"};
    std::merge(srcArrgs.begin(), srcArrgs.end(), tmpArrgs.begin(), tmpArrgs.end(), std::back_inserter(mergeArrgs));
    DumpVector("mergeArrgs", mergeArrgs);
  • 結(jié)果
  D: mergeArrgs: "Irving", "Vince Carter", "Rose", "James", 

std::inplace_merge

  • 作用:就地歸并兩個(gè)有序范圍扭吁。
  • 示例
    vector<std::string> srcArrgs = {"Vince Carter", "Rose", "James"};

    // inplace_merge
    vector<std::string> inplaceMergeArrgs(srcArrgs);
    std::inplace_merge(inplaceMergeArrgs.begin(), inplaceMergeArrgs.begin() + 2, inplaceMergeArrgs.end());
    DumpVector("inplaceMergeArrgs", inplaceMergeArrgs);
  • 結(jié)果
  D: inplaceMergeArrgs: "James", "Vince Carter", "Rose",
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末侥袜,一起剝皮案震驚了整個(gè)濱河市枫吧,隨后出現(xiàn)的幾起案子九杂,更是在濱河造成了極大的恐慌,老刑警劉巖爷狈,帶你破解...
    沈念sama閱讀 206,214評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件涎永,死亡現(xiàn)場離奇詭異羡微,居然都是意外死亡惶我,警方通過查閱死者的電腦和手機(jī)绸贡,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,307評論 2 382
  • 文/潘曉璐 我一進(jìn)店門听怕,熙熙樓的掌柜王于貴愁眉苦臉地迎上來尿瞭,“玉大人声搁,你說我怎么就攤上這事『芑辏” “怎么了莫换?”我有些...
    開封第一講書人閱讀 152,543評論 0 341
  • 文/不壞的土叔 我叫張陵骤铃,是天一觀的道長拉岁。 經(jīng)常有香客問我,道長惰爬,這世上最難降的妖魔是什么喊暖? 我笑而不...
    開封第一講書人閱讀 55,221評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮撕瞧,結(jié)果婚禮上陵叽,老公的妹妹穿的比我還像新娘狞尔。我一直安慰自己,他們只是感情好巩掺,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,224評論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著胖替,像睡著了一般研儒。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上独令,一...
    開封第一講書人閱讀 49,007評論 1 284
  • 那天端朵,我揣著相機(jī)與錄音,去河邊找鬼燃箭。 笑死冲呢,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的招狸。 我是一名探鬼主播敬拓,決...
    沈念sama閱讀 38,313評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼瓢颅!你這毒婦竟也來了恩尾?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,956評論 0 259
  • 序言:老撾萬榮一對情侶失蹤挽懦,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后木人,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體信柿,經(jīng)...
    沈念sama閱讀 43,441評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,925評論 2 323
  • 正文 我和宋清朗相戀三年醒第,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了渔嚷。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,018評論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡稠曼,死狀恐怖形病,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情霞幅,我是刑警寧澤漠吻,帶...
    沈念sama閱讀 33,685評論 4 322
  • 正文 年R本政府宣布,位于F島的核電站司恳,受9級特大地震影響途乃,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜扔傅,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,234評論 3 307
  • 文/蒙蒙 一耍共、第九天 我趴在偏房一處隱蔽的房頂上張望烫饼。 院中可真熱鬧,春花似錦试读、人聲如沸杠纵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,240評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽比藻。三九已至,卻和暖如春伊履,著一層夾襖步出監(jiān)牢的瞬間韩容,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,464評論 1 261
  • 我被黑心中介騙來泰國打工唐瀑, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留群凶,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,467評論 2 352
  • 正文 我出身青樓哄辣,卻偏偏與公主長得像请梢,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子力穗,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,762評論 2 345

推薦閱讀更多精彩內(nèi)容

  • 原文 STL算法是一組神奇的工具毅弧,可以提高代碼的表達(dá)性和正確性。 這篇文章解釋了如何使用STL算法当窗,以及它們能給你...
    sunix閱讀 1,110評論 0 0
  • 容器 在實(shí)際的開發(fā)過程中, 數(shù)據(jù)結(jié)構(gòu)本身的重要性不會(huì)遜于操作于數(shù)據(jù)結(jié)構(gòu)的算法的重要性巫员, 當(dāng)程序中存在著對時(shí)間要求很...
    編程小兔崽閱讀 1,071評論 0 1
  • (2020.12.08 Tues)STL容器允許重復(fù)利用已有的實(shí)現(xiàn)構(gòu)造自己特定類型下的數(shù)據(jù)結(jié)構(gòu)庶香,通過設(shè)置一些模板類...
    Mc杰夫閱讀 285評論 0 0
  • 一. 順序容器: 按順序存儲(chǔ)數(shù)據(jù); 插入速度快简识,查找相對較慢赶掖。 vector 在最后插入數(shù)據(jù);STLvector類...
    BookThief閱讀 1,975評論 0 4
  • 原文 正如在一篇專門的帖子中看到的,C++標(biāo)準(zhǔn)模板庫(STL)是一個(gè)神奇的工具七扰,它使代碼更加正確和富有表現(xiàn)力奢赂。主要...
    sunix閱讀 1,937評論 0 0