第9章 資料結構

2021-07-11 20:47:15 字數 880 閱讀 4889

9.1.1 建立和訪問乙個兩維陣列

[root@wx03 4]# cat a1.pl

@aoa = (

["fred", "barney" ],

["george", "jane", "elroy" ],

["homer", "marge", "bart" ],

);print $aoa[0]->[1];

print "\n";

[root@wx03 4]# perl a1.pl

barney

$aoa[0]->[1]; [0]表示第乙個元素,->[1]表示陣列引用的第2個元素

請注意 $array[3] 和 $array->[3] 是不一樣的。第乙個東西講的是 @array 裡的第四個元素, 而第二個東西講

的是乙個儲存在 $array 裡的陣列(可能是匿名的陣列)引用的第四個元素。

[root@wx03 4]# cat a2.pl

$ref_to_aoa = [

[ "fred", "barney674128462", "pebbles", "bamm bamm", "dino", ],

[ "homer", "bart", "marge", "maggie", ],

[ "george", "jane", "elroy", "judy", ],

];print $ref_to_aoa->[0]->[1];

print "\n";

[root@wx03 4]# perl a2.pl

barney674128462

請記住在每一對相鄰的花括弧或方括弧之間有乙個隱含的 ->。因此下面兩行:

[root@wx03 4]# cat tmp.out

第9章 資料結構

第9章 資料結構 my frames,button my sub of 日誌查詢 push button2 溫金簡訊查詢 push button3 中均簡訊查詢 push button4 機器資訊查詢 push button5,ip資訊查詢 push button6,裝置資訊維護 push butt...

尚矽谷資料結構 第 9 章 雜湊表

表示乙個雇員 class emp override public string tostring 建立emplinkedlist,表示鍊錶 class emplinkedlist 如果不是第乙個雇員,則使用乙個輔助的指標,幫助定位到最後 emp curemp head while true cure...

第3章 資料結構 佇列

佇列的定義 先進先出 插入在隊尾,刪除在隊頭 抽象型別定義 佇列順序儲存 出佇列 移動隊頭指標 空佇列 front rear 滿佇列 front rear 假溢位 問題 佇列有空位,但是無法存放 判斷佇列空或滿 法2 空閒單元 還有乙個空閒單元時,隊列為滿 佇列長度計算公式 rear front l...