作者trancewu (exile me)
看板EE_DSnP
标题Re: [问题] getlist的回传到底是?
时间Thu May 1 22:17:27 2008
※ 引述《BattleRoyale (翔焰)》之铭言:
: 在
: getMemRecycleList 呼叫 _recycleList[m].getList(n)
: 在getList中 它回传的是MemRecycleList<T>*
: 想请问说它到底要回传什麽呢@@"
: 里面的要求写说:
: // Go through this and _nextList,
: // find out a recycle list whose "_arrSize" == "n"
: // If not found, create a new MemRecycleList with _arrSize = n
: // and add to the last MemRecycleList
: // So, should never return NULL
: 这边的NULL跟原始reference code所说的return 0有一样吗?
: 我个人是觉得当找不到recyclist中有先前被回收的资料就要return 0
: 那有找到的话 是要retrurn什麽东西咧@__@
借一下之前的格式...
_recycleList[0] -> MemRecycleList
_arraySize = 0
_first -> Obj1 -> Obj2
_nextList -> MemRecycleList
_arraySize = 256
_first -> Obj3 -> Obj4
_nextList -> null
就是说今天假设要找一个_arraySize是256的MemRecycleList,
所以就先从_recycleList[0](因为256%256=0)所指到的MemRecycleList开始找,
如果没有找到就找_nextList所指到的MemRecycleList,
在没有就继续找_nextList指到的MemRecycleList,
如果找到了就可以回传this pointer或是前一个的_nextList。
一直到最後如果没有找到(也就是说_nextList==0)
这样就用_nextList去new一个新的MemRecycleList,
然後将这回传。
大概就是这样~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.251.153
1F:推 BattleRoyale:了解!! 谢谢@__@ 05/01 22:28