• <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 向量进行排序?

        时间:2024-05-11
          <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 向量进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:迭代 C++ 映射中的键 下一篇:如何使 map::find 操作不区分大小写?

                  相关文章

                  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>

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

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