gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libgeometry/kd_tree_dynamic.cpp...


From: Markus Gothe
Subject: [Gnash-commit] gnash ChangeLog libgeometry/kd_tree_dynamic.cpp...
Date: Tue, 28 Nov 2006 00:19:23 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Markus Gothe <nihilus>  06/11/28 00:19:23

Modified files:
        .              : ChangeLog 
        libgeometry    : kd_tree_dynamic.cpp 
Added files:
        libbase        : hash_wrapper.h 

Log message:
                * libgeometry/kd_tree_dynamic.cpp: hash_wrapper().
                * libbase/hash_wrapper.h: template-wrapper for add() and get() 
                to replacing hash()-code with <map>.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1794&r2=1.1795
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/hash_wrapper.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/kd_tree_dynamic.cpp?cvsroot=gnash&r1=1.14&r2=1.15

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1794
retrieving revision 1.1795
diff -u -b -r1.1794 -r1.1795
--- ChangeLog   27 Nov 2006 23:34:03 -0000      1.1794
+++ ChangeLog   28 Nov 2006 00:19:22 -0000      1.1795
@@ -1,7 +1,9 @@
 2006-11-25 Markus Gothe <address@hidden>
 
        * Reverted naming-changes.
-       * libgeometry/kd_tree_dynamic.cpp: switch to <map> from hash().
+       * libgeometry/kd_tree_dynamic.cpp: hash_wrapper().
+       * libbase/hash_wrapper.h: template-wrapper for add() and get() to 
+         replacing hash()-code with <map>.
 
 2006-11-27 Sandro Santilli <address@hidden>
 

Index: libgeometry/kd_tree_dynamic.cpp
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/kd_tree_dynamic.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- libgeometry/kd_tree_dynamic.cpp     27 Nov 2006 23:34:03 -0000      1.14
+++ libgeometry/kd_tree_dynamic.cpp     28 Nov 2006 00:19:22 -0000      1.15
@@ -13,7 +13,7 @@
 #include "kd_tree_dynamic.h"
 #include "tu_file.h"
 #include <cfloat>
-#include <map>
+#include "hash_wrapper.h"
 
 using namespace gnash;
 
@@ -21,38 +21,6 @@
 static const int       LEAF_FACE_COUNT = 6;
 static const int       MAX_SPLIT_PLANES_TESTED = 10;
 
-class indexed
-{
-private:
-
-       typedef std::map<int, int> container;
-
-       container _map;
-
-public:
-
-       indexed() {}
-
-       bool get(const int& key, int* ret)
-       {
-               container::iterator it = _map.find(key);
-               if ( it != _map.end() )
-               {
-                       *ret = it->second;
-                       return true;
-               }
-               else
-               {
-                       return false;
-               }
-       }
-
-       void add(const int& key, int& mov)
-       {
-               _map[key] = mov;
-       }
-};
-
 //#define CARVE_OFF_SPACE
 //#define ADHOC_METRIC
 #define MACDONALD_AND_BOOTH_METRIC
@@ -106,8 +74,8 @@
        assert(tris1->size() == 0);
 
        // Remap table from verts array to new verts0/1 arrays.
-       indexed verts_to_verts0;
-       indexed verts_to_verts1;
+       hash_wrapper<int, int>  verts_to_verts0;
+       hash_wrapper<int, int>  verts_to_verts1;
 
        // Divide the faces.
        for (int i = 0; i < triangle_count; i++)
@@ -165,7 +133,7 @@
 }
 
 
-static void    remap_vertex_order(kd_tree_dynamic::node* node, indexed* 
map_indices_old_to_new, int* new_vertex_count)
+static void    remap_vertex_order(kd_tree_dynamic::node* node, 
hash_wrapper<int, int>* map_indices_old_to_new, int* new_vertex_count)
 // Traverse this tree in depth-first order, and remap the vertex
 // indices to go in order.
 {

Index: libbase/hash_wrapper.h
===================================================================
RCS file: libbase/hash_wrapper.h
diff -N libbase/hash_wrapper.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libbase/hash_wrapper.h      28 Nov 2006 00:19:22 -0000      1.1
@@ -0,0 +1,57 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+//
+//
+
+/* $Id: hash_wrapper.h,v 1.1 2006/11/28 00:19:22 nihilus Exp $ */
+
+#ifndef HASH_WRAPPER_H
+#define HASH_WRAPPER_H
+
+#include <map>
+
+template<class T, class U>
+class hash_wrapper : public std::map<T, U>
+{
+private:
+
+       typedef typename std::map<T, U>::iterator iterator;
+
+public:
+
+               
+       void add(const T& key, U& mov)
+       {
+               (*this)[key] = mov;
+       }
+       
+       bool get(const T& key, U* ret)
+       {
+               iterator it = find(key);
+               if ( it != this->end() )
+               {
+                       *ret = it->second;
+                       return true;
+               }
+               else
+               {
+                       return false;
+               }
+       }
+};
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]