作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] 关於clear() insert()与erase()in hw5
时间Fri Dec 22 22:58:54 2006
※ 引述《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
1F:推 scxz:真抱歉...orz 12/23 00:19