template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
struct DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock
Represents the first block in the container. Internal structure.
Definition at line 179 of file LabelledMap.h.
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock::erase |
( |
unsigned int |
idx, |
|
|
unsigned int |
size |
|
) |
| |
|
inline |
Definition at line 247 of file LabelledMap.h.
248 {
249
250
251
252
253 ASSERT( idx < size );
254 if ( size <= ( N + 1 ) )
255 {
256
258 data.nextBlock = 0;
259 }
260 else if ( size == N + 2 )
261 {
262 if ( idx < N )
263 {
265 datas[ N - 1 ] = data.nextBlock->datas[ 0 ];
266 Data tmp = data.nextBlock->datas[ 1 ];
267 delete data.nextBlock;
268 data.lastData = tmp;
269 }
270 else if ( idx == N )
271 {
272 Data tmp = data.nextBlock->datas[ 1 ];
273 delete data.nextBlock;
274 data.lastData = tmp;
275 }
276 else
277 {
278 Data tmp = data.nextBlock->datas[ 0 ];
279 delete data.nextBlock;
280 data.lastData = tmp;
281 }
282 }
283 else
284 {
285 if ( idx < N )
286 {
288 datas[ N - 1 ] = data.nextBlock->datas[ 0 ];
289 data.nextBlock = data.nextBlock->erase( 0, size - N );
290 }
291 else
292 data.nextBlock = data.nextBlock->erase( idx - N, size - N );
293 }
294 }
References DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock::datas.
template<typename TData , unsigned int L, typename TWord , unsigned int N, unsigned int M>
Definition at line 185 of file LabelledMap.h.
186 {
187 ASSERT( idx <= size );
188 if ( size < N )
189 {
191 return (
datas[ idx ] = v );
192 }
193 else if ( size == N )
194 {
195 if ( idx < N )
196 {
197 data.lastData =
datas[ N - 1 ];
199 return (
datas[ idx ] = v );
200 }
201 else
202 {
203 return ( data.lastData = v );
204 }
205 }
206 else if ( size == (N+1) )
207 {
208
209
210 __AnyBlock* next = new __AnyBlock;
211 if ( idx < N )
212 {
213 next->datas[ 0 ] =
datas[ N - 1 ];
214 next->datas[ 1 ] = data.lastData;
216 data.nextBlock = next;
217 return (
datas[ idx ] = v );
218 }
219 else if ( idx == N )
220 {
221 next->datas[ 1 ] = data.lastData;
222 data.nextBlock = next;
223 return ( next->datas[ 0 ] = v );
224 }
225 else
226 {
227 next->datas[ 0 ] = data.lastData;
228 data.nextBlock = next;
229 return ( next->datas[ 1 ] = v );
230 }
231 }
232 else
233 {
234 if ( idx < N )
235 {
238 data.nextBlock->insert( 0, size - N, v1 );
239 return (
datas[ idx ] = v );
240 }
241 else
242 return data.nextBlock->insert( idx - N, size - N, v );
243 }
244 }
References DGtal::LabelledMap< TData, L, TWord, N, M >::__AnyBlock::datas, and DGtal::LabelledMap< TData, L, TWord, N, M >::__FirstBlock::datas.