summaryrefslogtreecommitdiffstats
path: root/stlport/stlport/stl/_slist_base.c
blob: e0e68c9b2608c2a5b58679dd03866d926c2adc3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 *
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Copyright (c) 1997
 * Moscow Center for SPARC Technology
 *
 * Copyright (c) 1999
 * Boris Fomitchev
 *
 * This material is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * Permission to use or copy this software for any purpose is hereby granted
 * without fee, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 */
#ifndef _STLP_SLIST_BASE_C
#define _STLP_SLIST_BASE_C

#ifndef _STLP_INTERNAL_SLIST_BASE_H
#  include <stl/_slist_base.h>
#endif

_STLP_BEGIN_NAMESPACE

_STLP_MOVE_TO_PRIV_NAMESPACE

template <class _Dummy>
_Slist_node_base*  _STLP_CALL
_Sl_global<_Dummy>::__previous(_Slist_node_base* __head,
                               const _Slist_node_base* __node) {
  while (__head && __head->_M_next != __node)
    __head = __head->_M_next;
  return __head;
}

template <class _Dummy>
void _STLP_CALL
_Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos, _Slist_node_base* __head) {
  _Slist_node_base* __before_last = __previous(__head, 0);
  if (__before_last != __head) {
    _Slist_node_base* __after = __pos->_M_next;
    __pos->_M_next = __head->_M_next;
    __head->_M_next = 0;
    __before_last->_M_next = __after;
  }
}

template <class _Dummy>
void _STLP_CALL
_Sl_global<_Dummy>::__splice_after(_Slist_node_base* __pos,
                                   _Slist_node_base* __before_first,
                                   _Slist_node_base* __before_last) {
  if (__pos != __before_first && __pos != __before_last) {
    _Slist_node_base* __first = __before_first->_M_next;
    _Slist_node_base* __after = __pos->_M_next;
    __before_first->_M_next = __before_last->_M_next;
    __pos->_M_next = __first;
    __before_last->_M_next = __after;
  }
}

template <class _Dummy>
_Slist_node_base* _STLP_CALL
_Sl_global<_Dummy>::__reverse(_Slist_node_base* __node) {
  _Slist_node_base* __result = __node;
  __node = __node->_M_next;
  __result->_M_next = 0;
  while(__node) {
    _Slist_node_base* __next = __node->_M_next;
    __node->_M_next = __result;
    __result = __node;
    __node = __next;
  }
  return __result;
}

template <class _Dummy>
size_t _STLP_CALL
_Sl_global<_Dummy>::size(_Slist_node_base* __node) {
  size_t __result = 0;
  for ( ; __node != 0; __node = __node->_M_next)
    ++__result;
  return __result;
}

_STLP_MOVE_TO_STD_NAMESPACE

_STLP_END_NAMESPACE

#endif /*  _STLP_SLIST_BASE_C */

// Local Variables:
// mode:C++
// End: