• <small id='tv8ha'></small><noframes id='tv8ha'>

      <bdo id='tv8ha'></bdo><ul id='tv8ha'></ul>
    1. <tfoot id='tv8ha'></tfoot>
      <legend id='tv8ha'><style id='tv8ha'><dir id='tv8ha'><q id='tv8ha'></q></dir></style></legend>
      <i id='tv8ha'><tr id='tv8ha'><dt id='tv8ha'><q id='tv8ha'><span id='tv8ha'><b id='tv8ha'><form id='tv8ha'><ins id='tv8ha'></ins><ul id='tv8ha'></ul><sub id='tv8ha'></sub></form><legend id='tv8ha'></legend><bdo id='tv8ha'><pre id='tv8ha'><center id='tv8ha'></center></pre></bdo></b><th id='tv8ha'></th></span></q></dt></tr></i><div id='tv8ha'><tfoot id='tv8ha'></tfoot><dl id='tv8ha'><fieldset id='tv8ha'></fieldset></dl></div>

      1. 如何对 STL 向量进行排序?

        How to sort an STL vector?(如何对 STL 向量进行排序?)
          <legend id='f1FHe'><style id='f1FHe'><dir id='f1FHe'><q id='f1FHe'></q></dir></style></legend>

        1. <i id='f1FHe'><tr id='f1FHe'><dt id='f1FHe'><q id='f1FHe'><span id='f1FHe'><b id='f1FHe'><form id='f1FHe'><ins id='f1FHe'></ins><ul id='f1FHe'></ul><sub id='f1FHe'></sub></form><legend id='f1FHe'></legend><bdo id='f1FHe'><pre id='f1FHe'><center id='f1FHe'></center></pre></bdo></b><th id='f1FHe'></th></span></q></dt></tr></i><div id='f1FHe'><tfoot id='f1FHe'></tfoot><dl id='f1FHe'><fieldset id='f1FHe'></fieldset></dl></div>

          <small id='f1FHe'></small><noframes id='f1FHe'>

            <tfoot id='f1FHe'></tfoot>
              <tbody id='f1FHe'></tbody>

                <bdo id='f1FHe'></bdo><ul id='f1FHe'></ul>
                • 本文介绍了如何对 STL 向量进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想对 vector 进行排序

                  vector<myClass> object;
                  

                  其中 myclass 包含许多 int 变量.如何在 myClass 的任何特定数据变量上对我的 vector 进行排序.

                  Where myclass contains many int variables. How can I sort my vector on any specific data variable of myClass.

                  推荐答案

                  重载小于运算符,然后排序.这是我从网上找到的一个例子...

                  Overload less than operator, then sort. This is an example I found off the web...

                  class MyData
                  {
                  public:
                    int m_iData;
                    string m_strSomeOtherData;
                    bool operator<(const MyData &rhs) const { return m_iData < rhs.m_iData; }
                  };
                  
                  std::sort(myvector.begin(), myvector.end());
                  

                  来源:此处

                  这篇关于如何对 STL 向量进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is the past-the-end iterator in STL C++?(STL C++ 中的最后迭代器是什么?)
                  vector::at vs. vector::operator[](vector::at 与 vector::operator[])
                  C++ equivalent of StringBuffer/StringBuilder?(C++ 等效于 StringBuffer/StringBuilder?)
                  Adding types to the std namespace(将类型添加到 std 命名空间)
                  Is the C++ std::set thread-safe?(C++ std::set 线程安全吗?)
                  How to use std::find/std::find_if with a vector of custom class objects?(如何将 std::find/std::find_if 与自定义类对象的向量一起使用?)

                    1. <i id='AK7Tr'><tr id='AK7Tr'><dt id='AK7Tr'><q id='AK7Tr'><span id='AK7Tr'><b id='AK7Tr'><form id='AK7Tr'><ins id='AK7Tr'></ins><ul id='AK7Tr'></ul><sub id='AK7Tr'></sub></form><legend id='AK7Tr'></legend><bdo id='AK7Tr'><pre id='AK7Tr'><center id='AK7Tr'></center></pre></bdo></b><th id='AK7Tr'></th></span></q></dt></tr></i><div id='AK7Tr'><tfoot id='AK7Tr'></tfoot><dl id='AK7Tr'><fieldset id='AK7Tr'></fieldset></dl></div>

                      <tfoot id='AK7Tr'></tfoot>
                          <bdo id='AK7Tr'></bdo><ul id='AK7Tr'></ul>
                            <tbody id='AK7Tr'></tbody>

                            <small id='AK7Tr'></small><noframes id='AK7Tr'>

                            <legend id='AK7Tr'><style id='AK7Tr'><dir id='AK7Tr'><q id='AK7Tr'></q></dir></style></legend>