0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

OpenHarmony語(yǔ)言基礎(chǔ)類庫(kù)【@ohos.util.LightWeightMap (非線性容器LightWeightMap)】

jf_46214456 ? 來(lái)源:jf_46214456 ? 作者:jf_46214456 ? 2024-04-26 17:59 ? 次閱讀

LightWeightMap可用于存儲(chǔ)具有關(guān)聯(lián)關(guān)系的key-value鍵值對(duì)集合,存儲(chǔ)元素中key值唯一,每個(gè)key對(duì)應(yīng)一個(gè)value。

LightWeightMap依據(jù)泛型定義,采用輕量級(jí)結(jié)構(gòu),初始默認(rèn)容量大小為8,每次擴(kuò)容大小為原始容量的兩倍。

集合中key值的查找依賴于hash算法,通過(guò)一個(gè)數(shù)組存儲(chǔ)hash值,然后映射到其他數(shù)組中的key值及value值。

LightWeightMap和[HashMap]都是用來(lái)存儲(chǔ)鍵值對(duì)的集合,LightWeightMap占用內(nèi)存更小。

推薦使用場(chǎng)景: 當(dāng)需要存取key-value鍵值對(duì)時(shí),推薦使用占用內(nèi)存更小的LightWeightMap。

文檔中存在泛型的使用,涉及以下泛型標(biāo)記符:

  • K:Key,鍵
  • V:Value,值

說(shuō)明:

本模塊首批接口從API version 8開(kāi)始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨(dú)標(biāo)記接口的起始版本。

導(dǎo)入模塊

import LightWeightMap from '@ohos.util.LightWeightMap';

LightWeightMap

屬性

系統(tǒng)能力: SystemCapability.Utils.Lang

名稱類型可讀可寫說(shuō)明
lengthnumberLightWeightMap的元素個(gè)數(shù)。

鴻蒙開(kāi)發(fā)指導(dǎo)文檔:[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]點(diǎn)擊或者復(fù)制轉(zhuǎn)到。

constructor

constructor()

LightWeightMap的構(gòu)造函數(shù)。

系統(tǒng)能力: SystemCapability.Utils.Lang

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200012The LightWeightMap's constructor cannot be directly invoked.

示例:

let lightWeightMap = new LightWeightMap();

isEmpty

isEmpty(): boolean

判斷該LightWeightMap是否為空。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
boolean為空返回true,不為空返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The isEmpty method cannot be bound.

示例:

const lightWeightMap = new LightWeightMap();
let result = lightWeightMap.isEmpty();

hasAll

hasAll(map: LightWeightMap): boolean

判斷此LightWeightMap中是否含有該指定map中的所有元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù)

參數(shù)名類型必填說(shuō)明
mapLightWeightMap比較對(duì)象。

返回值:

類型說(shuō)明
boolean包含所有元素返回true,否則返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The hasAll method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
map.set("sparrow", 356);
let result = lightWeightMap.hasAll(map);

hasKey

hasKey(key: K): boolean

判斷此LightWeightMap中是否含有該指定key。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
keyK指定key。

返回值:

類型說(shuō)明
boolean包含指定key返回true,否則返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The hasKey method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
let result = lightWeightMap.hasKey("squirrel");

hasValue

hasValue(value: V): boolean

判斷此LightWeightMap中是否含有該指定value。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
valueV指定元素。

返回值:

類型說(shuō)明
boolean包含指定元素返回true,否則返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The hasValue method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
let result = lightWeightMap.hasValue(123);

increaseCapacityTo

increaseCapacityTo(minimumCapacity: number): void

將當(dāng)前LightWeightMap擴(kuò)容至可以容納指定數(shù)量元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
minimumCapacitynumber需要容納的數(shù)量。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The increaseCapacityTo method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.increaseCapacityTo(10);

get

get(key: K): V

獲取指定key所對(duì)應(yīng)的value。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
keyK指定key。

返回值:

類型說(shuō)明
V返回key映射的value值。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The get method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.get("sparrow");

getIndexOfKey

getIndexOfKey(key: K): number

查找key元素第一次出現(xiàn)的下標(biāo)值,如果沒(méi)有找到該元素返回-1。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
keyK被查找的元素。

返回值:

類型說(shuō)明
number返回key元素第一次出現(xiàn)時(shí)的下標(biāo)值,查找失敗返回-1。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The getIndexOfKey method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfKey("sparrow");

