HashMap implementation

0
(0)
Name:
HashMap implementation
Author: Andrew Lord (2014.02.11 16:34)
Downloaded: 6
Download:
HashMap implementation 1
 hash.mqh (14.5 Kb) View

Description:

This is a HashMap implementation. This allows something like arrays but with string indexes. It maps strings to Objects. The Objects must be a subclass of the HashValue class provided.

The Hash by default will 'adopt' the value objects. In which case it will free the memory when they are no longer in the hash. This can be disabled in the constructor.

Here is an example:

 

    
    Hash *h = new Hash();

    // Store values
    h.hPutInt("low",0);
    h.hPutInt("high",1);

    // Get values
    int high = h.gGetInt("high");

    // Loop
    HashLoop *l ;
    for( l = new HashLoop(h) ; l.hasNext() ; l.next()) {

        string key = l.key();

        int j = l.valInt();

        Print(key," = ",j);

    }
    delete l;

    delete h;

Recommendations:

  • Accompany the submitted code with a meaning-bearing name and a brief description.
  • Attach a brief explanation to the code for users to make head or tail of it.
  • Insert illustrating images where applicable.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?



Author: Forex Wiki Team
We are a team of highly experienced Forex Traders [2000-2023] who are dedicated to living life on our own terms. Our primary objective is to attain financial independence and freedom, and we have pursued self-education and gained extensive experience in the Forex market as our means to achieve a self-sustainable lifestyle.