diff --git a/api/@ohos.util.ArrayList.d.ts b/api/@ohos.util.ArrayList.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af4b694e8fc9def7713c3a45c6a3b957e25e3905 --- /dev/null +++ b/api/@ohos.util.ArrayList.d.ts @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class ArrayList { + /** + * A constructor used to create a ArrayList object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this arraylist. + * @param element to be appended to this arraylist + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this + * arraylist. Shifts the element currently at that position (if any) and + * any subsequent elements to the right (adds one to their index). + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Check if arraylist contains the specified element + * @param element element to be contained + * @return the boolean type,if arraylist contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this arraylist, or -1 if this arraylist does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * delete the element, and move the index of all elements to the right of the element forward by one. + * @param index the index in the arraylist + * @return the T type ,returns undefined if arraylist is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this arraylist, + * if it is present. If the arraylist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this arraylist , + * or -1 if the arraylist does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByRange(fromIndex: number, toIndex: number): void; + /** + * Replaces each element of this arraylist with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called for + * each element in the arraylist,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param arraylist (Optional) The arraylist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, arraylist?: ArrayList) => T, + thisArg?: Object): void; + /** + * Executes a provided function once for each value in the arraylist object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to + * be called for each element in the arraylist + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param arraylist (Optional) The arraylist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, arraylist?: ArrayList) => void, + thisArg?: Object): void; + /** + * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, + * it will default to ASCII sorting + * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist + * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * If this parameter is empty, it will default to ASCII sorting + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator?: (firstValue: T, secondValue: T) => number): void; + /** + * Returns a view of the portion of this arraylist between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + subArrayList(fromIndex: number, toIndex: number): ArrayList; + /** + * Removes all of the elements from this arraylist.The arraylist will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this arraylist instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): ArrayList; + /** + * returns the capacity of this arraylist + * @return the number type + * @since 8 + */ + getCapacity(): number; + /** + * convert arraylist to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether arraylist is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * If the newCapacity provided by the user is greater than or equal to length, + * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(newCapacity: number): void; + /** + * Limit the capacity to the current length + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + trimToCurrentLength(): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default ArrayList; diff --git a/api/@ohos.util.Deque.d.ts b/api/@ohos.util.Deque.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8b284b44a2d6abcc82c9f3f845a7daf743870cf --- /dev/null +++ b/api/@ohos.util.Deque.d.ts @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Deque { + /** + * A constructor used to create a Deque object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Deque.This is a number one higher than the highest index in the deque. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Inserts an element into the deque header. + * @param element to be appended to this deque + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insertFront(element: T): void; + /** + * Inserting an element at the end of a deque + * @param element to be appended to this deque + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insertEnd(element: T): void; + /** + * Check if deque contains the specified element + * @param element element to be contained + * @return the boolean type,if deque contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Obtains the header element of a deque. + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Obtains the end element of a deque. + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Obtains the header element of a deque and delete the element. + * @return the T type + * @throws an exception if the deque is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popFirst(): T; + /** + * Obtains the end element of a deque and delete the element. + * @return the T type + * @throws an exception if the deque is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popLast(): T; + /** + * Executes a provided function once for each value in the deque object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called for each element in the deque + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param deque (Optional) The deque object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, deque?: Deque) => void, + thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default Deque; \ No newline at end of file diff --git a/api/@ohos.util.HashMap.d.ts b/api/@ohos.util.HashMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b014d6c07e7139e6191ab97969f275bed3b35c9 --- /dev/null +++ b/api/@ohos.util.HashMap.d.ts @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class HashMap { + /** + * A constructor used to create a HashMap object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the hashmap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Returns a specified element in a Map object, or null if there is no corresponding element + * @param key the index in HashMap + * @return value or null + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: HashMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove a specified element from a Map object + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Clear all element groups in the map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a new Iterator object that contains the keys contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Returns a new Iterator object that contains the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Replace the old value by new value corresponding to the specified key + * @param key Updated targets + * @param value Updated the target mapped value + * @returns the boolean type(Is there a target pointed to by the key) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replace(key: K, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: HashMap) => void, + thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[K, V]>; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[K, V]>; +} + +export default HashMap; diff --git a/api/@ohos.util.HashSet.d.ts b/api/@ohos.util.HashSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..88c292927a8e856c7d133e020cc42fe3ed8a9204 --- /dev/null +++ b/api/@ohos.util.HashSet.d.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class HashSet { + /** + * A constructor used to create a HashSet object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the hashset. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Set object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether the Set object contain s the elements + * @param value need to determine whether to include the element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(value: T): boolean; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(value: T): boolean; + /** + * Remove a specified element from a Set object + * @param value Target to be deleted + * @return the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(value: T): boolean; + /** + * Clears all element groups in a set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Executes a provided function once for each value in the Set object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, set?: HashSet) => void, + thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the values contained in this set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[T, T]>; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default HashSet; diff --git a/api/@ohos.util.LightWeightMap.d.ts b/api/@ohos.util.LightWeightMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..afff2630d53c65f57f45ef6935c099a885b11edd --- /dev/null +++ b/api/@ohos.util.LightWeightMap.d.ts @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LightWeightMap { + /** + * A constructor used to create a LightWeightMap object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the LightWeightMap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether this map has all the object in a specified map + * @param map the Map object to compare + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasAll(map: LightWeightMap): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Ensures that the capacity of an LightWeightMap container is greater than or equal to a apecified value, + * and that the container has all the original objects after capacity expansion + * @param minimumCapacity Minimum capacity to be reserved + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(minimumCapacity: number): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[K, V]>; + /** + * Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key + * @param key the index in LightWeightMap + * @return value or null + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Obtains the index of the key equal to a specified key in an LightWeightMap container + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfKey(key: K): number; + /** + * Obtains the index of the value equal to a specified value in an LightWeightMap container + * @param value Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfValue(value: K): number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Obtains the key at the loaction identified by index in an LightWeightMap container + * @param index Target subscript for search + * @return the key of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getKeyAt(index: number): K; + /** + * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: LightWeightMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove the mapping for this key from this map if present + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Deletes a key-value pair at the loaction identified by index from an LightWeightMap container + * @param index Target subscript for search + * @return the boolean type(Is there a delete value) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): boolean; + /** + * Removes all of the mapping from this map + * The map will be empty after this call returns + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Sets the value identified by index in an LightWeightMap container to a specified value + * @param index Target subscript for search + * @param value Updated the target mapped value + * @return the boolean type(Is there a value corresponding to the subscript) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setValueAt(index: number, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, + thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[K, V]>; + /** + * Obtains a string that contains all the keys and values in an LightWeightMap container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Obtains the value identified by index in an LightWeightMap container + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): V; + /** + * Returns an iterator of the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; +} + +export default LightWeightMap; \ No newline at end of file diff --git a/api/@ohos.util.LightWeightSet.d.ts b/api/@ohos.util.LightWeightSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..27f078499b5d396da9cee65460b42ac891d53be7 --- /dev/null +++ b/api/@ohos.util.LightWeightSet.d.ts @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LightWeightSet { + /** + * A constructor used to create a LightWeightSet object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the LightWeightSet. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(value: T): boolean; + /** + * Adds all the objects in a specified LightWeightSet container to the current LightWeightSet container + * @param set the Map object to provide the added element + * @returns the boolean type(Is there any new data added successfully) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + addAll(set: LightWeightMap): boolean; + /** + * Returns whether this set has all the object in a specified set + * @param set the Set object to compare + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasAll(set: LightWeightSet): boolean; + /** + * Checks whether an LightWeightSet container has a specified key + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(key: T): boolean; + /** + * Checks whether an the objects of an LightWeighSet containeer are of the same type as a specified Object LightWeightSet + * @param obj need to determine whether to include the obj + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + equal(obj: Object): boolean; + /** + * Ensures that the capacity of an LightWeightSet container is greater than or equal to a apecified value, + * and that the container has all the original objects after capacity expansion + * @param minimumCapacity Minimum capacity to be reserved + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ensureCapacityTo(minimumCapacity: number): void; + /** + * Obtains the index of s key of a specified Object type in an LightWeightSet container + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(key: T): number; + /** + * Deletes an object of a specified Object type from an LightWeightSet container + * @param key Target to be deleted + * @return Target element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: T): T; + /** + * Deletes an object at the loaction identified by index from an LightWeightSet container + * @param index Target subscript for search + * @return the boolean type(Is there a delete value) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): boolean; + /** + * Removes all of the mapping from this map + * The map will be empty after this call returns + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, map?: LightWeightSet) => void, + thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; + /** + * Obtains a string that contains all the keys and values in an LightWeightSet container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Obtains an Array that contains all the objects of an LightWeightSet container. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toArray(): Array; + /** + * Obtains the object at the location identified by index in an LightWeightSet container + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): T; + /** + * Returns a ES6 iterator of the values contained in this Set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[T, T]>; +} + +export default LightWeightSet; diff --git a/api/@ohos.util.LinkedList.d.ts b/api/@ohos.util.LinkedList.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14333ffb644f2fdc6651a830e83b46f8061daa83 --- /dev/null +++ b/api/@ohos.util.LinkedList.d.ts @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LinkedList { + /** + * Gets the element number of the LinkedList. This is a number one higher than the highest index in the linkedlist. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this linkedlist. + * @param element to be appended to this linkedlist + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this linkedlist. + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Returns the element at the specified position in this linkedlist, + * or returns undefined if this linkedlist is empty + * @param index specified position + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Inserts the specified element at the beginning of this LinkedList. + * @param element the element to add + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + addFirst(element: T): void; + /** + * Retrieves and removes the head (first element) of this linkedlist. + * @return the head of this list + * @throws NoSuchElementException if this linkedlist is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeFirst(): T; + /** + * Removes and returns the last element from this linkedlist. + * @return the head of this list + * @throws NoSuchElementException if this linkedlist is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + * + */ + removeLast(): T; + /** + * Check if linkedlist contains the specified element + * @param element element to be contained + * @return the boolean type,if vector contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this linkedlist, or -1 if this linkedlist does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * @param index the index in the linkedlist + * @return the T type ,returns undefined if linkedlist is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeFirstFound(element: T): boolean; + /** + * Removes the last occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeLastFound(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this linkedlist , + * or -1 if the linkedlist does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the first element (the item at index 0) of this linkedlist. + * or returns undefined if linkedlist is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Returns the Last element (the item at index length-1) of this linkedlist. + * or returns undefined if linkedlist is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Replaces the element at the specified position in this Vector with the specified element + * @param element replaced element + * @param index index to find + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): void; + /** + * Replaces each element of this linkedlist with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the linkedlist,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param linkedlist (Optional) The linkedlist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, linkedlist?: ArrayList) => void, + thisArg?: Object): void; + /** + * Sorts this linkedlist according to the order induced by the specified comparator,without comparator this parameter, + * it will default to ASCII sorting + * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an linkedlist + * sorted in ascending order;If it returns secondValue minus firstValue, it returns an linkedlist sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * If this parameter is empty, it will default to ASCII sorting + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator?: (firstValue: T, secondValue: T) => number): void; + /** + * Removes all of the elements from this linkedlist.The linkedlist will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this linkedlist instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): LinkedList; + /** + * convert linkedlist to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default LinkedList; diff --git a/api/@ohos.util.List.d.ts b/api/@ohos.util.List.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..89d90ba06e99083ff97f4425f058701277c6a698 --- /dev/null +++ b/api/@ohos.util.List.d.ts @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class List { + /** + * A constructor used to create a List object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the List. This is a number one higher than the highest index in the list. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this list. + * @param element to be appended to this list + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this list. + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Returns the element at the specified position in this list, + * or returns undefined if this list is empty + * @param index specified position + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Check if list contains the specified element + * @param element element to be contained + * @return the boolean type,if list contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this list, or -1 if this list does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * @param index the index in the list + * @return the T type ,returns undefined if list is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this list, + * if it is present. If the list does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this list , + * or -1 if the list does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the first element (the item at index 0) of this list. + * or returns undefined if list is empty + * @return the T type ,returns undefined if list is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Returns the Last element (the item at index length-1) of this list. + * or returns undefined if list is empty + * @return the T type ,returns undefined if list is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Replaces the element at the specified position in this List with the specified element + * @param element replaced element + * @param index index to find + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): void; + /** + * Compares the specified object with this list for equality.if the object are the same as this list + * return true, otherwise return false. + * @param obj Compare objects + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + equal(obj: Object): boolean; + /** + * Replaces each element of this list with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the list,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param list (Optional) The list object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, list?: ArrayList) => void, + thisArg?: Object): void; + /** + * Sorts this list according to the order induced by the specified comparator + * @param comparator (required) A function that accepts up to two arguments. + * Specifies the sort order. Must be a function,return number type,If it returns firstValue + * minus secondValue, it returns an list sorted in ascending order;If it returns secondValue + * minus firstValue, it returns an list sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator: (firstValue: T, secondValue: T) => number): void; + /** + * Removes all of the elements from this list.The list will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a view of the portion of this list between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getSubList(fromIndex: number, toIndex: number): List; + /** + * Replaces each element of this list with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the list,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param list (Optional) The list object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, list?: List) => T, + thisArg?: Object): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this list instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): List; + /** + * convert list to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether list is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default List; diff --git a/api/@ohos.util.PlainArray.d.ts b/api/@ohos.util.PlainArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..55495dd9c1384f227c2fcf08e6d34c5b08a696af --- /dev/null +++ b/api/@ohos.util.PlainArray.d.ts @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class PlainArray { + /** + * A constructor used to create a PlainArray object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the PlainArray. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends a key-value pair to PlainArray + * @param key Added the key of key-value + * @param value Added the value of key-value + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(key: number, value: T): boolean; + /** + * Clears the current PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Obtains a clone of the current PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): PlainArray; + /** + * Checks whether the current PlainArray object contains the specified key + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(key: number): boolean; + /** + * Queries the value associated with the specified key + * @param key Looking for goals + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: number): T; + /** + * Queries the index for a specified key + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfKey(key: number): number; + /** + * Queries the index for a specified value + * @param value Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfValue(value: T): number; + /** + * Checks whether the current PlainArray object is empty + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Queries the key at a specified index + * @param index Target subscript for search + * @return the key of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getKeyAt(index: number): number; + /** + * Remove the key-value pair based on a specified key if it exists and return the value + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: number): T; + /** + * Remove the key-value pair at a specified index if it exists and return the value + * @param index Target subscript for search + * @return the boolean type(Is there a delete value) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): boolean; + /** + * Remove a group of key-value pairs from a specified index + * @param index remove start index + * @param size Expected deletion quantity + * @return Actual deleted quantity + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeRangeFrom(index: number, size: number): number; + /** + * Update value on specified index + * @param index Target subscript for search + * @param value Updated the target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setValueAt(index: number, newValue: T): void; + /** + * Obtains the string representation of the PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Queries the value at a specified index + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): T; + /** + * Executes a provided function once for each value in the PlainArray object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, + thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[number, T]>; +} + +export default PlainArray; diff --git a/api/@ohos.util.Queue.d.ts b/api/@ohos.util.Queue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c28ca9ebb1359e22d92ddf13f163870e9377249b --- /dev/null +++ b/api/@ohos.util.Queue.d.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Queue { + /** + * A constructor used to create a Queue object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Queue.This is a number one higher than the highest index in the queue. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Inserting specified element at the end of a queue if it is possible to do + * so immediately without violating capacity restrictions. + * @param element to be appended to this queue + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Obtains the header element of a queue. + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Retrieves and removes the head of this queue + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + pop(): T; + /** + * Executes a provided function once for each value in the queue object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to + * be called for each element in the queue + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param queue (Optional) The queue object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, queue?: Queue) => void, + thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default Queue; diff --git a/api/@ohos.util.Stack.d.ts b/api/@ohos.util.Stack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eea500a878c9801f5959ac288856a857d96b80f --- /dev/null +++ b/api/@ohos.util.Stack.d.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Stack { + /** + * A constructor used to create a Stack object. + * @since 8 + */ + constructor(); + /** + * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Tests if this stack is empty + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Looks at the object at the top of this stack without removing it from the stack + * Return undfined if this stack is empty + * @return the top value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + peek(): T; + /** + * Removes the object at the top of this stack and returns that object as the value of this function + * an exception if the stack is empty + * @returns Stack top value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + pop(): boolean; + /** + * Pushes an item onto the top of this stack + * @param item to be appended to this Stack + * @returns the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + push(item: T): T; + /** + * Returns the 1-based position where an object is on this stack + * @param element Target to be deleted + * @returns the T type,If there is no such element, return -1 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + locate(element: T): number; + /** + * Executes a provided function once for each value in the Stack object. + * @param callbackfn (required) A function that accepts up to four arguments.The function + * to be called for each element in the Stack + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param stack (Optional) The Stack object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, stack?: Stack) => void, + thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default Stack; diff --git a/api/@ohos.util.TreeMap.d.ts b/api/@ohos.util.TreeMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..125b149ce5deedba56c3737dea07bb22324c88ba --- /dev/null +++ b/api/@ohos.util.TreeMap.d.ts @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class TreeMap { + /** + * A constructor used to create a TreeMap object. + * @param comparator (Optional) User-defined comparison functions + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next element + * @since 8 + */ + constructor(comparator?: (firstValue: K, secondValue: K) => boolean); + /** + * Gets the element number of the hashmap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Returns a specified element in a Map object, or null if there is no corresponding element + * @param key the index in TreeMap + * @return value or null + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Obtains the first sorted key in the treemap. + * Or returns undefined if tree map is empty + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstKey(): K; + /** + * Obtains the last sorted key in the treemap. + * Or returns undefined if tree map is empty + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastKey(): K; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: TreeMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove a specified element from a Map object + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Clear all element groups in the map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLowerByKey(key: K): K; + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getHigherByKey(key: K): K; + /** + * Returns a new Iterator object that contains the keys contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Returns a new Iterator object that contains the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Replace the old value by new value corresponding to the specified key + * @param key Updated targets + * @param value Updated the target mapped value + * @returns the boolean type(Is there a target pointed to by the key) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replace(key: K, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: TreeMap) => void, + thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[K, V]>; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[K, V]>; +} + +export default TreeMap; \ No newline at end of file diff --git a/api/@ohos.util.TreeSet.d.ts b/api/@ohos.util.TreeSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a71ef36bf015f787b3d791c05ac4f84e805fbeb0 --- /dev/null +++ b/api/@ohos.util.TreeSet.d.ts @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class TreeSet { + /** + * A constructor used to create a TreeSet object. + * @param comparator (Optional) User-defined comparison functions + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(comparator?: (firstValue: T, secondValue: T) => boolean) + /** + * Gets the element number of the TreeSet. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Set object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether the Set object contain s the elements + * @param value need to determine whether to include the element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(value: T): boolean; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(value: T): boolean; + /** + * Remove a specified element from a Set object + * @param value Target to be deleted + * @return the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(value: T): boolean; + /** + * Clears all element groups in a set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Gets the first elements in a set + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstValue(): T; + /** + * Gets the last elements in a set + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastValue(): T; + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLowerValue(key: T): T; + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getHigherValue(key: T): T; + /** + * Return and delete the first element, returns undefined if tree set is empty + * @return first value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popFirst(): T; + /** + * Return and delete the last element, returns undefined if tree set is empty + * @return last value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popLast(): T; + /** + * Executes a provided function once for each value in the Set object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, set?: TreeSet) => void, + thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the values contained in this set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[T, T]>; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default TreeSet; diff --git a/api/@ohos.util.Vector.d.ts b/api/@ohos.util.Vector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bf061e7f4ae5c5080b4b9e1943d6f6068698a332 --- /dev/null +++ b/api/@ohos.util.Vector.d.ts @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Vector { + /** + * A constructor used to create a Vector object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Vector. This is a number one higher than the highest index in the vector. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this vector. + * @param element to be appended to this vector + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this + * vector. Shifts the element currently at that position (if any) and + * any subsequent elements to the right (adds one to their index). + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Check if vector contains the specified element + * @param element element to be contained + * @return the boolean type,if vector contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the element at the specified position in this Vector,or returns undefined if vector is empty + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Returns the index of the first occurrence of the specified element + * in this vector, or -1 if this vector does not contain the element. + * @param element current index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Returns the first component (the item at index 0) of this vector. + * or returns undefined if vector is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstElement(): T; + /** + * Returns the Last component (the item at index length-1) of this vector. + * or returns undefined if vector is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastElement(): T; + /** + * Find the corresponding element according to the index, + * delete the element, and move the index of all elements to the right of the element forward by one. + * @param index the index in the vector + * @return the T type ,returns undefined if vector is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this vector, + * if it is present. If the vector does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Replaces the element at the specified position in this Vector with the specified element + * @param element replaced element + * @param index index to find + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): void; + /** + * Returns in the index of the last occurrence of the specified element in this vector , + * or -1 if the vector does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the index of the last occurrence of the specified element in this vector ,searching backwards from index, + * or returns -1 if the element is not found,or -1 if there is no such index + * @param element element to find + * @param index start index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexFrom(element: T, index: number): number; + /** + * Returns the index of the first occurrence of the specified element in this vector ,searching forwards from index, + * or returns -1 if the element is not found,or -1 if there is no such index + * @param element element to find + * @param index start index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexFrom(element: T, index: number): number; + /** + * Removes from this vector all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByRange(fromIndex: number, toIndex: number): void; + /** + * Replaces each element of this vector with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called + * for each element in the vector,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param vector (Optional) The vector object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector) => T, + thisArg?: Object): void; + /** + * Executes a provided function once for each value in the vector object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be + * called for each element in the vector + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param vector (Optional) The vector object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, vector?: Vector) => void, + thisArg?: Object): void; + /** + * Sorts this vector according to the order induced by the specified comparator,without comparator + * this parameter, it will default to ASCII sorting + * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an vector sorted + * in ascending order;If it returns secondValue minus firstValue, it returns an vector sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * If this parameter is empty, it will default to ASCII sorting + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator?: (firstValue: T, secondValue: T) => number): void; + /** + * Returns a view of the portion of this vector between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + subVector(fromIndex: number, toIndex: number): Vector; + /** + * Removes all of the elements from this vector.The vector will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this vector instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): Vector; + /** + * Sets the length of this vector + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setLength(newSize: number): void; + /** + * returns the capacity of this vector + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getCapacity(): number; + /** + * convert vector to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether vector is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * If the newCapacity provided by the user is greater than or equal to length, + * change the capacity of the vector to newCapacity, otherwise the capacity will not be changed + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(newCapacity: number): void; + /** + * Returns a string representation of this Vector, + * containing the String representation of each element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): string; + /** + * Limit the capacity to the current length + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + trimToCurrentLength(): void; + /** + * Copies the components of this vector into the specified array, + * to overwrite elements of the same index + * @param Array replaced array + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + copyToArray(array: Array): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} + +export default Vector;