X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=include%2Fc%2B%2B%2Fstl%2Fstl%2F_slist_base.c;fp=include%2Fc%2B%2B%2Fstl%2Fstl%2F_slist_base.c;h=e0e68c9b2608c2a5b58679dd03866d926c2adc3d;hp=0000000000000000000000000000000000000000;hb=173d8903eb9d51a4ea7d7fa3e52dc86c9bb6d4f1;hpb=b024710fe2b60cd4a42a8993b61333d6cdb56ca3 diff --git a/include/c++/stl/stl/_slist_base.c b/include/c++/stl/stl/_slist_base.c new file mode 100644 index 0000000..e0e68c9 --- /dev/null +++ b/include/c++/stl/stl/_slist_base.c @@ -0,0 +1,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 +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template +_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 +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 +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 +_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 +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: