Пример #1
0
static void
fill_hashtable_single(entree **table, entree *ep)
{
  EpSETSTATIC(ep);
  insertep(ep, table,  hashvalue(ep->name));
  if (ep->code) ep->arity = check_proto(ep->code);
  ep->pvalue = NULL;
}
Пример #2
0
static void
addTable(Table t, unsigned long name, unsigned long value)
{ Symbol *l = &t->symbols[hashvalue(t->size, name)];
  Symbol s = (Symbol)pceMalloc(sizeof(struct symbol));

  s->name = name;
  s->value = value;
  s->next = *l;
  *l = s;
}
Пример #3
0
// Pre-condition: h points to a valid hash table that IS NOT full.
// Post-condition: word will be inserted into the table h.
void insertTable(struct htable *h, char word[]) {
     
    int hashval;
    hashval = hashvalue(word);
    
    // Here's the linear probing part.
    while (strcmp(h->entries[hashval], "") != 0)
         hashval = (hashval+1)%TABLE_SIZE;
         
    strcpy(h->entries[hashval], word);     
}
Пример #4
0
static unsigned long
memberTable(Table t, unsigned long name)
{ Symbol s = t->symbols[hashvalue(t->size, name)];

  for(; s; s = s->next)
  { if ( s->name == name )
      return s->value;
  }

  return NOPIXEL;
}
Пример #5
0
// Pre-condition: h points to a valid hash table.
// Post-condition: deletes word from the table pointed to by h, if word is
//                 stored here. If not, no change is made to the table pointed
//                 to by h.
void deleteTable(struct htable *h, char word[]) {
 
    int hashval;
    hashval = hashvalue(word);
    
    // See what comes first, the word or a blank spot.    
    while (strcmp(h->entries[hashval], "") != 0 &&
           strcmp(h->entries[hashval], word) != 0)
        hashval = (hashval+1)%TABLE_SIZE;
        
    // Reset the word to be the empty string.
    if (strcmp(h->entries[hashval], word) == 0)
        strcpy(h->entries[hashval],"");
        
    // If we get here, the word wasn't in the table, so nothing is done.
}
Пример #6
0
// Pre-condition: h points to a valid hash table.
// Post-condition: 1 will be returned iff word is stored in the table pointed to
//                 by h. Otherwise, 0 is returned.
int searchTable(struct htable *h, char word[]) {
 
    int hashval;
    hashval = hashvalue(word);

    // See what comes first, the word or a blank spot.    
    while (strcmp(h->entries[hashval], "") != 0 &&
           strcmp(h->entries[hashval], word) != 0)
        hashval = (hashval+1)%TABLE_SIZE;
        
    // The word was in the table.
    if (strcmp(h->entries[hashval], word) == 0)
        return 1;
        
    // It wasn't.
    return 0;

}