Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hash_map and hash_set are non-standard, <a href="http://msdn.microsoft.com/en-us/library/bb983026.aspx" rel="nofollow noreferrer">unordered_map</a> and <a href="http://msdn.microsoft.com/en-us/library/bb982739.aspx" rel="nofollow noreferrer">unordered_set</a> are the most likely soon to be standard versions. Without having a reproducer, I don't think this is going to get far though. Under the hood, they are the same data structures, so they should have similar performance.</p> <hr> <p>I compiled the provided sample under MS Visual Studio 2008 v9.0.30729.1, as Visual C++ -> Win32 -> Console Application (though I rolled my own Timer class because I wasn't sure what you were using). Under debug, I got times of 1000 ms, but compiling under release was 50 ms.</p> <pre><code>#include &lt;vector&gt; #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; #include &lt;windows.h&gt; typedef struct { LARGE_INTEGER start; LARGE_INTEGER stop; } stopWatch; class CStopWatch { private: stopWatch timer; LARGE_INTEGER frequency; double LIToSecs( LARGE_INTEGER &amp; L); public: CStopWatch(); void startTimer( ); void stopTimer( ); double getElapsedTime(); }; double CStopWatch::LIToSecs( LARGE_INTEGER &amp; L) { return ((double)L.QuadPart /(double)frequency.QuadPart) ; } CStopWatch::CStopWatch(){ timer.start.QuadPart=0; timer.stop.QuadPart=0; QueryPerformanceFrequency( &amp;frequency ) ; } void CStopWatch::startTimer( ) { QueryPerformanceCounter(&amp;timer.start) ; } void CStopWatch::stopTimer( ) { QueryPerformanceCounter(&amp;timer.stop) ; } double CStopWatch::getElapsedTime() { LARGE_INTEGER time; time.QuadPart = timer.stop.QuadPart - timer.start.QuadPart; return LIToSecs( time) ; } using namespace std; int runIntersectionTest() { std::map&lt;int,int&gt; theMap; vector&lt;int&gt; set1; vector&lt;int&gt; set2; // Create 100,000 values for set1 for ( int i = 0; i &lt; 100000; i++ ) { int value = 1000000000 + i; set1.push_back(value); } // Create 1,000 values for set2 for ( int i = 0; i &lt; 1000; i++ ) { int random = rand() % 200000 + 1; random *= 10; int value = 1000000000 + random; set2.push_back(value); } // Now intersect the two sets by populating the map for ( vector&lt;int&gt;::iterator iterator = set1.begin(); iterator != set1.end(); iterator++ ) { int value = *iterator; theMap[value] = 1; } int intersectionSize = 0; for ( vector&lt;int&gt;::iterator iterator = set2.begin(); iterator != set2.end(); iterator++ ) { int value = *iterator; map&lt;int,int&gt;::iterator foundValue = theMap.find(value); if ( foundValue != theMap.end() ) { theMap[value] = 2; intersectionSize++; } } return intersectionSize; } int main(int argc, char* argv[]) { srand ( time(NULL) ); int tests = 2; while(tests--){ CStopWatch timer; timer.startTimer(); int intersectionSize = runIntersectionTest(); timer.stopTimer(); cout &lt;&lt; "Found " &lt;&lt; intersectionSize &lt;&lt; " values in the intersection, in " &lt;&lt; timer.getElapsedTime() &lt;&lt; "s\r\n"; } getchar(); return 0; } </code></pre> <p>(I would try with unordered_map but my version doesn't have it). I suspect there is some problem in your setup for C++.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload