Re: [問題] 關於clear() insert()與erase()in hw5
※ 引述《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
12/23 00:19, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):