.. oe:namespace:: OEChem



.. meta::
   :keywords: OEIdxSelected, IdxSelected


.. _OEChem_OEIdxSelected:

.. oe:class:: OEIdxSelected

   .. oe:api::


      template<class Arg>
      class OEIdxSelected : public OESystem::OEUnaryPredicate<Arg>

   This class represents `OEIdxSelected`, a template functor that identifies objects
   which provide a ``GetIdx`` method and have been selected by index in the
   boolean `array` or `vector` or :ref:`OEBitVector <OESystem_OEBitVector>` used
   to initialize the class.
   
   .. seealso::

      * :ref:`section_atombondindices_dontdothis` section

   The following methods are publicly inherited from :ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`:

   ============================================================================== ============================================================================== ===============================================================================
   :oe:meth:`operator()<OESystem::OEUnaryPredicate::operator()>`                  :oe:meth:`CreateCopy<OESystem::OEUnaryPredicate::CreateCopy>`                  :oe:meth:`CreatePredicateCopy<OESystem::OEUnaryPredicate::CreatePredicateCopy>`
   ============================================================================== ============================================================================== ===============================================================================

   The following methods are publicly inherited from :ref:`OEUnaryFunction <OESystem_OEUnaryFunction>`:

   ============================================================ ============================================================
   :oe:meth:`operator()<OESystem::OEUnaryFunction::operator()>` :oe:meth:`CreateCopy<OESystem::OEUnaryFunction::CreateCopy>`
   ============================================================ ============================================================


   The following specializations exist for this template:

   .. index::
      single: OEAtomIdxSelected
      single: OEBondIdxSelected
      single: OEConfIdxSelected

   ==================== ====================================================================
   Specialized Functor  Definition                                                          
   ==================== ====================================================================
   OEAtomIdxSelected    :ref:`OEIdxSelected <OEChem_OEIdxSelected>` <:ref:`OEAtomBase <OEChem_OEAtomBase>`>
   OEBondIdxSelected    :ref:`OEIdxSelected <OEChem_OEIdxSelected>` <:ref:`OEBondBase <OEChem_OEBondBase>`>
   OEConfIdxSelected    :ref:`OEIdxSelected <OEChem_OEIdxSelected>` <:ref:`OEConfBase <OEChem_OEConfBase>`>
   ==================== ====================================================================

   .. oe:method:: Constructors


      .. oe:language:: c++

         .. oe:api::

            OEIdxSelected(const OESystem::OEBitVector& bv)
            OEIdxSelected(const std::vector<bool>& vb)
            OEIdxSelected(const bool* ap, unsigned int sz)
            OEIdxSelected(const bool* ap)

         Construct the functor from an :ref:`OEBitVector <OESystem_OEBitVector>`, ``vector<bool>`` or boolean *array* (call it *s*)
         where the selection state of the object with internal index *i* is stored at *s[i]*
         (*e.g.* ``bv.SetBitOn(atom.GetIdx())``). The caller is responsible for making sure that the input
         :ref:`OEBitVector <OESystem_OEBitVector>`, ``vector<bool>`` or *array* is sufficient size to refer to the maximum index value of
         the objects it will be applied to.

         If only ``const bool *ap`` is supplied to the constructor, the functor continues to accesses the boolean array
         by its pointer. In that case, the caller is responsible for making certain that it is not be deleted before
         this functor is called. Because of this, it is recommended that you pass in the array size as well.

         If other arguments are supplied to the constructor, the selection states will be copied into an internal representation
         and the :ref:`OEBitVector <OESystem_OEBitVector>`, ``vector<bool>`` or *array* can be deleted before the functor is called.

      .. oe:language:: python java csharp

         .. oe:api::

            OEIdxSelected(const OESystem::OEBitVector& bv)

         Construct the functor from an :ref:`OEBitVector <OESystem_OEBitVector>` (call it *bv*)
         where the selection state of the object with internal index *i* is stored at *bv[i]*
         (*e.g.* ``bv.SetBitOn(atom.GetIdx())``). The caller is responsible for making sure that
         the input :ref:`OEBitVector <OESystem_OEBitVector>` is sufficient size to refer to the maximum
         index value of the objects it will be applied to.

         The selection states are copied into an internal representation
         and the :ref:`OEBitVector <OESystem_OEBitVector>` can be deleted before the functor is called.

   .. oe:method:: operator()

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

         .. oe:api::

            bool operator()(const Arg& a) const

      .. oe:language:: python

         .. oe:api:: python

            __call__(a: Arg) -> bool

      .. oe:language:: c++

         Returns ``true``, if the state of the
         *array*, ``vector`` or :ref:`OEBitVector <OESystem_OEBitVector>` used to construct
         the functor at the index returned by the 
         ``Arg.GetIdx()`` method is ``true``.

      .. oe:language:: python java csharp

         Returns ``true``, if the state of the
         :ref:`OEBitVector <OESystem_OEBitVector>` used to construct
         the functor at the index returned by the 
         ``Arg.GetIdx()`` method is ``true``.

   .. oe:method:: CreateCopy

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

         .. oe:api::

            OETYPENAME OESystem::OEUnaryFunction<Arg, bool>* CreateCopy() const

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEIdxSelected

      Deep copy constructor that returns a copy of the object.
      The memory for the returned `OEIdxSelected` 
      object is dynamically allocated and owned by the caller.

      .. oe:language:: c++ 

         The returned copy should be deallocated using C++
         delete operator in order to prevent a memory leak. 
