• <tfoot id='RCNwK'></tfoot>

  • <legend id='RCNwK'><style id='RCNwK'><dir id='RCNwK'><q id='RCNwK'></q></dir></style></legend>
    • <bdo id='RCNwK'></bdo><ul id='RCNwK'></ul>

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

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

      1. C++ 中的自定义迭代器

        Custom Iterator in C++(C++ 中的自定义迭代器)
      2. <i id='M8HNr'><tr id='M8HNr'><dt id='M8HNr'><q id='M8HNr'><span id='M8HNr'><b id='M8HNr'><form id='M8HNr'><ins id='M8HNr'></ins><ul id='M8HNr'></ul><sub id='M8HNr'></sub></form><legend id='M8HNr'></legend><bdo id='M8HNr'><pre id='M8HNr'><center id='M8HNr'></center></pre></bdo></b><th id='M8HNr'></th></span></q></dt></tr></i><div id='M8HNr'><tfoot id='M8HNr'></tfoot><dl id='M8HNr'><fieldset id='M8HNr'></fieldset></dl></div>

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

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

              • <tfoot id='M8HNr'></tfoot>
                  <tbody id='M8HNr'></tbody>

                  <bdo id='M8HNr'></bdo><ul id='M8HNr'></ul>
                • 本文介绍了C++ 中的自定义迭代器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!


                  我有一个 TContainer 类,它是几个指向 TItems 类的 stl 集合指针的集合.

                  I have a class TContainer that is an aggregate of several stl collections pointers to TItems class.

                  我需要创建一个迭代器来遍历 TContainer 类中所有集合中的元素,抽象出内部工作的客户端.

                  I need to create an Iterator to traverse the elements in all the collections in my TContainer class abstracting the client of the inner workings.


                  What would be a good way to do this?. Should I crate a class that extends an iterator (if so, what iterator class should I extend), should I create an iterator class that is an aggregate of iterators?

                  我只需要一个 FORWARD_ONLY 迭代器.

                  I only need a FORWARD_ONLY iterator.


                  I.E, If this is my container:

                  typedef std::vector <TItem*> ItemVector;
                  class TContainer {
                     std::vector <ItemVector *> m_Items;

                  什么是遍历 m_Items 成员变量的向量中包含的所有项目的好的迭代器.

                  What would be a good Iterator to traverse all the items contained in the vectors of the m_Items member variable.


                  当我做自己的迭代器时(不久前),我继承自 std::iterator 并将类型指定为第一个模板参数.希望有所帮助.

                  When I did my own iterator (a while ago now) I inherited from std::iterator and specified the type as the first template parameter. Hope that helps.

                  对于前向迭代器,在以下代码中使用 forward_iterator_tag 而不是 input_iterator_tag.

                  For forward iterators user forward_iterator_tag rather than input_iterator_tag in the following code.

                  这个类最初取自 istream_iterator 类(并为我自己使用而修改,因此它可能不再类似于 istram_iterator).

                  This class was originally taken from istream_iterator class (and modified for my own use so it may not resemble the istram_iterator any more).

                  template<typename T>
                  class <PLOP>_iterator
                           :public std::iterator<std::input_iterator_tag,       // type of iterator
                                                 T,ptrdiff_t,const T*,const T&> // Info about iterator
                          const T& operator*() const;
                          const T* operator->() const;
                          <PLOP>__iterator& operator++();
                          <PLOP>__iterator operator++(int);
                          bool equal(<PLOP>__iterator const& rhs) const;
                  template<typename T>
                  inline bool operator==(<PLOP>__iterator<T> const& lhs,<PLOP>__iterator<T> const& rhs)
                      return lhs.equal(rhs);


                  Check this documentation on iterator tags:


                  Having just re-read the information on iterators:

                  这是旧的做事方式 (iterator_tags),更现代的方法是为您的迭代器设置 iterator_traits<> 以使其与 STL 完全兼容.

                  This is the old way of doing things (iterator_tags) the more modern approach is to set up iterator_traits<> for your iterator to make it fully compatible with the STL.

                  这篇关于C++ 中的自定义迭代器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



                  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 与自定义类对象的向量一起使用?)

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

                  • <bdo id='TMONX'></bdo><ul id='TMONX'></ul>

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