[Aptitude-svn-commit] r4006 - in branches/aptitude-0.3/aptitude: . src/generic

Daniel Burrows dburrows at costa.debian.org
Wed Aug 31 03:48:09 UTC 2005


Author: dburrows
Date: Wed Aug 31 03:47:49 2005
New Revision: 4006

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/setset.h
Log:
Also use a hash table for the temporary intermediate map in find_subset.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Aug 31 03:47:49 2005
@@ -1,5 +1,10 @@
 2005-08-30  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/setset.h:
+
+	  Also use a hash table to represent the intermediate map object
+	  used in find_subset.
+
 	* src/generic/problemresolver/problemresolver.h, src/generic/setset.h, tests/test_setset.cc:
 
 	  Use a hash table to represent the by-value indexing in a setset.

Modified: branches/aptitude-0.3/aptitude/src/generic/setset.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/setset.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/setset.h	Wed Aug 31 03:47:49 2005
@@ -100,13 +100,30 @@
   template<typename R>
   struct tally_intersections
   {
-    std::map<typename entries_list::size_type, unsigned int> &counts;
+    HASH_NAMESPACE::hash_map<typename entries_list::size_type, unsigned int> &counts;
 
     const index_type &sets_by_key;
 
     const R &r;
+
+    inline typename index_type::const_iterator find_val(const Val &v) const
+    {
+      return sets_by_key.find(v);
+    }
+
+    inline void process_entry(const typename std::vector<index_entry>::const_iterator &vi,
+			      const Val &v) const
+    {
+      typename HASH_NAMESPACE::hash_map<typename entries_list::size_type, unsigned int>::iterator found
+	= counts.find(vi->first);
+
+      if(found == counts.end())
+	counts[vi->first] = 1;
+      else
+	++found->second;
+    }
   public:
-    tally_intersections(std::map<typename entries_list::size_type, unsigned int> &_counts,
+    tally_intersections(HASH_NAMESPACE::hash_map<typename entries_list::size_type, unsigned int> &_counts,
 			const index_type &_sets_by_key,
 			const R &_r)
       :counts(_counts), sets_by_key(_sets_by_key), r(_r)
@@ -117,7 +134,7 @@
     void operator()(const Val &v) const
     {
       typename index_type::const_iterator found
-	= sets_by_key.find(v);
+	= find_val(v);
 
       if(found != sets_by_key.end())
 	{
@@ -126,15 +143,7 @@
 	  for(typename std::vector<index_entry>::const_iterator vi
 		= vals.begin(); vi != vals.end(); ++vi)
 	    if(r(vi->second, v))
-	      {
-		typename std::map<typename entries_list::size_type, unsigned int>::iterator found
-		  = counts.find(vi->first);
-
-		if(found == counts.end())
-		  counts[vi->first] = 1;
-		else
-		  ++found->second;
-	      }
+	      process_entry(vi, v);
 	}
     }
   };
@@ -193,10 +202,10 @@
     // For each element that intersects s, count how many times it
     // intersects.  If every element of a set intersects s (i.e., the
     // count is equal to the set's size) then it is a subset of s.
-    std::map<typename entries_list::size_type, unsigned int> counts;
+    HASH_NAMESPACE::hash_map<typename entries_list::size_type, unsigned int> counts;
     s.for_each(tally_intersections<R>(counts, sets_by_key, r));
 
-    for(typename std::map<typename entries_list::size_type, unsigned int>::const_iterator ci
+    for(typename HASH_NAMESPACE::hash_map<typename entries_list::size_type, unsigned int>::const_iterator ci
 	  = counts.begin(); ci != counts.end(); ++ci)
       {
 	typename entries_list::const_iterator found = entries.begin()+ci->first;



More information about the Aptitude-svn-commit mailing list