2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('arraylist-add', function (Y, NAME) {
11 * Collection utilities beyond what is provided in the YUI core
13 * @submodule arraylist-add
14 * @deprecated Use ModelList or a custom ArrayList subclass
18 * Adds methods add and remove to Y.ArrayList
20 Y.mix(Y.ArrayList.prototype, {
23 * Add a single item to the ArrayList. Does not prevent duplicates.
26 * @param { mixed } item Item presumably of the same type as others in the
28 * @param {Number} index (Optional.) Number representing the position at
29 * which the item should be inserted.
30 * @return {ArrayList} the instance.
32 * @deprecated Use ModelList or a custom ArrayList subclass
35 add: function(item, index) {
36 var items = this._items;
38 if (Y.Lang.isNumber(index)) {
39 items.splice(index, 0, item);
49 * Removes first or all occurrences of an item to the ArrayList. If a
50 * comparator is not provided, uses itemsAreEqual method to determine
54 * @param { mixed } needle Item to find and remove from the list.
55 * @param { Boolean } all If true, remove all occurrences.
56 * @param { Function } comparator optional a/b function to test equivalence.
57 * @return {ArrayList} the instance.
59 * @deprecated Use ModelList or a custom ArrayList subclass
62 remove: function(needle, all, comparator) {
63 comparator = comparator || this.itemsAreEqual;
65 for (var i = this._items.length - 1; i >= 0; --i) {
66 if (comparator.call(this, needle, this.item(i))) {
67 this._items.splice(i, 1);
78 * Default comparator for items stored in this list. Used by remove().
80 * @method itemsAreEqual
81 * @param { mixed } a item to test equivalence with.
82 * @param { mixed } b other item to test equivalance.
83 * @return { Boolean } true if items are deemed equivalent.
85 * @deprecated Use ModelList or a custom ArrayList subclass
87 itemsAreEqual: function(a, b) {
94 }, '3.13.0', {"requires": ["arraylist"]});