Re: [問題] 關於clear() insert()與erase()in hw5

看板EE_DSnP作者 (Ric)時間17年前 (2006/12/22 22:54), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《scxz (tears and rain)》之銘言: : 標題: [問題] 關於clear() insert()與erase()in hw5 : 時間: Fri Dec 22 11:43:15 2006 : : 抱歉想請問一下 : : clear()這個function要把_data給delete掉嗎 還是只要把所有element弄掉就好 : 而可以保留之前要到的記憶體空間呢? 請見 HW#5 pdf 說明檔 page 3. - clear(): empty the ADT. For SList and DList, delete their SListNode and DListNode, respectively. For Array, reset its _size to 0, DO NOT release its memory. THis is to make it consistent with STL. Please follow it. Otherwise, your random number in LTestObj will be different from ours. : : 關於insert()與erase()這兩個function : 他們return的type是iterator : : 那該回傳的的位置是 : insert --> 傳進來的pos的下一個 : erase --> 傳近來的pos這個 : 這樣嗎 : : 另外ref code好像也沒有使用到這些回傳的iterator : 那請問是基於什麼原因要回傳iterator呢 : 請見 HW#5 pdf 說明檔 pages 2-3. This is to make the function prototype the same as STL. : -- : ※ 發信站: 批踢踢實業坊(ptt.cc) : ◆ From: 140.112.241.149 : ※ 編輯: scxz 來自: 140.112.241.149 (12/22 11:44) : 推 valken:insert erase回傳的iterator在pdf裡有寫 12/22 13:05 : 推 davidlue:我有delete掉耶 反正push本來就要考慮空的情形 12/22 19:13 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.212.26.31

12/23 00:19, , 1F
真抱歉...orz
12/23 00:19, 1F
文章代碼(AID): #15Y_6OPB (EE_DSnP)
文章代碼(AID): #15Y_6OPB (EE_DSnP)