1191 |
return pNewChunk; |
return pNewChunk; |
1192 |
} |
} |
1193 |
|
|
1194 |
/** @brief Moves a sub chunk. |
/** @brief Moves a sub chunk witin this list. |
1195 |
* |
* |
1196 |
* Moves a sub chunk from one position in a list to another |
* Moves a sub chunk from one position in this list to another |
1197 |
* position in the same list. The pSrc chunk is placed before the |
* position in the same list. The pSrc chunk is placed before the |
1198 |
* pDst chunk. |
* pDst chunk. |
1199 |
* |
* |
1209 |
pSubChunks->insert(iter, pSrc); |
pSubChunks->insert(iter, pSrc); |
1210 |
} |
} |
1211 |
|
|
1212 |
|
/** @brief Moves a sub chunk from this list to another list. |
1213 |
|
* |
1214 |
|
* Moves a sub chunk from this list list to the end of another |
1215 |
|
* list. |
1216 |
|
* |
1217 |
|
* @param pSrc - sub chunk to be moved |
1218 |
|
* @param pDst - destination list where the chunk shall be moved to |
1219 |
|
*/ |
1220 |
|
void List::MoveSubChunk(Chunk* pSrc, List* pNewParent) { |
1221 |
|
if (pNewParent == this || !pNewParent) return; |
1222 |
|
if (!pSubChunks) LoadSubChunks(); |
1223 |
|
if (!pNewParent->pSubChunks) pNewParent->LoadSubChunks(); |
1224 |
|
pSubChunks->remove(pSrc); |
1225 |
|
pNewParent->pSubChunks->push_back(pSrc); |
1226 |
|
// update chunk id map of this List |
1227 |
|
if ((*pSubChunksMap)[pSrc->GetChunkID()] == pSrc) { |
1228 |
|
pSubChunksMap->erase(pSrc->GetChunkID()); |
1229 |
|
// try to find another chunk of the same chunk ID |
1230 |
|
ChunkList::iterator iter = pSubChunks->begin(); |
1231 |
|
ChunkList::iterator end = pSubChunks->end(); |
1232 |
|
for (; iter != end; ++iter) { |
1233 |
|
if ((*iter)->GetChunkID() == pSrc->GetChunkID()) { |
1234 |
|
(*pSubChunksMap)[pSrc->GetChunkID()] = *iter; |
1235 |
|
break; // we're done, stop search |
1236 |
|
} |
1237 |
|
} |
1238 |
|
} |
1239 |
|
// update chunk id map of other list |
1240 |
|
if (!(*pNewParent->pSubChunksMap)[pSrc->GetChunkID()]) |
1241 |
|
(*pNewParent->pSubChunksMap)[pSrc->GetChunkID()] = pSrc; |
1242 |
|
} |
1243 |
|
|
1244 |
/** @brief Creates a new list sub chunk. |
/** @brief Creates a new list sub chunk. |
1245 |
* |
* |
1246 |
* Creates and adds a new list sub chunk to this list chunk. Note that |
* Creates and adds a new list sub chunk to this list chunk. Note that |