globle void *FindHashedPatternNode( void *theEnv, EXEC_STATUS, void *parent, unsigned short keyType, void *keyValue) { unsigned long hashValue; struct patternNodeHashEntry *hptr; hashValue = GetAtomicHashValue(keyType,keyValue,1) + HashExternalAddress(parent,0); /* TBD mult * 30 */ hashValue = (hashValue % PatternData(theEnv,execStatus)->PatternHashTableSize); for (hptr = PatternData(theEnv,execStatus)->PatternHashTable[hashValue]; hptr != NULL; hptr = hptr->next) { if ((hptr->parent == parent) && (keyType == hptr->type) && (keyValue == hptr->value)) { return(hptr->child); } } return(NULL); }
globle void AddHashedPatternNode( void *theEnv, EXEC_STATUS, void *parent, void *child, unsigned short keyType, void *keyValue) { unsigned long hashValue; struct patternNodeHashEntry *newhash, *temp; hashValue = GetAtomicHashValue(keyType,keyValue,1) + HashExternalAddress(parent,0); /* TBD mult * 30 */ newhash = get_struct(theEnv,execStatus,patternNodeHashEntry); newhash->parent = parent; newhash->child = child; newhash->type = keyType; newhash->value = keyValue; hashValue = (hashValue % PatternData(theEnv,execStatus)->PatternHashTableSize); temp = PatternData(theEnv,execStatus)->PatternHashTable[hashValue]; PatternData(theEnv,execStatus)->PatternHashTable[hashValue] = newhash; newhash->next = temp; }
unsigned long HashConstraint( struct constraintRecord *theConstraint) { unsigned short i = 0; unsigned long count = 0; unsigned long hashValue; struct expr *tmpPtr; count += (theConstraint->anyAllowed * 17) + (theConstraint->symbolsAllowed * 5) + (theConstraint->stringsAllowed * 23) + (theConstraint->floatsAllowed * 19) + (theConstraint->integersAllowed * 29) + (theConstraint->instanceNamesAllowed * 31) + (theConstraint->instanceAddressesAllowed * 17); count += (theConstraint->externalAddressesAllowed * 29) + (theConstraint->voidAllowed * 29) + (theConstraint->multifieldsAllowed * 29) + (theConstraint->factAddressesAllowed * 79) + (theConstraint->anyRestriction * 59) + (theConstraint->symbolRestriction * 61); count += (theConstraint->stringRestriction * 3) + (theConstraint->floatRestriction * 37) + (theConstraint->integerRestriction * 9) + (theConstraint->classRestriction * 11) + (theConstraint->instanceNameRestriction * 7); for (tmpPtr = theConstraint->classList; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } for (tmpPtr = theConstraint->restrictionList; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } for (tmpPtr = theConstraint->minValue; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } for (tmpPtr = theConstraint->maxValue; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } for (tmpPtr = theConstraint->minFields; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } for (tmpPtr = theConstraint->maxFields; tmpPtr != NULL; tmpPtr = tmpPtr->nextArg) { count += GetAtomicHashValue(tmpPtr->type,tmpPtr->value,i++); } if (theConstraint->multifield != NULL) { count += HashConstraint(theConstraint->multifield); } hashValue = count % SIZE_CONSTRAINT_HASH; return hashValue; }
globle intBool RemoveHashedPatternNode( void *theEnv, EXEC_STATUS, void *parent, void *child, unsigned short keyType, void *keyValue) { unsigned long hashValue; struct patternNodeHashEntry *hptr, *prev; hashValue = GetAtomicHashValue(keyType,keyValue,1) + HashExternalAddress(parent,0); /* TBD mult * 30 */ hashValue = (hashValue % PatternData(theEnv,execStatus)->PatternHashTableSize); for (hptr = PatternData(theEnv,execStatus)->PatternHashTable[hashValue], prev = NULL; hptr != NULL; hptr = hptr->next) { if (hptr->child == child) { if (prev == NULL) { PatternData(theEnv,execStatus)->PatternHashTable[hashValue] = hptr->next; rtn_struct(theEnv,execStatus,patternNodeHashEntry,hptr); return(1); } else { prev->next = hptr->next; rtn_struct(theEnv,execStatus,patternNodeHashEntry,hptr); return(1); } } prev = hptr; } return(0); }
bool RemoveHashedPatternNode( Environment *theEnv, void *parent, void *child, unsigned short keyType, void *keyValue) { size_t hashValue; struct patternNodeHashEntry *hptr, *prev; hashValue = GetAtomicHashValue(keyType,keyValue,1) + HashExternalAddress(parent,0); /* TBD mult * 30 */ hashValue = (hashValue % PatternData(theEnv)->PatternHashTableSize); for (hptr = PatternData(theEnv)->PatternHashTable[hashValue], prev = NULL; hptr != NULL; hptr = hptr->next) { if (hptr->child == child) { if (prev == NULL) { PatternData(theEnv)->PatternHashTable[hashValue] = hptr->next; rtn_struct(theEnv,patternNodeHashEntry,hptr); return true; } else { prev->next = hptr->next; rtn_struct(theEnv,patternNodeHashEntry,hptr); return true; } } prev = hptr; } return false; }
void *FindHashedPatternNode( Environment *theEnv, void *parent, unsigned short keyType, void *keyValue) { size_t hashValue; struct patternNodeHashEntry *hptr; hashValue = GetAtomicHashValue(keyType,keyValue,1) + HashExternalAddress(parent,0); /* TBD mult * 30 */ hashValue = (hashValue % PatternData(theEnv)->PatternHashTableSize); for (hptr = PatternData(theEnv)->PatternHashTable[hashValue]; hptr != NULL; hptr = hptr->next) { if ((hptr->parent == parent) && (keyType == hptr->type) && (keyValue == hptr->value)) { return(hptr->child); } } return NULL; }