News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

JHashtable Example

Started by aruljothi, Sep 28, 2008, 12:56 PM

Previous topic - Next topic

aruljothi

#include "assert.h"
#include "stdio.h"
#include "JHashTable.h"

typedef char * key_type;
typedef int value_type;

unsigned int hash_char_ptr(const key_type& key)
{
  return 5;   // world's second worst hash algorithm
}

int main(int, char**)
{
  typedef char * key_type;
  typedef int value_type;

  Java::Hashtable <key_type, value_type> translator(hash_char_ptr, NULL);

  assert(translator.isEmpty());

  translator.put("one", 1);
  assert(translator.containsKey("one"));
  assert(!translator.containsKey("three"));

  printf("one equals %d\n", translator.get("one"));

  return 0;
}