// Filename: eggMorphList.I // Created by: drose (29Jan99) // //////////////////////////////////////////////////////////////////// // // 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." // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // Function: EggMorphList::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE EggMorphList:: EggMorphList() { } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE EggMorphList:: EggMorphList(const EggMorphList ©) : _morphs(copy._morphs) { } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::Copy Assignment Operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void EggMorphList:: operator = (const EggMorphList ©) { _morphs = copy._morphs; } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::Destructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE EggMorphList:: ~EggMorphList() { } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::operator == // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE bool EggMorphList:: operator == (const EggMorphList &other) const { return (_morphs == other._morphs); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::operator != // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE bool EggMorphList:: operator != (const EggMorphList &other) const { return (_morphs != other._morphs); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::operator < // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE bool EggMorphList:: operator < (const EggMorphList &other) const { return (_morphs < other._morphs); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::compare_to // Access: Public // Description: 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; } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::begin // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME EggMorphList::iterator EggMorphList:: begin() { return _morphs.begin(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::begin // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: begin() const { return _morphs.begin(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::end // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME EggMorphList::iterator EggMorphList:: end() { return _morphs.end(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::end // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: end() const { return _morphs.end(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::size // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME EggMorphList::size_type EggMorphList:: size() const { return _morphs.size(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::empty // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE bool EggMorphList:: empty() const { return _morphs.empty(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::insert // Access: Public // Description: 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 pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { 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; } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::clear // Access: Public // Description: Empties the list of morphs. //////////////////////////////////////////////////////////////////// template INLINE void EggMorphList:: clear() { _morphs.clear(); } //////////////////////////////////////////////////////////////////// // Function: EggMorphList::write // Access: Public // Description: //////////////////////////////////////////////////////////////////// template void EggMorphList:: write(ostream &out, int indent_level, const 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"; } }