Skip to content

Commit

Permalink
Reflow, add Introduction header, fix some typoes
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed May 8, 2019
1 parent 2434c44 commit 99d9074
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions doc/Language/setbagmix.pod6
Expand Up @@ -4,22 +4,31 @@
=SUBTITLE Unordered collections of unique and weighted objects in Perl 6
=head1 Introduction
The six collection classes are L<Set|/type/Set>, L<SetHash|/typ[e/SetHash>,
L<Bag|/type/Bag>, L<BagHash|/type/BagHash>, L<Mix|/type/Mix> and
L<MixHash:/type/MixHash>. They all share similar semantics.
In a nutshell, these classes hold, in general, unordered collections of
objects, much like an L<object hash|hashmap#index-entry-object_hash>.
The L<QuantHash|/type/QuantHash> role is the role that is implemented by all
of these classes: therefore they are also referenced as C<QuantHash>es.
C<Set> and C<SetHash> also implement the L<Setty|/type/Setty> role,
C<Bag> and C<BagHash> implement the L<Baggy|/type/Baggy> role, C<Mix> and
C<MixHash> implement the L<Mixy|/type/Mixy> role (which itself implements
the C<Baggy> role).
Sets only consider if objects in the collection are present or not, bags can
hold several objects of the same kind, and mixes also allow fractional (and
negative) weights. The regular versions are immutable, the I<Hash> versions
are mutable.
Let's elaborate on that. If you want to collect objects in a container buti
you do not care about the order of these objects, Perl 6 provides the
I<unordered> collection types L<Set|/type/Set>,
L<SetHash|/type/SetHash>, L<Bag|/type/Bag>, L<BagHash|/type/BagHash>,
L<Mix|/type/Mix>, and L<MixHash|/type/MixHash>. Being unordered, these
containers can be more efficient than L<Lists|/type/List> for looking up
Let's elaborate on that. If you want to collect objects in a container but
you do not care about the order of these objects, Perl 6 provides these
I<unordered> collection types. Being unordered, these containers can be more
efficient than L<Lists|/type/List> or L<Arrays|/type/Array> for looking up
elements or dealing with repeated items.
On the other hand, if you want to get the contained objects (elements)
Expand Down Expand Up @@ -49,12 +58,6 @@ Use the mutable variants L<SetHash|/type/SetHash>, L<BagHash|/type/BagHash>,
and L<MixHash|/type/MixHash> if you want to add or remove elements after the
container has been constructed.
The six collection classes C<Set>, C<SetHash>, C<Bag>, C<BagHash>, C<Mix>,
C<MixHash>, all share similar semantics. C<Set> and C<SetHash> implement
the L<Setty|/type/Setty> role, C<Bag> and C<BagHash> implement the
L<Baggy|/type/Baggy> role, C<Mix> and C<MixHash> implement the
L<Mixy|/type/Mixy> role (which implements the C<Baggy> role).
For one thing, as far as they are concerned, identical objects refer to the
same element – where identity is determined using the L<WHICH|/routine/WHICH>
method (i.e. the same way that the L<===> operator checks identity). For value
Expand Down

0 comments on commit 99d9074

Please sign in to comment.