annotate lisp/oobr/hash-test.el @ 167:85ec50267440 r20-3b10

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