161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkTS 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * Vector is a linear data structure that is implemented based on arrays. When the memory of a vector is used up, 2361847f8eSopenharmony_ci * a larger contiguous memory area is automatically allocated, all the elements are copied to the new memory area, 2461847f8eSopenharmony_ci * and the current memory area is reclaimed. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 2761847f8eSopenharmony_ci * @since 8 2861847f8eSopenharmony_ci * @deprecated since 9 2961847f8eSopenharmony_ci * @useinstead ohos.util.ArrayList 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_cideclare class Vector<T> { 3261847f8eSopenharmony_ci /** 3361847f8eSopenharmony_ci * A constructor used to create a Vector object. 3461847f8eSopenharmony_ci * 3561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 3661847f8eSopenharmony_ci * @since 8 3761847f8eSopenharmony_ci * @deprecated since 9 3861847f8eSopenharmony_ci */ 3961847f8eSopenharmony_ci constructor(); 4061847f8eSopenharmony_ci /** 4161847f8eSopenharmony_ci * Gets the element number of the Vector. This is a number one higher than the highest index in the vector. 4261847f8eSopenharmony_ci * 4361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 4461847f8eSopenharmony_ci * @since 8 4561847f8eSopenharmony_ci * @deprecated since 9 4661847f8eSopenharmony_ci */ 4761847f8eSopenharmony_ci length: number; 4861847f8eSopenharmony_ci /** 4961847f8eSopenharmony_ci * Appends the specified element to the end of this vector. 5061847f8eSopenharmony_ci * 5161847f8eSopenharmony_ci * @param { T } element - Element to be appended to this vector 5261847f8eSopenharmony_ci * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 5361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 5461847f8eSopenharmony_ci * @since 8 5561847f8eSopenharmony_ci * @deprecated since 9 5661847f8eSopenharmony_ci */ 5761847f8eSopenharmony_ci add(element: T): boolean; 5861847f8eSopenharmony_ci /** 5961847f8eSopenharmony_ci * Inserts the specified element at the specified position in this 6061847f8eSopenharmony_ci * vector. Shifts the element currently at that position (if any) and 6161847f8eSopenharmony_ci * any subsequent elements to the right (adds one to their index). 6261847f8eSopenharmony_ci * 6361847f8eSopenharmony_ci * @param { T } element - Element at which the specified element is to be inserted 6461847f8eSopenharmony_ci * @param { number } index - Index to be inserted 6561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 6661847f8eSopenharmony_ci * @since 8 6761847f8eSopenharmony_ci * @deprecated since 9 6861847f8eSopenharmony_ci */ 6961847f8eSopenharmony_ci insert(element: T, index: number): void; 7061847f8eSopenharmony_ci /** 7161847f8eSopenharmony_ci * Check if vector contains the specified element 7261847f8eSopenharmony_ci * 7361847f8eSopenharmony_ci * @param { T } element - Element to be contained 7461847f8eSopenharmony_ci * @returns { boolean } the boolean type,if vector contains the specified element,return true,else return false 7561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 7661847f8eSopenharmony_ci * @since 8 7761847f8eSopenharmony_ci * @deprecated since 9 7861847f8eSopenharmony_ci */ 7961847f8eSopenharmony_ci has(element: T): boolean; 8061847f8eSopenharmony_ci /** 8161847f8eSopenharmony_ci * Returns the element at the specified position in this Vector,or returns undefined if vector is empty 8261847f8eSopenharmony_ci * 8361847f8eSopenharmony_ci * @param { number } index - Index to be contained 8461847f8eSopenharmony_ci * @returns { T } the number type ,returns the lowest index such that or -1 if there is no such index. 8561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 8661847f8eSopenharmony_ci * @since 8 8761847f8eSopenharmony_ci * @deprecated since 9 8861847f8eSopenharmony_ci */ 8961847f8eSopenharmony_ci get(index: number): T; 9061847f8eSopenharmony_ci /** 9161847f8eSopenharmony_ci * Returns the index of the first occurrence of the specified element 9261847f8eSopenharmony_ci * in this vector, or -1 if this vector does not contain the element. 9361847f8eSopenharmony_ci * 9461847f8eSopenharmony_ci * @param { T } element - Element current index 9561847f8eSopenharmony_ci * @returns { number } the number type 9661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 9761847f8eSopenharmony_ci * @since 8 9861847f8eSopenharmony_ci * @deprecated since 9 9961847f8eSopenharmony_ci */ 10061847f8eSopenharmony_ci getIndexOf(element: T): number; 10161847f8eSopenharmony_ci /** 10261847f8eSopenharmony_ci * Returns the first component (the item at index 0) of this vector. 10361847f8eSopenharmony_ci * or returns undefined if vector is empty 10461847f8eSopenharmony_ci * 10561847f8eSopenharmony_ci * @returns { T } the T type ,returns undefined if vector is empty 10661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 10761847f8eSopenharmony_ci * @since 8 10861847f8eSopenharmony_ci * @deprecated since 9 10961847f8eSopenharmony_ci */ 11061847f8eSopenharmony_ci getFirstElement(): T; 11161847f8eSopenharmony_ci /** 11261847f8eSopenharmony_ci * Returns the Last component (the item at index length-1) of this vector. 11361847f8eSopenharmony_ci * or returns undefined if vector is empty 11461847f8eSopenharmony_ci * 11561847f8eSopenharmony_ci * @returns { T } the T type ,returns undefined if vector is empty 11661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 11761847f8eSopenharmony_ci * @since 8 11861847f8eSopenharmony_ci * @deprecated since 9 11961847f8eSopenharmony_ci */ 12061847f8eSopenharmony_ci getLastElement(): T; 12161847f8eSopenharmony_ci /** 12261847f8eSopenharmony_ci * Find the corresponding element according to the index, 12361847f8eSopenharmony_ci * delete the element, and move the index of all elements to the right of the element forward by one. 12461847f8eSopenharmony_ci * 12561847f8eSopenharmony_ci * @param { number } index - The index in the vector 12661847f8eSopenharmony_ci * @returns { T } the T type ,returns undefined if vector is empty,If the index is 12761847f8eSopenharmony_ci * out of bounds (greater than or equal to length or less than 0), throw an exception 12861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 12961847f8eSopenharmony_ci * @since 8 13061847f8eSopenharmony_ci * @deprecated since 9 13161847f8eSopenharmony_ci */ 13261847f8eSopenharmony_ci removeByIndex(index: number): T; 13361847f8eSopenharmony_ci /** 13461847f8eSopenharmony_ci * Removes the first occurrence of the specified element from this vector, 13561847f8eSopenharmony_ci * if it is present. If the vector does not contain the element, it is 13661847f8eSopenharmony_ci * unchanged. More formally, removes the element with the lowest index 13761847f8eSopenharmony_ci * 13861847f8eSopenharmony_ci * @param { T } element - Element to remove 13961847f8eSopenharmony_ci * @returns { boolean } the boolean type ,If there is no such element, return false 14061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 14161847f8eSopenharmony_ci * @since 8 14261847f8eSopenharmony_ci * @deprecated since 9 14361847f8eSopenharmony_ci */ 14461847f8eSopenharmony_ci remove(element: T): boolean; 14561847f8eSopenharmony_ci /** 14661847f8eSopenharmony_ci * Replaces the element at the specified position in this Vector with the specified element 14761847f8eSopenharmony_ci * 14861847f8eSopenharmony_ci * @param { number } index - Index to find 14961847f8eSopenharmony_ci * @param { T } element - Element replaced element 15061847f8eSopenharmony_ci * @returns { T } the T type 15161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 15261847f8eSopenharmony_ci * @since 8 15361847f8eSopenharmony_ci * @deprecated since 9 15461847f8eSopenharmony_ci */ 15561847f8eSopenharmony_ci set(index: number, element: T): T; 15661847f8eSopenharmony_ci /** 15761847f8eSopenharmony_ci * Returns in the index of the last occurrence of the specified element in this vector , 15861847f8eSopenharmony_ci * or -1 if the vector does not contain the element. 15961847f8eSopenharmony_ci * 16061847f8eSopenharmony_ci * @param { T } element - Element to find 16161847f8eSopenharmony_ci * @returns { number } The number type 16261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 16361847f8eSopenharmony_ci * @since 8 16461847f8eSopenharmony_ci * @deprecated since 9 16561847f8eSopenharmony_ci */ 16661847f8eSopenharmony_ci getLastIndexOf(element: T): number; 16761847f8eSopenharmony_ci /** 16861847f8eSopenharmony_ci * Returns the index of the last occurrence of the specified element in this vector ,searching backwards from index, 16961847f8eSopenharmony_ci * or returns -1 if the element is not found,or -1 if there is no such index 17061847f8eSopenharmony_ci * 17161847f8eSopenharmony_ci * @param { T } element - Element to find 17261847f8eSopenharmony_ci * @param { number } index - Index start index 17361847f8eSopenharmony_ci * @returns { number } the number type 17461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 17561847f8eSopenharmony_ci * @since 8 17661847f8eSopenharmony_ci * @deprecated since 9 17761847f8eSopenharmony_ci */ 17861847f8eSopenharmony_ci getLastIndexFrom(element: T, index: number): number; 17961847f8eSopenharmony_ci /** 18061847f8eSopenharmony_ci * Returns the index of the first occurrence of the specified element in this vector ,searching forwards from index, 18161847f8eSopenharmony_ci * or returns -1 if the element is not found,or -1 if there is no such index 18261847f8eSopenharmony_ci * 18361847f8eSopenharmony_ci * @param { T } element - Element to find 18461847f8eSopenharmony_ci * @param { number } index - Index start index 18561847f8eSopenharmony_ci * @returns { number } the number type 18661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 18761847f8eSopenharmony_ci * @since 8 18861847f8eSopenharmony_ci * @deprecated since 9 18961847f8eSopenharmony_ci */ 19061847f8eSopenharmony_ci getIndexFrom(element: T, index: number): number; 19161847f8eSopenharmony_ci /** 19261847f8eSopenharmony_ci * Removes from this vector all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. 19361847f8eSopenharmony_ci * 19461847f8eSopenharmony_ci * @param { number } fromIndex - The starting position of the index, containing the value at that index position 19561847f8eSopenharmony_ci * @param { number } toIndex - The end of the index, excluding the value at that index 19661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 19761847f8eSopenharmony_ci * @since 8 19861847f8eSopenharmony_ci * @deprecated since 9 19961847f8eSopenharmony_ci */ 20061847f8eSopenharmony_ci removeByRange(fromIndex: number, toIndex: number): void; 20161847f8eSopenharmony_ci /** 20261847f8eSopenharmony_ci * Replaces each element of this vector with the result of applying the operator to that element. 20361847f8eSopenharmony_ci * 20461847f8eSopenharmony_ci * @param { function } callbackFn - A function that accepts up to four arguments.The function to be called 20561847f8eSopenharmony_ci * for each element in the vector,Returns the result of an operation 20661847f8eSopenharmony_ci * @param { Object } thisArg - The value passed to the function generally uses the 20761847f8eSopenharmony_ci * "this" value.If this parameter is empty, "undefined" will be passed to the "this" value 20861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 20961847f8eSopenharmony_ci * @since 8 21061847f8eSopenharmony_ci * @deprecated since 9 21161847f8eSopenharmony_ci */ 21261847f8eSopenharmony_ci replaceAllElements(callbackFn: (value: T, index?: number, vector?: Vector<T>) => T, thisArg?: Object): void; 21361847f8eSopenharmony_ci /** 21461847f8eSopenharmony_ci * Executes a provided function once for each value in the vector object. 21561847f8eSopenharmony_ci * 21661847f8eSopenharmony_ci * @param { function } callbackFn - callbackFn 21761847f8eSopenharmony_ci * callbackFn (required) A function that accepts up to four arguments.The function to be 21861847f8eSopenharmony_ci * called for each element in the vector 21961847f8eSopenharmony_ci * @param { Object } thisArg - The value passed to the function generally uses the "this" value. 22061847f8eSopenharmony_ci * If this parameter is empty, "undefined" will be passed to the "this" value 22161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 22261847f8eSopenharmony_ci * @since 8 22361847f8eSopenharmony_ci * @deprecated since 9 22461847f8eSopenharmony_ci */ 22561847f8eSopenharmony_ci forEach(callbackFn: (value: T, index?: number, vector?: Vector<T>) => void, thisArg?: Object): void; 22661847f8eSopenharmony_ci /** 22761847f8eSopenharmony_ci * Sorts this vector according to the order induced by the specified comparator,without comparator 22861847f8eSopenharmony_ci * this parameter, it will default to ASCII sorting 22961847f8eSopenharmony_ci * 23061847f8eSopenharmony_ci * @param { function } comparator - comparator 23161847f8eSopenharmony_ci * (Optional) A function that accepts up to two arguments.Specifies the sort order. 23261847f8eSopenharmony_ci * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an vector sorted 23361847f8eSopenharmony_ci * in ascending order;If it returns secondValue minus firstValue, it returns an vector sorted in descending order; 23461847f8eSopenharmony_ci * If this parameter is empty, it will default to ASCII sorting 23561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 23661847f8eSopenharmony_ci * @since 8 23761847f8eSopenharmony_ci * @deprecated since 9 23861847f8eSopenharmony_ci */ 23961847f8eSopenharmony_ci sort(comparator?: (firstValue: T, secondValue: T) => number): void; 24061847f8eSopenharmony_ci /** 24161847f8eSopenharmony_ci * Returns a view of the portion of this vector between the specified fromIndex,inclusive,and toIndex,exclusive 24261847f8eSopenharmony_ci * 24361847f8eSopenharmony_ci * @param { number } fromIndex - The starting position of the index, containing the value at that index position 24461847f8eSopenharmony_ci * @param { number } toIndex - The end of the index, excluding the value at that index 24561847f8eSopenharmony_ci * @returns { Vector<T> } 24661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 24761847f8eSopenharmony_ci * @since 8 24861847f8eSopenharmony_ci * @deprecated since 9 24961847f8eSopenharmony_ci */ 25061847f8eSopenharmony_ci subVector(fromIndex: number, toIndex: number): Vector<T>; 25161847f8eSopenharmony_ci /** 25261847f8eSopenharmony_ci * Removes all of the elements from this vector.The vector will 25361847f8eSopenharmony_ci * be empty after this call returns.length becomes 0 25461847f8eSopenharmony_ci * 25561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 25661847f8eSopenharmony_ci * @since 8 25761847f8eSopenharmony_ci * @deprecated since 9 25861847f8eSopenharmony_ci */ 25961847f8eSopenharmony_ci clear(): void; 26061847f8eSopenharmony_ci /** 26161847f8eSopenharmony_ci * Returns a shallow copy of this instance. (The elements themselves are not copied.) 26261847f8eSopenharmony_ci * 26361847f8eSopenharmony_ci * @returns { Vector<T> } this vector instance 26461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 26561847f8eSopenharmony_ci * @since 8 26661847f8eSopenharmony_ci * @deprecated since 9 26761847f8eSopenharmony_ci */ 26861847f8eSopenharmony_ci clone(): Vector<T>; 26961847f8eSopenharmony_ci /** 27061847f8eSopenharmony_ci * Sets the length of this vector 27161847f8eSopenharmony_ci * 27261847f8eSopenharmony_ci * @param { number } newSize - newSize 27361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 27461847f8eSopenharmony_ci * @since 8 27561847f8eSopenharmony_ci * @deprecated since 9 27661847f8eSopenharmony_ci */ 27761847f8eSopenharmony_ci setLength(newSize: number): void; 27861847f8eSopenharmony_ci /** 27961847f8eSopenharmony_ci * returns the capacity of this vector 28061847f8eSopenharmony_ci * 28161847f8eSopenharmony_ci * @returns { number } the number type 28261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 28361847f8eSopenharmony_ci * @since 8 28461847f8eSopenharmony_ci * @deprecated since 9 28561847f8eSopenharmony_ci */ 28661847f8eSopenharmony_ci getCapacity(): number; 28761847f8eSopenharmony_ci /** 28861847f8eSopenharmony_ci * convert vector to array 28961847f8eSopenharmony_ci * 29061847f8eSopenharmony_ci * @returns { Array<T> } the Array type 29161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 29261847f8eSopenharmony_ci * @since 8 29361847f8eSopenharmony_ci * @deprecated since 9 29461847f8eSopenharmony_ci */ 29561847f8eSopenharmony_ci convertToArray(): Array<T>; 29661847f8eSopenharmony_ci /** 29761847f8eSopenharmony_ci * Determine whether vector is empty and whether there is an element 29861847f8eSopenharmony_ci * 29961847f8eSopenharmony_ci * @returns { boolean } the boolean type 30061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 30161847f8eSopenharmony_ci * @since 8 30261847f8eSopenharmony_ci * @deprecated since 9 30361847f8eSopenharmony_ci */ 30461847f8eSopenharmony_ci isEmpty(): boolean; 30561847f8eSopenharmony_ci /** 30661847f8eSopenharmony_ci * If the newCapacity provided by the user is greater than or equal to length, 30761847f8eSopenharmony_ci * change the capacity of the vector to newCapacity, otherwise the capacity will not be changed 30861847f8eSopenharmony_ci * 30961847f8eSopenharmony_ci * @param { number } newCapacity - newCapacity 31061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 31161847f8eSopenharmony_ci * @since 8 31261847f8eSopenharmony_ci * @deprecated since 9 31361847f8eSopenharmony_ci */ 31461847f8eSopenharmony_ci increaseCapacityTo(newCapacity: number): void; 31561847f8eSopenharmony_ci /** 31661847f8eSopenharmony_ci * Returns a string representation of this Vector, 31761847f8eSopenharmony_ci * containing the String representation of each element 31861847f8eSopenharmony_ci * 31961847f8eSopenharmony_ci * @returns { string } 32061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 32161847f8eSopenharmony_ci * @since 8 32261847f8eSopenharmony_ci * @deprecated since 9 32361847f8eSopenharmony_ci */ 32461847f8eSopenharmony_ci toString(): string; 32561847f8eSopenharmony_ci /** 32661847f8eSopenharmony_ci * Limit the capacity to the current length 32761847f8eSopenharmony_ci * 32861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 32961847f8eSopenharmony_ci * @since 8 33061847f8eSopenharmony_ci * @deprecated since 9 33161847f8eSopenharmony_ci */ 33261847f8eSopenharmony_ci trimToCurrentLength(): void; 33361847f8eSopenharmony_ci /** 33461847f8eSopenharmony_ci * Copies the components of this vector into the specified array, 33561847f8eSopenharmony_ci * to overwrite elements of the same index 33661847f8eSopenharmony_ci * 33761847f8eSopenharmony_ci * @param { Array<T> } array - Replaced array 33861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 33961847f8eSopenharmony_ci * @since 8 34061847f8eSopenharmony_ci * @deprecated since 9 34161847f8eSopenharmony_ci */ 34261847f8eSopenharmony_ci copyToArray(array: Array<T>): void; 34361847f8eSopenharmony_ci /** 34461847f8eSopenharmony_ci * returns an ES6 iterator.Each item of the iterator is a Javascript Object 34561847f8eSopenharmony_ci * 34661847f8eSopenharmony_ci * @returns { IterableIterator<T> } 34761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 34861847f8eSopenharmony_ci * @since 8 34961847f8eSopenharmony_ci * @deprecated since 9 35061847f8eSopenharmony_ci */ 35161847f8eSopenharmony_ci [Symbol.iterator](): IterableIterator<T>; 35261847f8eSopenharmony_ci} 35361847f8eSopenharmony_ci 35461847f8eSopenharmony_ciexport default Vector; 355