From 8d91ab13fec46a638f982ffff50f37eacdc741d1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 2 May 2001 22:53:32 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/egg/eggMorphList.I | 155 +++++++++++++++++++++++++++++++++-- panda/src/egg/eggMorphList.h | 34 +++++++- 2 files changed, 180 insertions(+), 9 deletions(-) diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index 9402d10196..ceda097819 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -3,7 +3,148 @@ // //////////////////////////////////////////////////////////////////// -#include + +//////////////////////////////////////////////////////////////////// +// 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::begin +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE EggMorphList::iterator EggMorphList:: +begin() { + return _morphs.begin(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggMorphList::begin +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE EggMorphList::const_iterator EggMorphList:: +begin() const { + return _morphs.begin(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggMorphList::end +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE EggMorphList::iterator EggMorphList:: +end() { + return _morphs.end(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggMorphList::end +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE EggMorphList::const_iterator EggMorphList:: +end() const { + return _morphs.end(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggMorphList::size +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE 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 @@ -20,19 +161,19 @@ template pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { pair result; - iterator i; - for (i = begin(); i != end(); ++i) { - if ((*i) == value) { + Morphs::iterator mi; + for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { + if ((*mi) == value) { // This value is already present. - result.first = i; + result.first = mi; result.second = false; return result; } } // This value is not already present; add it to the list. - push_back(value); - result.first = begin() + size() - 1; + _morphs.push_back(value); + result.first = _morphs.begin() + _morphs.size() - 1; result.second = true; return result; } diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index a8cb72ef75..8c03ace76c 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -10,6 +10,8 @@ #include "eggMorph.h" +#include + #include //////////////////////////////////////////////////////////////////// @@ -17,10 +19,38 @@ // Description : A collection of 's or 's or some such. //////////////////////////////////////////////////////////////////// template -class EggMorphList : public vector { +class EggMorphList { +private: + typedef vector Morphs; + public: - pair::iterator, bool> insert(const MorphType &value); + typedef Morphs::iterator iterator; + typedef Morphs::const_iterator const_iterator; + typedef Morphs::size_type size_type; + + INLINE EggMorphList(); + INLINE EggMorphList(const EggMorphList ©); + INLINE void operator = (const EggMorphList ©); + INLINE ~EggMorphList(); + + INLINE bool operator == (const EggMorphList &other) const; + INLINE bool operator != (const EggMorphList &other) const; + INLINE bool operator < (const EggMorphList &other) const; + + INLINE iterator begin(); + INLINE const_iterator begin() const; + INLINE iterator end(); + INLINE const_iterator end() const; + + INLINE size_type size() const; + INLINE bool empty() const; + + pair insert(const MorphType &value); + void write(ostream &out, int indent_level) const; + +private: + Morphs _morphs; };