parrotcode: core functions and data structs for the | |
Contents | Language Implementations | Pipp |
languages/pipp/src/pipp_hash.c - core functions and data structs for the PHPArray PMC
A hashtable contains an array of bucket indexes.
Buckets are nodes in a linked list,
each containing a void *
key and value.
During hash creation,
the type of the value can be set.
All keys are stored as STRINGs.
PippHashTable *pipp_hash_create(PARROT_INTERP, UINTVAL size)
size
buckets.void pipp_hash_destroy(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_empty(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_sanity_check(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_renumber(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_rehash(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_resize(PARROT_INTERP, PippHashTable *ht, INTVAL new_size)
PippBucket *pipp_hash_get_bucket(PARROT_INTERP, PippHashTable *ht, STRING *key)
key
,
return a pointer to it.
Otherwise return NULL.PMC *pipp_hash_get(PARROT_INTERP, PippHashTable *ht, STRING *key)
key
,
return the value of that bucket.
Otherwise return NULL.PippBucket *pipp_hash_put(PARROT_INTERP, PippHashTable *ht, STRING *key, PMC *p_val)
p_val
,
indexed by key
,
in the hash.
Return the bucket where p_val
was stored.PippBucket *pipp_hash_find(PARROT_INTERP, PippHashTable *ht, STRING *key)
key
,
return 1.
Otherwise return 0.void pipp_hash_delete(PARROT_INTERP, PippHashTable *ht, STRING *key)
key
,
it is deleted.
If there's no matching bucket,
nothing happens.PippBucket *pipp_hash_push(PARROT_INTERP, PippHashTable *ht, PMC *p_val)
p_val
to the PippHash.
Its index will be determined by the value of ht->nextIndex.
Pushing onto a PippHash does *not* affect internalPointer.PMC *pipp_hash_pop(PARROT_INTERP, PippHashTable *ht)
PippBucket *pipp_hash_unshift(PARROT_INTERP, PippHashTable *ht, PMC *p_val)
p_val
to the PippHash.
Its index will be 0 and all other numerically indexed elements will be renumbered according to insertion order.
Unshifting also points internalPointer at the first element.PMC *pipp_hash_shift(PARROT_INTERP, PippHashTable *ht)
void pipp_hash_visit(PARROT_INTERP, PippHashTable *ht, visit_info *info)
void pipp_hash_freeze(PARROT_INTERP, PippHashTable *ht, visit_info *info)
info
.void pipp_hash_thaw(PARROT_INTERP, PippHashTable *ht, visit_info *info)
info
.PippIsInt *pipp_hash_get_intval(PARROT_INTERP, STRING *key)
s
looks like an INTVAL (i.e.
/^([-]?[1-9][0-9]|0)*$/) and doesn't cause an overflow,
return a PippIsInt where p-
intval> contains the INTVAL and p-
isInt> is true.
Otherwise,
return a PippIsInt where p-
isInt> is false and p-
intval> is undefined.
|