UXBagEntry
UXBagEntry is one row of a UXBag: a member,
and how many occurrences of it the bag holds.
#use <UXKit> // or #import "UXBag.xc"Overview
Section titled “Overview”class UXBagEntry : Object { Object* obj; // the member, compared by identity i32 count; // how many occurrences; never stored at zero}You do not create one. add creates it, and
remove discards it when the count reaches
zero.
The zero invariant
Section titled “The zero invariant”A bag never holds an entry whose count is zero: the entry is removed as soon as
its count would reach zero. For that reason
contains only checks whether an entry
exists, and uniqueCount is the number of entries.
Any entry you hold has a count of at least one.
Reading one
Section titled “Reading one”countFor answers the usual question
without a null check, and memberAt /
countAt walk the entries by index. The
entry itself is reachable through
entryFor, which returns null for a
non-member.
obj is a strong reference
Section titled “obj is a strong reference”The bag keeps its members alive. A tally needs this: a histogram whose entries vanished when the rest of the program released them would count wrong.
A bag you never empty holds everything it was ever given, so call
removeAll on a tally you are done
with.
Fields
Section titled “Fields”Object* objThe member. Compared with ==, so two equal-looking objects are two members
(see identity).
i32 countOccurrences. At least one for as long as the entry exists.
Conforms to
Section titled “Conforms to”- Inherits
Object
See also
Section titled “See also”UXBag: the bag these belong toUXCacheEntry: the same one-row-of-a-collection shape, keyed rather than counted