getIndexOfValue

getIndexOfValue(value: V): number

查找value元素第一次出現(xiàn)的下標(biāo)值,如果沒(méi)有找到該元素返回-1。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
valueV被查找的元素。

返回值:

類型說(shuō)明
number返回value元素第一次出現(xiàn)時(shí)的下標(biāo)值,查找失敗返回-1。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The getIndexOfValue method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfValue(123);

getKeyAt

getKeyAt(index: number): K

查找指定下標(biāo)的元素鍵值對(duì)中key值,否則返回undefined。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
indexnumber所查找的下標(biāo)。

返回值:

類型說(shuō)明
K返回該下標(biāo)對(duì)應(yīng)的元素鍵值對(duì)中key值。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The getKeyAt method cannot be bound.
10200001The value of index is out of range.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getKeyAt(1);

setAll

setAll(map: LightWeightMap): void

將一個(gè)LightWeightMap中的所有元素組添加到另一個(gè)lightWeightMap中。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
mapLightWeightMap被添加元素的lightWeightMap。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The setAll method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
map.setAll(lightWeightMap); // 將lightWeightMap中所有的元素添加到map中

set

set(key: K, value: V): Object

向LightWeightMap中添加或更新一組數(shù)據(jù)。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
keyK添加成員數(shù)據(jù)的鍵名。
valueV添加成員數(shù)據(jù)的值。

返回值:

類型說(shuō)明
Object返回添加數(shù)據(jù)后的lightWeightMap。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The set method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.set("squirrel", 123);

remove

remove(key: K): V

刪除并返回指定key映射的元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
keyK指定key。

返回值:

類型說(shuō)明
V返回刪除元素的值。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The remove method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.remove("sparrow");

removeAt

removeAt(index: number): boolean

刪除指定下標(biāo)對(duì)應(yīng)的元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
indexnumber指定下標(biāo)。

返回值:

類型說(shuō)明
boolean成功刪除元素返回true,否則返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The removeAt method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.removeAt(1);

setValueAt

setValueAt(index: number, newValue: V): boolean

替換指定下標(biāo)對(duì)應(yīng)鍵值對(duì)中的元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
indexnumber指定下標(biāo)。
newValueV替換鍵值對(duì)中的值。

返回值:

類型說(shuō)明
boolean成功替換指定位置數(shù)據(jù)返回true,否則返回false。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The setValueAt method cannot be bound.
10200001The value of index is out of range.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.setValueAt(1, 3546);

getValueAt

getValueAt(index: number): V

獲取指定下標(biāo)對(duì)應(yīng)鍵值對(duì)中的元素。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
indexnumber指定下標(biāo)。

返回值:

類型說(shuō)明
V返回指定下標(biāo)對(duì)應(yīng)鍵值對(duì)中的元素。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The getValueAt method cannot be bound.
10200001The value of index is out of range.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getValueAt(1);

clear

clear(): void

清除LightWeightMap中的所有元素,并把length置為0。

系統(tǒng)能力: SystemCapability.Utils.Lang

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The clear method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.clear();

keys

keys(): IterableIterator

返回包含此映射中包含的鍵的新迭代器對(duì)象。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
IterableIterator返回一個(gè)迭代器。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The keys method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
  console.log("value:" + temp);
  temp = iter.next().value;
}

values

values(): IterableIterator

返回包含此映射中包含的鍵值的新迭代器對(duì)象。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
IterableIterator返回一個(gè)迭代器。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The values method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.values();
let temp = iter.next().value;
while(temp != undefined) {
  console.log("value:" + temp);
  temp = iter.next().value;
}

forEach

forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void

通過(guò)回調(diào)函數(shù)來(lái)遍歷實(shí)例對(duì)象上的元素以及元素對(duì)應(yīng)的下標(biāo)。

系統(tǒng)能力: SystemCapability.Utils.Lang

參數(shù):

參數(shù)名類型必填說(shuō)明
callbackFnfunction回調(diào)函數(shù)。
thisArgObjectcallbackfn被調(diào)用時(shí)用作this值。

callbackfn的參數(shù)說(shuō)明:

參數(shù)名類型必填說(shuō)明
valueV當(dāng)前遍歷到的元素鍵值對(duì)的值。
keyK當(dāng)前遍歷到的元素鍵值對(duì)的鍵。
mapLightWeightMap當(dāng)前調(diào)用forEach方法的實(shí)例對(duì)象。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The forEach method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("sparrow", 123);
lightWeightMap.set("gull", 357);
lightWeightMap.forEach((value, key) = > {
    console.log("value:" + value, "key:" + key);
});

