4.7.1 Introduction
Often one needs to store a collection of ids so that the can be grouped together and maybe ordered. Sets provide a global service for creating, accessing, and modifying persistant, ordered, groups of ids.
4.7.2 Set
The most basic of sets, the set provides the following methods:
- hasNext() - True if there are more items in the Set.
- next() - Returns the next Item in the Set.
- reset() - Resets the internal pointer in the Set to the first Item.
- addItem($id) - Add an Id object to the Set.
- removeItem($id) - Remove the specified Id from the Set.
- remvoeAllItems() - Remove all Items from the Set.
- isInSet($id) - Returns TRUE if the specified Id is in the Set.
- count() - Return the number of items in the Set.
4.7.3 OrderedSet
In addition to the methods of the Set class, the OrderedSet provides the following methods:
- moveUp($id) - Move the specified Id toward the begining of the Set.
- moveDown($id) - Move the specified Id toward the end of the Set.
- moveToPosition($id, $position) - Move the specified Id to the specified position. (The first item is at position "0".)
- getPostion($id) - Get the position of the specified Id (The first item is at position "0".)
4.7.4 SetManager
The SetManager service provides a global way to access Sets as well as a place to cache created Set objects so that references can be passed out to each instead of re-instatiating them. As well, the SetManager stores the database index for the database in which the Sets are stored, so that this configuration does not need to be maintained by the application.