From 2f2239d7f3bfccf9a378867ba9e48401608ec92e Mon Sep 17 00:00:00 2001 From: chengyuli Date: Thu, 11 Sep 2025 16:18:16 +0800 Subject: [PATCH] Container check empty Issue: https://gitee.com/openharmony/interface_sdk-js/issues/ICXK0G Signed-off-by: chengyuli Change-Id: I0932dd9b57fa147565bbcf2a7042ef269e382039 --- api/@ohos.util.Deque.d.ts | 16 ++++++++-------- api/@ohos.util.LinkedList.d.ts | 16 ++++++++-------- api/@ohos.util.List.d.ts | 4 ++-- api/@ohos.util.Stack.d.ts | 8 ++++---- api/@ohos.util.TreeMap.d.ts | 8 ++++---- api/@ohos.util.TreeSet.d.ts | 8 ++++---- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/api/@ohos.util.Deque.d.ts b/api/@ohos.util.Deque.d.ts index e09c64cf80..e18d3b8152 100644 --- a/api/@ohos.util.Deque.d.ts +++ b/api/@ohos.util.Deque.d.ts @@ -231,14 +231,14 @@ declare class Deque { /** * Obtains the header element of a deque. * - * @returns { T | undefined } the first element of the deque if it exists, otherwise returns undefined. + * @returns { T } the first element of the deque. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getFirst(): T | undefined; + getFirst(): T; /** * Obtains the end element of a deque. @@ -272,14 +272,14 @@ declare class Deque { /** * Obtains the end element of a deque. * - * @returns { T | undefined } the last element of the deque if it exists, otherwise returns undefined. + * @returns { T } the last element of the deque if it exists, otherwise returns undefined. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getLast(): T | undefined; + getLast(): T; /** * Obtains the header element of a deque and delete the element. @@ -313,14 +313,14 @@ declare class Deque { /** * Obtains the header element of a deque and delete the element. * - * @returns { T | undefined } the deleted element of the deque if it exists, otherwise returns undefined. + * @returns { T } the deleted element of the deque if it exists, otherwise returns undefined. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - popFirst(): T | undefined; + popFirst(): T; /** * Obtains the end element of a deque and delete the element. @@ -354,14 +354,14 @@ declare class Deque { /** * Obtains the end element of a deque and delete the element. * - * @returns { T | undefined } the deleted element of the deque if it exists, otherwise returns undefined. + * @returns { T } the deleted element of the deque if it exists, otherwise returns undefined. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - popLast(): T | undefined; + popLast(): T; /** * Executes a provided function once for each value in the deque object. diff --git a/api/@ohos.util.LinkedList.d.ts b/api/@ohos.util.LinkedList.d.ts index 9928002778..c74e0d8571 100644 --- a/api/@ohos.util.LinkedList.d.ts +++ b/api/@ohos.util.LinkedList.d.ts @@ -235,14 +235,14 @@ declare class LinkedList { * Obtains an element at the specified position in this container. * * @param { int } index - specified position - * @returns { T | undefined} the element at the specified index, or undefined if the index is out of range. + * @returns { T } the element at the specified index, or undefined if the index is out of range. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - get(index: int): T | undefined; + get(index: int): T; /** * Inserts the specified element at the beginning of this LinkedList. @@ -683,14 +683,14 @@ declare class LinkedList { /** * Obtains the first element in this container. * - * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @returns { T } the T type, returns undefined if linkedList is empty * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getFirst(): T | undefined; + getFirst(): T; /** * Returns the Last element (the item at index length-1) of this linkedlist. @@ -726,14 +726,14 @@ declare class LinkedList { /** * Obtains the last element in this container. * - * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @returns { T } the T type, returns undefined if linkedList is empty * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getLast(): T | undefined; + getLast(): T; /** * Replaces the element at the specified position in this Vector with the specified element @@ -790,7 +790,7 @@ declare class LinkedList { * * @param { int } index - Position index of the target element. * @param { T } element - Element to be used for replacement. - * @returns { T | undefined } the T type ,returns undefined if linkedList is empty + * @returns { T } the T type * @throws { BusinessError } 10200001 - The value of index is out of range. * 1.Mandatory parameters are left unspecified; * 2.Incorrect parameter types; @@ -801,7 +801,7 @@ declare class LinkedList { * @since 20 * @arkts 1.2 */ - set(index: int, element: T): T | undefined; + set(index: int, element: T): T; /** * Replaces each element of this linkedlist with the result of applying the operator to that element. diff --git a/api/@ohos.util.List.d.ts b/api/@ohos.util.List.d.ts index 7b4aaa6a2e..5d4d25075c 100644 --- a/api/@ohos.util.List.d.ts +++ b/api/@ohos.util.List.d.ts @@ -592,7 +592,7 @@ declare class List { * * @param { int } index - Position index of the target element. * @param { T } element - Element to be used for replacement. - * @returns { T | undefined } the T type, returns undefined if linkedList is empty + * @returns { T } the T type * @throws { BusinessError } 10200001 - The value of "index" is out of range. It must be >= 0 && <= ${length - 1}. * Received value is: ${index} * @syscap SystemCapability.Utils.Lang @@ -601,7 +601,7 @@ declare class List { * @since 20 * @arkts 1.2 */ - set(index: int, element: T): T | undefined; + set(index: int, element: T): T; /** * Compares the specified object with this list for equality.if the object are the same as this list * return true, otherwise return false. diff --git a/api/@ohos.util.Stack.d.ts b/api/@ohos.util.Stack.d.ts index 2dc7eedf00..8f1366a0a5 100644 --- a/api/@ohos.util.Stack.d.ts +++ b/api/@ohos.util.Stack.d.ts @@ -173,14 +173,14 @@ declare class Stack { * Looks at the object at the top of this stack without removing it from the stack * Return undefined if this stack is empty * - * @returns { T | undefined } the top value, or undefined if container is empty + * @returns { T } the top value * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - peek(): T | undefined; + peek(): T; /** * Removes the object at the top of this stack and returns that object as the value of this function @@ -218,14 +218,14 @@ declare class Stack { * 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 { T | undefined } Stack top value, or undefined if container is empty + * @returns { T } Stack top value * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - pop(): T | undefined; + pop(): T; /** * Pushes an item onto the top of this stack diff --git a/api/@ohos.util.TreeMap.d.ts b/api/@ohos.util.TreeMap.d.ts index 68a1d106d3..413c6542da 100644 --- a/api/@ohos.util.TreeMap.d.ts +++ b/api/@ohos.util.TreeMap.d.ts @@ -349,27 +349,27 @@ declare class TreeMap { * Obtains the first sorted key in the treemap. * Or returns undefined if tree map is empty * - * @returns { K | undefined } the key of the first element if exists, undefined otherwise + * @returns { K } the key of the first element * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getFirstKey(): K | undefined; + getFirstKey(): K; /** * Obtains the last sorted key in the treemap. * Or returns undefined if tree map is empty * - * @returns { K | undefined } the key of the last element if exists, undefined otherwise + * @returns { K } the key of the last element * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - getLastKey(): K | undefined; + getLastKey(): K; /** * Adds all element groups in one map to another map diff --git a/api/@ohos.util.TreeSet.d.ts b/api/@ohos.util.TreeSet.d.ts index 9a61949bd4..8d8eb2b72c 100644 --- a/api/@ohos.util.TreeSet.d.ts +++ b/api/@ohos.util.TreeSet.d.ts @@ -565,26 +565,26 @@ declare class TreeSet { /** * Return and delete the first element, returns undefined if tree set is empty * - * @returns { T | undefined} the value of the first element in the TreeSet if exists, undefined otherwise + * @returns { T } the value of the first element in the TreeSet * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - popFirst(): T | undefined; + popFirst(): T; /** * Return and delete the last element, returns undefined if tree set is empty * - * @returns { T | undefined } the value of the last element in the TreeSet if exists, undefined otherwise + * @returns { T } the value of the last element in the TreeSet * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - popLast(): T | undefined; + popLast(): T; /** * Executes a provided function once for each value in the Set object. -- Gitee