Skip to content

_unhashed

bergsma edited this page Sep 26, 2014 · 5 revisions

#hashed

###Unhash a variable's contents.

Syntax

status = hashed variable ;

Arguments

  1. list variable

A list variable.

Return Value

str status
  • $ACKNOWLEDGE : The variable's contents have been unhashed.

The STATUS variable is set to $ACKNOWLEDGE

str status
  • $ACKNOWLEDGE : The variable's contents have been unhashed.

The STATUS variable is set to $ACKNOWLEDGE

Exceptions

  • %ARGUMENT: Invalid arguments. Usage: status = hashed variable ;

  • %IDENTIFIER: 'variable' argument is not a valid identifier, literal, or reference

Description

A hash table is a mapping between the elements of a list and their values. With a hash table, an efficient lookup mechanism is employed to retrieve the data elements. Hashing is most useful for list variables with many unique elements; it can result in better performance when accessing the variables' elements. The unlashed method is used to un-hash the variable.

Examples

wordCount = {} ;
hashed wordCount ;
h = fopen ( “book.dat”, “r” ) ;
while ( 1 ) {
  line = fget ( h ) ;
  if (STATUS == “%EOF” ) break ;
  words = strtok line ;
  n = count words ;
  for (i=0;i<n;i++) {
    word = words[i] ;
    /* Hashed wordCount makes this
     * next part fast.
     */
    if ( exists(wordCount.*word) )
      wordCount.*word++ ;
    else
      int wordCount.*word=0;
  }
}
fclose(h);
n = count wordCount ;
for (I=0;I<n;I++)
  puts {“Count of “,wordCount[I],
        “ = “,*wordCount[I] } ;

wordCount = {} ;
hashed wordCount ;
h = fopen ( “book.dat”, “r” ) ;
while ( 1 ) {
  line = fget ( h ) ;
  if (STATUS == “%EOF” ) break ;
  words = strtok line ;
  n = count words ;
  for (i=0;i<n;i++) {
    word = words[i] ;
    /* Hashed wordCount makes this
     * next part fast.
     */
    if ( exists(wordCount.*word) )
      wordCount.*word++ ;
    else
      int wordCount.*word=0;
  }
}
fclose(h);
n = count wordCount ;
for (I=0;I<n;I++)
  puts {“Count of “,wordCount[I],
        “ = “,*wordCount[I] } ;

Related Links

hashed

Clone this wiki locally