Try to fix intermittent refcount assertions in the presence of more than one thread...
[mozilla-central.git] / xpcom / ds / nsIMutableArray.idl
bloba5773019688dd3784039891fdc2e182c062fca48
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is XPCOM Array interface.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Alec Flett <alecf@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsIArray.idl"
41 /**
42 * nsIMutableArray
43 * A separate set of methods that will act on the array. Consumers of
44 * nsIArray should not QueryInterface to nsIMutableArray unless they
45 * own the array.
47 * As above, it is legal to add null elements to the array. Note also
48 * that null elements can be created as a side effect of
49 * insertElementAt(). Conversely, if insertElementAt() is never used,
50 * and null elements are never explicitly added to the array, then it
51 * is guaranteed that queryElementAt() will never return a null value.
53 * Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
54 * array must grow to complete the call, but the allocation fails.
56 [scriptable, uuid(af059da0-c85b-40ec-af07-ae4bfdc192cc)]
57 interface nsIMutableArray : nsIArray
59 /**
60 * appendElement()
62 * Append an element at the end of the array.
64 * @param element The element to append.
65 * @param weak Whether or not to store the element using a weak
66 * reference.
67 * @throws NS_ERROR_FAILURE when a weak reference is requested,
68 * but the element does not support
69 * nsIWeakReference.
71 void appendElement(in nsISupports element, in boolean weak);
73 /**
74 * removeElementAt()
76 * Remove an element at a specific position, moving all elements
77 * stored at a higher position down one.
78 * To remove a specific element, use indexOf() to find the index
79 * first, then call removeElementAt().
81 * @param index the position of the item
84 void removeElementAt(in unsigned long index);
86 /**
87 * insertElementAt()
89 * Insert an element at the given position, moving the element
90 * currently located in that position, and all elements in higher
91 * position, up by one.
93 * @param element The element to insert
94 * @param index The position in the array:
95 * If the position is lower than the current length
96 * of the array, the elements at that position and
97 * onwards are bumped one position up.
98 * If the position is equal to the current length
99 * of the array, the new element is appended.
100 * An index lower than 0 or higher than the current
101 * length of the array is invalid and will be ignored.
103 * @throws NS_ERROR_FAILURE when a weak reference is requested,
104 * but the element does not support
105 * nsIWeakReference.
107 void insertElementAt(in nsISupports element, in unsigned long index,
108 in boolean weak);
111 * replaceElementAt()
113 * Replace the element at the given position.
115 * @param element The new element to insert
116 * @param index The position in the array
117 * If the position is lower than the current length
118 * of the array, an existing element will be replaced.
119 * If the position is equal to the current length
120 * of the array, the new element is appended.
121 * If the position is higher than the current length
122 * of the array, empty elements are appended followed
123 * by the new element at the specified position.
124 * An index lower than 0 is invalid and will be ignored.
126 * @param weak Whether or not to store the new element using a weak
127 * reference.
129 * @throws NS_ERROR_FAILURE when a weak reference is requested,
130 * but the element does not support
131 * nsIWeakReference.
133 void replaceElementAt(in nsISupports element, in unsigned long index,
134 in boolean weak);
138 * clear()
140 * clear the entire array, releasing all stored objects
142 void clear();