Several more are
described in the library documentation.
302 Modeling Library Reference
Count
Returns the number of elements in the value array.
IsEmpty
Returns true if the value array has no elements. Returns false otherwise.
Item(int)
Length
etc. . . .
A.2.6 Bag
Bag
An unordered collection of possibly repeating elements. This is also known as a
multiset. The type is immutable; add/remove methods return a new bag.
Syntax
public sealed class Bag : CollectionValue
Constructors
Bag()
Constructs an empty bag. The static field Bag.EmptyBag is preferred instead
of using this form of the constructor.
Bag(IEnumerable)
Constructs a bag with elements taken from a collection. The Count of the resulting
bag will be the same as the number of values in the collection given as the
argument.
Bag(T[])
Constructs a bag with elements given as params arguments. The Count of the
bag will be the same as the number of arguments to the constructor.
Bag(IEnumerable>)
Constructs a bag with elements and their corresponding multiplicities given as
a pair enumeration.
Bag(Pair[])
Constructs a bag with params arguments that are pairs of elements and their
corresponding multiplicities.
Methods
The following entries describe some of the methods of this type. Many more are
described in the library documentation.
Pages:
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391