Interface nsIMutableArrayType

nsIMutableArray A separate set of methods that will act on the array. Consumers of nsIArray should not QueryInterface to nsIMutableArray unless they own the array.

As above, it is legal to add null elements to the array. Note also that null elements can be created as a side effect of insertElementAt(). Conversely, if insertElementAt() is never used, and null elements are never explicitly added to the array, then it is guaranteed that queryElementAt() will never return a null value.

Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the array must grow to complete the call, but the allocation fails.

Hierarchy

Properties

length: number

length

number of elements in the array.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Count()

    Retrieves the length of the array. This is an alias for the |nsIArray.length| attribute.

    Returns uint32_t

  • GetElementAt()

    Retrieve a specific element of the array. null is a valid result for this method.

    Note: If the index is out of bounds null will be returned. This differs from the behavior of nsIArray.queryElementAt() which will throw if an invalid index is specified.

    Parameters

    • index: uint32_t

      position of element

    Returns nsISupports

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • appendElement()

    Append an element at the end of the array.

    Parameters

    • element: nsISupports

      The element to append.

    Returns void

  • clear()

    clear the entire array, releasing all stored objects

    Returns void

  • enumerate the array

    Returns

    a new enumerator positioned at the start of the array

    Throws

    NS_ERROR_FAILURE if the array is empty (to make it easy to detect errors), or NS_ERROR_OUT_OF_MEMORY if out of memory.

    Parameters

    • aElemIID: object

    Returns nsISimpleEnumerator

  • indexOf()

    Get the position of a specific element. Note that since null is a valid input, exceptions are used to indicate that an element is not found.

    Returns

    a number >= startIndex which is the position of the element in the array.

    Throws

    NS_ERROR_FAILURE if the element was not in the array.

    Parameters

    • startIndex: number

      The initial element to search in the array To start at the beginning, use 0 as the startIndex

    • element: nsISupports

      The element you are looking for

    Returns number

  • insertElementAt()

    Insert an element at the given position, moving the element currently located in that position, and all elements in higher position, up by one.

    Parameters

    • element: nsISupports

      The element to insert

    • index: number

      The position in the array: If the position is lower than the current length of the array, the elements at that position and onwards are bumped one position up. If the position is equal to the current length of the array, the new element is appended. An index lower than 0 or higher than the current length of the array is invalid and will be ignored.

    Returns void

  • queryElementAt()

    Retrieve a specific element of the array, and QueryInterface it to the specified interface. null is a valid result for this method, but exceptions are thrown in other circumstances

    Throws

    NS_ERROR_NO_INTERFACE when an entry exists at the specified index, but the requested interface is not available.

    Throws

    NS_ERROR_ILLEGAL_VALUE when index > length-1

    Parameters

    • index: number

      position of element

    • uuid: object

      the IID of the requested interface

    • result: object

      the object, QI'd to the requested interface

    Returns void

  • removeElementAt()

    Remove an element at a specific position, moving all elements stored at a higher position down one. To remove a specific element, use indexOf() to find the index first, then call removeElementAt().

    Parameters

    • index: number

      the position of the item

    Returns void

  • replaceElementAt()

    Replace the element at the given position.

    Parameters

    • element: nsISupports

      The new element to insert

    • index: number

      The position in the array If the position is lower than the current length of the array, an existing element will be replaced. If the position is equal to the current length of the array, the new element is appended. If the position is higher than the current length of the array, empty elements are appended followed by the new element at the specified position. An index lower than 0 is invalid and will be ignored.

    Returns void

Generated using TypeDoc