Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-10 - 43,50523/his0.fr
There are no other files named his0.fr in the archive.
N OF THE ELEMENTS.
C
2	IF(NSEL.GE.MIN) GO TO 6
	KSI=N*RAN(Z)+1
	CALL INSERT(KSI,IA,M,IFREE,NSEL)
	GO TO 2
C
C  DEPACK THE OVERFLOW CHAINS AND LEAVE THE NODES NEGATIVE.
C
6	DO 5 KR=1,M
	IF(IA(KR).LE.0) GO TO 5
	I=KR; KK=KR
3	IZ=IABS(IA(I)); KQA=(IZ-1)/M; KRA=IZ-KQA*M
	IA(I)=-(KQA*M+KK)+1
	IF(KR.EQ.KRA) GO TO 5
	I=KRA; GO TO 3
5	CONTINUE
C
C  IF MIN WAS N-M, THE COMPLEMENTARY SAMPLE MUST BE TRANSFORMED
C  INTO A SAMPLE OF M ELEMENTS.
C
	IF(MIN.EQ.M) GO TO 30
C
C  DETERMINE THE ELEMENTS TO BE TAKEN INTO THE SAMPLE.
C
	DO 12 I=1,M
	J=-IA(I)
	IF(J.LE.0) GO TO 12
	IA(I)=0
10	
C  HASH TABLE (IA(I),I=1,M). IF A MATCHING NODE IS NOT FOUND
C  A NEW ONE WITH THIS KEY IS INSERTED. THE NUMBER OF THE
C  NODES IN THE HASH TABLE (NSEL) IS ALSO UPDATED. THE HASH TABLE
C  SHOULD BE INITIALIZED TO CONTAIN ZEROES AND THE POINTER TO THE
C  FIRST FREE NODE (IFREE) SHOULD BE INITIALIZES TO ONE.
C
	DIMENSION IA(1)
	KQ=KSI/M; KR=KSI+1-KQ*M
	IF(IA(KR).EQ.0) 1,2
C
C  THE HOME ADDRESS IS EMPTY, INSERT THERE.
C
1	IA(KR)=KSI+1; NSEL=NSEL+1
	RETURN
2	I=KR
	IF(IA(I).GT.0) 9,6
C
C  AN OVERFLOW CHAIN STARTS AT THE HOME ADDRESS. SEARCH FOR A 
C  NODE WITH THE SAME KEY.
C
9	IZ=IABS(IA(I)); KQA=(IZ-1)/M; KRA=IZ-KQA*M
C
C  IF AN EQUAL NODE IS FOUND, RETURN TO THE CALLER.
C
	IF(KQ.EQ.KQA) RETURN
	I=KRA
	IF(I.NE.KR) GO TO 9
C
C  A MATCHING NODE IS NOT FOUND. INSERT A NEW ONE INTO THE 
C  OVERFLOW CHAIN.
C
	IZ=IA(KR); KQA=(IZ-1)/M; KRA=IZ-KQA*M
11	IF(IA(IFREE).EQ.0) GO TO 12
	IFREE=IFREE+1; GO TO 11
12	IA(KR)=KQA*M+IFREE
	IA(IFREE)=-(KQ*M+KRA)
	NSEL=NSEL+1
	RETURN
C
C  THE HOME ADDRESS CONTAINS AN OVERFLOW NODE OF ANOTHER
C  OVERFLOW CHAIN. SEARCH FOR ITS PRECEDESSOR NODE.
C
6	IZ=IABS(IA(I)); KQA=(IZ-1)/M; KRA=IZ-KQA*M
	IF(KRA.EQ.KR) GO TO 5
	I=KRA; GO TO 6
C
C   MOVE THE COLLISION NODE TO ANOTER PLACE AND STORE KSI INTO THE
C  HOME ADDRESS.
C
5	IF(IA(IFREE).EQ.0) GO TO 10
	IFREE=IFREE+1; GO TO 5
10	IA(IFREE)=IA(KR)
	J=1; IF(IA(I).LT.0) J=-1
	IA(I)=J*(KQA*M+IFREE)
	IA(KR)=KSI+1; NSEL=NSEL+1
	RETURN
	END


C
C  A SAMPLE MAIN PROGRAM.
C
	DIMENSION IA(5000)
	N=10
	M=1
	CALL HTRY(M,N,IA)
	TYPE *,(IA(I),I=1,M)
	END