Advertisement

[x]
Attachment Details

Need help with hash_map

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2
I am trying to use the following hash_map:

typedef stdext::hash_map< SYMBOL_KEY , poption_data > hm_greeksByOptionSymbol;

as defined by these types:

typedef struct _symbol_key
{
      // constructor
      _symbol_key( const char *pszSym )
      {
            if ( pszSym )
                  strncpy( szSym, pszSym, sizeof(szSym));
            else
                  szSym[0] = 0;
      }

      ~_symbol_key(){};

      // overload the less than operator
      bool operator < ( const _symbol_key key ) const
      {
            int iRet = strcmp( szSym, key.szSym );
            return (iRet < 0);
      }

      operator size_t() const
      {
            return hash_compare( szSym );
      }

      unsigned long  hash_compare(const char *str) const
      {
            unsigned long hash = 5381;
            int c;

            while (c = *str++)
            {
//                  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
                  hash = hash + c;
            }

            return hash;
      }

      char szSym[40];
} SYMBOL_KEY;

typedef struct _option_data
{
      _option_data() :
            bid(0),ask(0),delta(0),theta(0),gamma(0),vega(0),sBid(0),sAsk(0)
            {};

      long      bid;
      long      ask;
      long      delta;
      long      theta;
      long      gamma;
      long      vega;
      long      sBid;
      long      sAsk;
      long      impVol;
} option_data, *poption_data;


**********************************************************
upon calling the following line of code:

mcapi::hm_greeksByOptionSymbol::iterator iter = m_hmGreeks->find( sk );            // CAUSING ERROR *******


i get the error:

An unhandled exception of type 'System.AccessViolationException' occurred


NOTES:
The exception if occurring before the first entry is entered into the hash.  Any assistance would be appreciated.

Related Solutions
Related Solutions
 
Loading Advertisement...
 
Accepted Solution by OnegaZhang:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
Loading Advertisement...
20080924-EE-VQP-41 / EE_QW_2_20070628