0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hash-test.el
|
|
4 ;; SUMMARY: Interactively test functions from hasht.el.
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: extensions, maint, tools
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
100
|
9 ;; ORG: InfoDock Associates
|
0
|
10 ;;
|
|
11 ;; ORIG-DATE: 16-Mar-90 at 03:38:48
|
100
|
12 ;; LAST-MOD: 20-Feb-97 at 07:04:19 by Bob Weiner
|
0
|
13 ;;
|
100
|
14 ;; Copyright (C) 1990-1995, 1997 Free Software Foundation, Inc.
|
0
|
15 ;; See the file BR-COPY for license information.
|
|
16 ;;
|
|
17 ;; This file is part of the OO-Browser.
|
|
18 ;;
|
|
19 ;; DESCRIPTION:
|
|
20 ;; DESCRIP-END.
|
|
21
|
|
22 (setq hs (hash-make '((("a1" "a2") . "a") (("b1" "b2") . "b") (("c1" "c2") . "c"))))
|
|
23 ; => (hasht . [a b c])
|
|
24
|
|
25 (setq cpy (hash-copy hs))
|
|
26 ; => (hasht . [a b c])
|
|
27 (eq hs cpy)
|
|
28 ; => nil
|
|
29 (equal hs cpy)
|
|
30 ; => t
|
|
31 (eq (hash-get "b" hs) (hash-get "b" cpy))
|
|
32 ; => t
|
|
33
|
|
34 (setq deep-cpy (hash-deep-copy hs))
|
|
35 ; => (hasht . [a b c])
|
|
36 (eq hs deep-cpy)
|
|
37 ; => nil
|
|
38 (equal hs deep-cpy)
|
|
39 ; => nil ;; Yes, this really should be nil since the symbols in the obarrays
|
|
40 ;; are not equal for some reason.
|
|
41 (eq (hash-get "b" hs) (hash-get "b" deep-cpy))
|
|
42 ; => nil
|
|
43
|
|
44 (hash-lookup "d" hs)
|
|
45 ; => nil
|
|
46
|
|
47 (hash-add '("d1" "d2") "d" hs)
|
|
48 ; => ("d1" "d2")
|
|
49
|
|
50 (hash-map 'car hs)
|
|
51 ; => (("a1" "a2") ("d1" "d2") ("b1" "b2") ("c1" "c2"))
|
|
52
|
|
53 (hash-delete "d" hs)
|
|
54 ; => d
|
|
55
|
|
56 (hash-map 'car hs)
|
|
57 ; => (("a1" "a2") ("b1" "b2") ("c1" "c2"))
|
|
58
|
|
59 (hash-key-p "a" hs)
|
|
60 ; => a
|
|
61
|
|
62 (hash-key-p "d" hs)
|
|
63 ; => nil
|
|
64
|
|
65 (hash-lookup "a" hs)
|
|
66 ; => ("a1" "a2")
|
|
67
|
|
68 (setq hs2 (hash-make '((("e1" "e2") . "e") (("f1" "f2") . "f"))))
|
|
69 ; => (hasht . [f e])
|
|
70
|
|
71 (setq hs3 (hash-merge hs hs2))
|
|
72 ; => (hasht . [0 e f b c])
|
|
73 (hash-lookup "e" hs3)
|
|
74 ; => ("e1" "e2")
|
|
75 (hash-lookup "b" hs3)
|
|
76 ; => ("b1" "b2")
|
|
77
|
|
78 (hash-make -3)
|
100
|
79 ; => (error ("(hash-make): Initializer must be >= 0, not `-3'"))
|
0
|
80
|
|
81 (hash-replace '("e11" "e22") "e" hs3)
|
|
82 ; => ("e11" "e22")
|
|
83 (hash-lookup "e" hs3)
|
|
84 ; => ("e11" "e22")
|
|
85
|
|
86 (setq hs3 (hash-resize hs3 11))
|
|
87 ; => (hasht . [0 0 a b c 0 e f 0 0 0])
|
|
88
|
|
89 (hash-lookup "c" hs3)
|
|
90 ; => ("c1" "c2")
|
|
91 (hash-lookup "e" hs3)
|
|
92 ; => ("e11" "e22")
|
|
93
|
|
94 (hash-count hs3)
|
|
95 ; => 5
|
|
96
|
|
97 (hash-prin1 hs3 (current-buffer))
|
|
98 ; => (
|
|
99 ; (("f1" "f2") . "f")
|
|
100 ; (("e11" "e22") . "e")
|
|
101 ; (("c1" "c2") . "c")
|
|
102 ; (("b1" "b2") . "b")
|
|
103 ; (("a1" "a2") . "a")
|
|
104 ; )
|
|
105
|
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
|
113
|