1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsIArrayExtensions.idl"
10 * A separate set of methods that will act on the array. Consumers of
11 * nsIArray should not QueryInterface to nsIMutableArray unless they
14 * As above, it is legal to add null elements to the array. Note also
15 * that null elements can be created as a side effect of
16 * insertElementAt(). Conversely, if insertElementAt() is never used,
17 * and null elements are never explicitly added to the array, then it
18 * is guaranteed that queryElementAt() will never return a null value.
20 * Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
21 * array must grow to complete the call, but the allocation fails.
23 [scriptable
, uuid(af059da0
-c85b
-40ec
-af07
-ae4bfdc192cc
)]
24 interface nsIMutableArray
: nsIArrayExtensions
29 * Append an element at the end of the array.
31 * @param element The element to append.
33 void appendElement
(in nsISupports element
);
38 * Remove an element at a specific position, moving all elements
39 * stored at a higher position down one.
40 * To remove a specific element, use indexOf() to find the index
41 * first, then call removeElementAt().
43 * @param index the position of the item
46 void removeElementAt
(in unsigned long index
);
51 * Insert an element at the given position, moving the element
52 * currently located in that position, and all elements in higher
53 * position, up by one.
55 * @param element The element to insert
56 * @param index The position in the array:
57 * If the position is lower than the current length
58 * of the array, the elements at that position and
59 * onwards are bumped one position up.
60 * If the position is equal to the current length
61 * of the array, the new element is appended.
62 * An index lower than 0 or higher than the current
63 * length of the array is invalid and will be ignored.
65 void insertElementAt
(in nsISupports element
, in unsigned long index
);
70 * Replace the element at the given position.
72 * @param element The new element to insert
73 * @param index The position in the array
74 * If the position is lower than the current length
75 * of the array, an existing element will be replaced.
76 * If the position is equal to the current length
77 * of the array, the new element is appended.
78 * If the position is higher than the current length
79 * of the array, empty elements are appended followed
80 * by the new element at the specified position.
81 * An index lower than 0 is invalid and will be ignored.
83 void replaceElementAt
(in nsISupports element
, in unsigned long index
);
89 * clear the entire array, releasing all stored objects