Ver código fonte

*** empty log message ***

David Rose 25 anos atrás
pai
commit
8d91ab13fe
2 arquivos alterados com 180 adições e 9 exclusões
  1. 148 7
      panda/src/egg/eggMorphList.I
  2. 32 2
      panda/src/egg/eggMorphList.h

+ 148 - 7
panda/src/egg/eggMorphList.I

@@ -3,7 +3,148 @@
 // 
 // 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include <indent.h>
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::
+EggMorphList() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::Copy Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::
+EggMorphList(const EggMorphList<MorphType> &copy) :
+  _morphs(copy._morphs)
+{
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::Copy Assignment Operator
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE void EggMorphList<MorphType>::
+operator = (const EggMorphList &copy) {
+  _morphs = copy._morphs;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::Destructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::
+~EggMorphList() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::operator == 
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE bool EggMorphList<MorphType>::
+operator == (const EggMorphList<MorphType> &other) const {
+  return (_morphs == other._morphs);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::operator != 
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE bool EggMorphList<MorphType>::
+operator != (const EggMorphList<MorphType> &other) const {
+  return (_morphs != other._morphs);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::operator < 
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE bool EggMorphList<MorphType>::
+operator < (const EggMorphList<MorphType> &other) const {
+  return (_morphs < other._morphs);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::begin
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
+begin() {
+  return _morphs.begin();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::begin
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
+begin() const {
+  return _morphs.begin();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::end
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
+end() {
+  return _morphs.end();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::end
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
+end() const {
+  return _morphs.end();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::size
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE EggMorphList<MorphType>::size_type EggMorphList<MorphType>::
+size() const {
+  return _morphs.size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggMorphList::empty
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+template<class MorphType>
+INLINE bool EggMorphList<MorphType>::
+empty() const {
+  return _morphs.empty();
+}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: EggMorphList::insert
 //     Function: EggMorphList::insert
@@ -20,19 +161,19 @@ template<class MorphType>
 pair<EggMorphList<MorphType>::iterator, bool> EggMorphList<MorphType>::
 pair<EggMorphList<MorphType>::iterator, bool> EggMorphList<MorphType>::
 insert(const MorphType &value) {
 insert(const MorphType &value) {
   pair<iterator, bool> result;
   pair<iterator, bool> 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.
       // This value is already present.
-      result.first = i;
+      result.first = mi;
       result.second = false;
       result.second = false;
       return result;
       return result;
     }
     }
   }
   }
 
 
   // This value is not already present; add it to the list.
   // 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;
   result.second = true;
   return result;
   return result;
 }
 }

+ 32 - 2
panda/src/egg/eggMorphList.h

@@ -10,6 +10,8 @@
 
 
 #include "eggMorph.h"
 #include "eggMorph.h"
 
 
+#include <indent.h>
+
 #include <vector>
 #include <vector>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -17,10 +19,38 @@
 // Description : A collection of <Dxyz>'s or <Duv>'s or some such.
 // Description : A collection of <Dxyz>'s or <Duv>'s or some such.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class MorphType>
 template<class MorphType>
-class EggMorphList : public vector<MorphType> {
+class EggMorphList {
+private:
+  typedef vector<MorphType> Morphs;
+
 public:
 public:
-  pair<EggMorphList<MorphType>::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<MorphType> &copy);
+  INLINE void operator = (const EggMorphList<MorphType> &copy);
+  INLINE ~EggMorphList();
+
+  INLINE bool operator == (const EggMorphList<MorphType> &other) const;
+  INLINE bool operator != (const EggMorphList<MorphType> &other) const;
+  INLINE bool operator < (const EggMorphList<MorphType> &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<iterator, bool> insert(const MorphType &value);
+
   void write(ostream &out, int indent_level) const;
   void write(ostream &out, int indent_level) const;
+
+private:
+  Morphs _morphs;
 };
 };