entries

entries(): IterableIterator<[K, V]>

返回包含此映射中包含的鍵值對(duì)的新迭代器對(duì)象。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
IterableIterator<[K, V]>返回一個(gè)迭代器。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The entries method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
  console.log("key:" + temp[0]);
  console.log("value:" + temp[1]);
  temp = iter.next().value;
}

toString

toString(): String

將此映射中包含的鍵值對(duì)拼接成字符串,并返回字符串類型。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
String返回一個(gè)字符串。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The toString method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.toString();

[Symbol.iterator]

HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿

搜狗高速瀏覽器截圖20240326151450.png

Symbol.iterator: IterableIterator<[K, V]>

返回一個(gè)迭代器,迭代器的每一項(xiàng)都是一個(gè) JavaScript 對(duì)象,并返回該對(duì)象。

系統(tǒng)能力: SystemCapability.Utils.Lang

返回值:

類型說(shuō)明
IterableIterator<[K, V]>返回一個(gè)迭代器。

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見(jiàn)[語(yǔ)言基礎(chǔ)類庫(kù)錯(cuò)誤碼]。

錯(cuò)誤碼ID錯(cuò)誤信息
10200011The Symbol.iterator method cannot be bound.

示例:

let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);

// 使用方法一:
for (let item of lightWeightMap) { 
  console.log("key:" + item[0]);
  console.log("value:" + item[1]);
}

