Skip to content

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"
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.

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.

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.

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.

Object* obj

The member. Compared with ==, so two equal-looking objects are two members (see identity).

i32 count

Occurrences. At least one for as long as the entry exists.

  • UXBag: the bag these belong to
  • UXCacheEntry: the same one-row-of-a-collection shape, keyed rather than counted