.. oe:namespace:: OESystem



.. meta::
   :keywords: OEIter


.. _OESystem_OEIter:

.. oe:class:: OEIter

   .. oe:api::


      template<class A>
      class OEIter

   This class represents `OEIter`.

   The :ref:`OEIter <OESystem_OEIter>` template class is used to represent
   *iterator* functionality. The template is parameterized over
   ``class A``, defining the behavior of iterators of across collections
   of type ``A``. The iterator can be thought of a behaving like a pointer
   to type ``A``.

   :oe:cls:`OEIters<OESystem::OEIter>` are typically initialized by assigning 
   them the value of an  :oe:cls:`OEIterBase(of compatible type T)<OESystem::OEIterBase>`,
   return from a function.

   .. oe:method:: Constructors

      .. oe:api::

         OEIter()
         OEIter(OEIterBase<A>* rhs)
         OEIter(const OEIter<A>& rhs)
         OEIter(OEIterBase<NonConstA>* rhs)
         template<typename P>
         OEIter(const P& pred, OEIter<A>& rhs)
         template<typename P>
         OEIter(const P& pred, OEIterBase<A>* rhs)

      Default and copy constructors.

   .. oe:method:: operator!
      :language: c++

      .. oe:api::

         bool operator!() const


   .. oe:method:: operator*
      :language: c++

      .. oe:api::

         A& operator*() const

      Dereference the iterator as a reference. This operator returns a
      C++ reference to the current item pointed to by the iterator.

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEIter<A>& operator=(OEIterBase<A>* rhs)
         OEIter<A>& operator=(const OEIter<A>& rhs)

      The assignment operator initializes the :ref:`OEIter <OESystem_OEIter>` to the given
      :ref:`OEIterBase <OESystem_OEIterBase>`, typically returned by an *OEChem* or *OESystem*
      function. If the :ref:`OEIter <OESystem_OEIter>` has already been initialized, the
      internal :ref:`OEIterBase <OESystem_OEIterBase>` is destroy and replaced with the new value.

      Assignment operator.


   .. oe:method:: operator!=
      :language: c++

      .. oe:api::

         bool operator!=(const OEIter<A>& rhs) const

      Returns ``true`` if the item pointed to by the first iterator is not
      the same as the item pointed to by the second iterator (using
      pointer inequality). 
      This operator is the negation of :oe:meth:`OESystem::OEIter::operator==`.

   .. oe:method:: operator++
      :language: c++

      .. oe:api::

         OEIter<A>& operator++()

      This prefix :oe:meth:`OESystem::OEIter::operator++` advances the
      iterator one position. 

   .. oe:method:: operator+=
      :language: c++

      .. oe:api::

         OEIter<A>& operator+=(int x)
         OEIter<A>& operator+=(unsigned int x)

      Advances the iterator 'x' places forward.

   .. oe:method:: operator--
      :language: c++

      .. oe:api::

         OEIter<A>& operator--()

      This prefix  :oe:meth:`OESystem::OEIter::operator--` operator moves the iterator 
      back one position, if possible. 

   .. oe:method:: operator-=
      :language: c++

      .. oe:api::

         OEIter<A>& operator-=(int x)
         OEIter<A>& operator-=(unsigned int x)

      Attempts to move the iterator 'x' places backward.

   .. oe:method:: operator->
      :language: c++ java csharp

      .. oe:api::

         A* operator->() const

      Dereferences the iterator as a pointer. This operator returns a
      pointer to the current item pointed to by the iterator.

   .. oe:method:: operator==
      :language: c++

      .. oe:api::

         bool operator==(const OEIter<A>& rhs) const

      Returns ``true`` if the item pointed to by the first iterator is
      the same as the item pointed to by the second iterator (using
      pointer equality). This operator is the negation of
      :oe:meth:`OESystem::OEIter::operator!=`.

   .. oe:method:: operator A &
      :language: c++

      .. oe:api::

         operator A &() const

   .. oe:method:: operator A *
      :language: c++

      .. oe:api::

         operator A *() const


   .. oe:method:: operator bool

      .. oe:language:: c++ java csharp

         .. oe:api::

            operator bool() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Returns true if the current iterator position is valid. This
      should typically be checked before each dereference of an
      iterator.

   .. oe:method:: Copy

      .. oe:api::

         OEIterBase<A> *Copy() const

      Copies an :ref:`OEIter <OESystem_OEIter>`. The returned value is a newly allocated
      :ref:`OEIterBase <OESystem_OEIterBase>` <A>* that should be immediately assigned to an
      :ref:`OEIter <OESystem_OEIter>`. The current location in the iterator is preserved by the
      copy.

   .. oe:method:: Push

      .. oe:api::

         void Push(OEIter<A> &iter)
         void Push(OEIterBase<A> *ib)
         template<typename F>
         void Push(const F &pred)

   .. oe:method:: Sort

      .. oe:api::

         void Sort(const OESystem::OEBinaryPredicate<A, A> &sort_criterion)

      Sorts contents of the iterator and
      resets the iterator to its first item. The re-ordering is local
      to the given instance of the iterator (*i.e.*, the container
      holding the items the iterator traverses is unchanged). Once
      this function is called the iterator is never delete safe, even
      if it normally would be.

      The :ref:`OEBinaryPredicate <OESystem_OEBinaryPredicate>` <A,A> passed
      to this function is used as
      the less comparison in the sort. It should return ``true`` if the
      first argument is less than the second argument and ``false``
      otherwise. An item that is less than another item will appear
      first after sorting.

   .. oe:method:: ToFirst

      .. oe:api::

         OEIter<A> &ToFirst()

      Resets the iterator to its first item, if possible.

   .. oe:method:: ToLast

      .. oe:api::

         OEIter<A> &ToLast()

      Resets the iterator to its last item, if  possible.

