1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16declare class PlainArray<T> { 17 /** 18 * A constructor used to create a PlainArray object. 19 * @throws { BusinessError } 10200012 - The PlainArray's constructor cannot be directly invoked. 20 * @since 8 21 * @syscap SystemCapability.Utils.Lang 22 */ 23 constructor(); 24 /** 25 * Gets the element number of the PlainArray. 26 * @since 8 27 * @syscap SystemCapability.Utils.Lang 28 */ 29 length: number; 30 /** 31 * Appends a key-value pair to PlainArray 32 * @param key Added the key of key-value 33 * @param value Added the value of key-value 34 * @throws { BusinessError } 10200011 - The add method cannot be bound. 35 * @throws { BusinessError } 401 - The type of parameters are invalid. 36 * @since 8 37 * @syscap SystemCapability.Utils.Lang 38 */ 39 add(key: number, value: T): void; 40 /** 41 * Clears the current PlainArray object 42 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 43 * @since 8 44 * @syscap SystemCapability.Utils.Lang 45 */ 46 clear(): void; 47 /** 48 * Obtains a clone of the current PlainArray object 49 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 50 * @since 8 51 * @syscap SystemCapability.Utils.Lang 52 */ 53 clone(): PlainArray<T>; 54 /** 55 * Checks whether the current PlainArray object contains the specified key 56 * @param key need to determine whether to include the key 57 * @returns the boolean type 58 * @throws { BusinessError } 10200011 - The has method cannot be bound. 59 * @throws { BusinessError } 401 - The type of parameters are invalid. 60 * @since 8 61 * @syscap SystemCapability.Utils.Lang 62 */ 63 has(key: number): boolean; 64 /** 65 * Queries the value associated with the specified key 66 * @param key Looking for goals 67 * @returns the value of key-value pairs 68 * @throws { BusinessError } 10200011 - The get method cannot be bound. 69 * @throws { BusinessError } 401 - The type of parameters are invalid. 70 * @since 8 71 * @syscap SystemCapability.Utils.Lang 72 */ 73 get(key: number): T; 74 /** 75 * Queries the index for a specified key 76 * @param key Looking for goals 77 * @returns Subscript corresponding to target 78 * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. 79 * @throws { BusinessError } 401 - The type of parameters are invalid. 80 * @since 8 81 * @syscap SystemCapability.Utils.Lang 82 */ 83 getIndexOfKey(key: number): number; 84 /** 85 * Queries the index for a specified value 86 * @param value Looking for goals 87 * @returns Subscript corresponding to target 88 * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. 89 * @since 8 90 * @syscap SystemCapability.Utils.Lang 91 */ 92 getIndexOfValue(value: T): number; 93 /** 94 * Checks whether the current PlainArray object is empty 95 * @returns the boolean type 96 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 97 * @since 8 98 * @syscap SystemCapability.Utils.Lang 99 */ 100 isEmpty(): boolean; 101 /** 102 * Queries the key at a specified index 103 * @param index Target subscript for search 104 * @returns the key of key-value pairs 105 * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. 106 * @throws { BusinessError } 401 - The type of parameters are invalid. 107 * @since 8 108 * @syscap SystemCapability.Utils.Lang 109 */ 110 getKeyAt(index: number): number; 111 /** 112 * Remove the key-value pair based on a specified key if it exists and return the value 113 * @param key Target to be deleted 114 * @returns Target mapped value 115 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 116 * @throws { BusinessError } 401 - The type of parameters are invalid. 117 * @since 8 118 * @syscap SystemCapability.Utils.Lang 119 */ 120 remove(key: number): T; 121 /** 122 * Remove the key-value pair at a specified index if it exists and return the value 123 * @param index Target subscript for search 124 * @returns the T type 125 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 126 * @throws { BusinessError } 401 - The type of parameters are invalid. 127 * @since 8 128 * @syscap SystemCapability.Utils.Lang 129 */ 130 removeAt(index: number): T; 131 /** 132 * Remove a group of key-value pairs from a specified index 133 * @param index remove start index 134 * @param size Expected deletion quantity 135 * @returns Actual deleted quantity 136 * @throws { BusinessError } 10200011 - The removeRangeFrom method cannot be bound. 137 * @throws { BusinessError } 10200001 - The value of index is out of range. 138 * @throws { BusinessError } 401 - The type of parameters are invalid. 139 * @since 8 140 * @syscap SystemCapability.Utils.Lang 141 */ 142 removeRangeFrom(index: number, size: number): number; 143 /** 144 * Update value on specified index 145 * @param index Target subscript for search 146 * @param value Updated the target mapped value 147 * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. 148 * @throws { BusinessError } 10200001 - The value of index is out of range. 149 * @throws { BusinessError } 401 - The type of parameters are invalid. 150 * @since 8 151 * @syscap SystemCapability.Utils.Lang 152 */ 153 setValueAt(index: number, value: T): void; 154 /** 155 * Obtains the string representation of the PlainArray object 156 * @throws { BusinessError } 10200011 - The toString method cannot be bound. 157 * @since 8 158 * @syscap SystemCapability.Utils.Lang 159 */ 160 toString(): String; 161 /** 162 * Queries the value at a specified index 163 * @param index Target subscript for search 164 * @returns the value of key-value pairs 165 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 166 * @throws { BusinessError } 10200001 - The value of index is out of range. 167 * @throws { BusinessError } 401 - The type of parameters are invalid. 168 * @since 8 169 * @syscap SystemCapability.Utils.Lang 170 */ 171 getValueAt(index: number): T; 172 /** 173 * Executes a provided function once for each value in the PlainArray object. 174 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 175 * @throws { BusinessError } 401 - The type of parameters are invalid. 176 * @since 8 177 * @syscap SystemCapability.Utils.Lang 178 */ 179 forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void, 180 thisArg?: Object): void; 181 /** 182 * returns an iterator.Each item of the iterator is a Javascript Object 183 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 184 * @since 8 185 * @syscap SystemCapability.Utils.Lang 186 */ 187 [Symbol.iterator](): IterableIterator<[number, T]>; 188} 189 190export default PlainArray; 191