librnr/examples/example_hash.c
static void force_grow(hash_t *h)
{
  hashcount_t   count, size;
  size_t        num_mtns = arraysize(Colorado14ers);
  int           mtn;
  char          buf[64];
  char         *key, *val;

  count = hash_count(h);
  size  = hash_size(h);

  printf(" starting count=%lu, table size=%lu\n", count, size); 

  // tables grows at highwater mark
  size = h->highmark;

  while( count++ < size )
  {
    mtn = (int)(random() % (long int)num_mtns);
    sprintf(buf, "%s(%d)", Colorado14ers[mtn][0], MtnCounter++);
    key = new_strdup(buf);
    val = new_strdup(Colorado14ers[mtn][1]);

    if( !hash_insert(h, key, val) )
    {
      puts("hash_insert failed");
      del_node_data(key, val);
      return;
    }
    else
    {
      printf(" added %s -> %s\n", key, val);
    }
  }

  count = hash_count(h);
  size  = hash_size(h);

  printf(" ending count=%lu, table size=%lu\n", count, size); 
}
/*!
 * \brief Force table to grow by feeding the table random entries.
 *
 * \param h   Pointer to hash table.
 */
\brief Force table to grow by feeding the table random entries.
\param h   Pointer to hash table.
\ brief Force table to grow by feeding the table random entries . \ param h Pointer to hash table .
static void force_grow(hash_t *h)
{
  hashcount_t   count, size;
  size_t        num_mtns = arraysize(Colorado14ers);
  int           mtn;
  char          buf[64];
  char         *key, *val;
  count = hash_count(h);
  size  = hash_size(h);
  printf(" starting count=%lu, table size=%lu\n", count, size); 
  size = h->highmark;
  while( count++ < size )
  {
    mtn = (int)(random() % (long int)num_mtns);
    sprintf(buf, "%s(%d)", Colorado14ers[mtn][0], MtnCounter++);
    key = new_strdup(buf);
    val = new_strdup(Colorado14ers[mtn][1]);
    if( !hash_insert(h, key, val) )
    {
      puts("hash_insert failed");
      del_node_data(key, val);
      return;
    }
    else
    {
      printf(" added %s -> %s\n", key, val);
    }
  }
  count = hash_count(h);
  size  = hash_size(h);
  printf(" ending count=%lu, table size=%lu\n", count, size); 
}
static void force_grow ( hash_t * h ) { hashcount_t count , size ; size_t num_mtns = arraysize ( Colorado14ers ) ; int mtn ; char buf [ 64 ] ; char * key , * val ; count = hash_count ( h ) ; size = hash_size ( h ) ; printf ( " \n " , count , size ) ; size = h -> highmark ; while ( count ++ < size ) { mtn = ( int ) ( random ( ) % ( long int ) num_mtns ) ; sprintf ( buf , " " , Colorado14ers [ mtn ] [ 0 ] , MtnCounter ++ ) ; key = new_strdup ( buf ) ; val = new_strdup ( Colorado14ers [ mtn ] [ 1 ] ) ; if ( ! hash_insert ( h , key , val ) ) { puts ( " " ) ; del_node_data ( key , val ) ; return ; } else { printf ( " \n " , key , val ) ; } } count = hash_count ( h ) ; size = hash_size ( h ) ; printf ( " \n " , count , size ) ; }
\brief Force table to grow by feeding the table random entries.
\ brief Force table to grow by feeding the table random entries .
// tables grows at highwater mark