/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * * All use of this software is subject to the terms of the revised BSD * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * * @file eggMorphList.I * @author drose * @date 1999-01-29 */ /** * */ template INLINE EggMorphList:: EggMorphList() { } /** * */ template INLINE EggMorphList:: EggMorphList(const EggMorphList ©) : _morphs(copy._morphs) { } /** * */ template INLINE void EggMorphList:: operator = (const EggMorphList ©) { _morphs = copy._morphs; } /** * */ template INLINE EggMorphList:: ~EggMorphList() { } /** * */ template INLINE bool EggMorphList:: operator == (const EggMorphList &other) const { return (_morphs == other._morphs); } /** * */ template INLINE bool EggMorphList:: operator != (const EggMorphList &other) const { return (_morphs != other._morphs); } /** * */ template INLINE bool EggMorphList:: operator < (const EggMorphList &other) const { return (_morphs < other._morphs); } /** * compare_to() compares a different space than the operator methods, which * only check the morph's name. compare_to() compares the name and the value * as well. */ template int EggMorphList:: compare_to(const EggMorphList &other, double threshold) const { if (_morphs.size() != other._morphs.size()) { return (int)_morphs.size() - (int)other._morphs.size(); } for (size_t i = 0; i < _morphs.size(); i++) { int compare = _morphs[i].compare_to(other._morphs[i], threshold); if (compare < 0) { return compare; } } return 0; } /** * */ template INLINE typename EggMorphList::iterator EggMorphList:: begin() { return _morphs.begin(); } /** * */ template INLINE typename EggMorphList::const_iterator EggMorphList:: begin() const { return _morphs.begin(); } /** * */ template INLINE typename EggMorphList::iterator EggMorphList:: end() { return _morphs.end(); } /** * */ template INLINE typename EggMorphList::const_iterator EggMorphList:: end() const { return _morphs.end(); } /** * */ template INLINE typename EggMorphList::size_type EggMorphList:: size() const { return _morphs.size(); } /** * */ template INLINE bool EggMorphList:: empty() const { return _morphs.empty(); } /** * This is similar to the insert() interface for sets, except it does not * guarantee that the resulting list is sorted. * * We have this member function so the EggMorphList resembles a set. It used * to *be* a set, but we cannot export STL sets from a Windows DLL. */ template std::pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { std::pair result; typename Morphs::iterator mi; for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { if ((*mi) == value) { // This value is already present. result.first = mi; result.second = false; return result; } } // This value is not already present; add it to the list. _morphs.push_back(value); result.first = _morphs.begin() + _morphs.size() - 1; result.second = true; return result; } /** * Empties the list of morphs. */ template INLINE void EggMorphList:: clear() { _morphs.clear(); } /** * */ template void EggMorphList:: write(std::ostream &out, int indent_level, const std::string &tag, int num_dimensions) const { const_iterator i; for (i = begin(); i != end(); ++i) { indent(out, indent_level); i->output(out, tag, num_dimensions); out << "\n"; } }