=========================================================================== BBS: The Abacus * HST/DS * Potterville MI Date: 03-22-93 (14:23) Number: 183 From: QUINN TYLER JACKSON Refer#: NONE To: CORIDON HENSHAW Recvd: NO Subj: Hashed NODELIST 2/ Conf: (35) Quick Basi --------------------------------------------------------------------------- >>> Continued from previous message ExitFunction: END FUNCTION FUNCTION fqjAdd2Kee$ (Zone, Net, Node, Pnt) fqjAdd2Kee$ = MKI$(Net) + MKI$(Node) + MKI$(Pnt) + MKI$(Zone) END FUNCTION FUNCTION fqjHashGet (Idx AS HashIdxType) Position = frgHashIdent(Idx, Offset) DO IF Position <> 0 THEN GET #HashHandle, Position, Buffer SELECT CASE Buffer.Kee CASE STRING$(8, 0)'If nothing found at expected position_ then the string 'is not in the dictionary. EXIT DO CASE IS = Idx.Kee 'Found the string. EXIT DO CASE ELSE 'The string was not in its expected position or another 'string shared the same position in the hash table '(a string collision). Retry by finding another ' position. Position = Position - Offset IF Position < 0 THEN Position = Position + MaxHash END SELECT ELSE EXIT DO END IF LOOP fqjHashGet = Position IF Position <> 0 THEN GET #HashHandle, Position, Idx END IF END FUNCTION 'This function hashs the passed string and returns information 'needed to locate it in the word dictionaries. FUNCTION frgHashIdent (Idx AS HashIdxType, Offset) ' This Kee generator added by Quinn Tyler Jackson. It is about as fast ' as what Rich had, but it more efficient and tighter. Position = ABS(CVL(Idx.Kee) MOD MaxHash) 'Calculate the retry offset of the position for collisions. IF Position = 0 THEN Position = 1 Offset = 1 ELSE Offset = MaxHash - Position END IF frgHashIdent = Position END FUNCTION ' This FUNCTION returns a prime number that is at least 30% greater than ' threshold. It will TRY to return a prime number that also fits into ' the ' form 4K+3, where k is any integer, but if the prime number is twice ' the ' size of the threshold, it will ignore this criterion. FUNCTION funFirstPrime (threshold) tp30 = INT((threshold * 1.3) + .5) IF tp30 / 2 = tp30 \ 2 THEN tp30 = tp30 + 1 END IF c = tp30 - 2 IF c < 1 THEN c = 1 END IF t2 = threshold * 2 DO c = c + 2 FOR z = 3 TO SQR(c) ind = TRUE IF c / z = c \ z THEN ind = FALSE EXIT FOR END IF NEXT z IF ind THEN IF (c - 3) / 4 = INT((c - 3) / 4) OR c > t2 THEN funFirstPrime = c EXIT DO END IF END IF LOOP END FUNCTION SUB ParseNodelist (NodeListFile AS STRING, ParsedListFile AS STRING) StartTime! = TIMER IF DIR$(ParsedListFile) <> "" THEN KILL ParsedListFile END IF '$STATIC DIM NodelistBuffer(0 TO 7) AS STRING * 50 DIM NodeList AS NodelistType DIM Bfr AS STRING * 256 DIM Idx AS IdxType DIM Hidx AS HashIdxType '$DYNAMIC BufferPtr = 0 NodeListHandle = FREEFILE OPEN NodeListFile FOR INPUT AS NodeListHandle LEN = 1024 sqjOpenHash ParsedListFile DO LINE INPUT #NodeListHandle, Bfr Options = BreakString(NodelistBuffer(), Bfr) SELECT CASE LEFT$(Bfr, 1) CASE "," Idx.Node = VAL(NodelistBuffer(1)) CASE "H" SELECT CASE LEFT$(Bfr, 3) CASE "Hos" Idx.Net = VAL(NodelistBuffer(1)) CASE "Hub" Idx.Node =_ VAL(NodelistBuffer(1)) >>> Continued to next message