1 Reply Latest reply: Feb 22, 2012 12:30 AM by marc1842fr RSS

    Using hash_multiset on Sun C++ 5.7

    user521525
      On Sun OS, In my C++ program want to use hash_multiset. SO I tried including #include <hash_set>

      I get Error: Could not open include file<hash_set>
      Error: hash_multiset is not defined

      This same program works well in MS Visual Studio

      Is there any equivalent library for Sun C++ 5.7 ???????

      Sample program:

      #include <iostream>
      #include <hash_set>
      #include <string>


      using namespace std;
      using namespace stdext;



      int main()
      {
      hash_multiset <string> hms1;
      hash_multiset <string> :: const_iterator hms1_RcIter;

      hms1.insert("mango");
      hms1.insert("guao");
      for(hms1_RcIter = hms1.begin(); hms1_RcIter != hms1.end(); hms1_RcIter++)
      cout<<*hms1_RcIter<<" ";

      int mysize = hms1.size();
      cout << "Size is "<< mysize << endl;

      mysize = hms1.count("mango");
      cout << "Count is "<< mysize << endl;

      hms1_RcIter = hms1.find("mango");
      if ( hms1_RcIter != hms1.end( ) )
      cout << "The element of hash_multiset hms1 with a key of mango is: "
      << *hms1_RcIter << "." << endl;
      else
      cout << "The hash_multiset hms1 doesn't have an element "
      << "with a key of mango." << endl;

      hms1_RcIter = hms1.find("tango");
      if ( hms1_RcIter != hms1.end( ) )
      cout << "The element of hash_multiset hms1 with a key of tango is: "
      << *hms1_RcIter << "." << endl;
      else
      cout << "The hash_multiset hms1 doesn't have an element "
      << "with a key of tango." << endl;

      return 0;
      }