xpcom/ds/nsIMutableArray.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/ds/nsIMutableArray.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,110 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsIArray.idl"
    1.10 +
    1.11 +/**
    1.12 + * nsIMutableArray
    1.13 + * A separate set of methods that will act on the array. Consumers of
    1.14 + * nsIArray should not QueryInterface to nsIMutableArray unless they
    1.15 + * own the array.
    1.16 + *
    1.17 + * As above, it is legal to add null elements to the array. Note also
    1.18 + * that null elements can be created as a side effect of
    1.19 + * insertElementAt(). Conversely, if insertElementAt() is never used,
    1.20 + * and null elements are never explicitly added to the array, then it
    1.21 + * is guaranteed that queryElementAt() will never return a null value.
    1.22 + *
    1.23 + * Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
    1.24 + * array must grow to complete the call, but the allocation fails.
    1.25 + */
    1.26 +[scriptable, uuid(af059da0-c85b-40ec-af07-ae4bfdc192cc)]
    1.27 +interface nsIMutableArray : nsIArray
    1.28 +{
    1.29 +    /**
    1.30 +     * appendElement()
    1.31 +     * 
    1.32 +     * Append an element at the end of the array.
    1.33 +     *
    1.34 +     * @param element The element to append.
    1.35 +     * @param weak    Whether or not to store the element using a weak
    1.36 +     *                reference.
    1.37 +     * @throws NS_ERROR_FAILURE when a weak reference is requested,
    1.38 +     *                          but the element does not support
    1.39 +     *                          nsIWeakReference.
    1.40 +     */
    1.41 +    void appendElement(in nsISupports element, in boolean weak);
    1.42 +
    1.43 +    /**
    1.44 +     * removeElementAt()
    1.45 +     * 
    1.46 +     * Remove an element at a specific position, moving all elements
    1.47 +     * stored at a higher position down one.
    1.48 +     * To remove a specific element, use indexOf() to find the index
    1.49 +     * first, then call removeElementAt().
    1.50 +     *
    1.51 +     * @param index the position of the item
    1.52 +     *
    1.53 +     */
    1.54 +    void removeElementAt(in unsigned long index);
    1.55 +
    1.56 +    /**
    1.57 +     * insertElementAt()
    1.58 +     *
    1.59 +     * Insert an element at the given position, moving the element 
    1.60 +     * currently located in that position, and all elements in higher
    1.61 +     * position, up by one.
    1.62 +     *
    1.63 +     * @param element The element to insert
    1.64 +     * @param index   The position in the array:
    1.65 +     *                If the position is lower than the current length
    1.66 +     *                of the array, the elements at that position and
    1.67 +     *                onwards are bumped one position up.
    1.68 +     *                If the position is equal to the current length
    1.69 +     *                of the array, the new element is appended.
    1.70 +     *                An index lower than 0 or higher than the current
    1.71 +     *                length of the array is invalid and will be ignored.
    1.72 +     *
    1.73 +     * @throws NS_ERROR_FAILURE when a weak reference is requested,
    1.74 +     *                          but the element does not support
    1.75 +     *                          nsIWeakReference.
    1.76 +     */
    1.77 +    void insertElementAt(in nsISupports element, in unsigned long index,
    1.78 +                         in boolean weak);
    1.79 +
    1.80 +    /**
    1.81 +     * replaceElementAt()
    1.82 +     *
    1.83 +     * Replace the element at the given position.
    1.84 +     *
    1.85 +     * @param element The new element to insert
    1.86 +     * @param index   The position in the array
    1.87 +     *                If the position is lower than the current length
    1.88 +     *                of the array, an existing element will be replaced.
    1.89 +     *                If the position is equal to the current length
    1.90 +     *                of the array, the new element is appended.
    1.91 +     *                If the position is higher than the current length
    1.92 +     *                of the array, empty elements are appended followed
    1.93 +     *                by the new element at the specified position.
    1.94 +     *                An index lower than 0 is invalid and will be ignored.
    1.95 +     *
    1.96 +     * @param weak    Whether or not to store the new element using a weak
    1.97 +     *                reference.
    1.98 +     *
    1.99 +     * @throws NS_ERROR_FAILURE when a weak reference is requested,
   1.100 +     *                          but the element does not support
   1.101 +     *                          nsIWeakReference.
   1.102 +     */
   1.103 +    void replaceElementAt(in nsISupports element, in unsigned long index,
   1.104 +                          in boolean weak);
   1.105 +    
   1.106 +    
   1.107 +    /**
   1.108 +     * clear()
   1.109 +     *
   1.110 +     * clear the entire array, releasing all stored objects
   1.111 +     */
   1.112 +    void clear();
   1.113 +};

mercurial