Iteration of collections using cursors Having found the branch B003 object, we can
now use the relationship Has to iterate over the sales staff assigned to that branch (the
Has relationship was defined in Figure 27.19 as a collection, os_Set). The ObjectStore
collection facility provides a number of classes to help navigate within a collection.
In this example, we have used the cursor mechanism, which is used to designate
a position within a collection (similar to the SQL cursor mechanism discussed in
Appendix E.1.4). Cursors can be used to traverse collections, as well as to retrieve,
insert, remove, and replace elements. To find the sales staff at branch B003, we have
created an instance of the parameterized template class os_Cursor, c, using the collection
of sales staff that has been defined through the Has relationship, in this case aBranch-
>Has. We can then iterate over this collection using the cursor methods first (which
moves to the first element in the set), next (which moves to the next element in the set),
and more (which determines whether there are any other elements in the set).
Iteration of collections using cursors Having found the branch B003 object, we can
now use the relationship Has to iterate over the sales staff assigned to that branch (the
Has relationship was defined in Figure 27.19 as a collection, os_Set). The ObjectStore
collection facility provides a number of classes to help navigate within a collection.
In this example, we have used the cursor mechanism, which is used to designate
a position within a collection (similar to the SQL cursor mechanism discussed in
Appendix E.1.4). Cursors can be used to traverse collections, as well as to retrieve,
insert, remove, and replace elements. To find the sales staff at branch B003, we have
created an instance of the parameterized template class os_Cursor, c, using the collection
of sales staff that has been defined through the Has relationship, in this case aBranch-
>Has. We can then iterate over this collection using the cursor methods first (which
moves to the first element in the set), next (which moves to the next element in the set),
and more (which determines whether there are any other elements in the set).
การแปล กรุณารอสักครู่..