#include <cmt_list.h>
Collaboration diagram for cmt_list< T >:
Public Types | |
typedef cmt_list_node< T > | NodeV |
typedef NodeV * | Node |
Public Member Functions | |
cmt_list () | |
~cmt_list () | |
void | push_front (const T &t) |
void | push_back (const T &t) |
void | pop_front () |
void | pop_back () |
void | erase (iterator it) |
void | erase (const_iterator it) |
int | size () |
iterator | begin () |
iterator | last () |
iterator | end () |
const_iterator | begin () const |
const_iterator | last () const |
const_iterator | end () const |
void | exchange (iterator it1, iterator it2) |
void | insert_before (iterator it, const T &t) |
void | insert_after (iterator it, const T &t) |
void | move_to_front (iterator source_it) |
void | move_to_back (iterator source_it) |
void | move_before (iterator source_it, iterator dest_it) |
void | move_after (iterator source_it, iterator dest_it) |
Private Member Functions | |
void | remove (Node node) |
Private Attributes | |
Node | m_first |
Node | m_last |
|
|
Definition at line 33 of file cmt_list.h. Referenced by cmt_list< T >::insert_after(), cmt_list< T >::insert_before(), cmt_list< T >::push_back(), and cmt_list< T >::push_front(). |
|
Definition at line 153 of file cmt_list.h. References cmt_list< T >::m_first, and cmt_list< T >::m_last.
|
|
Definition at line 159 of file cmt_list.h. References cmt_list< T >::m_last, and cmt_list< T >::remove().
|
|
Definition at line 248 of file cmt_list.h. References cmt_list< T >::m_first.
00249 {
00250 return (const_iterator (m_first));
00251 }
|
|
Definition at line 232 of file cmt_list.h. References cmt_list< T >::m_first.
00233 { 00234 return (iterator (m_first)); 00235 } |
|
Definition at line 258 of file cmt_list.h.
00259 {
00260 const_iterator it;
00261 return (it);
00262 }
|
|
Definition at line 242 of file cmt_list.h.
00243 { 00244 iterator it; 00245 return (it); 00246 } |
|
Definition at line 214 of file cmt_list.h. References cmt_list< T >::const_iterator::get_node(), and cmt_list< T >::remove().
00215 { 00216 remove (it.get_node ()); 00217 } |
|
Definition at line 209 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), and cmt_list< T >::remove().
00210 { 00211 remove (it.get_node ()); 00212 } |
|
Definition at line 264 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, and cmt_list< T >::Node.
00265 { 00266 if (it1 == it2) return; 00267 00268 Node node1 = it1.get_node (); 00269 if (node1 == 0) return; 00270 Node node2 = it2.get_node (); 00271 if (node2 == 0) return; 00272 00273 Node l1 = node1->m_left; 00274 Node r1 = node1->m_right; 00275 Node l2 = node2->m_left; 00276 Node r2 = node2->m_right; 00277 00278 Node f = m_first; 00279 Node l = m_last; 00280 00281 if ((l2 != 0) && (l2 != node1)) l2->m_right = node1; 00282 if ((r2 != 0) && (r2 != node1)) r2->m_left = node1; 00283 if ((l1 != 0) && (l1 != node2)) r1->m_right = node2; 00284 if ((r1 != 0) && (r1 != node2)) r1->m_left = node2; 00285 00286 node1->m_left = l2; 00287 node1->m_right = r2; 00288 node2->m_left = l1; 00289 node2->m_right = r1; 00290 00291 if (node1 == f) 00292 { 00293 m_first = node2; 00294 } 00295 00296 if (node1 == l) 00297 { 00298 m_last = node2; 00299 } 00300 00301 if (node2 == f) 00302 { 00303 m_first = node1; 00304 } 00305 00306 if (node2 == l) 00307 { 00308 m_last = node1; 00309 } 00310 } |
|
Definition at line 341 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, cmt_list< T >::Node, cmt_list< T >::NodeV, and cmt_list< T >::push_back().
00342 { 00343 Node node = it.get_node (); 00344 00345 if (node == 0) 00346 { 00347 push_back (t); 00348 } 00349 else 00350 { 00351 Node new_node = new NodeV (t); 00352 00353 new_node->m_left = node; 00354 new_node->m_right = node->m_right; 00355 00356 if (node->m_right != 0) 00357 { 00358 node->m_right->m_left = new_node; 00359 } 00360 00361 node->m_right = new_node; 00362 00363 if (node == m_last) 00364 { 00365 m_last = new_node; 00366 } 00367 } 00368 } |
|
Definition at line 312 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), cmt_list< T >::m_first, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, cmt_list< T >::Node, cmt_list< T >::NodeV, and cmt_list< T >::push_front().
00313 { 00314 Node node = it.get_node (); 00315 00316 if (node == 0) 00317 { 00318 push_front (t); 00319 } 00320 else 00321 { 00322 Node new_node = new NodeV (t); 00323 00324 new_node->m_right = node; 00325 new_node->m_left = node->m_left; 00326 00327 if (node->m_left != 0) 00328 { 00329 node->m_left->m_right = new_node; 00330 } 00331 00332 node->m_left = new_node; 00333 00334 if (node == m_first) 00335 { 00336 m_first = new_node; 00337 } 00338 } 00339 } |
|
Definition at line 253 of file cmt_list.h. References cmt_list< T >::m_last.
00254 {
00255 return (const_iterator (m_last));
00256 }
|
|
Definition at line 237 of file cmt_list.h. References cmt_list< T >::m_last.
00238 { 00239 return (iterator (m_last)); 00240 } |
|
Definition at line 442 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, and cmt_list< T >::Node.
00443 { 00444 if (source_it == dest_it) return; 00445 00446 Node source = source_it.get_node (); 00447 if (source == 0) return; 00448 00449 Node dest = dest_it.get_node (); 00450 00451 // First remove the source 00452 00453 if (source == m_first) 00454 { 00455 m_first = source->m_right; 00456 } 00457 00458 if (source == m_last) 00459 { 00460 m_last = source->m_left; 00461 } 00462 00463 if (source->m_right != 0) source->m_right->m_left = source->m_left; 00464 if (source->m_left != 0) source->m_left->m_right = source->m_right; 00465 00466 source->m_right = 0; 00467 source->m_left = 0; 00468 00469 if (dest == 0) 00470 { 00471 // = move_to_front 00472 00473 source->m_left = 0; 00474 source->m_right = m_first; 00475 00476 if (m_first != 0) 00477 { 00478 m_first->m_left = source; 00479 } 00480 00481 m_first = source; 00482 00483 if (m_last == 0) m_last = source; 00484 } 00485 else 00486 { 00487 source->m_left = dest; 00488 source->m_right = dest->m_right; 00489 00490 if (dest->m_right != 0) 00491 { 00492 dest->m_right->m_left = source; 00493 } 00494 00495 dest->m_right = source; 00496 00497 if (dest == m_last) 00498 { 00499 m_last = source; 00500 } 00501 } 00502 } |
|
Definition at line 380 of file cmt_list.h. References cmt_list< T >::iterator::get_node(), cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, and cmt_list< T >::Node. Referenced by cmt_list< T >::move_to_back(), and cmt_list< T >::move_to_front().
00381 { 00382 if (source_it == dest_it) return; 00383 00384 Node source = source_it.get_node (); 00385 if (source == 0) return; 00386 00387 Node dest = dest_it.get_node (); 00388 00389 // First remove the source 00390 00391 if (source == m_first) 00392 { 00393 m_first = source->m_right; 00394 } 00395 00396 if (source == m_last) 00397 { 00398 m_last = source->m_left; 00399 } 00400 00401 if (source->m_right != 0) source->m_right->m_left = source->m_left; 00402 if (source->m_left != 0) source->m_left->m_right = source->m_right; 00403 00404 source->m_right = 0; 00405 source->m_left = 0; 00406 00407 if (dest == 0) 00408 { 00409 // = move_to_back 00410 00411 source->m_right = 0; 00412 source->m_left = m_last; 00413 00414 if (m_last != 0) 00415 { 00416 m_last->m_right = source; 00417 } 00418 00419 m_last = source; 00420 00421 if (m_first == 0) m_first = source; 00422 } 00423 else 00424 { 00425 source->m_right = dest; 00426 source->m_left = dest->m_left; 00427 00428 if (dest->m_left != 0) 00429 { 00430 dest->m_left->m_right = source; 00431 } 00432 00433 dest->m_left = source; 00434 00435 if (dest == m_first) 00436 { 00437 m_first = source; 00438 } 00439 } 00440 } |
|
Definition at line 375 of file cmt_list.h. References cmt_list< T >::move_before().
00376 { 00377 move_before (source_it, end ()); 00378 } |
|
Definition at line 370 of file cmt_list.h. References cmt_list< T >::move_before().
00371 { 00372 move_before (source_it, begin ()); 00373 } |
|
Definition at line 204 of file cmt_list.h. References cmt_list< T >::m_last, and cmt_list< T >::remove().
00205 { 00206 remove (m_last); 00207 } |
|
Definition at line 199 of file cmt_list.h. References cmt_list< T >::m_first, and cmt_list< T >::remove().
00200 { 00201 remove (m_first); 00202 } |
|
Definition at line 183 of file cmt_list.h. References cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, cmt_list< T >::Node, and cmt_list< T >::NodeV. Referenced by cmt_list< T >::insert_after().
|
|
Definition at line 167 of file cmt_list.h. References cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, cmt_list< T >::Node, and cmt_list< T >::NodeV. Referenced by cmt_list< T >::insert_before().
|
|
Definition at line 505 of file cmt_list.h. References cmt_list< T >::m_first, cmt_list< T >::m_last, cmt_list_node< T >::m_left, cmt_list_node< T >::m_right, and cmt_list< T >::Node. Referenced by cmt_list< T >::erase(), cmt_list< T >::pop_back(), cmt_list< T >::pop_front(), and cmt_list< T >::~cmt_list().
00506 { 00507 if (node == 0) return; 00508 00509 if (node == m_first) 00510 { 00511 m_first = node->m_right; 00512 } 00513 00514 if (node == m_last) 00515 { 00516 m_last = node->m_left; 00517 } 00518 00519 if (node->m_right != 0) node->m_right->m_left = node->m_left; 00520 if (node->m_left != 0) node->m_left->m_right = node->m_right; 00521 00522 node->m_right = 0; 00523 node->m_left = 0; 00524 00525 delete node; 00526 } |
|
Definition at line 219 of file cmt_list.h. References cmt_list< T >::m_first, cmt_list_node< T >::m_right, and cmt_list< T >::Node.
|
|
|