Indexes are used when replacing or removing existing data items from a bag. There are
three types of indexing, which allows data items to be retrieved easily.
Each selector and value
within a data item in a bag have three associated index numbers:
The index relative to other items that have the same selector.
The index relative to the category of selector (user or system) to which the item belongs.
The index relative to all the data items in the bag (user and system).
This allows indexing by user selectors, system selectors, or both as shown in Figure 1.Figure 1. Indexing
In Figure 1, user item 3 (selector A) can be referred to by the
following index pairs:
selector A (ItemIndex 1)
MQSEL_ANY_USER_SELECTOR (ItemIndex 2)
MQSEL_ANY_SELECTOR (itemIndex 3)
The index is zero-based like an array in C; if there are 'n' occurrences, the index ranges from
zero through 'n-1', with no gaps.
Indexes are used when replacing or removing existing data items from a bag. When used in this
way, the insertion order is preserved, but indexes of other data items can be affected. For examples
of this, see Change information
within a bag and Delete data
items.
The three types of indexing allow easy retrieval of data items. For example, if there are three
instances of a particular selector in a bag, the mqCountItems call can count the number of instances
of that selector, and the mqInquire* calls can specify both the selector and the index to inquire
those values only. This is useful for attributes that can have a list of values such as some of the
exits on channels.