Re: [問題] getlist的回傳到底是?

看板EE_DSnP作者 (exile me)時間16年前 (2008/05/01 22:17), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《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

05/01 22:28, , 1F
瞭解!! 謝謝@__@
05/01 22:28, 1F
文章代碼(AID): #186T3wEU (EE_DSnP)
文章代碼(AID): #186T3wEU (EE_DSnP)