VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/ds/nsIArray.idl@ 44770

最後變更 在這個檔案從44770是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.4 KB
 
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
4 *
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/
9 *
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.
14 *
15 * The Original Code is XPCOM Array interface.
16 *
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.
21 *
22 * Contributor(s):
23 * Alec Flett <[email protected]>
24 *
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.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39#include "nsISupports.idl"
40
41interface nsISimpleEnumerator;
42
43/**
44 * nsIArray
45 *
46 * An indexed collection of elements. Provides basic functionality for
47 * retrieving elements at a specific position, searching for
48 * elements. Indexes are zero-based, such that the last element in the
49 * array is stored at the index length-1.
50 *
51 * For an array which can be modified, see nsIMutableArray below.
52 *
53 * Neither interface makes any attempt to protect the individual
54 * elements from modification. The convention is that the elements of
55 * the array should not be modified. Documentation within a specific
56 * interface should describe variations from this convention.
57 *
58 * It is also convention that if an interface provides access to an
59 * nsIArray, that the array should not be QueryInterfaced to an
60 * nsIMutableArray for modification. If the interface in question had
61 * intended the array to be modified, it would have returned an
62 * nsIMutableArray!
63 *
64 * null is a valid entry in the array, and as such any nsISupports
65 * parameters may be null, except where noted.
66 *
67 * @status UNDER_REVIEW
68 */
69[scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)]
70interface nsIArray : nsISupports
71{
72 /**
73 * length
74 *
75 * number of elements in the array.
76 */
77 readonly attribute unsigned long length;
78
79 /**
80 * queryElementAt()
81 *
82 * Retrieve a specific element of the array, and QueryInterface it
83 * to the specified interface. null is a valid result for
84 * this method, but exceptions are thrown in other circumstances
85 *
86 * @param index position of element
87 * @param uuid the IID of the requested interface
88 * @param result the object, QI'd to the requested interface
89 *
90 * @throws NS_ERROR_NO_INTERFACE when an entry exists at the
91 * specified index, but the requested interface is not
92 * available.
93 * @throws NS_ERROR_ILLEGAL_VALUE when index > length-1
94 *
95 */
96 void queryElementAt(in unsigned long index,
97 in nsIIDRef uuid,
98 [iid_is(uuid), retval] out nsQIResult result);
99
100 /**
101 * indexOf()
102 *
103 * Get the position of a specific element. Note that since null is
104 * a valid input, exceptions are used to indicate that an element
105 * is not found.
106 *
107 * @param startIndex The initial element to search in the array
108 * To start at the beginning, use 0 as the
109 * startIndex
110 * @param element The element you are looking for
111 * @returns a number >= startIndex which is the position of the
112 * element in the array.
113 * @throws NS_ERROR_NOT_FOUND if the element was not in the array.
114 */
115 unsigned long indexOf(in unsigned long startIndex,
116 in nsISupports element);
117
118 /**
119 * enumerate the array
120 *
121 * @returns a new enumerator positioned at the start of the array
122 * @throws NS_ERROR_FAILURE if the array is empty (to make it easy
123 * to detect errors)
124 */
125 nsISimpleEnumerator enumerate();
126
127};
128
129/**
130 * nsIMutableArray
131 * A separate set of methods that will act on the array. Consumers of
132 * nsIArray should not QueryInterface to nsIMutableArray unless they
133 * own the array.
134 *
135 * As above, it is legal to add null elements to the array. Note also
136 * that null elements can be created as a side effect of
137 * insertElementAt(). Conversely, if insertElementAt() is never used,
138 * and null elements are never explicitly added to the array, then it
139 * is guaranteed that queryElementAt() will never return a null value.
140 *
141 * Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
142 * array must grow to complete the call, but the allocation fails.
143 *
144 * @status UNDER_REVIEW
145 */
146
147[scriptable, uuid(2cd0b2f8-d4dd-48b8-87ba-b0200501f079)]
148interface nsIMutableArray : nsIArray
149{
150 /**
151 * appendElement()
152 *
153 * Append an element at the end of the array.
154 *
155 * @param element The element to append.
156 * @param element Whether or not to store the element using a weak
157 * reference.
158 * @throws NS_ERROR_UNEXPECTED when a weak reference is requested,
159 * but the element does not support
160 * nsIWeakReference.
161 */
162 void appendElement(in nsISupports element, in boolean weak);
163
164 /**
165 * removeElementAt()
166 *
167 * Remove an element at a specific position.
168 * To remove a specific element, use indexOf() to find the index
169 * first, then call removeElementAt().
170 *
171 * @param index the position of the item
172 *
173 */
174 void removeElementAt(in unsigned long index);
175
176 /**
177 * insertElementAt()
178 *
179 * Insert an element at the given position, and move all elements
180 * stored at a higher position up one.
181 *
182 * @param element The element to insert
183 * @param index The position in the array. If the position is
184 * greater than or equal to the length of the array
185 * (@see nsIArray) then the array will grow to
186 * exactly accomadate the index, and the new length
187 * will be index+1. The newly created entries will
188 * be null.
189 *
190 * @throws NS_ERROR_FAILURE when a weak reference is requested,
191 * but the element does not support
192 * nsIWeakReference.
193 */
194 void insertElementAt(in nsISupports element, in unsigned long index, in boolean weak);
195
196 /**
197 * clear()
198 *
199 * clear the entire array, releasing all stored objects
200 */
201 void clear();
202};
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette