• 容器 list


     (1) 插入操作,不能使用MyTestContain.begin()+3 之类?!(要对数据进行复制)

         list<int>::iterator pr=MyTestContain.begin();
         pr++;
         pr++;
         MyTestContain.insert(pr,more,more+3);//插入操作,必须加在队尾?!
         OutPut();

    (2)移除操作,只能移除元素
         MyTestContain.remove(2);//是移除所有的2?

    (3)拼接操作(只改变.next指针,不对数据进行复制,也可以实现任意位置的插入,推荐使用)

        list<int> one(5,2);

        MyTestContain.splice(MyTestContain.begin(),one);//是移除所有的2?

    list的操作都在指针的前面位置,例如指针 *pr=a 则插入数据在a的前面。

     (4) 去重操作

      MyTestContain.unique();

      但是只能去除连续的重复。

    (5) 合并操作

    MyTestContain.merge(MyTestContain2);

    很奇怪,要看MyTestContain的最后一个元素和MyTestContain2的第一个元素,没什么规律?

  • 相关阅读:
    CF763C Timofey and Remoduling
    CF762E Radio Stations
    CF762D Maximum Path
    CF763B Timofey and Rectangles
    URAL1696 Salary for Robots
    uva10884 Persephone
    LA4273 Post Offices
    SCU3037 Painting the Balls
    poj3375 Network Connection
    Golang zip压缩文件读写操作
  • 原文地址:https://www.cnblogs.com/gaoxianzhi/p/3241981.html
Copyright © 2020-2023  润新知