// 使用方法二:
let iter = lightWeightMap[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
  console.log("key:" + temp[0]);
  console.log("value:" + temp[1]);
  temp = iter.next().value;
}

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 鴻蒙
    +關(guān)注

    關(guān)注

    57

    文章

    2287

    瀏覽量

    42629
  • HarmonyOS
    +關(guān)注

    關(guān)注

    79

    文章

    1954

    瀏覽量

    29897
  • OpenHarmony
    +關(guān)注

    關(guān)注

    25

    文章

    3607

    瀏覽量

    15956
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util (util工具函數(shù))】

    ……………………
    的頭像 發(fā)表于 04-25 17:41 ?1487次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b> (<b class='flag-5'>util</b>工具函數(shù))】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.ArrayList (線性容器ArrayList)】

    ArrayList是一種線性數(shù)據(jù)結(jié)構(gòu),底層基于數(shù)組實(shí)現(xiàn)。ArrayList會(huì)根據(jù)實(shí)際需要?jiǎng)討B(tài)調(diào)整容量,每次擴(kuò)容增加50%。
    的頭像 發(fā)表于 04-25 18:48 ?567次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.ArrayList (<b class='flag-5'>線性</b><b class='flag-5'>容器</b>ArrayList)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.HashMap (非線性容器HashMap)】

    HashMap底層使用數(shù)組+鏈表+紅黑樹(shù)的方式實(shí)現(xiàn),查詢、插入和刪除的效率都很高。HashMap存儲(chǔ)內(nèi)容基于key-value的鍵值對(duì)映射,不能有重復(fù)的key,且一個(gè)key只能對(duì)應(yīng)一個(gè)value。
    的頭像 發(fā)表于 04-25 22:12 ?775次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.HashMap (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>HashMap)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.LightWeightSet (非線性容器LightWeightSet)】

    LightWeightSet可用于存儲(chǔ)一系列值的集合,存儲(chǔ)元素中value值唯一。
    的頭像 發(fā)表于 04-26 21:21 ?187次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.LightWeightSet (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>LightWeightSet)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.PlainArray (非線性容器PlainArray)】

    PlainArray可用于存儲(chǔ)具有關(guān)聯(lián)關(guān)系的key-value鍵值對(duì)集合,存儲(chǔ)元素中key值唯一,key值類型為number類型,每個(gè)key對(duì)應(yīng)一個(gè)value。
    的頭像 發(fā)表于 05-10 16:31 ?601次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.PlainArray (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>PlainArray)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.Vector (線性容器Vector)】

    Vector是一種線性數(shù)據(jù)結(jié)構(gòu),底層基于數(shù)組實(shí)現(xiàn)。當(dāng)Vector的內(nèi)存用盡時(shí),會(huì)自動(dòng)分配更大的連續(xù)內(nèi)存區(qū),將原先的元素復(fù)制到新的內(nèi)存區(qū),并釋放舊的內(nèi)存區(qū)。使用Vector能夠高效快速地訪問(wèn)元素。
    的頭像 發(fā)表于 04-28 21:24 ?425次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.Vector (<b class='flag-5'>線性</b><b class='flag-5'>容器</b>Vector)】

    HarmonyOS方舟開(kāi)發(fā)框架容器API的介紹與使用

    HashMap、HashSet、TreeMap、TreeSet、LightWeightMap、LightWeightSet、PlainArray七種。非線性容器中的key及value
    發(fā)表于 03-07 11:40

    OpenHarmony 3.1 Beta版本關(guān)鍵特性解析——ArkUI容器API介紹

    、HashSet、TreeMap、TreeSet、LightWeightMap、LightWeightSet、PlainArray 七種。非線性容器中的 key 及 value 的類
    發(fā)表于 04-24 14:58

    HarmonyOS非線性容器特性及使用場(chǎng)景

    非線性容器實(shí)現(xiàn)能快速查找的數(shù)據(jù)結(jié)構(gòu),其底層通過(guò)hash或者紅黑樹(shù)實(shí)現(xiàn),包括HashMap、HashSet、TreeMap、TreeSet、LightWeightMap、LightWeightSet
    發(fā)表于 09-27 15:18

    HarmonyOS語(yǔ)言基礎(chǔ)庫(kù)開(kāi)發(fā)指南上線啦!

    指南中提供了詳細(xì)的介紹和開(kāi)發(fā)指導(dǎo),幫助開(kāi)發(fā)者全面了解并發(fā)實(shí)現(xiàn)、容器庫(kù)基礎(chǔ)操作、XML的生成解析與轉(zhuǎn)換等。 本期HarmonyOS開(kāi)發(fā)者資料直通車帶您快速了解內(nèi)容干貨~ 一、語(yǔ)言基礎(chǔ)
    發(fā)表于 10-18 16:36

    HarmonyOS 非線性容器特性及使用場(chǎng)景

    、LightWeightMap、LightWeightSet、PlainArray 七種。非線性容器中的 key 及 value 的類型均滿足 ECMA 標(biāo)準(zhǔn)。 HashMap HashMap 可用來(lái)存儲(chǔ)具有
    的頭像 發(fā)表于 02-19 20:23 ?373次閱讀

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.HashSet (非線性容器HashSet)】

    HashSet基于[HashMap]實(shí)現(xiàn)。在HashSet中,只對(duì)value對(duì)象進(jìn)行處理。
    的頭像 發(fā)表于 04-26 15:13 ?245次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.HashSet (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>HashSet)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.TreeMap (非線性容器TreeMap)】

    TreeMap可用于存儲(chǔ)具有關(guān)聯(lián)關(guān)系的key-value鍵值對(duì)集合,存儲(chǔ)元素中key值唯一,每個(gè)key對(duì)應(yīng)一個(gè)value。
    的頭像 發(fā)表于 04-28 15:23 ?231次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.TreeMap (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>TreeMap)】

    OpenHarmony語(yǔ)言基礎(chǔ)庫(kù)【@ohos.util.TreeSet (非線性容器TreeSet)】

    TreeSet基于[TreeMap]實(shí)現(xiàn),在TreeSet中,只對(duì)value對(duì)象進(jìn)行處理。TreeSet可用于存儲(chǔ)一系列值的集合,元素中value唯一且有序。
    的頭像 發(fā)表于 04-28 18:02 ?489次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>【@<b class='flag-5'>ohos.util</b>.TreeSet (<b class='flag-5'>非線性</b><b class='flag-5'>容器</b>TreeSet)】

    鴻蒙語(yǔ)言基礎(chǔ)庫(kù)ohos.util.TreeSet 非線性容器TreeSet

    TreeSet基于[TreeMap]實(shí)現(xiàn),在TreeSet中,只對(duì)value對(duì)象進(jìn)行處理。TreeSet可用于存儲(chǔ)一系列值的集合,元素中value唯一且有序。
    的頭像 發(fā)表于 07-11 16:25 ?269次閱讀
    鴻蒙<b class='flag-5'>語(yǔ)言</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>:<b class='flag-5'>ohos.util</b>.TreeSet <b class='flag-5'>非線性</b><b class='flag-5'>容器</b>TreeSet