 hashmset - Maple Help

hashmset

Multiset data structure Calling Sequence hashmset[new]( v1 = m1, v2 = m2, ..., vk = mk ) hashmset[new]( [ v1, m1 ], [ v2, m2 ], ..., [ vk, mk ] ) hashmset[empty]( s ) hashmset[entries]( s ) hashmset[members]( s ) hashmset[insert]( v, m, s ) hashmset[insert]( v = m, s ) hashmset[remove]( v = m, s ) hashmset[remove]( v, m, s ) hashmset[subset]( s, t ) hashmset[intersect]( s, t ) hashmset[union]( s, t ) hashmset[minus]( s, t ) hashmset[symdif]( s, t ) Parameters

 v, v1, v2, ..., vk - anything; values to be inserted into, or removed from, the multiset m, m1, m2, ..., mk - posint; multiplicities of corresponding values s, t - name; multiset Description

 • Important: The hashmset package has been deprecated. Use the superseding package MultiSet instead.
 • The hashmset package provides an implementation of multisets. A multiset is an unordered collection of objects, in which objects can appear more than once. The number of occurrences of an object in a multiset is called its multiplicity''.
 • The new command returns a new multiset with the specified values and multiplicities. If called with no arguments, the returned multiset is empty.
 • The empty command tests whether s is an empty multiset. If the multiset s is empty, the empty function returns true. Otherwise, it returns false.
 • The entries command returns a list of pairs of the form $\left[v,m\right]$, in which v is an expression in the multiset s, and m is its multiplicity.
 • The members command returns the set of expressions that appear in the multiset s. It does not return information about their respective multiplicities.
 • The insert command adds a new element v to the multiset s or, if v is an element in s, increases the multiplicity of v in s. The multiplicity of v in s increases by the positive integer m.
 • The remove command deletes an element v from the multiset s, or, if m is less than the multiplicity of v in s, reduces the multiplicity of v in s. The multiplicity of v is reduced by the positive integer m.
 • The subset operator tests whether the multiset s (its first argument) is a proper sub-multiset of the multiset t (its second argument).
 • The intersect operator computes the intersection of the multisets s and t.
 • The union operator computes the union -- as multisets -- of s and t.
 • The symdif command computes the symmetric difference of s and t.
 • The minus operator computes the multiset difference of s and t.
 • Because many hashmset export names (functions and operators) match global function and operator names, it is recommended that you use the long form of the hashmset package names, for example, hashmset[export_name] or hashmset:-export_name. Examples

Important: The hashmset package has been deprecated. Use the superseding package MultiSet instead.

 > $s≔\mathrm{hashmset}:-\mathrm{new}\left(\left[a,2\right],\left[b,3\right]\right):$
 > $\mathrm{hashmset}:-\mathrm{entries}\left(s\right)$
 $\left[\left[{b}{,}{3}\right]{,}\left[{a}{,}{2}\right]\right]$ (1)
 > $\mathrm{hashmset}:-\mathrm{members}\left(s\right)$
 $\left\{{a}{,}{b}\right\}$ (2)
 > $\mathrm{hashmset}:-\mathrm{empty}\left(s\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{hashmset}:-\mathrm{insert}\left(a=2,s\right)$
 ${4}$ (4)
 > $\mathrm{hashmset}:-\mathrm{entries}\left(s\right)$
 $\left[\left[{b}{,}{3}\right]{,}\left[{a}{,}{4}\right]\right]$ (5)
 > $\mathrm{hashmset}:-\mathrm{insert}\left(c=2,s\right)$
 ${2}$ (6)
 > $\mathrm{hashmset}:-\mathrm{entries}\left(s\right)$
 $\left[\left[{b}{,}{3}\right]{,}\left[{a}{,}{4}\right]{,}\left[{c}{,}{2}\right]\right]$ (7)
 > $\mathrm{hashmset}:-\mathrm{remove}\left(a=3,s\right)$
 > $\mathrm{hashmset}:-\mathrm{entries}\left(s\right)$
 $\left[\left[{b}{,}{3}\right]{,}\left[{a}{,}{1}\right]{,}\left[{c}{,}{2}\right]\right]$ (8)
 > $t≔\mathrm{hashmset}:-\mathrm{new}\left(a=2,b=4,c=3,d=1\right):$
 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{hashmset}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}s⊆t;\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{entries}\left(s\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∩\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}t\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{entries}\left(s\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∪\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}t\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{entries}\left(t∖s\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}$
 $\left[\left[{b}{,}{1}\right]{,}\left[{a}{,}{1}\right]{,}\left[{c}{,}{1}\right]{,}\left[{d}{,}{1}\right]\right]$ (9)
 > $\mathrm{entries}\left(\mathrm{hashmset}:-\mathrm{symdif}\left(s,t\right)\right)$
 $\left[{1}\right]{,}\left[{1}\right]{,}\left[{1}\right]{,}\left[{1}\right]$ (10)