Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10376


Ignore:
Timestamp:
Apr 19, 2015, 10:13:42 PM (10 years ago)
Author:
landauf
Message:

added helper function to reduce code duplication

Location:
code/branches/core7/src/libraries/core/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/class/Identifier.cc

    r10375 r10376  
    205205            {
    206206                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
    207                     if (std::find(this->parents_.begin(), this->parents_.end(), *it_parent_parent) == this->parents_.end())
    208                         this->parents_.push_back(*it_parent_parent);
    209                 if (std::find(this->parents_.begin(), this->parents_.end(), *it_parent) == this->parents_.end())
    210                     this->parents_.push_back(*it_parent);
     207                    this->addIfNotExists(this->parents_, *it_parent_parent);
     208                this->addIfNotExists(this->parents_, *it_parent);
    211209            }
    212210        }
     
    236234
    237235    /**
     236     * Adds @param identifierToAdd to @param list if this identifier is not already contained in the list.
     237     */
     238    void Identifier::addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const
     239    {
     240        if (std::find(list.begin(), list.end(), identifierToAdd) == list.end())
     241            list.push_back(identifierToAdd);
     242    }
     243
     244    /**
    238245        @brief Returns true, if the Identifier is at least of the given type.
    239246        @param identifier The identifier to compare with
  • code/branches/core7/src/libraries/core/class/Identifier.h

    r10374 r10376  
    215215
    216216        private:
     217            void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const;
     218
    217219            std::list<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization)
    218220            std::list<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to (sorted by their order of initialization)
Note: See TracChangeset for help on using the changeset viewer.