]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Mippleton.hh
initial working frustum culling implementation
[chaz/yoink] / src / Moof / Mippleton.hh
index 95d3f21577e6e9d444e56cf6a4fb33f50e421b73..7058eccf76214911933a61a7d3fca5a07de4fcf9 100644 (file)
  * after the last interested code releases its hold on the object.
  */
 
-#include <map>
+#include <Moof/Hash.hh>
 #include <string>
 
-
 namespace Mf {
 
 
 template <class T>
 class Mippleton
 {
-       typedef std::pair<unsigned,T*>                          ptr_value_t;
-       typedef std::pair<std::string,ptr_value_t>      ptr_map_pair_t;
-       typedef std::map<std::string,ptr_value_t>       ptr_map_t;
+       typedef std::pair<unsigned,T*>                                                          ptr_value_t;
+       typedef std::pair<std::string,ptr_value_t>                                      ptr_map_pair_t;
+       typedef stlplus::hash<std::string,ptr_value_t,hash_string>      ptr_map_t;
+       //typedef std::map<std::string,ptr_value_t>     ptr_map_t;
 
-       static ptr_map_t ptrs_;
-       std::string name_;
+       static ptr_map_t        ptrs_;
+       std::string                     name_;
 
 public:
-       explicit Mippleton(const std::string& name) : name_(name) {}
+       explicit Mippleton(const std::string& name) :
+               name_(name) {}
 
        inline const std::string& getName() const
        {
@@ -65,11 +66,11 @@ public:
 
        inline static T* retain(const std::string& name)
        {
-               typename ptr_map_t::iterator it;
+               typename ptr_map_t::iterator it = ptrs_.find(name);
 
-               if ((it = ptrs_.find(name)) != ptrs_.end())
+               if (it != ptrs_.end())
                {
-                       (*it).second.first++;
+                       ++((*it).second.first);
                        return (*it).second.second;
                }
                else
@@ -84,10 +85,10 @@ public:
        {
                typename ptr_map_t::iterator it;
 
-               if ((it = ptrs_.find(name)) != ptrs_.end() && -(*it).second.first == 0)
+               if ((it = ptrs_.find(name)) != ptrs_.end() && --(*it).second.first == 0)
                {
                        delete (*it).second.second;
-                       ptrs_.erase(it);
+                       ptrs_.erase((*it).first);
                }
        }
 
@@ -98,7 +99,9 @@ public:
 };
 
 template <class T>
-std::map<std::string,std::pair<unsigned,T*> > Mippleton<T>::ptrs_;
+stlplus::hash< std::string,std::pair<unsigned,T*>,hash_string >
+//std::map< std::string,std::pair<unsigned,T*> >
+       Mippleton<T>::ptrs_;
 
 
 } // namespace Mf
This page took 0.018904 seconds and 4 git commands to generate.