/usr/share/axiom-20170501/src/algebra/TBCMPPK.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | )abbrev package TBCMPPK TabulatedComputationPackage
++ Author: Marc Moreno Maza
++ Date Created: 09/09/1998
++ Date Last Updated: 12/16/1998
++ Description:
++ \axiom{TabulatedComputationPackage(Key ,Entry)} provides some modest support
++ for dealing with operations with type \axiom{Key -> Entry}. The result of
++ such operations can be stored and retrieved with this package by using
++ a hash-table. The user does not need to worry about the management of
++ this hash-table. However, onnly one hash-table is built by calling
++ \axiom{TabulatedComputationPackage(Key ,Entry)}.
TabulatedComputationPackage(Key ,Entry) : SIG == CODE where
Key : SetCategory
Entry : SetCategory
N ==> NonNegativeInteger
H ==> HashTable(Key, Entry, "UEQUAL")
iprintpack ==> InternalPrintPackage()
SIG ==> with
initTable! : () -> Void
++ \axiom{initTable!()} initializes the hash-table.
printInfo! : (String, String) -> Void
++ \axiom{printInfo!(x,y)} initializes the mesages to be printed
++ when manipulating items from the hash-table. If
++ a key is retrieved then \axiom{x} is displayed. If an item is
++ stored then \axiom{y} is displayed.
startStats! : (String) -> Void
++ \axiom{startStats!(x)} initializes the statisitics process and
++ sets the comments to display when statistics are printed
printStats! : () -> Void
++ \axiom{printStats!()} prints the statistics.
clearTable! : () -> Void
++ \axiom{clearTable!()} clears the hash-table and assumes that
++ it will no longer be used.
usingTable? : () -> Boolean
++ \axiom{usingTable?()} returns true iff the hash-table is used
printingInfo? : () -> Boolean
++ \axiom{printingInfo?()} returns true iff messages are printed
++ when manipulating items from the hash-table.
makingStats? : () -> Boolean
++ \axiom{makingStats?()} returns true iff the statisitics process
++ is running.
extractIfCan : Key -> Union(Entry,"failed")
++ \axiom{extractIfCan(x)} searches the item whose key is \axiom{x}.
insert! : (Key, Entry) -> Void
++ \axiom{insert!(x,y)} stores the item whose key is \axiom{x} and whose
++ entry is \axiom{y}.
CODE ==> add
table?: Boolean := false
t: H := empty()
info?: Boolean := false
stats?: Boolean := false
used: NonNegativeInteger := 0
ok: String := "o"
ko: String := "+"
domainName: String := empty()$String
initTable!(): Void ==
table? := true
t := empty()
void()
printInfo!(s1: String, s2: String): Void ==
(empty? s1) or (empty? s2) => void()
not usingTable? =>
error "in printInfo!()$TBCMPPK: not allowed to use hashtable"
info? := true
ok := s1
ko := s2
void()
startStats!(s: String): Void ==
empty? s => void()
not table? =>
error "in startStats!()$TBCMPPK: not allowed to use hashtable"
stats? := true
used := 0
domainName := s
void()
printStats!(): Void ==
not table? =>
error "in printStats!()$TBCMPPK: not allowed to use hashtable"
not stats? =>
error "in printStats!()$TBCMPPK: statistics not started"
output(" ")$OutputPackage
title: String := concat("*** ", concat(domainName," Statistics ***"))
output(title)$OutputPackage
n: N := #t
output(" Table size: ", n::OutputForm)$OutputPackage
output(" Entries reused: ", used::OutputForm)$OutputPackage
clearTable!(): Void ==
not table? =>
error "in clearTable!()$TBCMPPK: not allowed to use hashtable"
t := empty()
table? := false
info? := false
stats? := false
domainName := empty()$String
void()
usingTable?() == table?
printingInfo?() == info?
makingStats?() == stats?
extractIfCan(k: Key): Union(Entry,"failed") ==
not table? => "failed" :: Union(Entry,"failed")
s: Union(Entry,"failed") := search(k,t)
s case Entry =>
if info? then iprint(ok)$iprintpack
if stats? then used := used + 1
return s
"failed" :: Union(Entry,"failed")
insert!(k: Key, e:Entry): Void ==
not table? => void()
t.k := e
if info? then iprint(ko)$iprintpack
void()
|