home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _slist_base.c < prev    next >
C/C++ Source or Header  |  2002-02-02  |  3KB  |  110 lines

  1. /*
  2.  *
  3.  *
  4.  * Copyright (c) 1994
  5.  * Hewlett-Packard Company
  6.  *
  7.  * Copyright (c) 1996,1997
  8.  * Silicon Graphics Computer Systems, Inc.
  9.  *
  10.  * Copyright (c) 1997
  11.  * Moscow Center for SPARC Technology
  12.  *
  13.  * Copyright (c) 1999 
  14.  * Boris Fomitchev
  15.  *
  16.  * This material is provided "as is", with absolutely no warranty expressed
  17.  * or implied. Any use is at your own risk.
  18.  *
  19.  * Permission to use or copy this software for any purpose is hereby granted 
  20.  * without fee, provided the above notices are retained on all copies.
  21.  * Permission to modify the code and to distribute modified code is granted,
  22.  * provided the above notices are retained, and a notice that the code was
  23.  * modified is included with the above copyright notice.
  24.  *
  25.  */
  26. #ifndef _STLP_SLIST_BASE_C
  27. #define _STLP_SLIST_BASE_C
  28.  
  29. #ifndef _STLP_INTERNAL_SLIST_BASE_H
  30. # include <stl/_slist_base.h>
  31. #endif
  32.  
  33. _STLP_BEGIN_NAMESPACE
  34.  
  35. # if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
  36.  
  37. template <class _Dummy>
  38. _Slist_node_base*  _STLP_CALL
  39. _Sl_global<_Dummy>::__previous(_Slist_node_base* __head,
  40.                    const _Slist_node_base* __node)
  41. {
  42.   while (__head && __head->_M_next != __node)
  43.     __head = __head->_M_next;
  44.   return __head;
  45. }
  46.  
  47. template <class _Dummy>
  48. void _STLP_CALL
  49. _Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos, _Slist_node_base* __head)
  50. {
  51.   _Slist_node_base* __before_last = __previous(__head, 0);
  52.   if (__before_last != __head) {
  53.     _Slist_node_base* __after = __pos->_M_next;
  54.     __pos->_M_next = __head->_M_next;
  55.     __head->_M_next = 0;
  56.     __before_last->_M_next = __after;
  57.   }
  58. }
  59.  
  60. template <class _Dummy>
  61. void _STLP_CALL
  62. _Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos,
  63.                    _Slist_node_base* __before_first,
  64.                    _Slist_node_base* __before_last)
  65. {
  66.   if (__pos != __before_first && __pos != __before_last) {
  67.     _Slist_node_base* __first = __before_first->_M_next;
  68.     _Slist_node_base* __after = __pos->_M_next;
  69.     __before_first->_M_next = __before_last->_M_next;
  70.     __pos->_M_next = __first;
  71.     __before_last->_M_next = __after;
  72.   }
  73. }
  74.  
  75. template <class _Dummy>
  76. _Slist_node_base* _STLP_CALL
  77. _Sl_global<_Dummy>::__reverse(_Slist_node_base* __node)
  78. {
  79.   _Slist_node_base* __result = __node;
  80.   __node = __node->_M_next;
  81.   __result->_M_next = 0;
  82.   while(__node) {
  83.     _Slist_node_base* __next = __node->_M_next;
  84.     __node->_M_next = __result;
  85.     __result = __node;
  86.     __node = __next;
  87.   }
  88.   return __result;
  89. }
  90.  
  91. template <class _Dummy> 
  92. size_t _STLP_CALL
  93. _Sl_global<_Dummy>::size(_Slist_node_base* __node)
  94. {
  95.   size_t __result = 0;
  96.   for ( ; __node != 0; __node = __node->_M_next)
  97.     ++__result;
  98.   return __result;
  99. }
  100.  
  101. #endif /* defined (__BUILDING_STLPORT) || ! defined (_STLP_OWN_IOSTREAMS) */
  102.  
  103. _STLP_END_NAMESPACE
  104.  
  105. #endif /*  _STLP_SLIST_BASE_C */
  106.  
  107. // Local Variables:
  108. // mode:C++
  109. // End:
  110.