forked from Krowemoh/TCL-Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAP.DELETE
49 lines (49 loc) · 877 Bytes
/
MAP.DELETE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
SUBROUTINE MAP.DELET(MAT MAP,SIZE,KEY)
*
GIT.FILENAME = 'MAP.DELETE'
GIT.REPO = 'https://github.com/Krowemoh/TCL-Utilities.git'
*
* VERSION
*
VERSION = '1'
*
@USER1 = 'MAP.DELETE'
@USER2 = 'MAP.DELETE'
*
KEY.LEN = LEN(KEY)
*
HASH = 5381
*
FOR I = 1 TO KEY.LEN
C = KEY[I,1]
*
* HASH = HASH * 33 + C
*
HASH = SADD(SMUL(HASH,33),SEQ(C))
NEXT I
*
* POS = HASH - (INT(HASH / SIZE) * HASH)
*
D = SDIV(HASH,SIZE)
E = INDEX(D,'.',1)
*
IF E = 0 THEN E = LEN(D)
*
DIVISION = D[1,E]
MULTIPLE = SMUL(DIVISION,SIZE)
POS = SSUB(HASH,MULTIPLE) + 1
*
LOCATE(KEY,MAP(POS)<1>,1,1;ANYPOS) THEN
KEYS = MAP(POS)<1,1>
VALUES = MAP(POS)<1,2>
*
MAP(POS)<1,1> = DELETE(KEYS<1>,1,1,ANYPOS)
MAP(POS)<1,2> = DELETE(VALUES<1>,1,1,ANYPOS)
END
*
RETURN
*
* END OF PROGRAM
*
END
*