Within the asdk.algorithm package there are several classes that enable filtering, copying, and filling various collection objects. Full treatment of these APIs is given in the Algorithms section of the user guide. This quick start tutorial focuses on the filtering algorithm which provides a means of controlling collection content based on a specific condition. This is accomplished using with Filtering class that ships with ASDK and provides functions for excluding items, including items, and maintaining uniqueness within collections.
Below is an example of how to use the Filtering class to include or exclude elements from a Collection as well as filter out any duplicate items:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
var groceryCart:asdk.Collection = new asdk.ArrayList(); |
Note that on line 7 a unary condition object is created (discussed in the next section). That object is passed to the include and exclude methods of Filtering as a way to obtain a list that contains only oranges or everything but oranges respectively (lines 9 and 12). Note that the unique method call on line 15 removes any duplicate entries from the list. Other helpful algorithms are discussed in more detail in the Algorithms section of the user guide.