librnr/examples/example_hash.c
static void force_shrink(hash_t *h)
{
  hashcount_t   count, size;
  hscan_t       hs;
  hnode_t      *hn;
  char         *key, *val;

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

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

  // tables shrinks at lowwater mark
  size = h->lowmark;

  hash_scan_begin(&hs, h);

  // delete first count nodes
  while( ((hn = hash_scan_next(&hs)) != NULL) && (count-- > size) )
  {
    key = (char *)hnode_getkey(hn);
    val = (char *)hnode_get(hn);
    printf(" deleted %s -> %s\n", key, val); 
    hash_node_delete(h, hn);
  }

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

  printf(" ending count=%lu, table size=%lu\n", count, size); 
}
/*!
 * \brief Force table to shink by deleting table random entries.
 *
 * \param h   Pointer to hash table.
 */
\brief Force table to shink by deleting table random entries.
\param h   Pointer to hash table.
\ brief Force table to shink by deleting table random entries . \ param h Pointer to hash table .
static void force_shrink(hash_t *h)
{
  hashcount_t   count, size;
  hscan_t       hs;
  hnode_t      *hn;
  char         *key, *val;
  count = hash_count(h);
  size  = hash_size(h);
  printf(" starting count=%lu, table size=%lu\n", count, size); 
  size = h->lowmark;
  hash_scan_begin(&hs, h);
  while( ((hn = hash_scan_next(&hs)) != NULL) && (count-- > size) )
  {
    key = (char *)hnode_getkey(hn);
    val = (char *)hnode_get(hn);
    printf(" deleted %s -> %s\n", key, val); 
    hash_node_delete(h, hn);
  }
  count = hash_count(h);
  size  = hash_size(h);
  printf(" ending count=%lu, table size=%lu\n", count, size); 
}
static void force_shrink ( hash_t * h ) { hashcount_t count , size ; hscan_t hs ; hnode_t * hn ; char * key , * val ; count = hash_count ( h ) ; size = hash_size ( h ) ; printf ( " \n " , count , size ) ; size = h -> lowmark ; hash_scan_begin ( & hs , h ) ; while ( ( ( hn = hash_scan_next ( & hs ) ) != NULL ) && ( count -- > size ) ) { key = ( char * ) hnode_getkey ( hn ) ; val = ( char * ) hnode_get ( hn ) ; printf ( " \n " , key , val ) ; hash_node_delete ( h , hn ) ; } count = hash_count ( h ) ; size = hash_size ( h ) ; printf ( " \n " , count , size ) ; }
\brief Force table to shink by deleting table random entries.
\ brief Force table to shink by deleting table random entries .
// tables shrinks at lowwater mark // delete first count nodes