hashmset
Multiset data structure
Calling Sequence
Parameters
Description
Examples
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 )
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
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 v,m, 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.
s≔hashmset:-new⁡a,2,b,3:
hashmset:-entries⁡s
b,3,a,2
hashmset:-members⁡s
a,b
hashmset:-empty⁡s
false
hashmset:-insert⁡a=2,s
4
b,3,a,4
hashmset:-insert⁡c=2,s
2
b,3,a,4,c,2
hashmset:-remove⁡a=3,s
b,3,a,1,c,2
t≔hashmset:-new⁡a=2,b=4,c=3,d=1:
usehashmsetins⊆t;entries⁡s∩t;entries⁡s∪t;entries⁡t∖send use
b,1,a,1,d,1,c,1
entries⁡hashmset:-symdif⁡s,t
1,1,1,1
See Also
convert/multiset
DEQueue
Long Form Names
priqueue
use
Download Help Document