[
  {
    "path": "stl-3.3-source/algo.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGO_H\n#define __SGI_STL_ALGO_H\n\n#include <algobase.h>\n#include <tempbuf.h>\n#include <stl_algo.h>\n#include <stl_numeric.h>\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from <stl_algo.h>\nusing __STD::for_each; \nusing __STD::find; \nusing __STD::find_if; \nusing __STD::adjacent_find; \nusing __STD::count; \nusing __STD::count_if; \nusing __STD::search; \nusing __STD::search_n; \nusing __STD::swap_ranges; \nusing __STD::transform; \nusing __STD::replace; \nusing __STD::replace_if; \nusing __STD::replace_copy; \nusing __STD::replace_copy_if; \nusing __STD::generate; \nusing __STD::generate_n; \nusing __STD::remove; \nusing __STD::remove_if; \nusing __STD::remove_copy; \nusing __STD::remove_copy_if; \nusing __STD::unique; \nusing __STD::unique_copy; \nusing __STD::reverse; \nusing __STD::reverse_copy; \nusing __STD::rotate; \nusing __STD::rotate_copy; \nusing __STD::random_shuffle; \nusing __STD::random_sample; \nusing __STD::random_sample_n; \nusing __STD::partition; \nusing __STD::stable_partition; \nusing __STD::sort; \nusing __STD::stable_sort; \nusing __STD::partial_sort; \nusing __STD::partial_sort_copy; \nusing __STD::nth_element; \nusing __STD::lower_bound; \nusing __STD::upper_bound; \nusing __STD::equal_range; \nusing __STD::binary_search; \nusing __STD::merge; \nusing __STD::inplace_merge; \nusing __STD::includes; \nusing __STD::set_union; \nusing __STD::set_intersection; \nusing __STD::set_difference; \nusing __STD::set_symmetric_difference; \nusing __STD::min_element; \nusing __STD::max_element; \nusing __STD::next_permutation; \nusing __STD::prev_permutation; \nusing __STD::find_first_of; \nusing __STD::find_end; \nusing __STD::is_sorted; \nusing __STD::is_heap; \n\n// Names from stl_heap.h\nusing __STD::push_heap;\nusing __STD::pop_heap;\nusing __STD::make_heap;\nusing __STD::sort_heap;\n\n// Names from <stl_numeric.h>\nusing __STD::accumulate; \nusing __STD::inner_product; \nusing __STD::partial_sum; \nusing __STD::adjacent_difference; \nusing __STD::power; \nusing __STD::iota; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALGO_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/algobase.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGOBASE_H\n#define __SGI_STL_ALGOBASE_H\n\n#ifndef __SGI_STL_PAIR_H\n#include <pair.h>\n#endif\n#ifndef __SGI_STL_ITERATOR_H\n#include <iterator.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_ALGOBASE_H\n#include <stl_algobase.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H\n#include <stl_uninitialized.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_algobase.h\nusing __STD::iter_swap; \nusing __STD::swap; \nusing __STD::min; \nusing __STD::max; \nusing __STD::copy; \nusing __STD::copy_backward; \nusing __STD::copy_n; \nusing __STD::fill; \nusing __STD::fill_n; \nusing __STD::mismatch; \nusing __STD::equal; \nusing __STD::lexicographical_compare; \nusing __STD::lexicographical_compare_3way; \n\n// Names from stl_uninitialized.h\nusing __STD::uninitialized_copy;\nusing __STD::uninitialized_copy_n;\nusing __STD::uninitialized_fill;\nusing __STD::uninitialized_fill_n;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALGOBASE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/algorithm",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGORITHM\n#define __SGI_STL_ALGORITHM\n\n#include <stl_algobase.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_tempbuf.h>\n#include <stl_algo.h>\n\n#endif /* __SGI_STL_ALGORITHM */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALLOC_H\n#define __SGI_STL_ALLOC_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_ALLOC_H\n#include <stl_alloc.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::__malloc_alloc_template; \nusing __STD::malloc_alloc; \nusing __STD::simple_alloc; \nusing __STD::debug_alloc; \nusing __STD::__default_alloc_template; \nusing __STD::alloc; \nusing __STD::single_client_alloc; \n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\nusing __STD::__malloc_alloc_oom_handler; \n#endif /* __STL_STATIC_TEMPLATE_MEMBER_BUG */\n#ifdef __STL_USE_STD_ALLOCATORS \nusing __STD::allocator;\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/bitset",
    "content": "/*\n * Copyright (c) 1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_BITSET\n#define __SGI_STL_BITSET\n\n// A bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused \n// bits.  (They are the high- order bits in the highest word.)  It is\n// a class invariant of class bitset<> that those unused bits are\n// always zero.\n\n// Most of the actual code isn't contained in bitset<> itself, but in the \n// base class _Base_bitset.  The base class works with whole words, not with\n// individual bits.  This allows us to specialize _Base_bitset for the\n// important special case where the bitset is only a single word.\n\n// The C++ standard does not define the precise semantics of operator[].\n// In this implementation the const version of operator[] is equivalent\n// to test(), except that it does no range checking.  The non-const version\n// returns a reference to a bit, again without doing any range checking.\n\n\n#include <stddef.h>     // for size_t\n#include <string.h>     // for memset\n#include <string>\n#include <stdexcept>    // for invalid_argument, out_of_range, overflow_error\n\n#ifdef __STL_USE_NEW_IOSTREAMS \n#include <iostream>\n#else\n#include <iostream.h>   // for istream, ostream\n#endif\n\n#define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))\n#define __BITSET_WORDS(__n) \\\n ((__n) < 1 ? 1 : ((__n) + __BITS_PER_WORD - 1)/__BITS_PER_WORD)\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1209\n#endif\n\n// structure to aid in counting bits\ntemplate<bool __dummy> \nstruct _Bit_count {\n  static unsigned char _S_bit_count[256];\n};\n\n// Mapping from 8 bit unsigned integers to the index of the first one\n// bit:\ntemplate<bool __dummy> \nstruct _First_one {\n  static unsigned char _S_first_one[256];\n};\n\n//\n// Base class: general case.\n//\n\ntemplate<size_t _Nw>\nstruct _Base_bitset {\n  typedef unsigned long _WordT;\n\n  _WordT _M_w[_Nw];                // 0 is the least significant word.\n\n  _Base_bitset( void ) { _M_do_reset(); }\n  _Base_bitset(unsigned long __val) {\n    _M_do_reset();\n    _M_w[0] = __val;\n  }\n\n  static size_t _S_whichword( size_t __pos )\n    { return __pos / __BITS_PER_WORD; }\n  static size_t _S_whichbyte( size_t __pos )\n    { return (__pos % __BITS_PER_WORD) / CHAR_BIT; }\n  static size_t _S_whichbit( size_t __pos )\n    { return __pos % __BITS_PER_WORD; }\n  static _WordT _S_maskbit( size_t __pos )\n    { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }\n\n  _WordT& _M_getword(size_t __pos)       { return _M_w[_S_whichword(__pos)]; }\n  _WordT  _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; }\n\n  _WordT& _M_hiword()       { return _M_w[_Nw - 1]; }\n  _WordT  _M_hiword() const { return _M_w[_Nw - 1]; }\n\n  void _M_do_and(const _Base_bitset<_Nw>& __x) {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      _M_w[__i] &= __x._M_w[__i];\n    }\n  }\n\n  void _M_do_or(const _Base_bitset<_Nw>& __x) {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      _M_w[__i] |= __x._M_w[__i];\n    }\n  }\n\n  void _M_do_xor(const _Base_bitset<_Nw>& __x) {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      _M_w[__i] ^= __x._M_w[__i];\n    }\n  }\n\n  void _M_do_left_shift(size_t __shift);\n  void _M_do_right_shift(size_t __shift);\n\n  void _M_do_flip() {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      _M_w[__i] = ~_M_w[__i];\n    }\n  }\n\n  void _M_do_set() {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      _M_w[__i] = ~static_cast<_WordT>(0);\n    }\n  }\n\n  void _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); }\n\n  bool _M_is_equal(const _Base_bitset<_Nw>& __x) const {\n    for (size_t __i = 0; __i < _Nw; ++__i) {\n      if (_M_w[__i] != __x._M_w[__i])\n        return false;\n    }\n    return true;\n  }\n\n  bool _M_is_any() const {\n    for ( size_t __i = 0; __i < _Nw; __i++ ) {\n      if ( _M_w[__i] != static_cast<_WordT>(0) )\n        return true;\n    }\n    return false;\n  }\n\n  size_t _M_do_count() const {\n    size_t __result = 0;\n    const unsigned char* __byte_ptr = (const unsigned char*)_M_w;\n    const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw);\n\n    while ( __byte_ptr < __end_ptr ) {\n      __result += _Bit_count<true>::_S_bit_count[*__byte_ptr];\n      __byte_ptr++;\n    }\n    return __result;\n  }\n\n  unsigned long _M_do_to_ulong() const; \n\n  // find first \"on\" bit\n  size_t _M_do_find_first(size_t __not_found) const;\n\n  // find the next \"on\" bit that follows \"prev\"\n  size_t _M_do_find_next(size_t __prev, size_t __not_found) const;\n};\n\n//\n// Definitions of non-inline functions from _Base_bitset.\n// \n\ntemplate<size_t _Nw>\nvoid _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) \n{\n  if (__shift != 0) {\n    const size_t __wshift = __shift / __BITS_PER_WORD;\n    const size_t __offset = __shift % __BITS_PER_WORD;\n\n    if (__offset == 0)\n      for (size_t __n = _Nw - 1; __n >= __wshift; --__n)\n        _M_w[__n] = _M_w[__n - __wshift];\n\n    else {\n      const size_t __sub_offset = __BITS_PER_WORD - __offset;\n      for (size_t __n = _Nw - 1; __n > __wshift; --__n)\n        _M_w[__n] = (_M_w[__n - __wshift] << __offset) | \n                    (_M_w[__n - __wshift - 1] >> __sub_offset);\n      _M_w[__wshift] = _M_w[0] << __offset;\n    }\n\n    fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0));\n  }\n}\n\ntemplate<size_t _Nw>\nvoid _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) \n{\n  if (__shift != 0) {\n    const size_t __wshift = __shift / __BITS_PER_WORD;\n    const size_t __offset = __shift % __BITS_PER_WORD;\n    const size_t __limit = _Nw - __wshift - 1;\n\n    if (__offset == 0)\n      for (size_t __n = 0; __n <= __limit; ++__n)\n        _M_w[__n] = _M_w[__n + __wshift];\n\n    else {\n      const size_t __sub_offset = __BITS_PER_WORD - __offset;\n      for (size_t __n = 0; __n < __limit; ++__n)\n        _M_w[__n] = (_M_w[__n + __wshift] >> __offset) |\n                    (_M_w[__n + __wshift + 1] << __sub_offset);\n      _M_w[__limit] = _M_w[_Nw-1] >> __offset;\n    }\n\n    fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0));\n  }\n}\n\ntemplate<size_t _Nw>\nunsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const\n{\n  for (size_t __i = 1; __i < _Nw; ++__i) \n    if (_M_w[__i]) \n      __STL_THROW(overflow_error(\"bitset\"));\n  \n  return _M_w[0];\n}\n\ntemplate<size_t _Nw>\nsize_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const \n{\n  for ( size_t __i = 0; __i < _Nw; __i++ ) {\n    _WordT __thisword = _M_w[__i];\n    if ( __thisword != static_cast<_WordT>(0) ) {\n      // find byte within word\n      for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {\n        unsigned char __this_byte\n          = static_cast<unsigned char>(__thisword & (~(unsigned char)0));\n        if ( __this_byte )\n          return __i*__BITS_PER_WORD + __j*CHAR_BIT +\n            _First_one<true>::_S_first_one[__this_byte];\n\n        __thisword >>= CHAR_BIT;\n      }\n    }\n  }\n  // not found, so return an indication of failure.\n  return __not_found;\n}\n\ntemplate<size_t _Nw>\nsize_t\n_Base_bitset<_Nw>::_M_do_find_next(size_t __prev, size_t __not_found) const\n{\n  // make bound inclusive\n  ++__prev;\n\n  // check out of bounds\n  if ( __prev >= _Nw * __BITS_PER_WORD )\n    return __not_found;\n\n    // search first word\n  size_t __i = _S_whichword(__prev);\n  _WordT __thisword = _M_w[__i];\n\n    // mask off bits below bound\n  __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);\n\n  if ( __thisword != static_cast<_WordT>(0) ) {\n    // find byte within word\n    // get first byte into place\n    __thisword >>= _S_whichbyte(__prev) * CHAR_BIT;\n    for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) {\n      unsigned char __this_byte\n        = static_cast<unsigned char>(__thisword & (~(unsigned char)0));\n      if ( __this_byte )\n        return __i*__BITS_PER_WORD + __j*CHAR_BIT +\n          _First_one<true>::_S_first_one[__this_byte];\n\n      __thisword >>= CHAR_BIT;\n    }\n  }\n\n  // check subsequent words\n  __i++;\n  for ( ; __i < _Nw; __i++ ) {\n    _WordT __thisword = _M_w[__i];\n    if ( __thisword != static_cast<_WordT>(0) ) {\n      // find byte within word\n      for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {\n        unsigned char __this_byte\n          = static_cast<unsigned char>(__thisword & (~(unsigned char)0));\n        if ( __this_byte )\n          return __i*__BITS_PER_WORD + __j*CHAR_BIT +\n            _First_one<true>::_S_first_one[__this_byte];\n\n        __thisword >>= CHAR_BIT;\n      }\n    }\n  }\n\n  // not found, so return an indication of failure.\n  return __not_found;\n} // end _M_do_find_next\n\n\n// ------------------------------------------------------------\n\n//\n// Base class: specialization for a single word.\n//\n\n__STL_TEMPLATE_NULL struct _Base_bitset<1> {\n  typedef unsigned long _WordT;\n  _WordT _M_w;\n\n  _Base_bitset( void ) : _M_w(0) {}\n  _Base_bitset(unsigned long __val) : _M_w(__val) {}\n\n  static size_t _S_whichword( size_t __pos )\n    { return __pos / __BITS_PER_WORD; }\n  static size_t _S_whichbyte( size_t __pos )\n    { return (__pos % __BITS_PER_WORD) / CHAR_BIT; }\n  static size_t _S_whichbit( size_t __pos )\n    {  return __pos % __BITS_PER_WORD; }\n  static _WordT _S_maskbit( size_t __pos )\n    { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }\n\n  _WordT& _M_getword(size_t)       { return _M_w; }\n  _WordT  _M_getword(size_t) const { return _M_w; }\n\n  _WordT& _M_hiword()       { return _M_w; }\n  _WordT  _M_hiword() const { return _M_w; }\n\n  void _M_do_and(const _Base_bitset<1>& __x) { _M_w &= __x._M_w; }\n  void _M_do_or(const _Base_bitset<1>& __x)  { _M_w |= __x._M_w; }\n  void _M_do_xor(const _Base_bitset<1>& __x) { _M_w ^= __x._M_w; }\n  void _M_do_left_shift(size_t __shift)     { _M_w <<= __shift; }\n  void _M_do_right_shift(size_t __shift)    { _M_w >>= __shift; }\n  void _M_do_flip()                       { _M_w = ~_M_w; }\n  void _M_do_set()                        { _M_w = ~static_cast<_WordT>(0); }\n  void _M_do_reset()                      { _M_w = 0; }\n\n  bool _M_is_equal(const _Base_bitset<1>& __x) const\n    { return _M_w == __x._M_w; }\n  bool _M_is_any() const\n    { return _M_w != 0; }\n\n  size_t _M_do_count() const {\n    size_t __result = 0;\n    const unsigned char* __byte_ptr = (const unsigned char*)&_M_w;\n    const unsigned char* __end_ptr\n      = ((const unsigned char*)&_M_w)+sizeof(_M_w);\n    while ( __byte_ptr < __end_ptr ) {\n      __result += _Bit_count<true>::_S_bit_count[*__byte_ptr];\n      __byte_ptr++;\n    }\n    return __result;\n  }\n\n  unsigned long _M_do_to_ulong() const { return _M_w; }\n\n  size_t _M_do_find_first(size_t __not_found) const;\n\n  // find the next \"on\" bit that follows \"prev\"\n  size_t _M_do_find_next(size_t __prev, size_t __not_found) const; \n\n};\n\n//\n// Definitions of non-inline functions from the single-word version of\n//  _Base_bitset.\n//\n\nsize_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const\n{\n  _WordT __thisword = _M_w;\n\n  if ( __thisword != static_cast<_WordT>(0) ) {\n    // find byte within word\n    for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {\n      unsigned char __this_byte\n        = static_cast<unsigned char>(__thisword & (~(unsigned char)0));\n      if ( __this_byte )\n        return __j*CHAR_BIT + _First_one<true>::_S_first_one[__this_byte];\n\n      __thisword >>= CHAR_BIT;\n    }\n  }\n  // not found, so return a value that indicates failure.\n  return __not_found;\n}\n\nsize_t _Base_bitset<1>::_M_do_find_next(size_t __prev, size_t __not_found ) const\n{\n  // make bound inclusive\n  ++__prev;\n\n  // check out of bounds\n  if ( __prev >= __BITS_PER_WORD )\n    return __not_found;\n\n    // search first (and only) word\n  _WordT __thisword = _M_w;\n\n  // mask off bits below bound\n  __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);\n\n  if ( __thisword != static_cast<_WordT>(0) ) {\n    // find byte within word\n    // get first byte into place\n    __thisword >>= _S_whichbyte(__prev) * CHAR_BIT;\n    for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) {\n      unsigned char __this_byte\n        = static_cast<unsigned char>(__thisword & (~(unsigned char)0));\n      if ( __this_byte )\n        return __j*CHAR_BIT + _First_one<true>::_S_first_one[__this_byte];\n\n      __thisword >>= CHAR_BIT;\n    }\n  }\n\n  // not found, so return a value that indicates failure.\n  return __not_found;\n} // end _M_do_find_next\n\n\n// ------------------------------------------------------------\n// Helper class to zero out the unused high-order bits in the highest word.\n\ntemplate <size_t _Extrabits> struct _Sanitize {\n  static void _M_do_sanitize(unsigned long& __val)\n    { __val &= ~((~static_cast<unsigned long>(0)) << _Extrabits); }\n};\n\n__STL_TEMPLATE_NULL struct _Sanitize<0> {\n  static void _M_do_sanitize(unsigned long) {}\n};\n\n\n\n// ------------------------------------------------------------\n// Class bitset.\n//   _Nb may be any nonzero number of type size_t.\n\ntemplate<size_t _Nb>\nclass bitset : private _Base_bitset<__BITSET_WORDS(_Nb)>\n{\nprivate:\n  typedef _Base_bitset<__BITSET_WORDS(_Nb)> _Base;\n  typedef unsigned long _WordT;\n\nprivate:\n  void _M_do_sanitize() {\n    _Sanitize<_Nb%__BITS_PER_WORD>::_M_do_sanitize(this->_M_hiword());\n  }\n\npublic:\n\n  // bit reference:\n  class reference;\n  friend class reference;\n\n  class reference {\n    friend class bitset;\n\n    _WordT *_M_wp;\n    size_t _M_bpos;\n\n    // left undefined\n    reference();\n\n  public:\n    reference( bitset& __b, size_t __pos ) {\n      _M_wp = &__b._M_getword(__pos);\n      _M_bpos = _Base::_S_whichbit(__pos);\n    }\n\n    ~reference() {}\n\n    // for b[i] = __x;\n    reference& operator=(bool __x) {\n      if ( __x )\n        *_M_wp |= _Base::_S_maskbit(_M_bpos);\n      else\n        *_M_wp &= ~_Base::_S_maskbit(_M_bpos);\n\n      return *this;\n    }\n\n    // for b[i] = b[__j];\n    reference& operator=(const reference& __j) {\n      if ( (*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)) )\n        *_M_wp |= _Base::_S_maskbit(_M_bpos);\n      else\n        *_M_wp &= ~_Base::_S_maskbit(_M_bpos);\n\n      return *this;\n    }\n\n    // flips the bit\n    bool operator~() const\n      { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }\n\n    // for __x = b[i];\n    operator bool() const\n      { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }\n\n    // for b[i].flip();\n    reference& flip() {\n      *_M_wp ^= _Base::_S_maskbit(_M_bpos);\n      return *this;\n    }\n  };\n\n  // 23.3.5.1 constructors:\n  bitset() {}\n  bitset(unsigned long __val) : _Base_bitset<__BITSET_WORDS(_Nb)>(__val) \n    { _M_do_sanitize(); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class _CharT, class _Traits, class _Alloc>\n  explicit bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,\n                  size_t __pos = 0)\n    : _Base() \n  {\n    if (__pos > __s.size()) \n      __STL_THROW(out_of_range(\"bitset\"));\n    _M_copy_from_string(__s, __pos,\n                        basic_string<_CharT, _Traits, _Alloc>::npos);\n  }\n  template<class _CharT, class _Traits, class _Alloc>\n  bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,\n         size_t __pos,\n         size_t __n)\n    : _Base() \n  {\n    if (__pos > __s.size()) \n      __STL_THROW(out_of_range(\"bitset\"));\n    _M_copy_from_string(__s, __pos, __n);\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  explicit bitset(const basic_string<char>& __s,\n                  size_t __pos = 0,\n                  size_t __n = basic_string<char>::npos) \n    : _Base() \n  {\n    if (__pos > __s.size()) \n      __STL_THROW(out_of_range(\"bitset\"));\n    _M_copy_from_string(__s, __pos, __n);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  // 23.3.5.2 bitset operations:\n  bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) {\n    this->_M_do_and(__rhs);\n    return *this;\n  }\n\n  bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) {\n    this->_M_do_or(__rhs);\n    return *this;\n  }\n\n  bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) {\n    this->_M_do_xor(__rhs);\n    return *this;\n  }\n\n  bitset<_Nb>& operator<<=(size_t __pos) {\n    this->_M_do_left_shift(__pos);\n    this->_M_do_sanitize();\n    return *this;\n  }\n\n  bitset<_Nb>& operator>>=(size_t __pos) {\n    this->_M_do_right_shift(__pos);\n    this->_M_do_sanitize();\n    return *this;\n  }\n\n  //\n  // Extension:\n  // Versions of single-bit set, reset, flip, test with no range checking.\n  //\n\n  bitset<_Nb>& _Unchecked_set(size_t __pos) {\n    this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);\n    return *this;\n  }\n\n  bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) {\n    if (__val)\n      this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);\n    else\n      this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);\n\n    return *this;\n  }\n\n  bitset<_Nb>& _Unchecked_reset(size_t __pos) {\n    this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);\n    return *this;\n  }\n\n  bitset<_Nb>& _Unchecked_flip(size_t __pos) {\n    this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);\n    return *this;\n  }\n\n  bool _Unchecked_test(size_t __pos) const {\n    return (this->_M_getword(__pos) & _Base::_S_maskbit(__pos))\n      != static_cast<_WordT>(0);\n  }\n\n  // Set, reset, and flip.\n\n  bitset<_Nb>& set() {\n    this->_M_do_set();\n    this->_M_do_sanitize();\n    return *this;\n  }\n\n  bitset<_Nb>& set(size_t __pos) {\n    if (__pos >= _Nb)\n      __STL_THROW(out_of_range(\"bitset\"));\n\n    return _Unchecked_set(__pos);\n  }\n\n  bitset<_Nb>& set(size_t __pos, int __val) {\n    if (__pos >= _Nb)\n      __STL_THROW(out_of_range(\"bitset\"));\n\n    return _Unchecked_set(__pos, __val);\n  }\n\n  bitset<_Nb>& reset() {\n    this->_M_do_reset();\n    return *this;\n  }\n\n  bitset<_Nb>& reset(size_t __pos) {\n    if (__pos >= _Nb)\n      __STL_THROW(out_of_range(\"bitset\"));\n\n    return _Unchecked_reset(__pos);\n  }\n\n  bitset<_Nb>& flip() {\n    this->_M_do_flip();\n    this->_M_do_sanitize();\n    return *this;\n  }\n\n  bitset<_Nb>& flip(size_t __pos) {\n    if (__pos >= _Nb)\n      __STL_THROW(out_of_range(\"bitset\"));\n\n    return _Unchecked_flip(__pos);\n  }\n\n  bitset<_Nb> operator~() const { \n    return bitset<_Nb>(*this).flip();\n  }\n\n  // element access:\n  //for b[i];\n  reference operator[](size_t __pos) { return reference(*this,__pos); }\n  bool operator[](size_t __pos) const { return _Unchecked_test(__pos); }\n\n  unsigned long to_ulong() const { return this->_M_do_to_ulong(); }\n\n#if defined(__STL_MEMBER_TEMPLATES) && \\\n    defined(__STL_EXPLICIT_FUNCTION_TMPL_ARGS)\n  template <class _CharT, class _Traits, class _Alloc>\n  basic_string<_CharT, _Traits, _Alloc> to_string() const {\n    basic_string<_CharT, _Traits, _Alloc> __result;\n    _M_copy_to_string(__result);\n    return __result;\n  }\n#endif /* member templates and explicit function template args */\n\n  // Helper functions for string operations.\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class _CharT, class _Traits, class _Alloc>\n  void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s,\n                          size_t,\n                          size_t);\n\n  template<class _CharT, class _Traits, class _Alloc>\n  void _M_copy_to_string(basic_string<_CharT,_Traits,_Alloc>&) const;\n#else /* __STL_MEMBER_TEMPLATES */\n  void _M_copy_from_string(const basic_string<char>&, size_t, size_t);\n  void _M_copy_to_string(basic_string<char>&) const;\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  size_t count() const { return this->_M_do_count(); }\n\n  size_t size() const { return _Nb; }\n\n  bool operator==(const bitset<_Nb>& __rhs) const {\n    return this->_M_is_equal(__rhs);\n  }\n  bool operator!=(const bitset<_Nb>& __rhs) const {\n    return !this->_M_is_equal(__rhs);\n  }\n\n  bool test(size_t __pos) const {\n    if (__pos > _Nb)\n      __STL_THROW(out_of_range(\"bitset\"));\n\n    return _Unchecked_test(__pos);\n  }\n\n  bool any() const { return this->_M_is_any(); }\n  bool none() const { return !this->_M_is_any(); }\n\n  bitset<_Nb> operator<<(size_t __pos) const\n    { return bitset<_Nb>(*this) <<= __pos; }\n  bitset<_Nb> operator>>(size_t __pos) const\n    { return bitset<_Nb>(*this) >>= __pos; }\n\n  //\n  // EXTENSIONS: bit-find operations.  These operations are\n  // experimental, and are subject to change or removal in future\n  // versions.\n  // \n\n  // find the index of the first \"on\" bit\n  size_t _Find_first() const \n    { return this->_M_do_find_first(_Nb); }\n\n  // find the index of the next \"on\" bit after prev\n  size_t _Find_next( size_t __prev ) const \n    { return this->_M_do_find_next(__prev, _Nb); }\n\n};\n\n//\n// Definitions of non-inline member functions.\n//\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <size_t _Nb>\ntemplate<class _CharT, class _Traits, class _Alloc>\nvoid bitset<_Nb>\n  ::_M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s,\n                        size_t __pos,\n                        size_t __n)\n{\n  reset();\n  const size_t __nbits = min(_Nb, min(__n, __s.size() - __pos));\n  for (size_t __i = 0; __i < __nbits; ++__i) {\n    switch(__s[__pos + __nbits - __i - 1]) {\n    case '0':\n      break;\n    case '1':\n      set(__i);\n      break;\n    default:\n      __STL_THROW(invalid_argument(\"bitset\"));\n    }\n  }\n}\n\ntemplate <size_t _Nb>\ntemplate <class _CharT, class _Traits, class _Alloc>\nvoid bitset<_Nb>\n  ::_M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const\n{\n  __s.assign(_Nb, '0');\n  \n  for (size_t __i = 0; __i < _Nb; ++__i) \n    if (_Unchecked_test(__i))\n      __s[_Nb - 1 - __i] = '1';\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <size_t _Nb>\nvoid bitset<_Nb>::_M_copy_from_string(const basic_string<char>& __s,\n                                      size_t __pos, size_t __n)\n{\n  reset();\n  size_t __tmp = _Nb;\n  const size_t __nbits = min(__tmp, min(__n, __s.size() - __pos));\n  for (size_t __i = 0; __i < __nbits; ++__i) {\n    switch(__s[__pos + __nbits - __i - 1]) {\n    case '0':\n      break;\n    case '1':\n      set(__i);\n      break;\n    default:\n      __STL_THROW(invalid_argument(\"bitset\"));\n    }\n  }\n}\n\ntemplate <size_t _Nb>\nvoid bitset<_Nb>::_M_copy_to_string(basic_string<char>& __s) const\n{\n  __s.assign(_Nb, '0');\n  \n  for (size_t __i = 0; __i < _Nb; ++__i) \n    if (_Unchecked_test(__i))\n      __s[_Nb - 1 - __i] = '1';\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n// ------------------------------------------------------------\n\n//\n// 23.3.5.3 bitset operations:\n//\n\ntemplate <size_t _Nb>\ninline bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) {\n  bitset<_Nb> __result(__x);\n  __result &= __y;\n  return __result;\n}\n\n\ntemplate <size_t _Nb>\ninline bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) {\n  bitset<_Nb> __result(__x);\n  __result |= __y;\n  return __result;\n}\n\ntemplate <size_t _Nb>\ninline bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) {\n  bitset<_Nb> __result(__x);\n  __result ^= __y;\n  return __result;\n}\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n\ntemplate <class _CharT, class _Traits, size_t _Nb>\nbasic_istream<_CharT, _Traits>&\noperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)\n{\n  basic_string<_CharT, _Traits> __tmp;\n  __tmp.reserve(_Nb);\n\n  // Skip whitespace\n  typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);\n  if (__sentry) {\n    basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();\n    for (size_t __i = 0; __i < _Nb; ++__i) {\n      static _Traits::int_type __eof = _Traits::eof();\n\n      typename _Traits::int_type __c1 = __buf->sbumpc();\n      if (_Traits::eq_int_type(__c1, __eof)) {\n        __is.setstate(ios_base::eofbit);\n        break;\n      }\n      else {\n        char __c2 = _Traits::to_char_type(__c1);\n        char __c  = __is.narrow(__c2, '*');\n\n        if (__c == '0' || __c == '1')\n          __tmp.push_back(__c);\n        else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {\n          __is.setstate(ios_base::failbit);\n          break;\n        }\n      }\n    }\n\n    if (__tmp.empty())\n      __is.setstate(ios_base::failbit);\n    else\n      __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb);\n  }\n\n  return __is;\n}\n\ntemplate <class _CharT, class _Traits, size_t _Nb>\nbasic_ostream<_CharT, _Traits>&\noperator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x)\n{\n  basic_string<_CharT, _Traits> __tmp;\n  __x._M_copy_to_string(__tmp);\n  return __os << __tmp;\n}\n\n#else /* __STL_USE_NEW_IOSTREAMS */\n\ntemplate <size_t _Nb>\nistream& operator>>(istream& __is, bitset<_Nb>& __x) {\n  string __tmp;\n  __tmp.reserve(_Nb);\n\n  if (__is.flags() & ios::skipws) {\n    char __c;\n    do \n      __is.get(__c);\n    while (__is && isspace(__c));\n    if (__is)\n      __is.putback(__c);\n  }\n\n  for (size_t __i = 0; __i < _Nb; ++__i) {\n    char __c;\n    __is.get(__c);\n\n    if (!__is)\n      break;\n    else if (__c != '0' && __c != '1') {\n      __is.putback(__c);\n      break;\n    }\n    else\n      __tmp.push_back(__c);\n  }\n\n  if (__tmp.empty()) \n    __is.clear(__is.rdstate() | ios::failbit);\n  else\n    __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb);\n\n  return __is;\n}\n\ntemplate <size_t _Nb>\nostream& operator<<(ostream& __os, const bitset<_Nb>& __x) {\n  string __tmp;\n  __x._M_copy_to_string(__tmp);\n  return __os << __tmp;\n}\n\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n// ------------------------------------------------------------\n// Lookup tables for find and count operations.\n\ntemplate<bool __dummy>\nunsigned char _Bit_count<__dummy>::_S_bit_count[] = {\n  0, /*   0 */ 1, /*   1 */ 1, /*   2 */ 2, /*   3 */ 1, /*   4 */\n  2, /*   5 */ 2, /*   6 */ 3, /*   7 */ 1, /*   8 */ 2, /*   9 */\n  2, /*  10 */ 3, /*  11 */ 2, /*  12 */ 3, /*  13 */ 3, /*  14 */\n  4, /*  15 */ 1, /*  16 */ 2, /*  17 */ 2, /*  18 */ 3, /*  19 */\n  2, /*  20 */ 3, /*  21 */ 3, /*  22 */ 4, /*  23 */ 2, /*  24 */\n  3, /*  25 */ 3, /*  26 */ 4, /*  27 */ 3, /*  28 */ 4, /*  29 */\n  4, /*  30 */ 5, /*  31 */ 1, /*  32 */ 2, /*  33 */ 2, /*  34 */\n  3, /*  35 */ 2, /*  36 */ 3, /*  37 */ 3, /*  38 */ 4, /*  39 */\n  2, /*  40 */ 3, /*  41 */ 3, /*  42 */ 4, /*  43 */ 3, /*  44 */\n  4, /*  45 */ 4, /*  46 */ 5, /*  47 */ 2, /*  48 */ 3, /*  49 */\n  3, /*  50 */ 4, /*  51 */ 3, /*  52 */ 4, /*  53 */ 4, /*  54 */\n  5, /*  55 */ 3, /*  56 */ 4, /*  57 */ 4, /*  58 */ 5, /*  59 */\n  4, /*  60 */ 5, /*  61 */ 5, /*  62 */ 6, /*  63 */ 1, /*  64 */\n  2, /*  65 */ 2, /*  66 */ 3, /*  67 */ 2, /*  68 */ 3, /*  69 */\n  3, /*  70 */ 4, /*  71 */ 2, /*  72 */ 3, /*  73 */ 3, /*  74 */\n  4, /*  75 */ 3, /*  76 */ 4, /*  77 */ 4, /*  78 */ 5, /*  79 */\n  2, /*  80 */ 3, /*  81 */ 3, /*  82 */ 4, /*  83 */ 3, /*  84 */\n  4, /*  85 */ 4, /*  86 */ 5, /*  87 */ 3, /*  88 */ 4, /*  89 */\n  4, /*  90 */ 5, /*  91 */ 4, /*  92 */ 5, /*  93 */ 5, /*  94 */\n  6, /*  95 */ 2, /*  96 */ 3, /*  97 */ 3, /*  98 */ 4, /*  99 */\n  3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */\n  4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */\n  5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */\n  5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */\n  4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */\n  6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */\n  2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */\n  4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */\n  3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */\n  3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */\n  4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */\n  5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */\n  2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */\n  4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */\n  4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */\n  6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */\n  4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */\n  5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */\n  6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */\n  4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */\n  3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */\n  5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */\n  4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */\n  6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */\n  5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */\n  4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */\n  5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */\n  6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */\n  4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */\n  6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */\n  6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */\n  8  /* 255 */\n}; // end _Bit_count\n\ntemplate<bool __dummy>\nunsigned char _First_one<__dummy>::_S_first_one[] = {\n  0, /*   0 */ 0, /*   1 */ 1, /*   2 */ 0, /*   3 */ 2, /*   4 */\n  0, /*   5 */ 1, /*   6 */ 0, /*   7 */ 3, /*   8 */ 0, /*   9 */\n  1, /*  10 */ 0, /*  11 */ 2, /*  12 */ 0, /*  13 */ 1, /*  14 */\n  0, /*  15 */ 4, /*  16 */ 0, /*  17 */ 1, /*  18 */ 0, /*  19 */\n  2, /*  20 */ 0, /*  21 */ 1, /*  22 */ 0, /*  23 */ 3, /*  24 */\n  0, /*  25 */ 1, /*  26 */ 0, /*  27 */ 2, /*  28 */ 0, /*  29 */\n  1, /*  30 */ 0, /*  31 */ 5, /*  32 */ 0, /*  33 */ 1, /*  34 */\n  0, /*  35 */ 2, /*  36 */ 0, /*  37 */ 1, /*  38 */ 0, /*  39 */\n  3, /*  40 */ 0, /*  41 */ 1, /*  42 */ 0, /*  43 */ 2, /*  44 */\n  0, /*  45 */ 1, /*  46 */ 0, /*  47 */ 4, /*  48 */ 0, /*  49 */\n  1, /*  50 */ 0, /*  51 */ 2, /*  52 */ 0, /*  53 */ 1, /*  54 */\n  0, /*  55 */ 3, /*  56 */ 0, /*  57 */ 1, /*  58 */ 0, /*  59 */\n  2, /*  60 */ 0, /*  61 */ 1, /*  62 */ 0, /*  63 */ 6, /*  64 */\n  0, /*  65 */ 1, /*  66 */ 0, /*  67 */ 2, /*  68 */ 0, /*  69 */\n  1, /*  70 */ 0, /*  71 */ 3, /*  72 */ 0, /*  73 */ 1, /*  74 */\n  0, /*  75 */ 2, /*  76 */ 0, /*  77 */ 1, /*  78 */ 0, /*  79 */\n  4, /*  80 */ 0, /*  81 */ 1, /*  82 */ 0, /*  83 */ 2, /*  84 */\n  0, /*  85 */ 1, /*  86 */ 0, /*  87 */ 3, /*  88 */ 0, /*  89 */\n  1, /*  90 */ 0, /*  91 */ 2, /*  92 */ 0, /*  93 */ 1, /*  94 */\n  0, /*  95 */ 5, /*  96 */ 0, /*  97 */ 1, /*  98 */ 0, /*  99 */\n  2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */\n  0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */\n  1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */\n  0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */\n  3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */\n  0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */\n  1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */\n  0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */\n  2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */\n  0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */\n  1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */\n  0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */\n  5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */\n  0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */\n  1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */\n  0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */\n  2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */\n  0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */\n  1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */\n  0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */\n  3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */\n  0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */\n  1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */\n  0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */\n  2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */\n  0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */\n  1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */\n  0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */\n  4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */\n  0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */\n  1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */\n  0, /* 255 */\n}; // end _First_one\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1209\n#endif\n\n__STL_END_NAMESPACE\n\n\n#undef __BITS_PER_WORD\n#undef __BITSET_WORDS\n\n#endif /* __SGI_STL_BITSET */\n\n\n// Local Variables:\n// mode:C++\n// End:\n\n"
  },
  {
    "path": "stl-3.3-source/bvector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_BVECTOR_H\n#define __SGI_STL_BVECTOR_H\n\n#include <stl_range_errors.h>\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n#include <vector.h>\n#else\n#include <algobase.h>\n#include <alloc.h>\n#endif \n\n#include <stl_bvector.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::bit_vector;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_BVECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n\n\n"
  },
  {
    "path": "stl-3.3-source/char_traits.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_CHAR_TRAITS_H\n#define __SGI_STL_CHAR_TRAITS_H\n\n#include <string.h>\n#include <wchar.h>\n\n#if defined(__STL_USE_NEW_IOSTREAMS) && !defined(__SGI_STL_IOSFWD)\n#include <iosfwd>\n#endif /* use new iostreams */\n\n__STL_BEGIN_NAMESPACE\n\n// Class __char_traits_base.\n\ntemplate <class _CharT, class _IntT> class __char_traits_base {\npublic:\n  typedef _CharT char_type;\n  typedef _IntT int_type;\n#ifdef __STL_USE_NEW_IOSTREAMS\n  typedef streamoff off_type;\n  typedef streampos pos_type;\n  typedef mbstate_t state_type;\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n  static void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; }\n  static bool eq(const _CharT& __c1, const _CharT& __c2) \n    { return __c1 == __c2; }\n  static bool lt(const _CharT& __c1, const _CharT& __c2) \n    { return __c1 < __c2; }\n\n  static int compare(const _CharT* __s1, const _CharT* __s2, size_t __n) {\n    for (size_t __i = 0; __i < __n; ++__i)\n      if (!eq(__s1[__i], __s2[__i]))\n        return __s1[__i] < __s2[__i] ? -1 : 1;\n    return 0;\n  }\n\n  static size_t length(const _CharT* __s) {\n    const _CharT __nullchar = _CharT();\n    size_t __i;\n    for (__i = 0; !eq(__s[__i], __nullchar); ++__i)\n      {}\n    return __i;\n  }\n\n  static const _CharT* find(const _CharT* __s, size_t __n, const _CharT& __c)\n  {\n    for ( ; __n > 0 ; ++__s, --__n)\n      if (eq(*__s, __c))\n        return __s;\n    return 0;\n  }\n\n  static _CharT* move(_CharT* __s1, const _CharT* __s2, size_t __n) {\n    memmove(__s1, __s2, __n * sizeof(_CharT));\n    return __s1;\n  }\n    \n  static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t __n) {\n    memcpy(__s1, __s2, __n * sizeof(_CharT));\n    return __s1;\n  } \n\n  static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) {\n    for (size_t __i = 0; __i < __n; ++__i)\n      __s[__i] = __c;\n    return __s;\n  }\n\n  static int_type not_eof(const int_type& __c) {\n    return !eq_int_type(__c, eof()) ? __c : 0;\n  }\n\n  static char_type to_char_type(const int_type& __c) {\n    return static_cast<char_type>(__c);\n  }\n\n  static int_type to_int_type(const char_type& __c) {\n    return static_cast<int_type>(__c);\n  }\n\n  static bool eq_int_type(const int_type& __c1, const int_type& __c2) {\n    return __c1 == __c2;\n  }\n\n  static int_type eof() {\n    return static_cast<int_type>(-1);\n  }\n};\n\n// Generic char_traits class.  Note that this class is provided only\n//  as a base for explicit specialization; it is unlikely to be useful\n//  as is for any particular user-defined type.  In particular, it \n//  *will not work* for a non-POD type.\n\ntemplate <class _CharT> class char_traits\n  : public __char_traits_base<_CharT, _CharT>\n{};\n\n// Specialization for char.\n\n__STL_TEMPLATE_NULL class char_traits<char> \n  : public __char_traits_base<char, int>\n{\npublic:\n  static char_type to_char_type(const int_type& __c) {\n    return static_cast<char_type>(static_cast<unsigned char>(__c));\n  }\n\n  static int_type to_int_type(const char_type& __c) {\n    return static_cast<unsigned char>(__c);\n  }\n\n  static int compare(const char* __s1, const char* __s2, size_t __n) \n    { return memcmp(__s1, __s2, __n); }\n  \n  static size_t length(const char* __s) { return strlen(__s); }\n\n  static void assign(char& __c1, const char& __c2) { __c1 = __c2; }\n\n  static char* assign(char* __s, size_t __n, char __c)\n    { memset(__s, __c, __n); return __s; }\n};\n\n// Specialization for wchar_t.\n\n__STL_TEMPLATE_NULL class char_traits<wchar_t>\n  : public __char_traits_base<wchar_t, wint_t>\n{};\n\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_CHAR_TRAITS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n\n"
  },
  {
    "path": "stl-3.3-source/concept_checks.h",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __CONCEPT_CHECKS_H\n#define __CONCEPT_CHECKS_H\n\n/*\n  Use these macro like assertions, but they assert properties\n  on types (usually template arguments). In technical terms they\n  verify whether a type \"models\" a \"concept\".\n\n  This set of requirements and the terminology used here is derived\n  from the book \"Generic Programming and the STL\" by Matt Austern\n  (Addison Wesley). For further information please consult that\n  book. The requirements also are intended to match the ANSI/ISO C++\n  standard.\n\n  This file covers the basic concepts and the iterator concepts.\n  There are several other files that provide the requirements\n  for the STL containers:\n    container_concepts.h\n    sequence_concepts.h\n    assoc_container_concepts.h\n\n  Jeremy Siek, 1999\n\n  TO DO:\n    - some issues with regards to concept classification and mutability\n      including AssociativeContianer -> ForwardContainer\n      and SortedAssociativeContainer -> ReversibleContainer\n    - HashedAssociativeContainer\n    - Allocator\n    - Function Object Concepts\n\n  */\n\n#ifndef __STL_USE_CONCEPT_CHECKS\n\n// Some compilers lack the features that are necessary for concept checks.\n// On those compilers we define the concept check macros to do nothing.\n#define __STL_REQUIRES(__type_var, __concept) do {} while(0)\n#define __STL_CLASS_REQUIRES(__type_var, __concept) \\\n  static int  __##__type_var##_##__concept\n#define __STL_CONVERTIBLE(__type_x, __type_y) do {} while(0)\n#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0)\n#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \\\n  static int  __##__type_x##__type_y##_require_same_type\n#define __STL_GENERATOR_CHECK(__func, __ret) do {} while(0)\n#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \\\n  static int  __##__func##__ret##_generator_check\n#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0)\n#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \\\n  static int  __##__func##__ret##__arg##_unary_function_check\n#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \\\n  do {} while(0)\n#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \\\n  static int  __##__func##__ret##__first##__second##_binary_function_check\n#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \\\n  do {} while(0)\n#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \\\n  static int __##__opname##__ret##__first##__second##_require_binary_op\n\n#else /* __STL_USE_CONCEPT_CHECKS */\n\n// This macro tests whether the template argument \"__type_var\"\n// satisfies the requirements of \"__concept\".  Here is a list of concepts\n// that we know how to check:\n//       _Allocator\n//       _Assignable\n//       _DefaultConstructible\n//       _EqualityComparable\n//       _LessThanComparable\n//       _TrivialIterator\n//       _InputIterator\n//       _OutputIterator\n//       _ForwardIterator\n//       _BidirectionalIterator\n//       _RandomAccessIterator\n//       _Mutable_TrivialIterator\n//       _Mutable_ForwardIterator\n//       _Mutable_BidirectionalIterator\n//       _Mutable_RandomAccessIterator\n\n#define __STL_REQUIRES(__type_var, __concept) \\\ndo { \\\n  void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\\\n    ::__concept##_requirement_violation; __x = __x; } while (0)\n\n// Use this to check whether type X is convertible to type Y\n#define __STL_CONVERTIBLE(__type_x, __type_y) \\\ndo { \\\n  void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \\\n  __type_y >::__type_X_is_not_convertible_to_type_Y; \\\n  __x = __x; } while (0)\n\n// Use this to test whether two template arguments are the same type\n#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) \\\ndo { \\\n  void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \\\n    __type_y  >::__type_X_not_same_as_type_Y; \\\n  __x = __x; } while (0)\n\n\n// function object checks\n#define __STL_GENERATOR_CHECK(__func, __ret) \\\ndo { \\\n  __ret (*__x)( __func&) = \\\n     _STL_GENERATOR_ERROR< \\\n  __func, __ret>::__generator_requirement_violation; \\\n  __x = __x; } while (0)\n\n\n#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \\\ndo { \\\n  __ret (*__x)( __func&, const __arg& ) = \\\n     _STL_UNARY_FUNCTION_ERROR< \\\n  __func, __ret, __arg>::__unary_function_requirement_violation; \\\n  __x = __x; } while (0)\n\n\n#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \\\ndo { \\\n  __ret (*__x)( __func&, const __first&, const __second& ) = \\\n     _STL_BINARY_FUNCTION_ERROR< \\\n  __func, __ret, __first, __second>::__binary_function_requirement_violation; \\\n  __x = __x; } while (0)\n\n\n#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \\\n    do { \\\n  __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \\\n    __ret, __first, __second>::__binary_operator_requirement_violation; \\\n  __ret (*__y)( const __first&, const __second& ) = \\\n    _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \\\n      __const_binary_operator_requirement_violation; \\\n  __y = __y; __x = __x; } while (0)\n\n\n#ifdef __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE\n\n#define __STL_CLASS_REQUIRES(__type_var, __concept)\n#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y)\n#define __STL_CLASS_GENERATOR_CHECK(__func, __ret)\n#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg)\n#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second)\n#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second)\n\n#else\n\n// Use this macro inside of template classes, where you would\n// like to place requirements on the template arguments to the class\n// Warning: do not pass pointers and such (e.g. T*) in as the __type_var,\n// since the type_var is used to construct identifiers. Instead typedef\n// the pointer type, then use the typedef name for the __type_var.\n#define __STL_CLASS_REQUIRES(__type_var, __concept) \\\n  typedef void (* __func##__type_var##__concept)( __type_var ); \\\n  template <__func##__type_var##__concept _Tp1> \\\n  struct __dummy_struct_##__type_var##__concept { }; \\\n  static __dummy_struct_##__type_var##__concept< \\\n    __concept##_concept_specification< \\\n      __type_var>::__concept##_requirement_violation>  \\\n  __dummy_ptr_##__type_var##__concept\n\n\n#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \\\n  typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \\\n                                                            __type_y ); \\\n  template < __func_##__type_x##__type_y##same_type _Tp1> \\\n  struct __dummy_struct_##__type_x##__type_y##_same_type { }; \\\n  static __dummy_struct_##__type_x##__type_y##_same_type< \\\n    _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y>  \\\n  __dummy_ptr_##__type_x##__type_y##_same_type\n\n\n#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \\\n  typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \\\n  template <__f_##__func##__ret##_generator _Tp1> \\\n  struct __dummy_struct_##__func##__ret##_generator { }; \\\n  static __dummy_struct_##__func##__ret##_generator< \\\n    _STL_GENERATOR_ERROR< \\\n      __func, __ret>::__generator_requirement_violation>  \\\n  __dummy_ptr_##__func##__ret##_generator\n\n\n#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \\\n  typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \\\n                                                         const __arg& ); \\\n  template <__f_##__func##__ret##__arg##_unary_check _Tp1> \\\n  struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \\\n  static __dummy_struct_##__func##__ret##__arg##_unary_check< \\\n    _STL_UNARY_FUNCTION_ERROR< \\\n      __func, __ret, __arg>::__unary_function_requirement_violation>  \\\n  __dummy_ptr_##__func##__ret##__arg##_unary_check\n\n\n#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \\\n  typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\\\n                                                    const __second& ); \\\n  template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \\\n  struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \\\n  static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \\\n    _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \\\n  __binary_function_requirement_violation>  \\\n  __dummy_ptr_##__func##__ret##__first##__second##_binary_check\n\n\n#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \\\n  typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \\\n                                                    const __second& ); \\\n  template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \\\n  struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \\\n  static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \\\n    _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \\\n  __binary_operator_requirement_violation>  \\\n  __dummy_ptr_##__func##__ret##__first##__second##_binary_op\n\n#endif\n\n/* helper class for finding non-const version of a type. Need to have\n   something to assign to etc. when testing constant iterators. */\n\ntemplate <class _Tp>\nstruct _Mutable_trait {\n  typedef _Tp _Type;\n};\ntemplate <class _Tp>\nstruct _Mutable_trait<const _Tp> {\n  typedef _Tp _Type;\n};\n\n\n/* helper function for avoiding compiler warnings about unused variables */\ntemplate <class _Type>\nvoid __sink_unused_warning(_Type) { }\n\ntemplate <class _TypeX, class _TypeY>\nstruct _STL_CONVERT_ERROR {\n  static void\n  __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) {\n    _TypeY __y = __x;\n    __sink_unused_warning(__y);\n  }\n};\n\n\ntemplate <class _Type> struct __check_equal { };\n\ntemplate <class _TypeX, class _TypeY>\nstruct _STL_SAME_TYPE_ERROR {\n  static void\n  __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { \n    __check_equal<_TypeX> t1 = __check_equal<_TypeY>();\n  }\n};\n\n\n// Some Functon Object Checks\n\ntemplate <class _Func, class _Ret>\nstruct _STL_GENERATOR_ERROR {\n  static _Ret __generator_requirement_violation(_Func& __f) {\n    return __f();\n  }\n};\n\ntemplate <class _Func>\nstruct _STL_GENERATOR_ERROR<_Func, void> {\n  static void __generator_requirement_violation(_Func& __f) {\n    __f();\n  }\n};\n\n\ntemplate <class _Func, class _Ret, class _Arg>\nstruct _STL_UNARY_FUNCTION_ERROR {\n  static _Ret\n  __unary_function_requirement_violation(_Func& __f,\n                                          const _Arg& __arg) {\n    return __f(__arg);\n  }\n};\n\ntemplate <class _Func, class _Arg>\nstruct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> {\n  static void\n  __unary_function_requirement_violation(_Func& __f,\n                                          const _Arg& __arg) {\n    __f(__arg);\n  }\n};\n\ntemplate <class _Func, class _Ret, class _First, class _Second>\nstruct _STL_BINARY_FUNCTION_ERROR {\n  static _Ret\n  __binary_function_requirement_violation(_Func& __f,\n                                          const _First& __first, \n                                          const _Second& __second) {\n    return __f(__first, __second);\n  }\n};\n\ntemplate <class _Func, class _First, class _Second>\nstruct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> {\n  static void\n  __binary_function_requirement_violation(_Func& __f,\n                                          const _First& __first, \n                                          const _Second& __second) {\n    __f(__first, __second);\n  }\n};\n\n\n#define __STL_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \\\ntemplate <class _Ret, class _First, class _Second> \\\nstruct _STL_BINARY##_NAME##_ERROR { \\\n  static _Ret \\\n  __const_binary_operator_requirement_violation(const _First& __first,  \\\n                                                const _Second& __second) { \\\n    return __first _OP __second; \\\n  } \\\n  static _Ret \\\n  __binary_operator_requirement_violation(_First& __first,  \\\n                                          _Second& __second) { \\\n    return __first _OP __second; \\\n  } \\\n}\n\n__STL_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL);\n__STL_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL);\n__STL_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN);\n__STL_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL);\n__STL_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN);\n__STL_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL);\n__STL_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS);\n__STL_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES);\n__STL_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE);\n__STL_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT);\n__STL_DEFINE_BINARY_OP_CHECK(%, _OP_MOD);\n// ...\n\n// TODO, add unary operators (prefix and postfix)\n\n/*\n  The presence of this class is just to trick EDG into displaying\n  these error messages before any other errors. Without the\n  classes, the errors in the functions get reported after\n  other class errors deep inside the library. The name\n  choice just makes for an eye catching error message :)\n */\nstruct _STL_ERROR {\n\n  template <class _Type>\n  static _Type\n  __default_constructor_requirement_violation(_Type) {\n    return _Type();\n  }\n  template <class _Type>\n  static _Type\n  __assignment_operator_requirement_violation(_Type __a) {\n    __a = __a;\n    return __a;\n  }\n  template <class _Type>\n  static _Type\n  __copy_constructor_requirement_violation(_Type __a) {\n    _Type __c(__a);\n    return __c;\n  }\n  template <class _Type>\n  static _Type\n  __const_parameter_required_for_copy_constructor(_Type /* __a */, \n                                                  const _Type& __b) {\n    _Type __c(__b);\n    return __c;\n  }\n  template <class _Type>\n  static _Type\n  __const_parameter_required_for_assignment_operator(_Type __a, \n                                                     const _Type& __b) {\n    __a = __b;\n    return __a;\n  }\n  template <class _Type>\n  static _Type\n  __less_than_comparable_requirement_violation(_Type __a, _Type __b) {\n    if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a;\n    return __b;\n  }\n  template <class _Type>\n  static _Type\n  __equality_comparable_requirement_violation(_Type __a, _Type __b) {\n    if (__a == __b || __a != __b) return __a;\n    return __b;\n  }\n  template <class _Iterator>\n  static void\n  __dereference_operator_requirement_violation(_Iterator __i) {\n    __sink_unused_warning(*__i);\n  }\n  template <class _Iterator>\n  static void\n  __dereference_operator_and_assignment_requirement_violation(_Iterator __i) {\n    *__i = *__i;\n  }\n  template <class _Iterator>\n  static void\n  __preincrement_operator_requirement_violation(_Iterator __i) {\n    ++__i;\n  }\n  template <class _Iterator>\n  static void\n  __postincrement_operator_requirement_violation(_Iterator __i) {\n    __i++;\n  }\n  template <class _Iterator>\n  static void\n  __predecrement_operator_requirement_violation(_Iterator __i) {\n    --__i;\n  }\n  template <class _Iterator>\n  static void\n  __postdecrement_operator_requirement_violation(_Iterator __i) {\n    __i--;\n  }\n  template <class _Iterator, class _Type>\n  static void\n  __postincrement_operator_and_assignment_requirement_violation(_Iterator __i,\n                                                                _Type __t) {\n    *__i++ = __t;\n  }\n  template <class _Iterator, class _Distance>\n  static _Iterator\n  __iterator_addition_assignment_requirement_violation(_Iterator __i, \n                                                       _Distance __n) {\n    __i += __n;\n    return __i;\n  }\n  template <class _Iterator, class _Distance>\n  static _Iterator\n  __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) {\n    __i = __i + __n;\n    __i = __n + __i;\n    return __i;\n  }\n  template <class _Iterator, class _Distance>\n  static _Iterator\n  __iterator_subtraction_assignment_requirement_violation(_Iterator __i,\n                                                          _Distance __n) {\n    __i -= __n;\n    return __i;\n  }\n  template <class _Iterator, class _Distance>\n  static _Iterator\n  __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) {\n    __i = __i - __n;\n    return __i;\n  }\n  template <class _Iterator, class _Distance>\n  static _Distance\n  __difference_operator_requirement_violation(_Iterator __i, _Iterator __j,\n                                              _Distance __n) {\n    __n = __i - __j;\n    return __n;\n  }\n  template <class _Exp, class _Type, class _Distance>\n  static _Type\n  __element_access_operator_requirement_violation(_Exp __x, _Type*,\n                                                  _Distance __n) {\n    return __x[__n];\n  }\n  template <class _Exp, class _Type, class _Distance>\n  static void\n  __element_assignment_operator_requirement_violation(_Exp __x,\n                                                      _Type* __t,\n                                                      _Distance __n) {\n    __x[__n] = *__t;\n  }\n\n}; /* _STL_ERROR */\n\n/* Associated Type Requirements */\n\n__STL_BEGIN_NAMESPACE\ntemplate <class _Iterator> struct iterator_traits;\n__STL_END_NAMESPACE\n\ntemplate <class _Iter> \nstruct __value_type_type_definition_requirement_violation {\n  typedef typename __STD::iterator_traits<_Iter>::value_type value_type;\n};\n\ntemplate <class _Iter> \nstruct __difference_type_type_definition_requirement_violation {\n  typedef typename __STD::iterator_traits<_Iter>::difference_type\n          difference_type;\n};\n\ntemplate <class _Iter> \nstruct __reference_type_definition_requirement_violation {\n  typedef typename __STD::iterator_traits<_Iter>::reference reference;\n};\n\ntemplate <class _Iter> \nstruct __pointer_type_definition_requirement_violation {\n  typedef typename __STD::iterator_traits<_Iter>::pointer pointer;\n};\n\ntemplate <class _Iter> \nstruct __iterator_category_type_definition_requirement_violation {\n  typedef typename __STD::iterator_traits<_Iter>::iterator_category \n          iterator_category;\n};\n\n/* Assignable Requirements */\n\n\ntemplate <class _Type>\nstruct _Assignable_concept_specification {\n  static void _Assignable_requirement_violation(_Type __a) {\n    _STL_ERROR::__assignment_operator_requirement_violation(__a);\n    _STL_ERROR::__copy_constructor_requirement_violation(__a);\n    _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a);\n    _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a);\n  }\n};\n\n/* DefaultConstructible Requirements */\n\n\ntemplate <class _Type>\nstruct _DefaultConstructible_concept_specification {\n  static void _DefaultConstructible_requirement_violation(_Type __a) {\n    _STL_ERROR::__default_constructor_requirement_violation(__a);\n  }\n};\n\n/* EqualityComparable Requirements */\n\ntemplate <class _Type>\nstruct _EqualityComparable_concept_specification {\n  static void _EqualityComparable_requirement_violation(_Type __a) {\n    _STL_ERROR::__equality_comparable_requirement_violation(__a, __a);\n  }\n};\n\n/* LessThanComparable Requirements */\ntemplate <class _Type>\nstruct _LessThanComparable_concept_specification {\n  static void _LessThanComparable_requirement_violation(_Type __a) {\n    _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a);\n  }\n};\n\n/* TrivialIterator Requirements */\n\ntemplate <class _TrivialIterator>\nstruct _TrivialIterator_concept_specification {\nstatic void\n_TrivialIterator_requirement_violation(_TrivialIterator __i) {\n  typedef typename\n    __value_type_type_definition_requirement_violation<_TrivialIterator>::\n    value_type __T;\n  // Refinement of Assignable\n  _Assignable_concept_specification<_TrivialIterator>::\n    _Assignable_requirement_violation(__i);\n  // Refinement of DefaultConstructible\n  _DefaultConstructible_concept_specification<_TrivialIterator>::\n    _DefaultConstructible_requirement_violation(__i);\n  // Refinement of EqualityComparable\n  _EqualityComparable_concept_specification<_TrivialIterator>::\n    _EqualityComparable_requirement_violation(__i);\n  // Valid Expressions\n  _STL_ERROR::__dereference_operator_requirement_violation(__i);\n}\n};\n\ntemplate <class _TrivialIterator>\nstruct _Mutable_TrivialIterator_concept_specification {\nstatic void\n_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) {\n  _TrivialIterator_concept_specification<_TrivialIterator>::\n    _TrivialIterator_requirement_violation(__i);\n  // Valid Expressions\n  _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i);\n}\n};\n\n/* InputIterator Requirements */\n\ntemplate <class _InputIterator>\nstruct _InputIterator_concept_specification {\nstatic void\n_InputIterator_requirement_violation(_InputIterator __i) {\n  // Refinement of TrivialIterator\n  _TrivialIterator_concept_specification<_InputIterator>::\n    _TrivialIterator_requirement_violation(__i);\n  // Associated Types\n  __difference_type_type_definition_requirement_violation<_InputIterator>();\n  __reference_type_definition_requirement_violation<_InputIterator>();\n  __pointer_type_definition_requirement_violation<_InputIterator>();\n  __iterator_category_type_definition_requirement_violation<_InputIterator>();\n  // Valid Expressions\n  _STL_ERROR::__preincrement_operator_requirement_violation(__i);\n  _STL_ERROR::__postincrement_operator_requirement_violation(__i);\n}\n};\n\n/* OutputIterator Requirements */\n\ntemplate <class _OutputIterator>\nstruct _OutputIterator_concept_specification {\nstatic void\n_OutputIterator_requirement_violation(_OutputIterator __i) {\n  // Refinement of Assignable\n  _Assignable_concept_specification<_OutputIterator>::\n    _Assignable_requirement_violation(__i);\n  // Associated Types\n  __iterator_category_type_definition_requirement_violation<_OutputIterator>();\n  // Valid Expressions\n  _STL_ERROR::__dereference_operator_requirement_violation(__i);\n  _STL_ERROR::__preincrement_operator_requirement_violation(__i);\n  _STL_ERROR::__postincrement_operator_requirement_violation(__i);\n  _STL_ERROR::\n    __postincrement_operator_and_assignment_requirement_violation(__i, *__i);\n}\n};\n\n/* ForwardIterator Requirements */\n\ntemplate <class _ForwardIterator>\nstruct _ForwardIterator_concept_specification {\nstatic void\n_ForwardIterator_requirement_violation(_ForwardIterator __i) {\n  // Refinement of InputIterator\n  _InputIterator_concept_specification<_ForwardIterator>::\n    _InputIterator_requirement_violation(__i);\n}\n};\n\ntemplate <class _ForwardIterator>\nstruct _Mutable_ForwardIterator_concept_specification {\nstatic void\n_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) {\n  _ForwardIterator_concept_specification<_ForwardIterator>::\n    _ForwardIterator_requirement_violation(__i);\n  // Refinement of OutputIterator\n  _OutputIterator_concept_specification<_ForwardIterator>::\n    _OutputIterator_requirement_violation(__i);\n}\n};\n\n/* BidirectionalIterator Requirements */\n\ntemplate <class _BidirectionalIterator>\nstruct _BidirectionalIterator_concept_specification {\nstatic void\n_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) {\n  // Refinement of ForwardIterator\n  _ForwardIterator_concept_specification<_BidirectionalIterator>::\n    _ForwardIterator_requirement_violation(__i);\n  // Valid Expressions\n  _STL_ERROR::__predecrement_operator_requirement_violation(__i);\n  _STL_ERROR::__postdecrement_operator_requirement_violation(__i);\n}\n};\n\ntemplate <class _BidirectionalIterator>\nstruct _Mutable_BidirectionalIterator_concept_specification {\nstatic void\n_Mutable_BidirectionalIterator_requirement_violation(\n       _BidirectionalIterator __i)\n{\n  _BidirectionalIterator_concept_specification<_BidirectionalIterator>::\n    _BidirectionalIterator_requirement_violation(__i);\n  // Refinement of mutable_ForwardIterator\n  _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>::\n    _Mutable_ForwardIterator_requirement_violation(__i);\n  typedef typename\n    __value_type_type_definition_requirement_violation<\n    _BidirectionalIterator>::value_type __T;\n  typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0;\n  // Valid Expressions\n  _STL_ERROR::\n    __postincrement_operator_and_assignment_requirement_violation(__i,\n                                                                  *__tmp_ptr);\n}\n};\n\n/* RandomAccessIterator Requirements */\n\ntemplate <class _RandAccIter>\nstruct _RandomAccessIterator_concept_specification {\nstatic void\n_RandomAccessIterator_requirement_violation(_RandAccIter __i) {\n  // Refinement of BidirectionalIterator\n  _BidirectionalIterator_concept_specification<_RandAccIter>::\n    _BidirectionalIterator_requirement_violation(__i);\n  // Refinement of LessThanComparable\n  _LessThanComparable_concept_specification<_RandAccIter>::\n    _LessThanComparable_requirement_violation(__i);\n  typedef typename \n        __value_type_type_definition_requirement_violation<_RandAccIter>\n        ::value_type\n    value_type;\n  typedef typename\n        __difference_type_type_definition_requirement_violation<_RandAccIter>\n        ::difference_type \n    _Dist;\n  typedef typename _Mutable_trait<_Dist>::_Type _MutDist;\n\n  // Valid Expressions\n  _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i,\n                                                                   _MutDist());\n  _STL_ERROR::__iterator_addition_requirement_violation(__i,\n                                                        _MutDist());\n  _STL_ERROR::\n    __iterator_subtraction_assignment_requirement_violation(__i,\n                                                            _MutDist());\n  _STL_ERROR::__iterator_subtraction_requirement_violation(__i,\n                                                           _MutDist());\n  _STL_ERROR::__difference_operator_requirement_violation(__i, __i,\n                                                          _MutDist());\n  typename _Mutable_trait<value_type>::_Type* __dummy_ptr = 0;\n  _STL_ERROR::__element_access_operator_requirement_violation(__i,\n                                                              __dummy_ptr,\n                                                              _MutDist());\n}\n};\n\ntemplate <class _RandAccIter>\nstruct _Mutable_RandomAccessIterator_concept_specification {\nstatic void\n_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i)\n{\n  _RandomAccessIterator_concept_specification<_RandAccIter>::\n    _RandomAccessIterator_requirement_violation(__i);\n  // Refinement of mutable_BidirectionalIterator\n  _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>::\n    _Mutable_BidirectionalIterator_requirement_violation(__i);\n  typedef typename\n        __value_type_type_definition_requirement_violation<_RandAccIter>\n        ::value_type\n    value_type;\n  typedef typename\n        __difference_type_type_definition_requirement_violation<_RandAccIter>\n        ::difference_type\n    _Dist;\n\n  typename _Mutable_trait<value_type>::_Type* __tmp_ptr = 0;\n  // Valid Expressions\n  _STL_ERROR::__element_assignment_operator_requirement_violation(__i,\n                  __tmp_ptr, _Dist());\n}\n};\n\n#define __STL_TYPEDEF_REQUIREMENT(__REQUIREMENT) \\\ntemplate <class Type> \\\nstruct __##__REQUIREMENT##__typedef_requirement_violation { \\\n  typedef typename Type::__REQUIREMENT __REQUIREMENT; \\\n}\n\n__STL_TYPEDEF_REQUIREMENT(value_type);\n__STL_TYPEDEF_REQUIREMENT(difference_type);\n__STL_TYPEDEF_REQUIREMENT(size_type);\n__STL_TYPEDEF_REQUIREMENT(reference);\n__STL_TYPEDEF_REQUIREMENT(const_reference);\n__STL_TYPEDEF_REQUIREMENT(pointer);\n__STL_TYPEDEF_REQUIREMENT(const_pointer);\n\n\ntemplate <class _Alloc>\nstruct _Allocator_concept_specification {\nstatic void\n_Allocator_requirement_violation(_Alloc __a) {\n  // Refinement of DefaultConstructible\n  _DefaultConstructible_concept_specification<_Alloc>::\n    _DefaultConstructible_requirement_violation(__a);\n  // Refinement of EqualityComparable\n  _EqualityComparable_concept_specification<_Alloc>::\n    _EqualityComparable_requirement_violation(__a);\n  // Associated Types\n  __value_type__typedef_requirement_violation<_Alloc>();\n  __difference_type__typedef_requirement_violation<_Alloc>();\n  __size_type__typedef_requirement_violation<_Alloc>();\n  __reference__typedef_requirement_violation<_Alloc>();\n  __const_reference__typedef_requirement_violation<_Alloc>();\n  __pointer__typedef_requirement_violation<_Alloc>();\n  __const_pointer__typedef_requirement_violation<_Alloc>();\n  typedef typename _Alloc::value_type _Tp;\n  //__STL_REQUIRES_SAME_TYPE(typename _Alloc::__STL_TEMPLATE rebind<_Tp>::other,\n  //                         _Alloc);\n}\n};\n\n#endif /* __STL_USE_CONCEPT_CHECKS */\n\n#endif /* __CONCEPT_CHECKS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/container_concepts.h",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __STL_CONTAINER_CONCEPTS_H\n#define __STL_CONTAINER_CONCEPTS_H\n\n\n#include <concept_checks.h>\n\n#ifdef __STL_USE_CONCEPT_CHECKS\n\n\n// This file covers the following concepts:\n//       _Container\n//       _ForwardContainer\n//       _ReversibleContainer\n//       _const_ReversibleContainer\n//       _RandomAccessContainer\n//\n\nstruct _ERROR_IN_STL_CONTAINER {\n\n  /* Container expresssions */\n\n  template <class _Container>\n  static void\n  __begin_iterator_accessor_requirement_violation(_Container __c) {\n    __c.begin();\n  }\n  template <class _Container>\n  static void\n  __const_begin_iterator_accessor_requirement_violation(const _Container& __c) {\n    __c.begin();\n  }\n  template <class _Container>\n  static void\n  __end_iterator_accessor_requirement_violation(_Container __c) {\n    __c.end();\n  }\n  template <class _Container>\n  static void\n  __const_end_iterator_accessor_requirement_violation(const _Container& __c) {\n    __c.end();\n  }\n\n  template <class _Container>\n  static void\n  __rbegin_iterator_accessor_requirement_violation(_Container __c) {\n    __c.rbegin();\n  }\n  template <class _Container>\n  static void\n  __const_rbegin_iterator_accessor_requirement_violation(const _Container& __c) {\n    __c.rbegin();\n  }\n  template <class _Container>\n  static void\n  __rend_iterator_accessor_requirement_violation(_Container __c) {\n    __c.rend();\n  }\n  template <class _Container>\n  static void\n  __const_rend_iterator_accessor_requirement_violation(const _Container& __c) {\n    __c.rend();\n  }\n  template <class _Container>\n  static void\n  __size_function_must_be_const(const _Container& __c) {\n    __c.size();\n  }\n  template <class _Container>\n  static void\n  __size_function_requirement_violation(_Container& __c) {\n    __c.size();\n    __size_function_must_be_const(__c);\n  }\n  template <class _Container>\n  static void\n  __max_size_function_must_be_const(const _Container& __c) {\n    __c.max_size();\n  }\n  template <class _Container>\n  static void\n  __max_size_function_requirement_violation(_Container& __c) {\n    __c.max_size();\n    __max_size_function_must_be_const(__c);\n  }\n  template <class _Container>\n  static void\n  __empty_function_must_be_const(const _Container& __c) {\n    __c.empty();\n  }\n  template <class _Container>\n  static void\n  __empty_function_requirement_violation(_Container& __c) {\n    __c.empty();\n    __empty_function_must_be_const(__c);\n  }\n  template <class _Container>\n  static void\n  __swap_function_requirement_violation(_Container& __c) {\n    __c.swap(__c);\n  }\n\n};\n\n\n__STL_TYPEDEF_REQUIREMENT(iterator);\n__STL_TYPEDEF_REQUIREMENT(const_iterator);\n\n/* Containers */\n\ntemplate <class _Container>\nstruct _Container_concept_specification {\nstatic void\n_Container_requirement_violation(_Container __c) {\n  // Refinement of Assignable\n  _Assignable_concept_specification<_Container>::_Assignable_requirement_violation(__c);\n  // Associated Types\n  __value_type__typedef_requirement_violation<_Container>();\n  __difference_type__typedef_requirement_violation<_Container>();\n  __size_type__typedef_requirement_violation<_Container>();\n  __reference__typedef_requirement_violation<_Container>();\n  __const_reference__typedef_requirement_violation<_Container>();\n  __pointer__typedef_requirement_violation<_Container>();\n  __const_pointer__typedef_requirement_violation<_Container>();\n  __iterator__typedef_requirement_violation<_Container>();\n  __const_iterator__typedef_requirement_violation<_Container>();\n  // Valid Expressions\n  _ERROR_IN_STL_CONTAINER::__const_begin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__const_end_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__begin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__end_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__size_function_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__max_size_function_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__empty_function_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__swap_function_requirement_violation(__c);\n  // Requirements on Iterators\n  typedef typename _Container::iterator iter;\n  typedef typename _Container::const_iterator const_iter;\n  _InputIterator_concept_specification<const_iter>::_InputIterator_requirement_violation(const_iter());\n  _InputIterator_concept_specification<iter>::_InputIterator_requirement_violation(iter());\n}\n};\n\ntemplate <class _ForwardContainer>\nstruct _ForwardContainer_concept_specification {\nstatic void\n_ForwardContainer_requirement_violation(_ForwardContainer __c) {\n  // Refinement of Container\n  _Container_concept_specification<_ForwardContainer>::_Container_requirement_violation(__c);\n  // Requirements on Iterators\n  typedef typename _ForwardContainer::iterator iter;\n  typedef typename _ForwardContainer::const_iterator const_iter;\n  _ForwardIterator_concept_specification<const_iter>::_ForwardIterator_requirement_violation(const_iter());\n  _Mutable_ForwardIterator_concept_specification<iter>::_Mutable_ForwardIterator_requirement_violation(iter());\n}\n};\n\n\n__STL_TYPEDEF_REQUIREMENT(reverse_iterator);\n__STL_TYPEDEF_REQUIREMENT(const_reverse_iterator);\n\ntemplate <class _ReversibleContainer>\nstruct _ReversibleContainer_concept_specification {\nstatic void\n_ReversibleContainer_requirement_violation(_ReversibleContainer __c) {\n  // Refinement of ForwardContainer\n  _ForwardContainer_concept_specification<_ReversibleContainer>::_ForwardContainer_requirement_violation(__c);\n  // Associated types\n  __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();\n  __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();\n  // Valid Expressions\n  _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c);\n  // Requirements on Iterators\n  typedef typename _ReversibleContainer::iterator iter;\n  typedef typename _ReversibleContainer::const_iterator const_iter;\n  _BidirectionalIterator_concept_specification<const_iter>::_BidirectionalIterator_requirement_violation(const_iter());\n  _Mutable_BidirectionalIterator_concept_specification<iter>::_Mutable_BidirectionalIterator_requirement_violation(iter());\n}\n};\n\ntemplate <class _ReversibleContainer>\nstruct _const_ReversibleContainer_concept_specification {\nstatic void\n_const_ReversibleContainer_requirement_violation(_ReversibleContainer __c) {\n  // Refinement of Container (JGS, not ForwardContainer)\n  _Container_concept_specification<_ReversibleContainer>::_Container_requirement_violation(__c);\n  // Associated types\n  __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();\n  __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();\n  // Valid Expressions\n  _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c);\n  _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c);\n  // Requirements on Iterators\n  typedef typename _ReversibleContainer::iterator iter;\n  typedef typename _ReversibleContainer::const_iterator const_iter;\n  \n  // This line won't compile on gcc 2.91 due to a compiler bug.\n#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 91)\n  __BidirectionalIterator_concept_specification<const_iter>::_BidirectionalIterator_requirement_violation(const_iter());\n#endif\n}\n};\n\n\ntemplate <class _RandomAccessContainer>\nstruct _RandomAccessContainer_concept_specification {\nstatic void\n_RandomAccessContainer_requirement_violation(_RandomAccessContainer __c) {\n  // Refinement of ReversibleContainer\n  _ReversibleContainer_concept_specification<_RandomAccessContainer>::_ReversibleContainer_requirement_violation(__c);\n  // Valid Expressions\n  typedef typename _RandomAccessContainer::value_type __T;\n  typedef typename _RandomAccessContainer::difference_type _Dist;\n  typedef typename _Mutable_trait<__T>::_Type Type;\n  typedef Type* _TypePtr;\n  typedef typename _Mutable_trait<_Dist>::_Type Dist;\n  _STL_ERROR::__element_access_operator_requirement_violation(__c,\n\t\t\t\t\t\t\t      _TypePtr(), \n\t\t\t\t\t\t\t      Dist());\n  // Requirements on Iterators\n  typedef typename _RandomAccessContainer::iterator iter;\n  typedef typename _RandomAccessContainer::const_iterator const_iter;\n  _RandomAccessIterator_concept_specification<const_iter>::_RandomAccessIterator_requirement_violation(const_iter());\n  _Mutable_RandomAccessIterator_concept_specification<iter>::_Mutable_RandomAccessIterator_requirement_violation(iter());\n}\n};\n\n#endif /* if __STL_USE_CONCEPT_CHECKS */\n\n#endif /* __STL_CONTAINER_CONCEPTS_H */\n"
  },
  {
    "path": "stl-3.3-source/defalloc.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n// Inclusion of this file is DEPRECATED.  This is the original HP\n// default allocator.  It is provided only for backward compatibility.\n// This file WILL BE REMOVED in a future release.\n//\n// DO NOT USE THIS FILE unless you have an old container implementation\n// that requires an allocator with the HP-style interface.  \n//\n// Standard-conforming allocators have a very different interface.  The\n// standard default allocator is declared in the header <memory>.\n\n#ifndef DEFALLOC_H\n#define DEFALLOC_H\n\n#include <new.h>\n#include <stddef.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <iostream.h>\n#include <algobase.h>\n\n\ntemplate <class T>\ninline T* allocate(ptrdiff_t size, T*) {\n    set_new_handler(0);\n    T* tmp = (T*)(::operator new((size_t)(size * sizeof(T))));\n    if (tmp == 0) {\n\tcerr << \"out of memory\" << endl; \n\texit(1);\n    }\n    return tmp;\n}\n\n\ntemplate <class T>\ninline void deallocate(T* buffer) {\n    ::operator delete(buffer);\n}\n\ntemplate <class T>\nclass allocator {\npublic:\n    typedef T value_type;\n    typedef T* pointer;\n    typedef const T* const_pointer;\n    typedef T& reference;\n    typedef const T& const_reference;\n    typedef size_t size_type;\n    typedef ptrdiff_t difference_type;\n    pointer allocate(size_type n) { \n\treturn ::allocate((difference_type)n, (pointer)0);\n    }\n    void deallocate(pointer p) { ::deallocate(p); }\n    pointer address(reference x) { return (pointer)&x; }\n    const_pointer const_address(const_reference x) { \n\treturn (const_pointer)&x; \n    }\n    size_type init_page_size() { \n\treturn max(size_type(1), size_type(4096/sizeof(T))); \n    }\n    size_type max_size() const { \n\treturn max(size_type(1), size_type(UINT_MAX/sizeof(T))); \n    }\n};\n\nclass allocator<void> {\npublic:\n    typedef void* pointer;\n};\n\n\n\n#endif\n"
  },
  {
    "path": "stl-3.3-source/deque",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_DEQUE\n#define __SGI_STL_DEQUE\n\n#include <stl_range_errors.h>\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_deque.h>\n\n#endif /* __SGI_STL_DEQUE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/deque.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_DEQUE_H\n#define __SGI_STL_DEQUE_H\n\n#include <stl_range_errors.h>\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_deque.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::deque;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_DEQUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/function.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_FUNCTION_H\n#define __SGI_STL_FUNCTION_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#include <stddef.h>\n#ifndef __SGI_STL_INTERNAL_FUNCTION_H\n#include <stl_function.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACE_FOR_RELOPS\n\n// Names from stl_relops.h\nusing __STD_RELOPS::operator!=;\nusing __STD_RELOPS::operator>;\nusing __STD_RELOPS::operator<=;\nusing __STD_RELOPS::operator>=;\n\n#endif /* __STL_USE_NAMESPACE_FOR_RELOPS */\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_function.h\nusing __STD::unary_function; \nusing __STD::binary_function; \nusing __STD::plus; \nusing __STD::minus; \nusing __STD::multiplies; \nusing __STD::divides; \nusing __STD::identity_element; \nusing __STD::modulus; \nusing __STD::negate; \nusing __STD::equal_to; \nusing __STD::not_equal_to; \nusing __STD::greater; \nusing __STD::less; \nusing __STD::greater_equal; \nusing __STD::less_equal; \nusing __STD::logical_and; \nusing __STD::logical_or; \nusing __STD::logical_not; \nusing __STD::unary_negate; \nusing __STD::binary_negate; \nusing __STD::not1; \nusing __STD::not2; \nusing __STD::binder1st; \nusing __STD::binder2nd; \nusing __STD::bind1st; \nusing __STD::bind2nd; \nusing __STD::unary_compose; \nusing __STD::binary_compose; \nusing __STD::compose1; \nusing __STD::compose2; \nusing __STD::pointer_to_unary_function; \nusing __STD::pointer_to_binary_function; \nusing __STD::ptr_fun; \nusing __STD::identity; \nusing __STD::select1st; \nusing __STD::select2nd; \nusing __STD::project1st; \nusing __STD::project2nd; \nusing __STD::constant_void_fun; \nusing __STD::constant_unary_fun; \nusing __STD::constant_binary_fun; \nusing __STD::constant0; \nusing __STD::constant1; \nusing __STD::constant2; \nusing __STD::subtractive_rng; \nusing __STD::mem_fun_t; \nusing __STD::const_mem_fun_t; \nusing __STD::mem_fun_ref_t; \nusing __STD::const_mem_fun_ref_t; \nusing __STD::mem_fun1_t; \nusing __STD::const_mem_fun1_t; \nusing __STD::mem_fun1_ref_t; \nusing __STD::const_mem_fun1_ref_t; \nusing __STD::mem_fun; \nusing __STD::mem_fun_ref; \nusing __STD::mem_fun1; \nusing __STD::mem_fun1_ref; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_FUNCTION_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/functional",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_FUNCTIONAL\n#define __SGI_STL_FUNCTIONAL\n\n#include <stl_config.h>\n#include <stddef.h>\n#include <stl_function.h>\n\n#endif /* __SGI_STL_FUNCTIONAL */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/hash_map",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_MAP\n#define __SGI_STL_HASH_MAP\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_map.h>\n\n#endif /* __SGI_STL_HASH_MAP */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/hash_map.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_MAP_H\n#define __SGI_STL_HASH_MAP_H\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <algobase.h>\n#include <stl_hash_map.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\nusing __STD::hash_map;\nusing __STD::hash_multimap;\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_HASH_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/hash_set",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_SET\n#define __SGI_STL_HASH_SET\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_set.h>\n\n#endif /* __SGI_STL_HASH_SET */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/hash_set.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_SET_H\n#define __SGI_STL_HASH_SET_H\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <algobase.h>\n#include <stl_hash_set.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\nusing __STD::hash_set;\nusing __STD::hash_multiset;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_HASH_SET_H */\n"
  },
  {
    "path": "stl-3.3-source/hashtable.h",
    "content": "/*\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_HASHTABLE_H\n#define __SGI_STL_HASHTABLE_H\n\n#include <stl_hashtable.h>\n#include <algo.h>\n#include <alloc.h>\n#include <vector.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_HASHTABLE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/heap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_HEAP_H\n#define __SGI_STL_HEAP_H\n\n#include <stl_config.h>\n#include <stl_heap.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::push_heap;\nusing __STD::pop_heap;\nusing __STD::make_heap;\nusing __STD::sort_heap;\n\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_HEAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/iterator",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ITERATOR\n#define __SGI_STL_ITERATOR\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stddef.h>       \n\n#ifdef __STL_USE_NEW_IOSTREAMS \n#include <iosfwd>\n#else /* __STL_USE_NEW_IOSTREAMS */\n#include <iostream.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#include <stl_iterator_base.h>\n#include <stl_iterator.h>\n\n#endif /* __SGI_STL_ITERATOR */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/iterator.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ITERATOR_H\n#define __SGI_STL_ITERATOR_H\n\n#ifndef __SGI_STL_FUNCTION_H\n#include <function.h>\n#endif\n#include <stddef.h>\n\n#ifdef __STL_USE_NEW_IOSTREAMS \n#include <iosfwd>\n#else /* __STL_USE_NEW_IOSTREAMS */\n#include <iostream.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_H\n#include <stl_iterator_base.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#include <stl_iterator.h>\n#endif\n#ifndef __TYPE_TRAITS_H\n#include <type_traits.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#include <stl_construct.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n#include <stl_raw_storage_iter.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_iterator.h\n\nusing __STD::input_iterator_tag;\nusing __STD::output_iterator_tag;\nusing __STD::forward_iterator_tag;\nusing __STD::bidirectional_iterator_tag;\nusing __STD::random_access_iterator_tag;\n\n#if 0\nusing __STD::iterator;\n#endif\nusing __STD::input_iterator;\nusing __STD::output_iterator;\nusing __STD::forward_iterator;\nusing __STD::bidirectional_iterator;\nusing __STD::random_access_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\nusing __STD::iterator_traits;\n#endif\n\nusing __STD::iterator_category;\nusing __STD::distance_type;\nusing __STD::value_type;\n\nusing __STD::distance; \nusing __STD::advance; \n\nusing __STD::insert_iterator;\nusing __STD::front_insert_iterator;\nusing __STD::back_insert_iterator;\nusing __STD::inserter;\nusing __STD::front_inserter;\nusing __STD::back_inserter;\n\nusing __STD::reverse_iterator;\nusing __STD::reverse_bidirectional_iterator;\n\nusing __STD::istream_iterator;\nusing __STD::ostream_iterator;\n\n// Names from stl_construct.h\nusing __STD::construct;\nusing __STD::destroy;\n\n// Names from stl_raw_storage_iter.h\nusing __STD::raw_storage_iterator;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ITERATOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/limits",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is not portable code.  Parts of numeric_limits<> are\n * inherently machine-dependent.  At present this file is suitable\n * for the MIPS and ia32 architectures.\n */\n\n#ifndef __SGI_CPP_LIMITS\n#define __SGI_CPP_LIMITS\n\n#include <limits.h>\n#include <float.h>\n#include <stl_config.h>\n\n__STL_BEGIN_NAMESPACE\n\nenum float_round_style {\n  round_indeterminate       = -1,\n  round_toward_zero         =  0,\n  round_to_nearest          =  1,\n  round_toward_infinity     =  2,\n  round_toward_neg_infinity =  3\n};\n\nenum float_denorm_style {\n  denorm_indeterminate = -1,\n  denorm_absent        =  0,\n  denorm_present       =  1\n};\n\n// The C++ standard (section 18.2.1) requires that some of the members of\n// numeric_limits be static const data members that are given constant-\n// initializers within the class declaration.  On compilers where the\n// __STL_STATIC_CONST_INIT_BUG macro is defined, it is impossible to write\n// a standard-conforming numeric_limits class.\n//\n// There are two possible workarounds: either initialize the data\n// members outside the class, or change them from data members to\n// enums.  Neither workaround is satisfactory: the former makes it\n// impossible to use the data members in constant-expressions, and the\n// latter means they have the wrong type and that it is impossible to\n// take their addresses.  We choose the former workaround.\n\n#ifdef __STL_STATIC_CONST_INIT_BUG\n# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \\\n  enum { __mem_name = __mem_value }\n#else /* __STL_STATIC_CONST_INIT_BUG */\n# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \\\n  static const __mem_type __mem_name = __mem_value\n#endif /* __STL_STATIC_CONST_INIT_BUG */\n\n// Base class for all specializations of numeric_limits.\n\ntemplate <class __number>\nclass _Numeric_limits_base {\npublic:\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);\n\n  static __number min() __STL_NOTHROW { return __number(); }\n  static __number max() __STL_NOTHROW { return __number(); }\n\n  __STL_DECLARE_LIMITS_MEMBER(int, digits,   0);\n  __STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed,  false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_exact,   false);\n\n  __STL_DECLARE_LIMITS_MEMBER(int, radix, 0);\n\n  static __number epsilon() __STL_NOTHROW     { return __number(); }\n  static __number round_error() __STL_NOTHROW { return __number(); }\n\n  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent,   0);\n  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0);\n  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent,   0);\n  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity,      false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN,     false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false);\n  __STL_DECLARE_LIMITS_MEMBER(float_denorm_style,\n                              has_denorm,\n                              denorm_absent);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss,   false);\n\n  static __number infinity() __STL_NOTHROW      { return __number(); }\n  static __number quiet_NaN() __STL_NOTHROW     { return __number(); }\n  static __number signaling_NaN() __STL_NOTHROW { return __number(); }\n  static __number denorm_min() __STL_NOTHROW    { return __number(); }\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559,  false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo,  false);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, traps,            false);\n  __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before,  false);\n  __STL_DECLARE_LIMITS_MEMBER(float_round_style,\n                              round_style,\n                              round_toward_zero);\n};\n\n#ifdef __STL_STATIC_CONST_INIT_BUG\n# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem)\n#else /* __STL_STATIC_CONST_INIT_BUG */\n# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem) \\\n  template <class __number>                              \\\n  const __type _Numeric_limits_base<__number>:: __mem\n#endif /* __STL_STATIC_CONST_INIT_BUG */\n\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_specialized);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits10);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_signed);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_integer);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_exact);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, radix);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent10);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent10);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_infinity);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_quiet_NaN);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_signaling_NaN);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(float_denorm_style, has_denorm);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_denorm_loss);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_iec559);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_bounded);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_modulo);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, traps);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, tinyness_before);\n__STL_DEFINE_NUMERIC_BASE_MEMBER(float_round_style, round_style);\n\n\n// Base class for integers.\n\ntemplate <class _Int,\n          _Int __imin, _Int __imax,\n          int __idigits = -1, bool __ismod = true>\nclass _Integer_limits : public _Numeric_limits_base<_Int> \n{\npublic:\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);\n\n  static _Int min() __STL_NOTHROW { return __imin; }\n  static _Int max() __STL_NOTHROW { return __imax; }\n\n  __STL_DECLARE_LIMITS_MEMBER(int,\n                              digits,\n                              (__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT)\n                                                   - (__imin == 0 ? 0 : 1) \n                                              : __idigits);\n  __STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000); \n                                // log 2 = 0.301029995664...\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed,  __imin != 0);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_exact,   true);\n  __STL_DECLARE_LIMITS_MEMBER(int,  radix,      2);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, __ismod);\n};\n\n#ifdef __STL_STATIC_CONST_INIT_BUG\n# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem)\n#else /* __STL_STATIC_CONST_INIT_BUG */\n# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem)              \\\n  template <class _Int, _Int __imin, _Int __imax, int __idig, bool __ismod>  \\\n  const __type _Integer_limits<_Int, __imin, __imax, __idig, __ismod>::__mem\n#endif /* __STL_STATIC_CONST_INIT_BUG */\n\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_specialized);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits10);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_signed);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_integer);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_exact);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, radix);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_bounded);\n__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_modulo);\n\n\n// Base class for floating-point numbers.\ntemplate <class __number,\n         int __Digits, int __Digits10,\n         int __MinExp, int __MaxExp,\n         int __MinExp10, int __MaxExp10,\n         bool __IsIEC559,\n         float_round_style __RoundStyle>\nclass _Floating_limits : public _Numeric_limits_base<__number>\n{\npublic:\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);\n\n  __STL_DECLARE_LIMITS_MEMBER(int, digits,   __Digits);\n  __STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true);\n\n  __STL_DECLARE_LIMITS_MEMBER(int, radix, 2);\n\n  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent,   __MinExp);\n  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent,   __MaxExp);\n  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10);\n  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity,      true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN,     true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true);\n  __STL_DECLARE_LIMITS_MEMBER(float_denorm_style,\n                              has_denorm,\n                              denorm_indeterminate);\n  __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss,   false);\n\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559,       __IsIEC559);\n  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded,      true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, traps,           true);\n  __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);\n\n  __STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);\n};\n\n#ifdef __STL_STATIC_CONST_INIT_BUG\n# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem)\n#else /* __STL_STATIC_CONST_INIT_BUG */\n# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem)                   \\\n  template <class __Num, int __Dig, int __Dig10,                           \\\n            int __MnX, int __MxX, int __MnX10, int __MxX10,                \\\n            bool __IsIEEE, float_round_style __Sty>                        \\\n  const __type _Floating_limits<__Num, __Dig, __Dig10,                     \\\n                                __MnX, __MxX, __MnX10, __MxX10,            \\\n                                __IsIEEE, __Sty>:: __mem\n#endif /* __STL_STATIC_CONST_INIT_BUG */\n\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_specialized);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits10);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_signed);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, radix);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent10);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent10);  \n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_infinity);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_quiet_NaN);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_signaling_NaN);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_denorm_style, has_denorm);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_denorm_loss);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_iec559);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_bounded);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, traps);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, tinyness_before);\n__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_round_style, round_style);\n\n\n#undef __STL_DECLARE_NUMERIC_LIMITS_MEMBER\n#undef __STL_DEFINE_NUMERIC_BASE_MEMBER\n#undef __STL_DEFINE_INTEGER_LIMITS_MEMBER\n#undef __STL_DEFINE_FLOAT_LIMITS_MEMBER\n\n// Class numeric_limits\n\n// The unspecialized class.\n\ntemplate<class _Tp> \nclass numeric_limits : public _Numeric_limits_base<_Tp> {};\n\n// Specializations for all built-in integral types.\n\n#ifndef __STL_NO_BOOL\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<bool>\n  : public _Integer_limits<bool, false, true, 1, false>\n{};\n\n#endif /* __STL_NO_BOOL */\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<char>\n  : public _Integer_limits<char, CHAR_MIN, CHAR_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<signed char>\n  : public _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<unsigned char>\n  : public _Integer_limits<unsigned char, 0, UCHAR_MAX>\n{};\n\n#ifdef __STL_HAS_WCHAR_T\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<wchar_t>\n  : public _Integer_limits<wchar_t, INT_MIN, INT_MAX>\n{};\n\n#endif\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<short>\n  : public _Integer_limits<short, SHRT_MIN, SHRT_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<unsigned short>\n  : public _Integer_limits<unsigned short, 0, USHRT_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<int>\n  : public _Integer_limits<int, INT_MIN, INT_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<unsigned int>\n  : public _Integer_limits<unsigned int, 0, UINT_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<long>\n  : public _Integer_limits<long, LONG_MIN, LONG_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<unsigned long>\n  : public _Integer_limits<unsigned long, 0, ULONG_MAX>\n{};\n\n#ifdef __STL_LONG_LONG\n\n// Some compilers have long long, but don't define the\n// LONGLONG_MIN and LONGLONG_MAX macros in limits.h.  This\n// assumes that long long is 64 bits.\n#if !defined(LONGLONG_MIN) && !defined(LONGLONG_MAX) \\\n                           && !defined(ULONGLONG_MAX)\n\n#define ULONGLONG_MAX 0xffffffffffffffffLLU\n#define LONGLONG_MAX 0x7fffffffffffffffLL\n#define LONGLONG_MIN (-LONGLONG_MAX - 1LL)\n\n#endif\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<long long>\n  : public _Integer_limits<long long, LONGLONG_MIN, LONGLONG_MAX>\n{};\n\n__STL_TEMPLATE_NULL\nclass numeric_limits<unsigned long long>\n  : public _Integer_limits<unsigned long long, 0, ULONGLONG_MAX>\n{};\n\n#endif /* __STL_LONG_LONG */\n\n// Specializations for all built-in floating-point type.\n\n__STL_TEMPLATE_NULL class numeric_limits<float>\n  : public _Floating_limits<float, \n                            FLT_MANT_DIG,   // Binary digits of precision\n                            FLT_DIG,        // Decimal digits of precision\n                            FLT_MIN_EXP,    // Minimum exponent\n                            FLT_MAX_EXP,    // Maximum exponent\n                            FLT_MIN_10_EXP, // Minimum base 10 exponent\n                            FLT_MAX_10_EXP, // Maximum base 10 exponent\n                            true,           // conforms to iec559\n                            round_to_nearest>\n{\npublic:\n  static float min() __STL_NOTHROW { return FLT_MIN; }\n  static float denorm_min() __STL_NOTHROW { return FLT_MIN; }\n  static float max() __STL_NOTHROW { return FLT_MAX; }\n  static float epsilon() __STL_NOTHROW { return FLT_EPSILON; }\n  static float round_error() __STL_NOTHROW { return 0.5f; } // Units: ulps.\n  static float infinity() __STL_NOTHROW;\n  static float quiet_NaN() __STL_NOTHROW;\n  static float signaling_NaN() __STL_NOTHROW;\n};\n\n__STL_TEMPLATE_NULL class numeric_limits<double>\n  : public _Floating_limits<double, \n                            DBL_MANT_DIG,   // Binary digits of precision\n                            DBL_DIG,        // Decimal digits of precision\n                            DBL_MIN_EXP,    // Minimum exponent\n                            DBL_MAX_EXP,    // Maximum exponent\n                            DBL_MIN_10_EXP, // Minimum base 10 exponent\n                            DBL_MAX_10_EXP, // Maximum base 10 exponent\n                            true,           // conforms to iec559\n                            round_to_nearest>\n{\npublic:\n  static double min() __STL_NOTHROW { return DBL_MIN; }\n  static double denorm_min() __STL_NOTHROW { return DBL_MIN; }\n  static double max() __STL_NOTHROW { return DBL_MAX; }\n  static double epsilon() __STL_NOTHROW { return DBL_EPSILON; }\n  static double round_error() __STL_NOTHROW { return 0.5; } // Units: ulps.\n  static double infinity() __STL_NOTHROW;\n  static double quiet_NaN() __STL_NOTHROW;\n  static double signaling_NaN() __STL_NOTHROW;\n};\n\n__STL_TEMPLATE_NULL class numeric_limits<long double>\n  : public _Floating_limits<long double, \n                            LDBL_MANT_DIG,  // Binary digits of precision\n                            LDBL_DIG,       // Decimal digits of precision\n                            LDBL_MIN_EXP,   // Minimum exponent\n                            LDBL_MAX_EXP,   // Maximum exponent\n                            LDBL_MIN_10_EXP,// Minimum base 10 exponent\n                            LDBL_MAX_10_EXP,// Maximum base 10 exponent\n                            false,          // Doesn't conform to iec559\n                            round_to_nearest>\n{\npublic:\n  static long double min() __STL_NOTHROW { return LDBL_MIN; }\n  static long double denorm_min() __STL_NOTHROW { return LDBL_MIN; }\n  static long double max() __STL_NOTHROW { return LDBL_MAX; }\n  static long double epsilon() __STL_NOTHROW { return LDBL_EPSILON; }\n  static long double round_error() __STL_NOTHROW { return 4; } // Units: ulps.\n  static long double infinity() __STL_NOTHROW;\n  static long double quiet_NaN() __STL_NOTHROW;\n  static long double signaling_NaN() __STL_NOTHROW;\n};\n\n// We write special values (Inf and NaN) as bit patterns and \n// cast the the appropriate floating-point types. \n\n#if defined(_MIPSEB)\n// Big-endian MIPS.  float is 32 bits, double 64, long double 128.\n\n#define _Define_float(__f, __h, __l)                                     \\\n   inline float numeric_limits<float>::__f() __STL_NOTHROW {             \\\n     static const unsigned short __x[2] = { __h, __l };                  \\\n     return *reinterpret_cast<const float*>(__x); }\n#define _Define_double(__f, __h, __l)                                    \\\n   inline double numeric_limits<double>::__f() __STL_NOTHROW {           \\\n     static const unsigned short __x[4] = { __h, __l };                  \\\n     return *reinterpret_cast<const double*>(__x); }\n#define _Define_ldouble(__f, __h, __l)                                   \\\n   inline long double numeric_limits<long double>::__f() __STL_NOTHROW { \\\n     static const unsigned short __x[8] = { __h, __l };                  \\\n     return *reinterpret_cast<const long double*>(__x); }\n\n_Define_float(infinity, 0x7f80, 0)\n_Define_float(quiet_NaN, 0x7f81, 0)\n_Define_float(signaling_NaN, 0x7fc1, 0)\n\n_Define_double(infinity, 0x7ff0, 0)\n_Define_double(quiet_NaN, 0x7ff1, 0)\n_Define_double(signaling_NaN, 0x7ff9, 0)\n\n_Define_ldouble(infinity, 0x7ff0, 0)\n_Define_ldouble(quiet_NaN, 0x7ff1, 0)\n_Define_ldouble(signaling_NaN, 0x7ff9, 0)\n\n#elif defined(__i386) || defined(_M_IX86)\n// Little-endian ia32.  float is 32 bits, double 64, long double 80.\n\n#define _Define_float(__f, __h, __l)                                     \\\n   inline float numeric_limits<float>::__f() __STL_NOTHROW {             \\\n     static const unsigned short __x[2] = { __l, __h };                  \\\n     return *reinterpret_cast<const float*>(__x); }\n#define _Define_double(__f, __h, __l)                                    \\\n   inline double numeric_limits<double>::__f() __STL_NOTHROW {           \\\n     static const unsigned short __x[4] = { 0, 0, __l, __h };            \\\n     return *reinterpret_cast<const double*>(__x); }\n#define _Define_ldouble(__f, __h, __l)                                   \\\n   inline long double numeric_limits<long double>::__f() __STL_NOTHROW { \\\n     static const unsigned short __x[5] = { 0, 0, 0, __l, __h };         \\\n     return *reinterpret_cast<const long double*>(__x); }\n\n_Define_float(infinity, 0x7f80, 0)\n_Define_float(quiet_NaN, 0x7fa0, 0)\n_Define_float(signaling_NaN, 0x7fc0, 0)\n\n_Define_double(infinity, 0x7ff0, 0)\n_Define_double(quiet_NaN, 0x7ff4, 0)\n_Define_double(signaling_NaN, 0x7ff8, 0)\n\n_Define_ldouble(infinity, 0x7fff, 0x8000)\n_Define_ldouble(quiet_NaN, 0x7fff, 0xa000)\n_Define_ldouble(signaling_NaN, 0x7fff, 0xc000)\n\n#else \n\n/* This is an architecture we don't know how to handle.  Return some \n   obviously wrong values. */\n\n#define _Define_float(__f)                                               \\\n   inline float numeric_limits<float>::__f() __STL_NOTHROW {             \\\n     return 0; }\n#define _Define_double(__f)                                              \\\n   inline double numeric_limits<double>::__f() __STL_NOTHROW {           \\\n     return 0; }\n#define _Define_ldouble(__f)                                             \\\n   inline long double numeric_limits<long double>::__f() __STL_NOTHROW { \\\n     return 0; }\n\n_Define_float(infinity)\n_Define_float(quiet_NaN)\n_Define_float(signaling_NaN)\n\n_Define_double(infinity)\n_Define_double(quiet_NaN)\n_Define_double(signaling_NaN)\n\n_Define_ldouble(infinity)\n_Define_ldouble(quiet_NaN)\n_Define_ldouble(signaling_NaN)   \n\n#endif\n\n#undef _Define_float\n#undef _Define_double\n#undef _Define_ldouble\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_CPP_LIMITS */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/list",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_LIST\n#define __SGI_STL_LIST\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_list.h>\n\n#endif /* __SGI_STL_LIST */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/list.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_LIST_H\n#define __SGI_STL_LIST_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_list.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::list;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_LIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/map",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MAP\n#define __SGI_STL_MAP\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <stl_map.h>\n#include <stl_multimap.h>\n\n#endif /* __SGI_STL_MAP */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/map.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MAP_H\n#define __SGI_STL_MAP_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_map.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\nusing __STD::map;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/memory",
    "content": "/*\n * Copyright (c) 1997-1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_MEMORY\n#define __SGI_STL_MEMORY\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_tempbuf.h>\n#include <stl_uninitialized.h>\n#include <stl_raw_storage_iter.h>\n\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \\\n    defined(__STL_MEMBER_TEMPLATES)\n\ntemplate<class _Tp1> struct auto_ptr_ref {\n  _Tp1* _M_ptr;\n  auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {}\n};\n\n#endif\n\ntemplate <class _Tp> class auto_ptr {\nprivate:\n  _Tp* _M_ptr;\n\npublic:\n  typedef _Tp element_type;\n\n  explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {}\n  auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW\n    : _M_ptr(__a.release()) {}\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW {\n    if (&__a != this) {\n      delete _M_ptr;\n      _M_ptr = __a.release();\n    }\n    return *this;\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Tp1>\n  auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW {\n    if (__a.get() != this->get()) {\n      delete _M_ptr;\n      _M_ptr = __a.release();\n    }\n    return *this;\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  // Note: The C++ standard says there is supposed to be an empty throw\n  // specification here, but omitting it is standard conforming.  Its \n  // presence can be detected only if _Tp::~_Tp() throws, but (17.4.3.6/2)\n  // this is prohibited.\n  ~auto_ptr() { delete _M_ptr; }\n\n  _Tp& operator*() const __STL_NOTHROW {\n    return *_M_ptr;\n  }\n  _Tp* operator->() const __STL_NOTHROW {\n    return _M_ptr;\n  }\n  _Tp* get() const __STL_NOTHROW {\n    return _M_ptr;\n  }\n  _Tp* release() __STL_NOTHROW {\n    _Tp* __tmp = _M_ptr;\n    _M_ptr = 0;\n    return __tmp;\n  }\n  void reset(_Tp* __p = 0) __STL_NOTHROW {\n    if (__p != _M_ptr) {\n      delete _M_ptr;\n      _M_ptr = __p;\n    }\n  }\n\n  // According to the C++ standard, these conversions are required.  Most\n  // present-day compilers, however, do not enforce that requirement---and, \n  // in fact, most present-day compilers do not support the language \n  // features that these conversions rely on.\n  \n#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \\\n    defined(__STL_MEMBER_TEMPLATES)\n\npublic:\n  auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW\n    : _M_ptr(__ref._M_ptr) {}\n\n  auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW {\n    if (__ref._M_ptr != this->get()) {\n      delete _M_ptr;\n      _M_ptr = __ref._M_ptr;\n    }\n    return *this;\n  }\n\n  template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW \n    { return auto_ptr_ref<_Tp1>(this->release()); }\n  template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW\n    { return auto_ptr<_Tp1>(this->release()); }\n\n#endif /* auto ptr conversions && member templates */\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_MEMORY */\n\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/multimap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MULTIMAP_H\n#define __SGI_STL_MULTIMAP_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_multimap.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\nusing __STD::multimap;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MULTIMAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/multiset.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MULTISET_H\n#define __SGI_STL_MULTISET_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_multiset.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\nusing __STD::multiset;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MULTISET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/numeric",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_NUMERIC\n#define __SGI_STL_NUMERIC\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stddef.h>\n\n#ifdef __STL_USE_NEW_IOSTREAMS \n#include <iostream>\n#else /* __STL_USE_NEW_IOSTREAMS */\n#include <iostream.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#include <stl_iterator_base.h>\n#include <stl_iterator.h>\n#include <stl_function.h>\n#include <stl_numeric.h>\n\n#endif /* __SGI_STL_NUMERIC */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/pair.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PAIR_H\n#define __SGI_STL_PAIR_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#include <stl_pair.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::pair;\nusing __STD::make_pair;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_PAIR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/pthread_alloc",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PTHREAD_ALLOC\n#define __SGI_STL_PTHREAD_ALLOC\n\n// Pthread-specific node allocator.\n// This is similar to the default allocator, except that free-list\n// information is kept separately for each thread, avoiding locking.\n// This should be reasonably fast even in the presence of threads.\n// The down side is that storage may not be well-utilized.\n// It is not an error to allocate memory in thread A and deallocate\n// it in thread B.  But this effectively transfers ownership of the memory,\n// so that it can only be reallocated by thread B.  Thus this can effectively\n// result in a storage leak if it's done on a regular basis.\n// It can also result in frequent sharing of\n// cache lines among processors, with potentially serious performance\n// consequences.\n\n#include <errno.h>\n#include <stl_config.h>\n#include <stl_alloc.h>\n#ifndef __RESTRICT\n#  define __RESTRICT\n#endif\n\n#ifndef __STL_NO_BAD_ALLOC\n#  include <new>\n#endif\n\n__STL_BEGIN_NAMESPACE\n\n#define __STL_DATA_ALIGNMENT 8\n\nunion _Pthread_alloc_obj {\n    union _Pthread_alloc_obj * __free_list_link;\n    char __client_data[__STL_DATA_ALIGNMENT];    /* The client sees this.    */\n};\n\n// Pthread allocators don't appear to the client to have meaningful\n// instances.  We do in fact need to associate some state with each\n// thread.  That state is represented by\n// _Pthread_alloc_per_thread_state<_Max_size>.\n\ntemplate<size_t _Max_size>\nstruct _Pthread_alloc_per_thread_state {\n  typedef _Pthread_alloc_obj __obj;\n  enum { _S_NFREELISTS = _Max_size/__STL_DATA_ALIGNMENT };\n  _Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS]; \n  _Pthread_alloc_per_thread_state<_Max_size> * __next; \n\t// Free list link for list of available per thread structures.\n  \t// When one of these becomes available for reuse due to thread\n\t// termination, any objects in its free list remain associated\n\t// with it.  The whole structure may then be used by a newly\n\t// created thread.\n  _Pthread_alloc_per_thread_state() : __next(0)\n  {\n    memset((void *)__free_list, 0, (size_t) _S_NFREELISTS * sizeof(__obj *));\n  }\n  // Returns an object of size __n, and possibly adds to size n free list.\n  void *_M_refill(size_t __n);\n};\n\n// Pthread-specific allocator.\n// The argument specifies the largest object size allocated from per-thread\n// free lists.  Larger objects are allocated using malloc_alloc.\n// Max_size must be a power of 2.\ntemplate <size_t _Max_size = 128>\nclass _Pthread_alloc_template {\n\npublic: // but only for internal use:\n\n  typedef _Pthread_alloc_obj __obj;\n\n  // Allocates a chunk for nobjs of size size.  nobjs may be reduced\n  // if it is inconvenient to allocate the requested number.\n  static char *_S_chunk_alloc(size_t __size, int &__nobjs);\n\n  enum {_S_ALIGN = __STL_DATA_ALIGNMENT};\n\n  static size_t _S_round_up(size_t __bytes) {\n        return (((__bytes) + (int) _S_ALIGN-1) & ~((int) _S_ALIGN - 1));\n  }\n  static size_t _S_freelist_index(size_t __bytes) {\n        return (((__bytes) + (int) _S_ALIGN-1)/(int)_S_ALIGN - 1);\n  }\n\nprivate:\n  // Chunk allocation state. And other shared state.\n  // Protected by _S_chunk_allocator_lock.\n  static pthread_mutex_t _S_chunk_allocator_lock;\n  static char *_S_start_free;\n  static char *_S_end_free;\n  static size_t _S_heap_size;\n  static _Pthread_alloc_per_thread_state<_Max_size>* _S_free_per_thread_states;\n  static pthread_key_t _S_key;\n  static bool _S_key_initialized;\n        // Pthread key under which per thread state is stored. \n        // Allocator instances that are currently unclaimed by any thread.\n  static void _S_destructor(void *instance);\n        // Function to be called on thread exit to reclaim per thread\n        // state.\n  static _Pthread_alloc_per_thread_state<_Max_size> *_S_new_per_thread_state();\n        // Return a recycled or new per thread state.\n  static _Pthread_alloc_per_thread_state<_Max_size> *_S_get_per_thread_state();\n        // ensure that the current thread has an associated\n        // per thread state.\n  class _M_lock;\n  friend class _M_lock;\n  class _M_lock {\n      public:\n        _M_lock () { pthread_mutex_lock(&_S_chunk_allocator_lock); }\n        ~_M_lock () { pthread_mutex_unlock(&_S_chunk_allocator_lock); }\n  };\n\npublic:\n\n  /* n must be > 0      */\n  static void * allocate(size_t __n)\n  {\n    __obj * volatile * __my_free_list;\n    __obj * __RESTRICT __result;\n    _Pthread_alloc_per_thread_state<_Max_size>* __a;\n\n    if (__n > _Max_size) {\n        return(malloc_alloc::allocate(__n));\n    }\n    if (!_S_key_initialized ||\n        !(__a = (_Pthread_alloc_per_thread_state<_Max_size>*)\n                                 pthread_getspecific(_S_key))) {\n        __a = _S_get_per_thread_state();\n    }\n    __my_free_list = __a -> __free_list + _S_freelist_index(__n);\n    __result = *__my_free_list;\n    if (__result == 0) {\n        void *__r = __a -> _M_refill(_S_round_up(__n));\n        return __r;\n    }\n    *__my_free_list = __result -> __free_list_link;\n    return (__result);\n  };\n\n  /* p may not be 0 */\n  static void deallocate(void *__p, size_t __n)\n  {\n    __obj *__q = (__obj *)__p;\n    __obj * volatile * __my_free_list;\n    _Pthread_alloc_per_thread_state<_Max_size>* __a;\n\n    if (__n > _Max_size) {\n        malloc_alloc::deallocate(__p, __n);\n        return;\n    }\n    if (!_S_key_initialized ||\n        !(__a = (_Pthread_alloc_per_thread_state<_Max_size> *)\n                pthread_getspecific(_S_key))) {\n        __a = _S_get_per_thread_state();\n    }\n    __my_free_list = __a->__free_list + _S_freelist_index(__n);\n    __q -> __free_list_link = *__my_free_list;\n    *__my_free_list = __q;\n  }\n\n  static void * reallocate(void *__p, size_t __old_sz, size_t __new_sz);\n\n} ;\n\ntypedef _Pthread_alloc_template<> pthread_alloc;\n\n\ntemplate <size_t _Max_size>\nvoid _Pthread_alloc_template<_Max_size>::_S_destructor(void * __instance)\n{\n    _M_lock __lock_instance;\t// Need to acquire lock here.\n    _Pthread_alloc_per_thread_state<_Max_size>* __s =\n        (_Pthread_alloc_per_thread_state<_Max_size> *)__instance;\n    __s -> __next = _S_free_per_thread_states;\n    _S_free_per_thread_states = __s;\n}\n\ntemplate <size_t _Max_size>\n_Pthread_alloc_per_thread_state<_Max_size> *\n_Pthread_alloc_template<_Max_size>::_S_new_per_thread_state()\n{    \n    /* lock already held here.\t*/\n    if (0 != _S_free_per_thread_states) {\n        _Pthread_alloc_per_thread_state<_Max_size> *__result =\n\t\t\t\t\t_S_free_per_thread_states;\n        _S_free_per_thread_states = _S_free_per_thread_states -> __next;\n        return __result;\n    } else {\n        return new _Pthread_alloc_per_thread_state<_Max_size>;\n    }\n}\n\ntemplate <size_t _Max_size>\n_Pthread_alloc_per_thread_state<_Max_size> *\n_Pthread_alloc_template<_Max_size>::_S_get_per_thread_state()\n{\n    /*REFERENCED*/\n    _M_lock __lock_instance;\t// Need to acquire lock here.\n    int __ret_code;\n    _Pthread_alloc_per_thread_state<_Max_size> * __result;\n    if (!_S_key_initialized) {\n        if (pthread_key_create(&_S_key, _S_destructor)) {\n\t    __THROW_BAD_ALLOC;  // defined in stl_alloc.h\n        }\n        _S_key_initialized = true;\n    }\n    __result = _S_new_per_thread_state();\n    __ret_code = pthread_setspecific(_S_key, __result);\n    if (__ret_code) {\n      if (__ret_code == ENOMEM) {\n\t__THROW_BAD_ALLOC;\n      } else {\n\t// EINVAL\n\tabort();\n      }\n    }\n    return __result;\n}\n\n/* We allocate memory in large chunks in order to avoid fragmenting     */\n/* the malloc heap too much.                                            */\n/* We assume that size is properly aligned.                             */\ntemplate <size_t _Max_size>\nchar *_Pthread_alloc_template<_Max_size>\n::_S_chunk_alloc(size_t __size, int &__nobjs)\n{\n  {\n    char * __result;\n    size_t __total_bytes;\n    size_t __bytes_left;\n    /*REFERENCED*/\n    _M_lock __lock_instance;         // Acquire lock for this routine\n\n    __total_bytes = __size * __nobjs;\n    __bytes_left = _S_end_free - _S_start_free;\n    if (__bytes_left >= __total_bytes) {\n        __result = _S_start_free;\n        _S_start_free += __total_bytes;\n        return(__result);\n    } else if (__bytes_left >= __size) {\n        __nobjs = __bytes_left/__size;\n        __total_bytes = __size * __nobjs;\n        __result = _S_start_free;\n        _S_start_free += __total_bytes;\n        return(__result);\n    } else {\n        size_t __bytes_to_get =\n\t\t2 * __total_bytes + _S_round_up(_S_heap_size >> 4);\n        // Try to make use of the left-over piece.\n        if (__bytes_left > 0) {\n            _Pthread_alloc_per_thread_state<_Max_size>* __a = \n                (_Pthread_alloc_per_thread_state<_Max_size>*)\n\t\t\tpthread_getspecific(_S_key);\n            __obj * volatile * __my_free_list =\n                        __a->__free_list + _S_freelist_index(__bytes_left);\n\n            ((__obj *)_S_start_free) -> __free_list_link = *__my_free_list;\n            *__my_free_list = (__obj *)_S_start_free;\n        }\n#       ifdef _SGI_SOURCE\n          // Try to get memory that's aligned on something like a\n          // cache line boundary, so as to avoid parceling out\n          // parts of the same line to different threads and thus\n          // possibly different processors.\n          {\n            const int __cache_line_size = 128;  // probable upper bound\n            __bytes_to_get &= ~(__cache_line_size-1);\n            _S_start_free = (char *)memalign(__cache_line_size, __bytes_to_get); \n            if (0 == _S_start_free) {\n              _S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get);\n            }\n          }\n#       else  /* !SGI_SOURCE */\n          _S_start_free = (char *)malloc_alloc::allocate(__bytes_to_get);\n#       endif\n        _S_heap_size += __bytes_to_get;\n        _S_end_free = _S_start_free + __bytes_to_get;\n    }\n  }\n  // lock is released here\n  return(_S_chunk_alloc(__size, __nobjs));\n}\n\n\n/* Returns an object of size n, and optionally adds to size n free list.*/\n/* We assume that n is properly aligned.                                */\n/* We hold the allocation lock.                                         */\ntemplate <size_t _Max_size>\nvoid *_Pthread_alloc_per_thread_state<_Max_size>\n::_M_refill(size_t __n)\n{\n    int __nobjs = 128;\n    char * __chunk =\n\t_Pthread_alloc_template<_Max_size>::_S_chunk_alloc(__n, __nobjs);\n    __obj * volatile * __my_free_list;\n    __obj * __result;\n    __obj * __current_obj, * __next_obj;\n    int __i;\n\n    if (1 == __nobjs)  {\n        return(__chunk);\n    }\n    __my_free_list = __free_list\n\t\t + _Pthread_alloc_template<_Max_size>::_S_freelist_index(__n);\n\n    /* Build free list in chunk */\n      __result = (__obj *)__chunk;\n      *__my_free_list = __next_obj = (__obj *)(__chunk + __n);\n      for (__i = 1; ; __i++) {\n        __current_obj = __next_obj;\n        __next_obj = (__obj *)((char *)__next_obj + __n);\n        if (__nobjs - 1 == __i) {\n            __current_obj -> __free_list_link = 0;\n            break;\n        } else {\n            __current_obj -> __free_list_link = __next_obj;\n        }\n      }\n    return(__result);\n}\n\ntemplate <size_t _Max_size>\nvoid *_Pthread_alloc_template<_Max_size>\n::reallocate(void *__p, size_t __old_sz, size_t __new_sz)\n{\n    void * __result;\n    size_t __copy_sz;\n\n    if (__old_sz > _Max_size\n\t&& __new_sz > _Max_size) {\n        return(realloc(__p, __new_sz));\n    }\n    if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);\n    __result = allocate(__new_sz);\n    __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;\n    memcpy(__result, __p, __copy_sz);\n    deallocate(__p, __old_sz);\n    return(__result);\n}\n\ntemplate <size_t _Max_size>\n_Pthread_alloc_per_thread_state<_Max_size> *\n_Pthread_alloc_template<_Max_size>::_S_free_per_thread_states = 0;\n\ntemplate <size_t _Max_size>\npthread_key_t _Pthread_alloc_template<_Max_size>::_S_key;\n\ntemplate <size_t _Max_size>\nbool _Pthread_alloc_template<_Max_size>::_S_key_initialized = false;\n\ntemplate <size_t _Max_size>\npthread_mutex_t _Pthread_alloc_template<_Max_size>::_S_chunk_allocator_lock\n= PTHREAD_MUTEX_INITIALIZER;\n\ntemplate <size_t _Max_size>\nchar *_Pthread_alloc_template<_Max_size>\n::_S_start_free = 0;\n\ntemplate <size_t _Max_size>\nchar *_Pthread_alloc_template<_Max_size>\n::_S_end_free = 0;\n\ntemplate <size_t _Max_size>\nsize_t _Pthread_alloc_template<_Max_size>\n::_S_heap_size = 0;\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\ntemplate <class _Tp>\nclass pthread_allocator {\n  typedef pthread_alloc _S_Alloc;          // The underlying allocator.\npublic:\n  typedef size_t     size_type;\n  typedef ptrdiff_t  difference_type;\n  typedef _Tp*       pointer;\n  typedef const _Tp* const_pointer;\n  typedef _Tp&       reference;\n  typedef const _Tp& const_reference;\n  typedef _Tp        value_type;\n\n  template <class _NewType> struct rebind {\n    typedef pthread_allocator<_NewType> other;\n  };\n\n  pthread_allocator() __STL_NOTHROW {}\n  pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}\n  template <class _OtherType>\n\tpthread_allocator(const pthread_allocator<_OtherType>&)\n\t\t__STL_NOTHROW {}\n  ~pthread_allocator() __STL_NOTHROW {}\n\n  pointer address(reference __x) const { return &__x; }\n  const_pointer address(const_reference __x) const { return &__x; }\n\n  // __n is permitted to be 0.  The C++ standard says nothing about what\n  // the return value is when __n == 0.\n  _Tp* allocate(size_type __n, const void* = 0) {\n    return __n != 0 ? static_cast<_Tp*>(_S_Alloc::allocate(__n * sizeof(_Tp)))\n                    : 0;\n  }\n\n  // p is not permitted to be a null pointer.\n  void deallocate(pointer __p, size_type __n)\n    { _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); }\n\n  size_type max_size() const __STL_NOTHROW \n    { return size_t(-1) / sizeof(_Tp); }\n\n  void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }\n  void destroy(pointer _p) { _p->~_Tp(); }\n};\n\ntemplate<>\nclass pthread_allocator<void> {\npublic:\n  typedef size_t      size_type;\n  typedef ptrdiff_t   difference_type;\n  typedef void*       pointer;\n  typedef const void* const_pointer;\n  typedef void        value_type;\n\n  template <class _NewType> struct rebind {\n    typedef pthread_allocator<_NewType> other;\n  };\n};\n\ntemplate <size_t _Max_size>\ninline bool operator==(const _Pthread_alloc_template<_Max_size>&,\n                       const _Pthread_alloc_template<_Max_size>&)\n{\n  return true;\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator==(const pthread_allocator<_T1>&,\n                       const pthread_allocator<_T2>& a2) \n{\n  return true;\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator!=(const pthread_allocator<_T1>&,\n                       const pthread_allocator<_T2>&)\n{\n  return false;\n}\n\ntemplate <class _Tp, size_t _Max_size>\nstruct _Alloc_traits<_Tp, _Pthread_alloc_template<_Max_size> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max_size> > _Alloc_type;\n  typedef __allocator<_Tp, _Pthread_alloc_template<_Max_size> > \n          allocator_type;\n};\n\ntemplate <class _Tp, class _Atype, size_t _Max>\nstruct _Alloc_traits<_Tp, __allocator<_Atype, _Pthread_alloc_template<_Max> > >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, _Pthread_alloc_template<_Max> > _Alloc_type;\n  typedef __allocator<_Tp, _Pthread_alloc_template<_Max> > allocator_type;\n};\n\ntemplate <class _Tp, class _Atype>\nstruct _Alloc_traits<_Tp, pthread_allocator<_Atype> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, _Pthread_alloc_template<> > _Alloc_type;\n  typedef pthread_allocator<_Tp> allocator_type;\n};\n\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_PTHREAD_ALLOC */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/pthread_alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PTHREAD_ALLOC_H\n#define __SGI_STL_PTHREAD_ALLOC_H\n\n#include <pthread_alloc>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::_Pthread_alloc_template;\nusing __STD::pthread_alloc;\n\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_PTHREAD_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/queue",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_QUEUE\n#define __SGI_STL_QUEUE\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_vector.h>\n#include <stl_bvector.h>\n#include <stl_heap.h>\n#include <stl_deque.h>\n#include <stl_function.h>\n#include <stl_queue.h>\n\n#endif /* __SGI_STL_QUEUE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/rope",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ROPE\n#define __SGI_STL_ROPE\n\n#include <stl_algobase.h>\n#include <stl_tempbuf.h>\n#include <stl_algo.h>\n#include <stl_function.h>\n#include <stl_numeric.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_hash_fun.h>\n#include <stl_rope.h>\n\n#endif /* __SGI_STL_ROPE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/rope.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ROPE_H\n#define __SGI_STL_ROPE_H\n\n#include <hashtable.h>\n#include <stl_rope.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::char_producer; \nusing __STD::sequence_buffer; \nusing __STD::rope; \nusing __STD::crope; \nusing __STD::wrope; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ROPE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/ropeimpl.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n# include <stdio.h>     \n\n#ifdef __STL_USE_NEW_IOSTREAMS \n# include <iostream>\n#else /* __STL_USE_NEW_IOSTREAMS */\n# include <iostream.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#ifdef __STL_USE_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf\n// if necessary.  Assumes _M_path_end[leaf_index] and leaf_pos are correct.\n// Results in a valid buf_ptr if the iterator can be legitimately\n// dereferenced.\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( \n  _Rope_iterator_base<_CharT,_Alloc>& __x)\n{\n    const _RopeRep* __leaf = __x._M_path_end[__x._M_leaf_index];\n    size_t __leaf_pos = __x._M_leaf_pos;\n    size_t __pos = __x._M_current_pos;\n\n    switch(__leaf->_M_tag) {\n\tcase _RopeRep::_S_leaf:\n\t    __x._M_buf_start = \n\t      ((_Rope_RopeLeaf<_CharT,_Alloc>*)__leaf)->_M_data;\n\t    __x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos);\n\t    __x._M_buf_end = __x._M_buf_start + __leaf->_M_size;\n\t    break;\n\tcase _RopeRep::_S_function:\n\tcase _RopeRep::_S_substringfn:\n\t    {\n\t\tsize_t __len = _S_iterator_buf_len;\n\t\tsize_t __buf_start_pos = __leaf_pos;\n\t\tsize_t __leaf_end = __leaf_pos + __leaf->_M_size;\n\t\tchar_producer<_CharT>* __fn =\n\t\t\t((_Rope_RopeFunction<_CharT,_Alloc>*)__leaf)->_M_fn;\n\n\t\tif (__buf_start_pos + __len <= __pos) {\n\t\t    __buf_start_pos = __pos - __len/4;\n\t\t    if (__buf_start_pos + __len > __leaf_end) {\n\t\t\t__buf_start_pos = __leaf_end - __len;\n\t\t    }\n\t\t}\n\t\tif (__buf_start_pos + __len > __leaf_end) {\n\t\t    __len = __leaf_end - __buf_start_pos;\n\t\t}\n\t\t(*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf);\n\t\t__x._M_buf_ptr = __x._M_tmp_buf + (__pos - __buf_start_pos);\n\t\t__x._M_buf_start = __x._M_tmp_buf;\n\t\t__x._M_buf_end = __x._M_tmp_buf + __len;\n\t    }\n\t    break;\n\tdefault:\n\t    __stl_assert(0);\n    }\n}\n\n// Set path and buffer inside a rope iterator.  We assume that \n// pos and root are already set.\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator_base<_CharT,_Alloc>::_S_setcache\n(_Rope_iterator_base<_CharT,_Alloc>& __x)\n{\n    const _RopeRep* __path[_RopeRep::_S_max_rope_depth+1];\n    const _RopeRep* __curr_rope;\n    int __curr_depth = -1;  /* index into path    */\n    size_t __curr_start_pos = 0;\n    size_t __pos = __x._M_current_pos;\n    unsigned char __dirns = 0; // Bit vector marking right turns in the path\n\n    __stl_assert(__pos <= __x._M_root->_M_size);\n    if (__pos >= __x._M_root->_M_size) {\n\t__x._M_buf_ptr = 0;\n\treturn;\n    }\n    __curr_rope = __x._M_root;\n    if (0 != __curr_rope->_M_c_string) {\n\t/* Treat the root as a leaf. */\n\t__x._M_buf_start = __curr_rope->_M_c_string;\n\t__x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size;\n\t__x._M_buf_ptr = __curr_rope->_M_c_string + __pos;\n\t__x._M_path_end[0] = __curr_rope;\n\t__x._M_leaf_index = 0;\n\t__x._M_leaf_pos = 0;\n\treturn;\n    }\n    for(;;) {\n\t++__curr_depth;\n\t__stl_assert(__curr_depth <= _RopeRep::_S_max_rope_depth);\n\t__path[__curr_depth] = __curr_rope;\n\tswitch(__curr_rope->_M_tag) {\n\t  case _RopeRep::_S_leaf:\n\t  case _RopeRep::_S_function:\n\t  case _RopeRep::_S_substringfn:\n\t    __x._M_leaf_pos = __curr_start_pos;\n\t    goto done;\n\t  case _RopeRep::_S_concat:\n\t    {\n\t\t_Rope_RopeConcatenation<_CharT,_Alloc>* __c =\n\t\t\t(_Rope_RopeConcatenation<_CharT,_Alloc>*)__curr_rope;\n\t\t_RopeRep* __left = __c->_M_left;\n\t\tsize_t __left_len = __left->_M_size;\n\t\t\n\t\t__dirns <<= 1;\n\t\tif (__pos >= __curr_start_pos + __left_len) {\n\t\t    __dirns |= 1;\n\t\t    __curr_rope = __c->_M_right;\n\t\t    __curr_start_pos += __left_len;\n\t\t} else {\n\t\t    __curr_rope = __left;\n\t\t}\n\t    }\n\t    break;\n\t}\n    }\n  done:\n    // Copy last section of path into _M_path_end.\n      {\n\tint __i = -1;\n\tint __j = __curr_depth + 1 - _S_path_cache_len;\n\n\tif (__j < 0) __j = 0;\n\twhile (__j <= __curr_depth) {\n\t    __x._M_path_end[++__i] = __path[__j++];\n\t}\n\t__x._M_leaf_index = __i;\n      }\n      __x._M_path_directions = __dirns;\n      _S_setbuf(__x);\n}\n\n// Specialized version of the above.  Assumes that\n// the path cache is valid for the previous position.\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr\n(_Rope_iterator_base<_CharT,_Alloc>& __x)\n{\n    int __current_index = __x._M_leaf_index;\n    const _RopeRep* __current_node = __x._M_path_end[__current_index];\n    size_t __len = __current_node->_M_size;\n    size_t __node_start_pos = __x._M_leaf_pos;\n    unsigned char __dirns = __x._M_path_directions;\n    _Rope_RopeConcatenation<_CharT,_Alloc>* __c;\n\n    __stl_assert(__x._M_current_pos <= __x._M_root->_M_size);\n    if (__x._M_current_pos - __node_start_pos < __len) {\n\t/* More stuff in this leaf, we just didn't cache it. */\n\t_S_setbuf(__x);\n\treturn;\n    }\n    __stl_assert(__node_start_pos + __len == __x._M_current_pos);\n    //  node_start_pos is starting position of last_node.\n    while (--__current_index >= 0) {\n\tif (!(__dirns & 1) /* Path turned left */) \n\t  break;\n\t__current_node = __x._M_path_end[__current_index];\n\t__c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node;\n\t// Otherwise we were in the right child.  Thus we should pop\n\t// the concatenation node.\n\t__node_start_pos -= __c->_M_left->_M_size;\n\t__dirns >>= 1;\n    }\n    if (__current_index < 0) {\n\t// We underflowed the cache. Punt.\n\t_S_setcache(__x);\n\treturn;\n    }\n    __current_node = __x._M_path_end[__current_index];\n    __c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node;\n    // current_node is a concatenation node.  We are positioned on the first\n    // character in its right child.\n    // node_start_pos is starting position of current_node.\n    __node_start_pos += __c->_M_left->_M_size;\n    __current_node = __c->_M_right;\n    __x._M_path_end[++__current_index] = __current_node;\n    __dirns |= 1;\n    while (_RopeRep::_S_concat == __current_node->_M_tag) {\n\t++__current_index;\n\tif (_S_path_cache_len == __current_index) {\n\t    int __i;\n\t    for (__i = 0; __i < _S_path_cache_len-1; __i++) {\n\t\t__x._M_path_end[__i] = __x._M_path_end[__i+1];\n\t    }\n\t    --__current_index;\n\t}\n\t__current_node =\n\t    ((_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node)->_M_left;\n\t__x._M_path_end[__current_index] = __current_node;\n\t__dirns <<= 1;\n\t// node_start_pos is unchanged.\n    }\n    __x._M_leaf_index = __current_index;\n    __x._M_leaf_pos = __node_start_pos;\n    __x._M_path_directions = __dirns;\n    _S_setbuf(__x);\n}\n\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator_base<_CharT,_Alloc>::_M_incr(size_t __n) {\n    _M_current_pos += __n;\n    if (0 != _M_buf_ptr) {\n        size_t __chars_left = _M_buf_end - _M_buf_ptr;\n        if (__chars_left > __n) {\n            _M_buf_ptr += __n;\n        } else if (__chars_left == __n) {\n            _M_buf_ptr += __n;\n            _S_setcache_for_incr(*this);\n        } else {\n            _M_buf_ptr = 0;\n        }\n    }\n}\n\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator_base<_CharT,_Alloc>::_M_decr(size_t __n) {\n    if (0 != _M_buf_ptr) {\n        size_t __chars_left = _M_buf_ptr - _M_buf_start;\n        if (__chars_left >= __n) {\n            _M_buf_ptr -= __n;\n        } else {\n            _M_buf_ptr = 0;\n        }\n    }\n    _M_current_pos -= __n;\n}\n\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_iterator<_CharT,_Alloc>::_M_check() {\n    if (_M_root_rope->_M_tree_ptr != _M_root) {\n        // _Rope was modified.  Get things fixed up.\n        _RopeRep::_S_unref(_M_root);\n        _M_root = _M_root_rope->_M_tree_ptr;\n        _RopeRep::_S_ref(_M_root);\n        _M_buf_ptr = 0;\n    }\n}\n\ntemplate <class _CharT, class _Alloc>\ninline \n_Rope_const_iterator<_CharT, _Alloc>::_Rope_const_iterator(\n  const _Rope_iterator<_CharT,_Alloc>& __x)\n: _Rope_iterator_base<_CharT,_Alloc>(__x) \n{ }\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_iterator<_CharT,_Alloc>::_Rope_iterator(\n  rope<_CharT,_Alloc>& __r, size_t __pos)\n: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos), \n  _M_root_rope(&__r)\n{\n    _RopeRep::_S_ref(_M_root);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline size_t \nrope<_CharT,_Alloc>::_S_char_ptr_len(const _CharT* __s)\n{\n    const _CharT* __p = __s;\n\n    while (!_S_is0(*__p)) { ++__p; }\n    return (__p - __s);\n}\n\n\n#ifndef __GC\n\ntemplate <class _CharT, class _Alloc>\ninline void _Rope_RopeRep<_CharT,_Alloc>::_M_free_c_string()\n{\n    _CharT* __cstr = _M_c_string;\n    if (0 != __cstr) {\n\tsize_t __size = _M_size + 1;\n\tdestroy(__cstr, __cstr + __size);\n\t_Data_deallocate(__cstr, __size);\n    }\n}\n\n\ntemplate <class _CharT, class _Alloc>\n#ifdef __STL_USE_STD_ALLOCATORS\n  inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string(_CharT* __s,\n\t\t\t\t\t\t\t   size_t __n,\n\t\t\t\t\t\t           allocator_type __a)\n#else\n  inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string(_CharT* __s,\n\t\t\t\t\t\t\t   size_t __n)\n#endif\n{\n    if (!_S_is_basic_char_type((_CharT*)0)) {\n\tdestroy(__s, __s + __n);\n    }\n//  This has to be a static member, so this gets a bit messy\n#   ifdef __STL_USE_STD_ALLOCATORS\n        __a.deallocate(\n\t    __s, _Rope_RopeLeaf<_CharT,_Alloc>::_S_rounded_up_size(__n));\n#   else\n\t_Data_deallocate(\n\t    __s, _Rope_RopeLeaf<_CharT,_Alloc>::_S_rounded_up_size(__n));\n#   endif\n}\n\n\n//  There are several reasons for not doing this with virtual destructors\n//  and a class specific delete operator:\n//  - A class specific delete operator can't easily get access to\n//    allocator instances if we need them.\n//  - Any virtual function would need a 4 or byte vtable pointer;\n//    this only requires a one byte tag per object.\ntemplate <class _CharT, class _Alloc>\nvoid _Rope_RopeRep<_CharT,_Alloc>::_M_free_tree()\n{\n    switch(_M_tag) {\n\tcase _S_leaf:\n\t    {\n\t        _Rope_RopeLeaf<_CharT,_Alloc>* __l\n\t\t\t= (_Rope_RopeLeaf<_CharT,_Alloc>*)this;\n\t        __l->_Rope_RopeLeaf<_CharT,_Alloc>::~_Rope_RopeLeaf();\n\t        _L_deallocate(__l, 1);\n\t        break;\n\t    }\n\tcase _S_concat:\n\t    {\n\t        _Rope_RopeConcatenation<_CharT,_Alloc>* __c\n\t\t    = (_Rope_RopeConcatenation<_CharT,_Alloc>*)this;\n\t        __c->_Rope_RopeConcatenation<_CharT,_Alloc>::\n\t\t       ~_Rope_RopeConcatenation();\n\t        _C_deallocate(__c, 1);\n\t        break;\n\t    }\n\tcase _S_function:\n\t    {\n\t        _Rope_RopeFunction<_CharT,_Alloc>* __f\n\t\t    = (_Rope_RopeFunction<_CharT,_Alloc>*)this;\n\t        __f->_Rope_RopeFunction<_CharT,_Alloc>::~_Rope_RopeFunction();\n\t        _F_deallocate(__f, 1);\n\t        break;\n\t    }\n\tcase _S_substringfn:\n\t    {\n\t        _Rope_RopeSubstring<_CharT,_Alloc>* __ss =\n\t\t\t(_Rope_RopeSubstring<_CharT,_Alloc>*)this;\n\t\t__ss->_Rope_RopeSubstring<_CharT,_Alloc>::\n\t\t        ~_Rope_RopeSubstring();\n\t\t_S_deallocate(__ss, 1);\n\t\tbreak;\n\t    }\n    }\n}\n#else\n\ntemplate <class _CharT, class _Alloc>\n#ifdef __STL_USE_STD_ALLOCATORS\n  inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string\n\t\t(const _CharT*, size_t, allocator_type)\n#else\n  inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string\n\t\t(const _CharT*, size_t)\n#endif\n{}\n\n#endif\n\n\n// Concatenate a C string onto a leaf rope by copying the rope data.\n// Used for short ropes.\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeLeaf*\nrope<_CharT,_Alloc>::_S_leaf_concat_char_iter\n\t\t(_RopeLeaf* __r, const _CharT* __iter, size_t __len)\n{\n    size_t __old_len = __r->_M_size;\n    _CharT* __new_data = (_CharT*)\n\t_Data_allocate(_S_rounded_up_size(__old_len + __len));\n    _RopeLeaf* __result;\n    \n    uninitialized_copy_n(__r->_M_data, __old_len, __new_data);\n    uninitialized_copy_n(__iter, __len, __new_data + __old_len);\n    _S_cond_store_eos(__new_data[__old_len + __len]);\n    __STL_TRY {\n\t__result = _S_new_RopeLeaf(__new_data, __old_len + __len,\n\t\t\t\t   __r->get_allocator());\n    }\n    __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,\n\t\t\t\t\t     __r->get_allocator()));\n    return __result;\n}\n\n#ifndef __GC\n// As above, but it's OK to clobber original if refcount is 1\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeLeaf*\nrope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter\n\t\t(_RopeLeaf* __r, const _CharT* __iter, size_t __len)\n{\n    __stl_assert(__r->_M_ref_count >= 1);\n    if (__r->_M_ref_count > 1)\n      return _S_leaf_concat_char_iter(__r, __iter, __len);\n    size_t __old_len = __r->_M_size;\n    if (_S_allocated_capacity(__old_len) >= __old_len + __len) {\n\t// The space has been partially initialized for the standard\n\t// character types.  But that doesn't matter for those types.\n\tuninitialized_copy_n(__iter, __len, __r->_M_data + __old_len);\n\tif (_S_is_basic_char_type((_CharT*)0)) {\n\t    _S_cond_store_eos(__r->_M_data[__old_len + __len]);\n\t    __stl_assert(__r->_M_c_string == __r->_M_data);\n\t} else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) {\n\t    __r->_M_free_c_string();\n\t    __r->_M_c_string = 0;\n\t}\n\t__r->_M_size = __old_len + __len;\n\t__stl_assert(__r->_M_ref_count == 1);\n\t__r->_M_ref_count = 2;\n\treturn __r;\n    } else {\n\t_RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len);\n\t__stl_assert(__result->_M_ref_count == 1);\n\treturn __result;\n    }\n}\n#endif\n\n// Assumes left and right are not 0.\n// Does not increment (nor decrement on exception) child reference counts.\n// Result has ref count 1.\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep*\nrope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right)\n{\n    _RopeConcatenation* __result =\n      _S_new_RopeConcatenation(__left, __right, __left->get_allocator());\n    size_t __depth = __result->_M_depth;\n    \n#   ifdef __STL_USE_STD_ALLOCATORS\n      __stl_assert(__left->get_allocator() == __right->get_allocator());\n#   endif\n    if (__depth > 20 && (__result->_M_size < 1000 ||\n\t\t\t __depth > _RopeRep::_S_max_rope_depth)) {\n        _RopeRep* __balanced;\n      \n\t__STL_TRY {\n\t   __balanced = _S_balance(__result);\n#          ifndef __GC\n\t     if (__result != __balanced) {\n\t\t__stl_assert(1 == __result->_M_ref_count\n\t\t\t     && 1 == __balanced->_M_ref_count);\n\t     }\n#          endif\n\t   __result->_M_unref_nonnil();\n        }\n\t__STL_UNWIND((_C_deallocate(__result,1)));\n\t\t// In case of exception, we need to deallocate\n\t\t// otherwise dangling result node.  But caller\n\t\t// still owns its children.  Thus unref is\n\t\t// inappropriate.\n\treturn __balanced;\n    } else {\n\treturn __result;\n    }\n}\n\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter\n\t\t(_RopeRep* __r, const _CharT*__s, size_t __slen)\n{\n    _RopeRep* __result;\n    if (0 == __slen) {\n\t_S_ref(__r);\n\treturn __r;\n    }\n    if (0 == __r)\n      return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,\n\t\t\t\t\t      __r->get_allocator());\n    if (_RopeRep::_S_leaf == __r->_M_tag && \n          __r->_M_size + __slen <= _S_copy_max) {\n\t__result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);\n#       ifndef __GC\n\t  __stl_assert(1 == __result->_M_ref_count);\n#       endif\n\treturn __result;\n    }\n    if (_RopeRep::_S_concat == __r->_M_tag\n\t&& _RopeRep::_S_leaf == ((_RopeConcatenation*)__r)->_M_right->_M_tag) {\n\t_RopeLeaf* __right = \n\t  (_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right);\n\tif (__right->_M_size + __slen <= _S_copy_max) {\n\t  _RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left;\n\t  _RopeRep* __nright = \n\t    _S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen);\n\t  __left->_M_ref_nonnil();\n\t  __STL_TRY {\n\t    __result = _S_tree_concat(__left, __nright);\n          }\n\t  __STL_UNWIND(_S_unref(__left); _S_unref(__nright));\n#         ifndef __GC\n\t    __stl_assert(1 == __result->_M_ref_count);\n#         endif\n\t  return __result;\n\t}\n    }\n    _RopeRep* __nright =\n      __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());\n    __STL_TRY {\n      __r->_M_ref_nonnil();\n      __result = _S_tree_concat(__r, __nright);\n    }\n    __STL_UNWIND(_S_unref(__r); _S_unref(__nright));\n#   ifndef __GC\n      __stl_assert(1 == __result->_M_ref_count);\n#   endif\n    return __result;\n}\n\n#ifndef __GC\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep* \nrope<_CharT,_Alloc>::_S_destr_concat_char_iter(\n  _RopeRep* __r, const _CharT* __s, size_t __slen)\n{\n    _RopeRep* __result;\n    if (0 == __r)\n      return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,\n\t\t\t\t\t      __r->get_allocator());\n    size_t __count = __r->_M_ref_count;\n    size_t __orig_size = __r->_M_size;\n    __stl_assert(__count >= 1);\n    if (__count > 1) return _S_concat_char_iter(__r, __s, __slen);\n    if (0 == __slen) {\n\t__r->_M_ref_count = 2;      // One more than before\n\treturn __r;\n    }\n    if (__orig_size + __slen <= _S_copy_max && \n          _RopeRep::_S_leaf == __r->_M_tag) {\n\t__result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);\n\treturn __result;\n    }\n    if (_RopeRep::_S_concat == __r->_M_tag) {\n\t_RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)__r)->_M_right);\n\tif (_RopeRep::_S_leaf == __right->_M_tag\n\t    && __right->_M_size + __slen <= _S_copy_max) {\n\t  _RopeRep* __new_right = \n\t    _S_destr_leaf_concat_char_iter(__right, __s, __slen);\n\t  if (__right == __new_right) {\n\t      __stl_assert(__new_right->_M_ref_count == 2);\n\t      __new_right->_M_ref_count = 1;\n\t  } else {\n\t      __stl_assert(__new_right->_M_ref_count >= 1);\n\t      __right->_M_unref_nonnil();\n\t  }\n\t  __stl_assert(__r->_M_ref_count == 1);\n\t  __r->_M_ref_count = 2;    // One more than before.\n\t  ((_RopeConcatenation*)__r)->_M_right = __new_right;\n\t  __r->_M_size = __orig_size + __slen;\n\t  if (0 != __r->_M_c_string) {\n\t      __r->_M_free_c_string();\n\t      __r->_M_c_string = 0;\n\t  }\n\t  return __r;\n\t}\n    }\n    _RopeRep* __right =\n      __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());\n    __r->_M_ref_nonnil();\n    __STL_TRY {\n      __result = _S_tree_concat(__r, __right);\n    }\n    __STL_UNWIND(_S_unref(__r); _S_unref(__right))\n    __stl_assert(1 == __result->_M_ref_count);\n    return __result;\n}\n#endif /* !__GC */\n\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep*\nrope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right)\n{\n    if (0 == __left) {\n\t_S_ref(__right);\n\treturn __right;\n    }\n    if (0 == __right) {\n\t__left->_M_ref_nonnil();\n\treturn __left;\n    }\n    if (_RopeRep::_S_leaf == __right->_M_tag) {\n\tif (_RopeRep::_S_leaf == __left->_M_tag) {\n\t  if (__right->_M_size + __left->_M_size <= _S_copy_max) {\n\t    return _S_leaf_concat_char_iter((_RopeLeaf*)__left,\n\t\t\t\t\t ((_RopeLeaf*)__right)->_M_data,\n\t\t\t\t\t __right->_M_size);\n\t  }\n\t} else if (_RopeRep::_S_concat == __left->_M_tag\n\t\t   && _RopeRep::_S_leaf ==\n\t\t      ((_RopeConcatenation*)__left)->_M_right->_M_tag) {\n\t  _RopeLeaf* __leftright =\n\t\t    (_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right); \n\t  if (__leftright->_M_size + __right->_M_size <= _S_copy_max) {\n\t    _RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left;\n\t    _RopeRep* __rest = _S_leaf_concat_char_iter(__leftright,\n\t\t\t\t\t   ((_RopeLeaf*)__right)->_M_data,\n\t\t\t\t\t   __right->_M_size);\n\t    __leftleft->_M_ref_nonnil();\n\t    __STL_TRY {\n\t      return(_S_tree_concat(__leftleft, __rest));\n            }\n\t    __STL_UNWIND(_S_unref(__leftleft); _S_unref(__rest))\n\t  }\n\t}\n    }\n    __left->_M_ref_nonnil();\n    __right->_M_ref_nonnil();\n    __STL_TRY {\n      return(_S_tree_concat(__left, __right));\n    }\n    __STL_UNWIND(_S_unref(__left); _S_unref(__right));\n}\n\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep*\nrope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, \n                               size_t __start, size_t __endp1)\n{\n    if (0 == __base) return 0;\n    size_t __len = __base->_M_size;\n    size_t __adj_endp1;\n    const size_t __lazy_threshold = 128;\n    \n    if (__endp1 >= __len) {\n\tif (0 == __start) {\n\t    __base->_M_ref_nonnil();\n\t    return __base;\n\t} else {\n\t    __adj_endp1 = __len;\n\t}\n    } else {\n\t__adj_endp1 = __endp1;\n    }\n    switch(__base->_M_tag) {\n\tcase _RopeRep::_S_concat:\n\t    {\n\t\t_RopeConcatenation* __c = (_RopeConcatenation*)__base;\n\t\t_RopeRep* __left = __c->_M_left;\n\t\t_RopeRep* __right = __c->_M_right;\n\t\tsize_t __left_len = __left->_M_size;\n\t\t_RopeRep* __result;\n\n\t\tif (__adj_endp1 <= __left_len) {\n\t\t    return _S_substring(__left, __start, __endp1);\n\t\t} else if (__start >= __left_len) {\n\t\t    return _S_substring(__right, __start - __left_len,\n\t\t\t\t  __adj_endp1 - __left_len);\n\t\t}\n\t\t_Self_destruct_ptr __left_result(\n\t\t  _S_substring(__left, __start, __left_len));\n\t\t_Self_destruct_ptr __right_result(\n\t\t  _S_substring(__right, 0, __endp1 - __left_len));\n\t\t__result = _S_concat(__left_result, __right_result);\n#               ifndef __GC\n\t\t  __stl_assert(1 == __result->_M_ref_count);\n#               endif\n\t\treturn __result;\n\t    }\n\tcase _RopeRep::_S_leaf:\n\t    {\n\t\t_RopeLeaf* __l = (_RopeLeaf*)__base;\n\t\t_RopeLeaf* __result;\n\t\tsize_t __result_len;\n\t\tif (__start >= __adj_endp1) return 0;\n\t\t__result_len = __adj_endp1 - __start;\n\t\tif (__result_len > __lazy_threshold) goto lazy;\n#               ifdef __GC\n\t\t    const _CharT* __section = __l->_M_data + __start;\n\t\t    __result = _S_new_RopeLeaf(__section, __result_len,\n\t\t\t\t\t  __base->get_allocator());\n\t\t    __result->_M_c_string = 0;  // Not eos terminated.\n#               else\n\t\t    // We should sometimes create substring node instead.\n\t\t    __result = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(\n\t\t\t\t\t__l->_M_data + __start, __result_len,\n\t\t\t\t\t__base->get_allocator());\n#               endif\n\t\treturn __result;\n\t    }\n\tcase _RopeRep::_S_substringfn:\n\t    // Avoid introducing multiple layers of substring nodes.\n\t    {\n\t\t_RopeSubstring* __old = (_RopeSubstring*)__base;\n\t\tsize_t __result_len;\n\t\tif (__start >= __adj_endp1) return 0;\n\t\t__result_len = __adj_endp1 - __start;\n\t\tif (__result_len > __lazy_threshold) {\n\t\t    _RopeSubstring* __result =\n\t\t\t_S_new_RopeSubstring(__old->_M_base,\n\t\t\t\t\t  __start + __old->_M_start,\n\t\t\t\t\t  __adj_endp1 - __start,\n\t\t\t\t\t  __base->get_allocator());\n\t\t    return __result;\n\n\t\t} // *** else fall through: ***\n\t    }\n\tcase _RopeRep::_S_function:\n\t    {\n\t\t_RopeFunction* __f = (_RopeFunction*)__base;\n\t\t_CharT* __section;\n\t\tsize_t __result_len;\n\t\tif (__start >= __adj_endp1) return 0;\n\t\t__result_len = __adj_endp1 - __start;\n\n\t\tif (__result_len > __lazy_threshold) goto lazy;\n\t\t__section = (_CharT*)\n\t\t\t_Data_allocate(_S_rounded_up_size(__result_len));\n\t\t__STL_TRY {\n\t\t  (*(__f->_M_fn))(__start, __result_len, __section);\n                }\n\t\t__STL_UNWIND(_RopeRep::__STL_FREE_STRING(\n\t               __section, __result_len, __base->get_allocator()));\n\t\t_S_cond_store_eos(__section[__result_len]);\n\t\treturn _S_new_RopeLeaf(__section, __result_len,\n\t\t\t\t       __base->get_allocator());\n\t    }\n    }\n    /*NOTREACHED*/\n    __stl_assert(false);\n  lazy:\n    {\n\t// Create substring node.\n\treturn _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start,\n\t\t\t       __base->get_allocator());\n    }\n}\n\ntemplate<class _CharT>\nclass _Rope_flatten_char_consumer : public _Rope_char_consumer<_CharT> {\n    private:\n\t_CharT* _M_buf_ptr;\n    public:\n\n\t_Rope_flatten_char_consumer(_CharT* __buffer) {\n\t    _M_buf_ptr = __buffer;\n\t};\n\t~_Rope_flatten_char_consumer() {}\n\tbool operator() (const _CharT* __leaf, size_t __n) {\n\t    uninitialized_copy_n(__leaf, __n, _M_buf_ptr);\n\t    _M_buf_ptr += __n;\n\t    return true;\n\t}\n};\n\t    \ntemplate<class _CharT>\nclass _Rope_find_char_char_consumer : public _Rope_char_consumer<_CharT> {\n    private:\n\t_CharT _M_pattern;\n    public:\n\tsize_t _M_count;  // Number of nonmatching characters\n\t_Rope_find_char_char_consumer(_CharT __p) \n\t  : _M_pattern(__p), _M_count(0) {}\n\t~_Rope_find_char_char_consumer() {}\n\tbool operator() (const _CharT* __leaf, size_t __n) {\n\t    size_t __i;\n\t    for (__i = 0; __i < __n; __i++) {\n\t\tif (__leaf[__i] == _M_pattern) {\n\t\t    _M_count += __i; return false;\n\t\t}\n\t    }\n\t    _M_count += __n; return true;\n\t}\n};\n\t    \n#ifdef __STL_USE_NEW_IOSTREAMS\n  template<class _CharT, class _Traits>\n  // Here _CharT is both the stream and rope character type.\n#else\n  template<class _CharT>\n  // Here _CharT is the rope character type.  Unlike in the\n  // above case, we somewhat handle the case in which it doesn't\n  // match the stream character type, i.e. char.\n#endif\nclass _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> {\n    private:\n#       ifdef __STL_USE_NEW_IOSTREAMS\n\t  typedef basic_ostream<_CharT,_Traits> _Insert_ostream;\n#\telse\n\t  typedef ostream _Insert_ostream;\n#\tendif\n\t_Insert_ostream& _M_o;\n    public:\n\t_Rope_insert_char_consumer(_Insert_ostream& __writer) \n\t  : _M_o(__writer) {};\n\t~_Rope_insert_char_consumer() { };\n\t\t// Caller is presumed to own the ostream\n\tbool operator() (const _CharT* __leaf, size_t __n);\n\t\t// Returns true to continue traversal.\n};\n\t    \n#ifdef __STL_USE_NEW_IOSTREAMS\n  template<class _CharT, class _Traits>\n  bool _Rope_insert_char_consumer<_CharT, _Traits>::operator()\n                                        (const _CharT* __leaf, size_t __n)\n  {\n    size_t __i;\n    //  We assume that formatting is set up correctly for each element.\n    for (__i = 0; __i < __n; __i++) _M_o.put(__leaf[__i]);\n    return true;\n  }\n\n#else\n  template<class _CharT>\n  bool _Rope_insert_char_consumer<_CharT>::operator()\n\t\t\t\t\t(const _CharT* __leaf, size_t __n)\n  {\n    size_t __i;\n    //  We assume that formatting is set up correctly for each element.\n    for (__i = 0; __i < __n; __i++) _M_o << __leaf[__i];\n    return true;\n  }\n\n\n  __STL_TEMPLATE_NULL\n  inline bool _Rope_insert_char_consumer<char>::operator()\n\t\t\t\t\t(const char* __leaf, size_t __n)\n  {\n    size_t __i;\n    for (__i = 0; __i < __n; __i++) _M_o.put(__leaf[__i]);\n    return true;\n  }\n#endif\n\ntemplate <class _CharT, class _Alloc>\nbool rope<_CharT, _Alloc>::_S_apply_to_pieces(\n\t\t\t\t_Rope_char_consumer<_CharT>& __c,\n\t\t\t\tconst _RopeRep* __r,\n\t\t\t\tsize_t __begin, size_t __end)\n{\n    if (0 == __r) return true;\n    switch(__r->_M_tag) {\n\tcase _RopeRep::_S_concat:\n\t    {\n\t\t_RopeConcatenation* __conc = (_RopeConcatenation*)__r;\n\t\t_RopeRep* __left =  __conc->_M_left;\n\t\tsize_t __left_len = __left->_M_size;\n\t\tif (__begin < __left_len) {\n\t\t    size_t __left_end = min(__left_len, __end);\n\t\t    if (!_S_apply_to_pieces(__c, __left, __begin, __left_end))\n\t\t\treturn false;\n\t\t}\n\t\tif (__end > __left_len) {\n\t\t    _RopeRep* __right =  __conc->_M_right;\n\t\t    size_t __right_start = max(__left_len, __begin);\n\t\t    if (!_S_apply_to_pieces(__c, __right,\n\t\t\t\t\t __right_start - __left_len,\n\t\t\t\t\t __end - __left_len)) {\n\t\t\treturn false;\n\t\t    }\n\t\t}\n\t    }\n\t    return true;\n\tcase _RopeRep::_S_leaf:\n\t    {\n\t\t_RopeLeaf* __l = (_RopeLeaf*)__r;\n\t\treturn __c(__l->_M_data + __begin, __end - __begin);\n\t    }\n\tcase _RopeRep::_S_function:\n\tcase _RopeRep::_S_substringfn:\n\t    {\n\t\t_RopeFunction* __f = (_RopeFunction*)__r;\n\t\tsize_t __len = __end - __begin;\n\t\tbool __result;\n\t\t_CharT* __buffer =\n\t\t  (_CharT*)alloc::allocate(__len * sizeof(_CharT));\n\t\t__STL_TRY {\n\t\t  (*(__f->_M_fn))(__begin, __len, __buffer);\n\t\t  __result = __c(__buffer, __len);\n                  alloc::deallocate(__buffer, __len * sizeof(_CharT));\n                }\n\t\t__STL_UNWIND((alloc::deallocate(__buffer,\n\t\t\t\t\t\t__len * sizeof(_CharT))))\n\t\treturn __result;\n\t    }\n\tdefault:\n\t    __stl_assert(false);\n\t    /*NOTREACHED*/\n\t    return false;\n    }\n}\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n  template<class _CharT, class _Traits>\n  inline void _Rope_fill(basic_ostream<_CharT, _Traits>& __o, size_t __n)\n#else\n  inline void _Rope_fill(ostream& __o, size_t __n)\n#endif\n{\n    char __f = __o.fill();\n    size_t __i;\n\n    for (__i = 0; __i < __n; __i++) __o.put(__f);\n}\n    \n\ntemplate <class _CharT> inline bool _Rope_is_simple(_CharT*) { return false; }\ninline bool _Rope_is_simple(char*) { return true; }\ninline bool _Rope_is_simple(wchar_t*) { return true; }\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n  template<class _CharT, class _Traits, class _Alloc>\n  basic_ostream<_CharT, _Traits>& operator<<\n\t\t\t\t\t(basic_ostream<_CharT, _Traits>& __o,\n\t\t\t\t\t const rope<_CharT, _Alloc>& __r)\n#else\n  template<class _CharT, class _Alloc>\n  ostream& operator<< (ostream& __o, const rope<_CharT, _Alloc>& __r)\n#endif\n{\n    size_t __w = __o.width();\n    bool __left = bool(__o.flags() & ios::left);\n    size_t __pad_len;\n    size_t __rope_len = __r.size();\n#   ifdef __STL_USE_NEW_IOSTREAMS\n      _Rope_insert_char_consumer<_CharT, _Traits> __c(__o);\n#   else\n      _Rope_insert_char_consumer<_CharT> __c(__o);\n#   endif\n    bool __is_simple = _Rope_is_simple((_CharT*)0);\n    \n    if (__rope_len < __w) {\n\t__pad_len = __w - __rope_len;\n    } else {\n\t__pad_len = 0;\n    }\n    if (!__is_simple) __o.width(__w/__rope_len);\n    __STL_TRY {\n      if (__is_simple && !__left && __pad_len > 0) {\n\t_Rope_fill(__o, __pad_len);\n      }\n      __r.apply_to_pieces(0, __r.size(), __c);\n      if (__is_simple && __left && __pad_len > 0) {\n\t_Rope_fill(__o, __pad_len);\n      }\n      if (!__is_simple)\n        __o.width(__w);\n    }\n    __STL_UNWIND(if (!__is_simple) __o.width(__w))\n    return __o;\n}\n\ntemplate <class _CharT, class _Alloc>\n_CharT*\nrope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r,\n\t\t\t\t size_t __start, size_t __len,\n\t\t\t\t _CharT* __buffer)\n{\n    _Rope_flatten_char_consumer<_CharT> __c(__buffer);\n    _S_apply_to_pieces(__c, __r, __start, __start + __len);\n    return(__buffer + __len);\n}\n\ntemplate <class _CharT, class _Alloc>\nsize_t\nrope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const\n{\n    _Rope_find_char_char_consumer<_CharT> __c(__pattern);\n    _S_apply_to_pieces(__c, _M_tree_ptr, __start, size());\n    size_type __result_pos = __start + __c._M_count;\n#   ifndef __STL_OLD_ROPE_SEMANTICS\n\tif (__result_pos == size()) __result_pos = npos;\n#   endif\n    return __result_pos;\n}\n\ntemplate <class _CharT, class _Alloc>\n_CharT*\nrope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer)\n{\n    if (0 == __r) return __buffer;\n    switch(__r->_M_tag) {\n\tcase _RopeRep::_S_concat:\n\t    {\n\t\t_RopeConcatenation* __c = (_RopeConcatenation*)__r;\n\t\t_RopeRep* __left = __c->_M_left;\n\t\t_RopeRep* __right = __c->_M_right;\n\t\t_CharT* __rest = _S_flatten(__left, __buffer);\n\t\treturn _S_flatten(__right, __rest);\n\t    }\n\tcase _RopeRep::_S_leaf:\n\t    {\n\t\t_RopeLeaf* __l = (_RopeLeaf*)__r;\n\t\treturn copy_n(__l->_M_data, __l->_M_size, __buffer).second;\n\t    }\n\tcase _RopeRep::_S_function:\n\tcase _RopeRep::_S_substringfn:\n\t    // We dont yet do anything with substring nodes.\n\t    // This needs to be fixed before ropefiles will work well.\n\t    {\n\t\t_RopeFunction* __f = (_RopeFunction*)__r;\n\t\t(*(__f->_M_fn))(0, __f->_M_size, __buffer);\n\t\treturn __buffer + __f->_M_size;\n\t    }\n\tdefault:\n\t    __stl_assert(false);\n\t    /*NOTREACHED*/\n\t    return 0;\n    }\n}\n\n\n// This needs work for _CharT != char\ntemplate <class _CharT, class _Alloc>\nvoid\nrope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent)\n{\n    for (int __i = 0; __i < __indent; __i++) putchar(' ');\n    if (0 == __r) {\n\tprintf(\"NULL\\n\"); return;\n    }\n    if (_RopeRep::_S_concat == __r->_M_tag) {\n\t_RopeConcatenation* __c = (_RopeConcatenation*)__r;\n\t_RopeRep* __left = __c->_M_left;\n\t_RopeRep* __right = __c->_M_right;\n\n#       ifdef __GC\n\t  printf(\"Concatenation %p (depth = %d, len = %ld, %s balanced)\\n\",\n\t    __r, __r->_M_depth, __r->_M_size, __r->_M_is_balanced? \"\" : \"not\");\n#       else\n\t  printf(\"Concatenation %p (rc = %ld, depth = %d, \"\n\t           \"len = %ld, %s balanced)\\n\",\n\t\t __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size,\n\t\t __r->_M_is_balanced? \"\" : \"not\");\n#       endif\n\t_S_dump(__left, __indent + 2);\n\t_S_dump(__right, __indent + 2);\n\treturn;\n    } else {\n\tchar* __kind;\n\n\tswitch (__r->_M_tag) {\n\t    case _RopeRep::_S_leaf:\n\t\t__kind = \"Leaf\";\n\t\tbreak;\n\t    case _RopeRep::_S_function:\n\t\t__kind = \"Function\";\n\t\tbreak;\n\t    case _RopeRep::_S_substringfn:\n\t\t__kind = \"Function representing substring\";\n\t\tbreak;\n\t    default:\n\t\t__kind = \"(corrupted kind field!)\";\n\t}\n#       ifdef __GC\n\t  printf(\"%s %p (depth = %d, len = %ld) \",\n\t\t __kind, __r, __r->_M_depth, __r->_M_size);\n#       else\n\t  printf(\"%s %p (rc = %ld, depth = %d, len = %ld) \",\n\t\t __kind, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size);\n#       endif\n\tif (_S_is_one_byte_char_type((_CharT*)0)) {\n\t    const int __max_len = 40;\n\t    _Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len));\n\t    _CharT __buffer[__max_len + 1];\n\t    bool __too_big = __r->_M_size > __prefix->_M_size;\n\n\t    _S_flatten(__prefix, __buffer);\n\t    __buffer[__prefix->_M_size] = _S_eos((_CharT*)0); \n\t    printf(\"%s%s\\n\", \n\t           (char*)__buffer, __too_big? \"...\\n\" : \"\\n\");\n\t} else {\n\t    printf(\"\\n\");\n\t}\n    }\n}\n\ntemplate <class _CharT, class _Alloc>\nconst unsigned long\nrope<_CharT,_Alloc>::_S_min_len[\n  _Rope_RopeRep<_CharT,_Alloc>::_S_max_rope_depth + 1] = {\n/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21,\n/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377,\n/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181,\n/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368,\n/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811,\n/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309,\n/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352,\n/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155,\n/* 39 */165580141, /* 40 */267914296, /* 41 */433494437,\n/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903,\n/* 45 */2971215073u };\n// These are Fibonacci numbers < 2**32.\n\ntemplate <class _CharT, class _Alloc>\nrope<_CharT,_Alloc>::_RopeRep*\nrope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)\n{\n    _RopeRep* __forest[_RopeRep::_S_max_rope_depth + 1];\n    _RopeRep* __result = 0;\n    int __i;\n    // Invariant:\n    // The concatenation of forest in descending order is equal to __r.\n    // __forest[__i]._M_size >= _S_min_len[__i]\n    // __forest[__i]._M_depth = __i\n    // References from forest are included in refcount.\n\n    for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) \n      __forest[__i] = 0;\n    __STL_TRY {\n      _S_add_to_forest(__r, __forest);\n      for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) \n        if (0 != __forest[__i]) {\n#\tifndef __GC\n\t  _Self_destruct_ptr __old(__result);\n#\tendif\n\t  __result = _S_concat(__forest[__i], __result);\n\t__forest[__i]->_M_unref_nonnil();\n#\tif !defined(__GC) && defined(__STL_USE_EXCEPTIONS)\n\t  __forest[__i] = 0;\n#\tendif\n      }\n    }\n    __STL_UNWIND(for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++)\n\t\t _S_unref(__forest[__i]))\n    if (__result->_M_depth > _RopeRep::_S_max_rope_depth) {\n#     ifdef __STL_USE_EXCEPTIONS\n\t__STL_THROW(length_error(\"rope too long\"));\n#     else\n\tabort();\n#     endif\n    }\n    return(__result);\n}\n\n\ntemplate <class _CharT, class _Alloc>\nvoid\nrope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest)\n{\n    if (__r->_M_is_balanced) {\n\t_S_add_leaf_to_forest(__r, __forest);\n\treturn;\n    }\n    __stl_assert(__r->_M_tag == _RopeRep::_S_concat);\n    {\n\t_RopeConcatenation* __c = (_RopeConcatenation*)__r;\n\n\t_S_add_to_forest(__c->_M_left, __forest);\n\t_S_add_to_forest(__c->_M_right, __forest);\n    }\n}\n\n\ntemplate <class _CharT, class _Alloc>\nvoid\nrope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest)\n{\n    _RopeRep* __insertee;   \t\t// included in refcount\n    _RopeRep* __too_tiny = 0;    \t// included in refcount\n    int __i;  \t\t\t\t// forest[0..__i-1] is empty\n    size_t __s = __r->_M_size;\n\n    for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i) {\n\tif (0 != __forest[__i]) {\n#\t    ifndef __GC\n\t      _Self_destruct_ptr __old(__too_tiny);\n#\t    endif\n\t    __too_tiny = _S_concat_and_set_balanced(__forest[__i], __too_tiny);\n\t    __forest[__i]->_M_unref_nonnil();\n\t    __forest[__i] = 0;\n\t}\n    }\n    {\n#\tifndef __GC\n\t  _Self_destruct_ptr __old(__too_tiny);\n#\tendif\n\t__insertee = _S_concat_and_set_balanced(__too_tiny, __r);\n    }\n    // Too_tiny dead, and no longer included in refcount.\n    // Insertee is live and included.\n    __stl_assert(_S_is_almost_balanced(__insertee));\n    __stl_assert(__insertee->_M_depth <= __r->_M_depth + 1);\n    for (;; ++__i) {\n\tif (0 != __forest[__i]) {\n#\t    ifndef __GC\n\t      _Self_destruct_ptr __old(__insertee);\n#\t    endif\n\t    __insertee = _S_concat_and_set_balanced(__forest[__i], __insertee);\n\t    __forest[__i]->_M_unref_nonnil();\n\t    __forest[__i] = 0;\n\t    __stl_assert(_S_is_almost_balanced(__insertee));\n\t}\n\t__stl_assert(_S_min_len[__i] <= __insertee->_M_size);\n\t__stl_assert(__forest[__i] == 0);\n\tif (__i == _RopeRep::_S_max_rope_depth || \n\t      __insertee->_M_size < _S_min_len[__i+1]) {\n\t    __forest[__i] = __insertee;\n\t    // refcount is OK since __insertee is now dead.\n\t    return;\n\t}\n    }\n}\n\ntemplate <class _CharT, class _Alloc>\n_CharT\nrope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i)\n{\n    __GC_CONST _CharT* __cstr = __r->_M_c_string;\n\n    __stl_assert(__i < __r->_M_size);\n    if (0 != __cstr) return __cstr[__i]; \n    for(;;) {\n      switch(__r->_M_tag) {\n\tcase _RopeRep::_S_concat:\n\t    {\n\t\t_RopeConcatenation* __c = (_RopeConcatenation*)__r;\n\t\t_RopeRep* __left = __c->_M_left;\n\t\tsize_t __left_len = __left->_M_size;\n\n\t\tif (__i >= __left_len) {\n\t\t    __i -= __left_len;\n\t\t    __r = __c->_M_right;\n\t\t} else {\n\t\t    __r = __left;\n\t\t}\n\t    }\n\t    break;\n\tcase _RopeRep::_S_leaf:\n\t    {\n\t\t_RopeLeaf* __l = (_RopeLeaf*)__r;\n\t\treturn __l->_M_data[__i];\n\t    }\n\tcase _RopeRep::_S_function:\n\tcase _RopeRep::_S_substringfn:\n\t    {\n\t\t_RopeFunction* __f = (_RopeFunction*)__r;\n\t\t_CharT __result;\n\n\t\t(*(__f->_M_fn))(__i, 1, &__result);\n\t\treturn __result;\n\t    }\n      }\n    }\n}\n\n# ifndef __GC\n// Return a uniquely referenced character slot for the given\n// position, or 0 if that's not possible.\ntemplate <class _CharT, class _Alloc>\n_CharT*\nrope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i)\n{\n    _RopeRep* __clrstack[_RopeRep::_S_max_rope_depth];\n    size_t __csptr = 0;\n\n    for(;;) {\n      if (__r->_M_ref_count > 1) return 0;\n      switch(__r->_M_tag) {\n\tcase _RopeRep::_S_concat:\n\t    {\n\t\t_RopeConcatenation* __c = (_RopeConcatenation*)__r;\n\t\t_RopeRep* __left = __c->_M_left;\n\t\tsize_t __left_len = __left->_M_size;\n\n\t\tif (__c->_M_c_string != 0) __clrstack[__csptr++] = __c;\n\t\tif (__i >= __left_len) {\n\t\t    __i -= __left_len;\n\t\t    __r = __c->_M_right;\n\t\t} else {\n\t\t    __r = __left;\n\t\t}\n\t    }\n\t    break;\n\tcase _RopeRep::_S_leaf:\n\t    {\n\t\t_RopeLeaf* __l = (_RopeLeaf*)__r;\n\t\tif (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0)\n\t\t    __clrstack[__csptr++] = __l;\n\t\twhile (__csptr > 0) {\n\t\t    -- __csptr;\n\t\t    _RopeRep* __d = __clrstack[__csptr];\n\t\t    __d->_M_free_c_string();\n\t\t    __d->_M_c_string = 0;\n\t\t}\n\t\treturn __l->_M_data + __i;\n\t    }\n\tcase _RopeRep::_S_function:\n\tcase _RopeRep::_S_substringfn:\n\t    return 0;\n      }\n    }\n}\n# endif /* __GC */\n\n// The following could be implemented trivially using\n// lexicographical_compare_3way.\n// We do a little more work to avoid dealing with rope iterators for\n// flat strings.\ntemplate <class _CharT, class _Alloc>\nint\nrope<_CharT,_Alloc>::_S_compare (const _RopeRep* __left, \n                                 const _RopeRep* __right)\n{\n    size_t __left_len;\n    size_t __right_len;\n\n    if (0 == __right) return 0 != __left;\n    if (0 == __left) return -1;\n    __left_len = __left->_M_size;\n    __right_len = __right->_M_size;\n    if (_RopeRep::_S_leaf == __left->_M_tag) {\n\t_RopeLeaf* __l = (_RopeLeaf*) __left;\n\tif (_RopeRep::_S_leaf == __right->_M_tag) {\n\t    _RopeLeaf* __r = (_RopeLeaf*) __right;\n\t    return lexicographical_compare_3way(\n\t\t\t__l->_M_data, __l->_M_data + __left_len,\n\t\t\t__r->_M_data, __r->_M_data + __right_len);\n\t} else {\n\t    const_iterator __rstart(__right, 0);\n\t    const_iterator __rend(__right, __right_len);\n\t    return lexicographical_compare_3way(\n\t\t\t__l->_M_data, __l->_M_data + __left_len,\n\t\t\t__rstart, __rend);\n\t}\n    } else {\n\tconst_iterator __lstart(__left, 0);\n\tconst_iterator __lend(__left, __left_len);\n\tif (_RopeRep::_S_leaf == __right->_M_tag) {\n\t    _RopeLeaf* __r = (_RopeLeaf*) __right;\n\t    return lexicographical_compare_3way(\n\t\t\t\t   __lstart, __lend,\n\t\t\t\t   __r->_M_data, __r->_M_data + __right_len);\n\t} else {\n\t    const_iterator __rstart(__right, 0);\n\t    const_iterator __rend(__right, __right_len);\n\t    return lexicographical_compare_3way(\n\t\t\t\t   __lstart, __lend,\n\t\t\t\t   __rstart, __rend);\n\t}\n    }\n}\n\n// Assignment to reference proxies.\ntemplate <class _CharT, class _Alloc>\n_Rope_char_ref_proxy<_CharT, _Alloc>&\n_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c) {\n    _RopeRep* __old = _M_root->_M_tree_ptr;\n#   ifndef __GC\n\t// First check for the case in which everything is uniquely\n\t// referenced.  In that case we can do this destructively.\n\t_CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos);\n\tif (0 != __ptr) {\n\t    *__ptr = __c;\n\t    return *this;\n\t}\n#   endif\n    _Self_destruct_ptr __left(\n      _My_rope::_S_substring(__old, 0, _M_pos));\n    _Self_destruct_ptr __right(\n      _My_rope::_S_substring(__old, _M_pos+1, __old->_M_size));\n    _Self_destruct_ptr __result_left(\n      _My_rope::_S_destr_concat_char_iter(__left, &__c, 1));\n\n#   ifndef __GC\n      __stl_assert(__left == __result_left || 1 == __result_left->_M_ref_count);\n#   endif\n    _RopeRep* __result =\n\t\t_My_rope::_S_concat(__result_left, __right);\n#   ifndef __GC\n      __stl_assert(1 <= __result->_M_ref_count);\n      _RopeRep::_S_unref(__old);\n#   endif\n    _M_root->_M_tree_ptr = __result;\n    return *this;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_char_ref_proxy<_CharT, _Alloc>::operator _CharT () const\n{\n    if (_M_current_valid) {\n\treturn _M_current;\n    } else {\n        return _My_rope::_S_fetch(_M_root->_M_tree_ptr, _M_pos);\n    }\n}\ntemplate <class _CharT, class _Alloc>\n_Rope_char_ptr_proxy<_CharT, _Alloc>\n_Rope_char_ref_proxy<_CharT, _Alloc>::operator& () const {\n    return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this);\n}\n\ntemplate <class _CharT, class _Alloc>\nrope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,\n\t\t\t   const allocator_type& __a)\n: _Base(__a)\n{\n    rope<_CharT,_Alloc> __result;\n    const size_t __exponentiate_threshold = 32;\n    size_t __exponent;\n    size_t __rest;\n    _CharT* __rest_buffer;\n    _RopeRep* __remainder;\n    rope<_CharT,_Alloc> __remainder_rope;\n\n    if (0 == __n)\n      return;\n    \n    __exponent = __n / __exponentiate_threshold;\n    __rest = __n % __exponentiate_threshold;\n    if (0 == __rest) {\n\t__remainder = 0;\n    } else {\n\t__rest_buffer = _Data_allocate(_S_rounded_up_size(__rest));\n\tuninitialized_fill_n(__rest_buffer, __rest, __c);\n\t_S_cond_store_eos(__rest_buffer[__rest]);\n\t__STL_TRY {\n\t    __remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a);\n        }\n\t__STL_UNWIND(_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a))\n    }\n    __remainder_rope._M_tree_ptr = __remainder;\n    if (__exponent != 0) {\n\t_CharT* __base_buffer =\n\t  _Data_allocate(_S_rounded_up_size(__exponentiate_threshold));\n\t_RopeLeaf* __base_leaf;\n\trope __base_rope;\n\tuninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c);\n\t_S_cond_store_eos(__base_buffer[__exponentiate_threshold]);\n\t__STL_TRY {\n          __base_leaf = _S_new_RopeLeaf(__base_buffer,\n                                        __exponentiate_threshold, __a);\n        }\n\t__STL_UNWIND(_RopeRep::__STL_FREE_STRING(__base_buffer, \n\t                                         __exponentiate_threshold, __a))\n\t__base_rope._M_tree_ptr = __base_leaf;\n \tif (1 == __exponent) {\n\t  __result = __base_rope;\n#         ifndef __GC\n\t    __stl_assert(2 == __result._M_tree_ptr->_M_ref_count);\n\t\t// One each for base_rope and __result\n#         endif\n\t} else {\n\t  __result = power(__base_rope, __exponent,\n\t\t\t   _Rope_Concat_fn<_CharT,_Alloc>());\n\t}\n\tif (0 != __remainder) {\n\t  __result += __remainder_rope;\n\t}\n    } else {\n\t__result = __remainder_rope;\n    }\n    _M_tree_ptr = __result._M_tree_ptr;\n    _M_tree_ptr->_M_ref_nonnil();\n}\n\ntemplate<class _CharT, class _Alloc>\n  _CharT rope<_CharT,_Alloc>::_S_empty_c_str[1];\n\ntemplate<class _CharT, class _Alloc>\nconst _CharT* rope<_CharT,_Alloc>::c_str() const {\n    if (0 == _M_tree_ptr) {\n        _S_empty_c_str[0] = _S_eos((_CharT*)0);  // Possibly redundant,\n\t\t\t\t\t     // but probably fast.\n        return _S_empty_c_str;\n    }\n    __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string;\n    if (0 != __old_c_string) return(__old_c_string);\n    size_t __s = size();\n    _CharT* __result = _Data_allocate(__s + 1);\n    _S_flatten(_M_tree_ptr, __result);\n    __result[__s] = _S_eos((_CharT*)0);\n#   ifdef __GC\n\t_M_tree_ptr->_M_c_string = __result;\n#   else\n      if ((__old_c_string = (__GC_CONST _CharT*)\n             _Atomic_swap((unsigned long *)(&(_M_tree_ptr->_M_c_string)),\n\t\t\t  (unsigned long)__result)) != 0) {\n\t// It must have been added in the interim.  Hence it had to have been\n\t// separately allocated.  Deallocate the old copy, since we just\n\t// replaced it.\n\tdestroy(__old_c_string, __old_c_string + __s + 1);\n\t_Data_deallocate(__old_c_string, __s + 1);\n      }\n#   endif\n    return(__result);\n}\n\ntemplate<class _CharT, class _Alloc>\nconst _CharT* rope<_CharT,_Alloc>::replace_with_c_str() {\n    if (0 == _M_tree_ptr) {\n        _S_empty_c_str[0] = _S_eos((_CharT*)0);\n        return _S_empty_c_str;\n    }\n    __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string;\n    if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && 0 != __old_c_string) {\n\treturn(__old_c_string);\n    }\n    size_t __s = size();\n    _CharT* __result = _Data_allocate(_S_rounded_up_size(__s));\n    _S_flatten(_M_tree_ptr, __result);\n    __result[__s] = _S_eos((_CharT*)0);\n    _M_tree_ptr->_M_unref_nonnil();\n    _M_tree_ptr = _S_new_RopeLeaf(__result, __s, get_allocator());\n    return(__result);\n}\n\n// Algorithm specializations.  More should be added.\n\ntemplate<class _Rope_iterator>  // was templated on CharT and Alloc\nvoid\t\t\t\t// VC++ workaround\n_Rope_rotate(_Rope_iterator __first,\n             _Rope_iterator __middle,\n             _Rope_iterator __last)\n{\n  typedef typename _Rope_iterator::value_type _CharT;\n  typedef typename _Rope_iterator::_allocator_type _Alloc;\n  \n  __stl_assert(__first.container() == __middle.container()\n                           && __middle.container() == __last.container());\n  rope<_CharT,_Alloc>& __r(__first.container());\n  rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index());\n  rope<_CharT,_Alloc> __suffix = \n    __r.substr(__last.index(), __r.size() - __last.index());\n  rope<_CharT,_Alloc> __part1 = \n    __r.substr(__middle.index(), __last.index() - __middle.index());\n  rope<_CharT,_Alloc> __part2 = \n    __r.substr(__first.index(), __middle.index() - __first.index());\n  __r = __prefix;\n  __r += __part1;\n  __r += __part2;\n  __r += __suffix;\n}\n\n#if !defined(__GNUC__)\n// Appears to confuse g++\ninline void rotate(_Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __first,\n                   _Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __middle,\n                   _Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __last) {\n    _Rope_rotate(__first, __middle, __last);\n}\n#endif\n\n# if 0\n// Probably not useful for several reasons:\n// - for SGIs 7.1 compiler and probably some others,\n//   this forces lots of rope<wchar_t, ...> instantiations, creating a\n//   code bloat and compile time problem.  (Fixed in 7.2.)\n// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive\n//   for unicode strings.  Unsigned short may be a better character\n//   type.\ninline void rotate(\n\t\t_Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __first,\n                _Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __middle,\n                _Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __last) {\n    _Rope_rotate(__first, __middle, __last);\n}\n# endif\n\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/sequence_concepts.h",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef STL_SEQUENCE_CONCEPTS_H\n#define STL_SEQUENCE_CONCEPTS_H\n\n#include <container_concepts.h>\n\n#ifdef __STL_USE_CONCEPT_CHECKS\n\n// This file covers the following concepts:\n//       _Sequence\n//       _FrontInsertionSequence\n//       _BackInsertionSequence\n\nstruct _ERROR_IN_STL_SEQ {\n\n  template <class _XX>\n  static void\n  __fill_constructor_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    typename _XX::difference_type __n = typename _XX::difference_type();\n    _XX __x(__n, __t);\n    __sink_unused_warning(__x);\n  }\n  template <class _XX>\n  static void\n  __fill_default_constructor_requirement_violation(_XX& __s) {\n    _STL_ERROR::__default_constructor_requirement_violation(*__s.begin());\n    typename _XX::difference_type __n = typename _XX::difference_type();\n    _XX __x(__n);\n    __sink_unused_warning(__x);\n  }  \n  template <class _XX>\n  static void\n  __range_constructor_requirement_violation(_XX& __s) {\n    _XX __x(__s.begin(), __s.end());\n    __sink_unused_warning(__x);\n  }\n  template <class _XX>\n  static void\n  __insert_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    typename _XX::iterator __p = typename _XX::iterator();\n    __p = __s.insert(__p, __t);\n  }\n  template <class _XX>\n  static void\n  __fill_insert_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    typename _XX::iterator __p = typename _XX::iterator();\n    typename _XX::difference_type __n = typename _XX::difference_type();\n    __s.insert(__p, __n, __t);\n  }\n  template <class _XX>\n  static void\n  __range_insert_function_requirement_violation(_XX& __s) {\n    typename _XX::iterator __p = typename _XX::iterator();\n    typename _XX::iterator __i = typename _XX::iterator();\n    typename _XX::iterator __j = typename _XX::iterator();\n    __s.insert(__p, __i, __j);\n  }\n  template <class _XX>\n  static void\n  __insert_element_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    std::pair<typename _XX::iterator, bool> __r;\n    __r = __s.insert(__t);\n    __sink_unused_warning(__r);\n  }\n  template <class _XX>\n  static void\n  __unconditional_insert_element_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    typename _XX::iterator __p;\n    __p = __s.insert(__t);\n    __sink_unused_warning(__p);\n  }\n  template <class _XX>\n  static void\n  __erase_function_requirement_violation(_XX& __s) {\n    typename _XX::iterator __p = typename _XX::iterator();\n    __p = __s.erase(__p);\n  }\n  template <class _XX>\n  static void\n  __range_erase_function_requirement_violation(_XX& __s) {\n    typename _XX::iterator __p = typename _XX::iterator();\n    typename _XX::iterator __q = typename _XX::iterator();\n    __p = __s.erase(__p, __q);\n  }\n  template <class _XX>\n  static void\n  __const_front_function_requirement_violation(const _XX& __s) {\n    typename _XX::const_reference __t = __s.front();\n    __sink_unused_warning(__t);\n  }\n  template <class _XX>\n  static void\n  __front_function_requirement_violation(_XX& __s) {\n    typename _XX::reference __t = __s.front();\n    __const_front_function_requirement_violation(__s);\n    __sink_unused_warning(__t);\n  }\n  template <class _XX>\n  static void\n  __const_back_function_requirement_violation(const _XX& __s) {\n    typename _XX::const_reference __t = __s.back();\n    __sink_unused_warning(__t);\n  }\n  template <class _XX>\n  static void\n  __back_function_requirement_violation(_XX& __s) {\n    typename _XX::reference __t = __s.back();\n    __const_back_function_requirement_violation(__s);\n    __sink_unused_warning(__t);\n  }\n  template <class _XX>\n  static void\n  __push_front_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    __s.push_front(__t);\n  }\n  template <class _XX>\n  static void\n  __pop_front_function_requirement_violation(_XX& __s) {\n    __s.pop_front();\n  }\n  template <class _XX>\n  static void\n  __push_back_function_requirement_violation(_XX& __s) {\n    typename _XX::value_type __t = typename _XX::value_type();\n    __s.push_back(__t);\n  }\n  template <class _XX>\n  static void\n  __pop_back_function_requirement_violation(_XX& __s) {\n    __s.pop_back();\n  }\n\n};\n\n/* Sequence Containers */\n\ntemplate <class _Sequence>\nstruct _Sequence_concept_specification {\nstatic void\n_Sequence_requirement_violation(_Sequence __s) {\n  // Refinement of ForwardContainer\n  _ForwardContainer_concept_specification<_Sequence>::_ForwardContainer_requirement_violation(__s);\n  // Refinement of DefaultConstructible\n  _DefaultConstructible_concept_specification<_Sequence>::_DefaultConstructible_requirement_violation(__s);\n  // Valid Expressions\n  _ERROR_IN_STL_SEQ::__fill_constructor_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__fill_default_constructor_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__range_constructor_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__insert_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__fill_insert_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__range_insert_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__erase_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__range_erase_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__front_function_requirement_violation(__s);\n}\n};\n\ntemplate <class _FrontInsertionSequence>\nstruct _FrontInsertionSequence_concept_specification {\nstatic void\n_FrontInsertionSequence_requirement_violation(_FrontInsertionSequence __s) {\n  // Refinement of Sequence\n  _Sequence_concept_specification<_FrontInsertionSequence>::_Sequence_requirement_violation(__s);\n  // Valid Expressions\n  _ERROR_IN_STL_SEQ::__push_front_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__pop_front_function_requirement_violation(__s);\n}\n};\n\ntemplate <class _BackInsertionSequence>\nstruct _BackInsertionSequence_concept_specification {\nstatic void\n_BackInsertionSequence_requirement_violation(_BackInsertionSequence __s) {\n  // Refinement of Sequence\n  _Sequence_concept_specification<_BackInsertionSequence>::_Sequence_requirement_violation(__s);\n  // Valid Expressions\n  _ERROR_IN_STL_SEQ::__back_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__push_back_function_requirement_violation(__s);\n  _ERROR_IN_STL_SEQ::__pop_back_function_requirement_violation(__s);\n}\n};\n\n#endif /* if __STL_USE_CONCEPT_CHECKS */\n\n\n#endif /* STL_SEQUENCE_CONCEPTS_H */\n"
  },
  {
    "path": "stl-3.3-source/set",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_SET\n#define __SGI_STL_SET\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <stl_set.h>\n#include <stl_multiset.h>\n\n#endif /* __SGI_STL_SET */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/set.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_SET_H\n#define __SGI_STL_SET_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_set.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\nusing __STD::set;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/slist",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_SLIST\n#define __SGI_STL_SLIST\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_slist.h>\n\n#endif /* __SGI_STL_SLIST */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/slist.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_SLIST_H\n#define __SGI_STL_SLIST_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_slist.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::slist;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_SLIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stack",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_STACK\n#define __SGI_STL_STACK\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_deque.h>\n#include <stl_stack.h>\n\n#endif /* __SGI_STL_STACK */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stack.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_STACK_H\n#define __SGI_STL_STACK_H\n\n#include <vector.h>\n#include <deque.h>\n#include <heap.h>\n#include <stl_stack.h>\n#include <stl_queue.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::stack;\nusing __STD::queue;\nusing __STD::priority_queue;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_STACK_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stdexcept",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STDEXCEPT\n#define __SGI_STDEXCEPT\n\n#include <stl_exception.h>\n\n#if defined(__STL_USE_EXCEPTIONS) || \\\n    !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)\n\n#include <stl_string_fwd.h>\n\n__STL_BEGIN_NAMESPACE\n\nclass __Named_exception : public __STL_EXCEPTION_BASE {\npublic:\n  __Named_exception(const string& __str) {\n    strncpy(_M_name, __get_c_string(__str), _S_bufsize);\n    _M_name[_S_bufsize - 1] = '\\0';\n  }\n  virtual const char* what() const __STL_NOTHROW { return _M_name; }\n\nprivate:\n  enum { _S_bufsize = 256 };\n  char _M_name[_S_bufsize];\n};\n\nclass logic_error : public __Named_exception {\npublic:\n  logic_error(const string& __s) : __Named_exception(__s) {}\n};\n\nclass runtime_error : public __Named_exception {\npublic:\n  runtime_error(const string& __s) : __Named_exception(__s) {}\n};\n\nclass domain_error : public logic_error {\npublic:\n  domain_error(const string& __arg) : logic_error(__arg) {}\n};\n\nclass invalid_argument : public logic_error {\npublic:\n  invalid_argument(const string& __arg) : logic_error(__arg) {}\n};\n\nclass length_error : public logic_error {\npublic:\n  length_error(const string& __arg) : logic_error(__arg) {}\n};\n\nclass out_of_range : public logic_error {\npublic:\n  out_of_range(const string& __arg) : logic_error(__arg) {}\n};\n\nclass range_error : public runtime_error {\npublic:\n  range_error(const string& __arg) : runtime_error(__arg) {}\n};\n\nclass overflow_error : public runtime_error {\npublic:\n  overflow_error(const string& __arg) : runtime_error(__arg) {}\n};\n\nclass underflow_error : public runtime_error {\npublic:\n  underflow_error(const string& __arg) : runtime_error(__arg) {}\n};\n\n__STL_END_NAMESPACE\n\n#ifndef __SGI_STL_STRING\n#include <string>\n#endif\n\n#endif /* Not o32, and no exceptions */\n\n#endif /* __SGI_STDEXCEPT */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl-3.3.SearchResults",
    "content": "---- pop_heap Matches (18 in 5 files) ----\nAlgo.h:using __STD::pop_heap;\nHeap.h:using __STD::pop_heap;\nStl_algo.h:      __pop_heap(__first, __middle, __i, _Tp(*__i),\nStl_algo.h:      __pop_heap(__first, __middle, __i, _Tp(*__i), __comp,\nStl_heap.h:// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.\nStl_heap.h:__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\nStl_heap.h:__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last,\nStl_heap.h:  __pop_heap(__first, __last - 1, __last - 1, \nStl_heap.h:inline void pop_heap(_RandomAccessIterator __first, \nStl_heap.h:  __pop_heap_aux(__first, __last, __VALUE_TYPE(__first));\nStl_heap.h:__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\nStl_heap.h:__pop_heap_aux(_RandomAccessIterator __first,\nStl_heap.h:  __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp,\nStl_heap.h:pop_heap(_RandomAccessIterator __first,\nStl_heap.h:  __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp);\nStl_heap.h:    pop_heap(__first, __last--);\nStl_heap.h:    pop_heap(__first, __last--, __comp);\nStl_queue.h:      pop_heap(c.begin(), c.end(), comp);\n"
  },
  {
    "path": "stl-3.3-source/stl_algo.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ALGO_H\n#define __SGI_STL_INTERNAL_ALGO_H\n\n#include <stl_heap.h>\n\n// See concept_checks.h for the concept-checking macros \n// __STL_REQUIRES, __STL_CONVERTIBLE, etc.\n\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1209\n#endif\n\n// __median (an extension, not present in the C++ standard).\n\ntemplate <class _Tp>\ninline const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) {\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  if (__a < __b)\n    if (__b < __c)\n      return __b;\n    else if (__a < __c)\n      return __c;\n    else\n      return __a;\n  else if (__a < __c)\n    return __a;\n  else if (__b < __c)\n    return __c;\n  else\n    return __b;\n}\n\ntemplate <class _Tp, class _Compare>\ninline const _Tp&\n__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) {\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n  if (__comp(__a, __b))\n    if (__comp(__b, __c))\n      return __b;\n    else if (__comp(__a, __c))\n      return __c;\n    else\n      return __a;\n  else if (__comp(__a, __c))\n    return __a;\n  else if (__comp(__b, __c))\n    return __c;\n  else\n    return __b;\n}\n\n// for_each.  Apply a function to every element of a range.\ntemplate <class _InputIter, class _Function>\n_Function for_each(_InputIter __first, _InputIter __last, _Function __f) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  for ( ; __first != __last; ++__first)\n    __f(*__first);\n  return __f;\n}\n\n// find and find_if.\n\ntemplate <class _InputIter, class _Tp>\ninline _InputIter find(_InputIter __first, _InputIter __last,\n                       const _Tp& __val,\n                       input_iterator_tag)\n{\n  while (__first != __last && !(*__first == __val))\n    ++__first;\n  return __first;\n}\n\ntemplate <class _InputIter, class _Predicate>\ninline _InputIter find_if(_InputIter __first, _InputIter __last,\n                          _Predicate __pred,\n                          input_iterator_tag)\n{\n  while (__first != __last && !__pred(*__first))\n    ++__first;\n  return __first;\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _RandomAccessIter, class _Tp>\n_RandomAccessIter find(_RandomAccessIter __first, _RandomAccessIter __last,\n                       const _Tp& __val,\n                       random_access_iterator_tag)\n{\n  typename iterator_traits<_RandomAccessIter>::difference_type __trip_count\n    = (__last - __first) >> 2;\n\n  for ( ; __trip_count > 0 ; --__trip_count) {\n    if (*__first == __val) return __first;\n    ++__first;\n\n    if (*__first == __val) return __first;\n    ++__first;\n\n    if (*__first == __val) return __first;\n    ++__first;\n\n    if (*__first == __val) return __first;\n    ++__first;\n  }\n\n  switch(__last - __first) {\n  case 3:\n    if (*__first == __val) return __first;\n    ++__first;\n  case 2:\n    if (*__first == __val) return __first;\n    ++__first;\n  case 1:\n    if (*__first == __val) return __first;\n    ++__first;\n  case 0:\n  default:\n    return __last;\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Predicate>\n_RandomAccessIter find_if(_RandomAccessIter __first, _RandomAccessIter __last,\n                          _Predicate __pred,\n                          random_access_iterator_tag)\n{\n  typename iterator_traits<_RandomAccessIter>::difference_type __trip_count\n    = (__last - __first) >> 2;\n\n  for ( ; __trip_count > 0 ; --__trip_count) {\n    if (__pred(*__first)) return __first;\n    ++__first;\n\n    if (__pred(*__first)) return __first;\n    ++__first;\n\n    if (__pred(*__first)) return __first;\n    ++__first;\n\n    if (__pred(*__first)) return __first;\n    ++__first;\n  }\n\n  switch(__last - __first) {\n  case 3:\n    if (__pred(*__first)) return __first;\n    ++__first;\n  case 2:\n    if (__pred(*__first)) return __first;\n    ++__first;\n  case 1:\n    if (__pred(*__first)) return __first;\n    ++__first;\n  case 0:\n  default:\n    return __last;\n  }\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _InputIter, class _Tp>\ninline _InputIter find(_InputIter __first, _InputIter __last,\n                       const _Tp& __val)\n{\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, \n            typename iterator_traits<_InputIter>::value_type, _Tp);\n  return find(__first, __last, __val, __ITERATOR_CATEGORY(__first));\n}\n\ntemplate <class _InputIter, class _Predicate>\ninline _InputIter find_if(_InputIter __first, _InputIter __last,\n                          _Predicate __pred) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n          typename iterator_traits<_InputIter>::value_type);\n  return find_if(__first, __last, __pred, __ITERATOR_CATEGORY(__first));\n}\n\n// adjacent_find.\n\ntemplate <class _ForwardIter>\n_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _EqualityComparable);\n  if (__first == __last)\n    return __last;\n  _ForwardIter __next = __first;\n  while(++__next != __last) {\n    if (*__first == *__next)\n      return __first;\n    __first = __next;\n  }\n  return __last;\n}\n\ntemplate <class _ForwardIter, class _BinaryPredicate>\n_ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last,\n                           _BinaryPredicate __binary_pred) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool,\n          typename iterator_traits<_ForwardIter>::value_type,\n          typename iterator_traits<_ForwardIter>::value_type);\n  if (__first == __last)\n    return __last;\n  _ForwardIter __next = __first;\n  while(++__next != __last) {\n    if (__binary_pred(*__first, *__next))\n      return __first;\n    __first = __next;\n  }\n  return __last;\n}\n\n// count and count_if.  There are two version of each, one whose return type\n// type is void and one (present only if we have partial specialization)\n// whose return type is iterator_traits<_InputIter>::difference_type.  The\n// C++ standard only has the latter version, but the former, which was present\n// in the HP STL, is retained for backward compatibility.\n\ntemplate <class _InputIter, class _Tp, class _Size>\nvoid count(_InputIter __first, _InputIter __last, const _Tp& __value,\n           _Size& __n) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type,\n                 _EqualityComparable);\n  __STL_REQUIRES(_Tp, _EqualityComparable);\n  for ( ; __first != __last; ++__first)\n    if (*__first == __value)\n      ++__n;\n}\n\ntemplate <class _InputIter, class _Predicate, class _Size>\nvoid count_if(_InputIter __first, _InputIter __last, _Predicate __pred,\n              _Size& __n) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, \n                  typename iterator_traits<_InputIter>::value_type);\n  for ( ; __first != __last; ++__first)\n    if (__pred(*__first))\n      ++__n;\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _InputIter, class _Tp>\ntypename iterator_traits<_InputIter>::difference_type\ncount(_InputIter __first, _InputIter __last, const _Tp& __value) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type,\n                 _EqualityComparable);\n  __STL_REQUIRES(_Tp, _EqualityComparable);\n  typename iterator_traits<_InputIter>::difference_type __n = 0;\n  for ( ; __first != __last; ++__first)\n    if (*__first == __value)\n      ++__n;\n  return __n;\n}\n\ntemplate <class _InputIter, class _Predicate>\ntypename iterator_traits<_InputIter>::difference_type\ncount_if(_InputIter __first, _InputIter __last, _Predicate __pred) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, \n                  typename iterator_traits<_InputIter>::value_type);\n  typename iterator_traits<_InputIter>::difference_type __n = 0;\n  for ( ; __first != __last; ++__first)\n    if (__pred(*__first))\n      ++__n;\n  return __n;\n}\n\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// search.\n\ntemplate <class _ForwardIter1, class _ForwardIter2>\n_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,\n                     _ForwardIter2 __first2, _ForwardIter2 __last2) \n{\n  __STL_REQUIRES(_ForwardIter1, _ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _ForwardIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n   typename iterator_traits<_ForwardIter1>::value_type,\n   typename iterator_traits<_ForwardIter2>::value_type);\n\n  // Test for empty ranges\n  if (__first1 == __last1 || __first2 == __last2)\n    return __first1;\n\n  // Test for a pattern of length 1.\n  _ForwardIter2 __tmp(__first2);\n  ++__tmp;\n  if (__tmp == __last2)\n    return find(__first1, __last1, *__first2);\n\n  // General case.\n\n  _ForwardIter2 __p1, __p;\n\n  __p1 = __first2; ++__p1;\n\n  _ForwardIter1 __current = __first1;\n\n  while (__first1 != __last1) {\n    __first1 = find(__first1, __last1, *__first2);\n    if (__first1 == __last1)\n      return __last1;\n\n    __p = __p1;\n    __current = __first1; \n    if (++__current == __last1)\n      return __last1;\n\n    while (*__current == *__p) {\n      if (++__p == __last2)\n        return __first1;\n      if (++__current == __last1)\n        return __last1;\n    }\n\n    ++__first1;\n  }\n  return __first1;\n}\n\ntemplate <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>\n_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,\n                     _ForwardIter2 __first2, _ForwardIter2 __last2,\n                     _BinaryPred  __predicate) \n{\n  __STL_REQUIRES(_ForwardIter1, _ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPred, bool,\n   typename iterator_traits<_ForwardIter1>::value_type,\n   typename iterator_traits<_ForwardIter2>::value_type);\n\n  // Test for empty ranges\n  if (__first1 == __last1 || __first2 == __last2)\n    return __first1;\n\n  // Test for a pattern of length 1.\n  _ForwardIter2 __tmp(__first2);\n  ++__tmp;\n  if (__tmp == __last2) {\n    while (__first1 != __last1 && !__predicate(*__first1, *__first2))\n      ++__first1;\n    return __first1;    \n  }\n\n  // General case.\n\n  _ForwardIter2 __p1, __p;\n\n  __p1 = __first2; ++__p1;\n\n  _ForwardIter1 __current = __first1;\n\n  while (__first1 != __last1) {\n    while (__first1 != __last1) {\n      if (__predicate(*__first1, *__first2))\n        break;\n      ++__first1;\n    }\n    while (__first1 != __last1 && !__predicate(*__first1, *__first2))\n      ++__first1;\n    if (__first1 == __last1)\n      return __last1;\n\n    __p = __p1;\n    __current = __first1; \n    if (++__current == __last1) return __last1;\n\n    while (__predicate(*__current, *__p)) {\n      if (++__p == __last2)\n        return __first1;\n      if (++__current == __last1)\n        return __last1;\n    }\n\n    ++__first1;\n  }\n  return __first1;\n}\n\n// search_n.  Search for __count consecutive copies of __val.\n\ntemplate <class _ForwardIter, class _Integer, class _Tp>\n_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,\n                      _Integer __count, const _Tp& __val) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _EqualityComparable);\n  __STL_REQUIRES(_Tp, _EqualityComparable);\n\n  if (__count <= 0)\n    return __first;\n  else {\n    __first = find(__first, __last, __val);\n    while (__first != __last) {\n      _Integer __n = __count - 1;\n      _ForwardIter __i = __first;\n      ++__i;\n      while (__i != __last && __n != 0 && *__i == __val) {\n        ++__i;\n        --__n;\n      }\n      if (__n == 0)\n        return __first;\n      else\n        __first = find(__i, __last, __val);\n    }\n    return __last;\n  }\n}\n\ntemplate <class _ForwardIter, class _Integer, class _Tp, class _BinaryPred>\n_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,\n                      _Integer __count, const _Tp& __val,\n                      _BinaryPred __binary_pred) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPred, bool, \n             typename iterator_traits<_ForwardIter>::value_type, _Tp);\n  if (__count <= 0)\n    return __first;\n  else {\n    while (__first != __last) {\n      if (__binary_pred(*__first, __val))\n        break;\n      ++__first;\n    }\n    while (__first != __last) {\n      _Integer __n = __count - 1;\n      _ForwardIter __i = __first;\n      ++__i;\n      while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {\n        ++__i;\n        --__n;\n      }\n      if (__n == 0)\n        return __first;\n      else {\n        while (__i != __last) {\n          if (__binary_pred(*__i, __val))\n            break;\n          ++__i;\n        }\n        __first = __i;\n      }\n    }\n    return __last;\n  }\n} \n\n// swap_ranges\n\ntemplate <class _ForwardIter1, class _ForwardIter2>\n_ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1,\n                          _ForwardIter2 __first2) {\n  __STL_REQUIRES(_ForwardIter1, _Mutable_ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _Mutable_ForwardIterator);\n  __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter1>::value_type,\n                    typename iterator_traits<_ForwardIter2>::value_type);\n  __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter2>::value_type,\n                    typename iterator_traits<_ForwardIter1>::value_type);\n  for ( ; __first1 != __last1; ++__first1, ++__first2)\n    iter_swap(__first1, __first2);\n  return __first2;\n}\n\n// transform\n\ntemplate <class _InputIter, class _OutputIter, class _UnaryOperation>\n_OutputIter transform(_InputIter __first, _InputIter __last,\n                      _OutputIter __result, _UnaryOperation __opr) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n\n  for ( ; __first != __last; ++__first, ++__result)\n    *__result = __opr(*__first);\n  return __result;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter,\n          class _BinaryOperation>\n_OutputIter transform(_InputIter1 __first1, _InputIter1 __last1,\n                      _InputIter2 __first2, _OutputIter __result,\n                      _BinaryOperation __binary_op) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result)\n    *__result = __binary_op(*__first1, *__first2);\n  return __result;\n}\n\n// replace, replace_if, replace_copy, replace_copy_if\n\ntemplate <class _ForwardIter, class _Tp>\nvoid replace(_ForwardIter __first, _ForwardIter __last,\n             const _Tp& __old_value, const _Tp& __new_value) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n         typename iterator_traits<_ForwardIter>::value_type, _Tp);\n  __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);\n  for ( ; __first != __last; ++__first)\n    if (*__first == __old_value)\n      *__first = __new_value;\n}\n\ntemplate <class _ForwardIter, class _Predicate, class _Tp>\nvoid replace_if(_ForwardIter __first, _ForwardIter __last,\n                _Predicate __pred, const _Tp& __new_value) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n             typename iterator_traits<_ForwardIter>::value_type);\n  for ( ; __first != __last; ++__first)\n    if (__pred(*__first))\n      *__first = __new_value;\n}\n\ntemplate <class _InputIter, class _OutputIter, class _Tp>\n_OutputIter replace_copy(_InputIter __first, _InputIter __last,\n                         _OutputIter __result,\n                         const _Tp& __old_value, const _Tp& __new_value) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n         typename iterator_traits<_InputIter>::value_type, _Tp);\n  for ( ; __first != __last; ++__first, ++__result)\n    *__result = *__first == __old_value ? __new_value : *__first;\n  return __result;\n}\n\ntemplate <class _InputIter, class _OutputIter, class _Predicate, class _Tp>\n_OutputIter replace_copy_if(_InputIter __first, _InputIter __last,\n                            _OutputIter __result,\n                            _Predicate __pred, const _Tp& __new_value) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n                typename iterator_traits<_InputIter>::value_type);\n  for ( ; __first != __last; ++__first, ++__result)\n    *__result = __pred(*__first) ? __new_value : *__first;\n  return __result;\n}\n\n// generate and generate_n\n\ntemplate <class _ForwardIter, class _Generator>\nvoid generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_GENERATOR_CHECK(_Generator, \n          typename iterator_traits<_ForwardIter>::value_type);\n  for ( ; __first != __last; ++__first)\n    *__first = __gen();\n}\n\ntemplate <class _OutputIter, class _Size, class _Generator>\n_OutputIter generate_n(_OutputIter __first, _Size __n, _Generator __gen) {\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  for ( ; __n > 0; --__n, ++__first)\n    *__first = __gen();\n  return __first;\n}\n\n// remove, remove_if, remove_copy, remove_copy_if\n\ntemplate <class _InputIter, class _OutputIter, class _Tp>\n_OutputIter remove_copy(_InputIter __first, _InputIter __last,\n                        _OutputIter __result, const _Tp& __value) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n       typename iterator_traits<_InputIter>::value_type, _Tp);\n  for ( ; __first != __last; ++__first)\n    if (!(*__first == __value)) {\n      *__result = *__first;\n      ++__result;\n    }\n  return __result;\n}\n\ntemplate <class _InputIter, class _OutputIter, class _Predicate>\n_OutputIter remove_copy_if(_InputIter __first, _InputIter __last,\n                           _OutputIter __result, _Predicate __pred) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n             typename iterator_traits<_InputIter>::value_type);\n  for ( ; __first != __last; ++__first)\n    if (!__pred(*__first)) {\n      *__result = *__first;\n      ++__result;\n    }\n  return __result;\n}\n\ntemplate <class _ForwardIter, class _Tp>\n_ForwardIter remove(_ForwardIter __first, _ForwardIter __last,\n                    const _Tp& __value) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n       typename iterator_traits<_ForwardIter>::value_type, _Tp);\n  __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);\n  __first = find(__first, __last, __value);\n  _ForwardIter __i = __first;\n  return __first == __last ? __first \n                           : remove_copy(++__i, __last, __first, __value);\n}\n\ntemplate <class _ForwardIter, class _Predicate>\n_ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last,\n                       _Predicate __pred) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n               typename iterator_traits<_ForwardIter>::value_type);\n  __first = find_if(__first, __last, __pred);\n  _ForwardIter __i = __first;\n  return __first == __last ? __first \n                           : remove_copy_if(++__i, __last, __first, __pred);\n}\n\n// unique and unique_copy\n\ntemplate <class _InputIter, class _OutputIter, class _Tp>\n_OutputIter __unique_copy(_InputIter __first, _InputIter __last,\n                          _OutputIter __result, _Tp*) {\n  _Tp __value = *__first;\n  *__result = __value;\n  while (++__first != __last)\n    if (!(__value == *__first)) {\n      __value = *__first;\n      *++__result = __value;\n    }\n  return ++__result;\n}\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter __unique_copy(_InputIter __first, _InputIter __last,\n                                 _OutputIter __result, \n                                 output_iterator_tag) {\n  return __unique_copy(__first, __last, __result, __VALUE_TYPE(__first));\n}\n\ntemplate <class _InputIter, class _ForwardIter>\n_ForwardIter __unique_copy(_InputIter __first, _InputIter __last,\n                           _ForwardIter __result, forward_iterator_tag) {\n  *__result = *__first;\n  while (++__first != __last)\n    if (!(*__result == *__first))\n      *++__result = *__first;\n  return ++__result;\n}\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter unique_copy(_InputIter __first, _InputIter __last,\n                               _OutputIter __result) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type,\n                 _EqualityComparable);\n  if (__first == __last) return __result;\n  return __unique_copy(__first, __last, __result,\n                       __ITERATOR_CATEGORY(__result));\n}\n\ntemplate <class _InputIter, class _OutputIter, class _BinaryPredicate,\n          class _Tp>\n_OutputIter __unique_copy(_InputIter __first, _InputIter __last,\n                          _OutputIter __result,\n                          _BinaryPredicate __binary_pred, _Tp*) {\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, _Tp, _Tp);\n  _Tp __value = *__first;\n  *__result = __value;\n  while (++__first != __last)\n    if (!__binary_pred(__value, *__first)) {\n      __value = *__first;\n      *++__result = __value;\n    }\n  return ++__result;\n}\n\ntemplate <class _InputIter, class _OutputIter, class _BinaryPredicate>\ninline _OutputIter __unique_copy(_InputIter __first, _InputIter __last,\n                                 _OutputIter __result,\n                                 _BinaryPredicate __binary_pred,\n                                 output_iterator_tag) {\n  return __unique_copy(__first, __last, __result, __binary_pred,\n                       __VALUE_TYPE(__first));\n}\n\ntemplate <class _InputIter, class _ForwardIter, class _BinaryPredicate>\n_ForwardIter __unique_copy(_InputIter __first, _InputIter __last,\n                           _ForwardIter __result, \n                           _BinaryPredicate __binary_pred,\n                           forward_iterator_tag) {\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool,\n     typename iterator_traits<_ForwardIter>::value_type,\n     typename iterator_traits<_InputIter>::value_type);\n  *__result = *__first;\n  while (++__first != __last)\n    if (!__binary_pred(*__result, *__first)) *++__result = *__first;\n  return ++__result;\n}\n\ntemplate <class _InputIter, class _OutputIter, class _BinaryPredicate>\ninline _OutputIter unique_copy(_InputIter __first, _InputIter __last,\n                               _OutputIter __result,\n                               _BinaryPredicate __binary_pred) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  if (__first == __last) return __result;\n  return __unique_copy(__first, __last, __result, __binary_pred,\n                       __ITERATOR_CATEGORY(__result));\n}\n\ntemplate <class _ForwardIter>\n_ForwardIter unique(_ForwardIter __first, _ForwardIter __last) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _EqualityComparable);\n  __first = adjacent_find(__first, __last);\n  return unique_copy(__first, __last, __first);\n}\n\ntemplate <class _ForwardIter, class _BinaryPredicate>\n_ForwardIter unique(_ForwardIter __first, _ForwardIter __last,\n                    _BinaryPredicate __binary_pred) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool, \n      typename iterator_traits<_ForwardIter>::value_type,\n      typename iterator_traits<_ForwardIter>::value_type);\n  __first = adjacent_find(__first, __last, __binary_pred);\n  return unique_copy(__first, __last, __first, __binary_pred);\n}\n\n// reverse and reverse_copy, and their auxiliary functions\n\ntemplate <class _BidirectionalIter>\nvoid __reverse(_BidirectionalIter __first, _BidirectionalIter __last, \n               bidirectional_iterator_tag) {\n  while (true)\n    if (__first == __last || __first == --__last)\n      return;\n    else\n      iter_swap(__first++, __last);\n}\n\ntemplate <class _RandomAccessIter>\nvoid __reverse(_RandomAccessIter __first, _RandomAccessIter __last,\n               random_access_iterator_tag) {\n  while (__first < __last)\n    iter_swap(__first++, --__last);\n}\n\ntemplate <class _BidirectionalIter>\ninline void reverse(_BidirectionalIter __first, _BidirectionalIter __last) {\n  __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator);\n  __reverse(__first, __last, __ITERATOR_CATEGORY(__first));\n}\n\ntemplate <class _BidirectionalIter, class _OutputIter>\n_OutputIter reverse_copy(_BidirectionalIter __first,\n                         _BidirectionalIter __last,\n                         _OutputIter __result) {\n  __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  while (__first != __last) {\n    --__last;\n    *__result = *__last;\n    ++__result;\n  }\n  return __result;\n}\n\n// rotate and rotate_copy, and their auxiliary functions\n\ntemplate <class _EuclideanRingElement>\n_EuclideanRingElement __gcd(_EuclideanRingElement __m,\n                            _EuclideanRingElement __n)\n{\n  while (__n != 0) {\n    _EuclideanRingElement __t = __m % __n;\n    __m = __n;\n    __n = __t;\n  }\n  return __m;\n}\n\ntemplate <class _ForwardIter, class _Distance>\n_ForwardIter __rotate(_ForwardIter __first,\n                      _ForwardIter __middle,\n                      _ForwardIter __last,\n                      _Distance*,\n                      forward_iterator_tag) {\n  if (__first == __middle)\n    return __last;\n  if (__last  == __middle)\n    return __first;\n\n  _ForwardIter __first2 = __middle;\n  do {\n    swap(*__first++, *__first2++);\n    if (__first == __middle)\n      __middle = __first2;\n  } while (__first2 != __last);\n\n  _ForwardIter __new_middle = __first;\n\n  __first2 = __middle;\n\n  while (__first2 != __last) {\n    swap (*__first++, *__first2++);\n    if (__first == __middle)\n      __middle = __first2;\n    else if (__first2 == __last)\n      __first2 = __middle;\n  }\n\n  return __new_middle;\n}\n\n\ntemplate <class _BidirectionalIter, class _Distance>\n_BidirectionalIter __rotate(_BidirectionalIter __first,\n                            _BidirectionalIter __middle,\n                            _BidirectionalIter __last,\n                            _Distance*,\n                            bidirectional_iterator_tag) {\n  __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator);\n  if (__first == __middle)\n    return __last;\n  if (__last  == __middle)\n    return __first;\n\n  __reverse(__first,  __middle, bidirectional_iterator_tag());\n  __reverse(__middle, __last,   bidirectional_iterator_tag());\n\n  while (__first != __middle && __middle != __last)\n    swap (*__first++, *--__last);\n\n  if (__first == __middle) {\n    __reverse(__middle, __last,   bidirectional_iterator_tag());\n    return __last;\n  }\n  else {\n    __reverse(__first,  __middle, bidirectional_iterator_tag());\n    return __first;\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Distance, class _Tp>\n_RandomAccessIter __rotate(_RandomAccessIter __first,\n                           _RandomAccessIter __middle,\n                           _RandomAccessIter __last,\n                           _Distance *, _Tp *) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  _Distance __n = __last   - __first;\n  _Distance __k = __middle - __first;\n  _Distance __l = __n - __k;\n  _RandomAccessIter __result = __first + (__last - __middle);\n\n  if (__k == 0)\n    return __last;\n\n  else if (__k == __l) {\n    swap_ranges(__first, __middle, __middle);\n    return __result;\n  }\n\n  _Distance __d = __gcd(__n, __k);\n\n  for (_Distance __i = 0; __i < __d; __i++) {\n    _Tp __tmp = *__first;\n    _RandomAccessIter __p = __first;\n\n    if (__k < __l) {\n      for (_Distance __j = 0; __j < __l/__d; __j++) {\n        if (__p > __first + __l) {\n          *__p = *(__p - __l);\n          __p -= __l;\n        }\n\n        *__p = *(__p + __k);\n        __p += __k;\n      }\n    }\n\n    else {\n      for (_Distance __j = 0; __j < __k/__d - 1; __j ++) {\n        if (__p < __last - __k) {\n          *__p = *(__p + __k);\n          __p += __k;\n        }\n\n        *__p = * (__p - __l);\n        __p -= __l;\n      }\n    }\n\n    *__p = __tmp;\n    ++__first;\n  }\n\n  return __result;\n}\n\ntemplate <class _ForwardIter>\ninline _ForwardIter rotate(_ForwardIter __first, _ForwardIter __middle,\n                           _ForwardIter __last) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  return __rotate(__first, __middle, __last,\n                  __DISTANCE_TYPE(__first),\n                  __ITERATOR_CATEGORY(__first));\n}\n\ntemplate <class _ForwardIter, class _OutputIter>\n_OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle,\n                        _ForwardIter __last, _OutputIter __result) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  return copy(__first, __middle, copy(__middle, __last, __result));\n}\n\n// Return a random number in the range [0, __n).  This function encapsulates\n// whether we're using rand (part of the standard C library) or lrand48\n// (not standard, but a much better choice whenever it's available).\n\ntemplate <class _Distance>\ninline _Distance __random_number(_Distance __n) {\n#ifdef __STL_NO_DRAND48\n  return rand() % __n;\n#else\n  return lrand48() % __n;\n#endif\n}\n\n// random_shuffle\n\ntemplate <class _RandomAccessIter>\ninline void random_shuffle(_RandomAccessIter __first,\n                           _RandomAccessIter __last) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  if (__first == __last) return;\n  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)\n    iter_swap(__i, __first + __random_number((__i - __first) + 1));\n}\n\ntemplate <class _RandomAccessIter, class _RandomNumberGenerator>\nvoid random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last,\n                    _RandomNumberGenerator& __rand) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  if (__first == __last) return;\n  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)\n    iter_swap(__i, __first + __rand((__i - __first) + 1));\n}\n\n// random_sample and random_sample_n (extensions, not part of the standard).\n\ntemplate <class _ForwardIter, class _OutputIter, class _Distance>\n_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,\n                            _OutputIter __out, const _Distance __n)\n{\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  _Distance __remaining = 0;\n  distance(__first, __last, __remaining);\n  _Distance __m = min(__n, __remaining);\n\n  while (__m > 0) {\n    if (__random_number(__remaining) < __m) {\n      *__out = *__first;\n      ++__out;\n      --__m;\n    }\n\n    --__remaining;\n    ++__first;\n  }\n  return __out;\n}\n\ntemplate <class _ForwardIter, class _OutputIter, class _Distance,\n          class _RandomNumberGenerator>\n_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,\n                            _OutputIter __out, const _Distance __n,\n                            _RandomNumberGenerator& __rand)\n{\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_UNARY_FUNCTION_CHECK(_RandomNumberGenerator, _Distance, _Distance);\n  _Distance __remaining = 0;\n  distance(__first, __last, __remaining);\n  _Distance __m = min(__n, __remaining);\n\n  while (__m > 0) {\n    if (__rand(__remaining) < __m) {\n      *__out = *__first;\n      ++__out;\n      --__m;\n    }\n\n    --__remaining;\n    ++__first;\n  }\n  return __out;\n}\n\ntemplate <class _InputIter, class _RandomAccessIter, class _Distance>\n_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last,\n                                  _RandomAccessIter __out,\n                                  const _Distance __n)\n{\n  _Distance __m = 0;\n  _Distance __t = __n;\n  for ( ; __first != __last && __m < __n; ++__m, ++__first) \n    __out[__m] = *__first;\n\n  while (__first != __last) {\n    ++__t;\n    _Distance __M = __random_number(__t);\n    if (__M < __n)\n      __out[__M] = *__first;\n    ++__first;\n  }\n\n  return __out + __m;\n}\n\ntemplate <class _InputIter, class _RandomAccessIter,\n          class _RandomNumberGenerator, class _Distance>\n_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last,\n                                  _RandomAccessIter __out,\n                                  _RandomNumberGenerator& __rand,\n                                  const _Distance __n)\n{\n  __STL_UNARY_FUNCTION_CHECK(_RandomNumberGenerator, _Distance, _Distance);\n  _Distance __m = 0;\n  _Distance __t = __n;\n  for ( ; __first != __last && __m < __n; ++__m, ++__first)\n    __out[__m] = *__first;\n\n  while (__first != __last) {\n    ++__t;\n    _Distance __M = __rand(__t);\n    if (__M < __n)\n      __out[__M] = *__first;\n    ++__first;\n  }\n\n  return __out + __m;\n}\n\ntemplate <class _InputIter, class _RandomAccessIter>\ninline _RandomAccessIter\nrandom_sample(_InputIter __first, _InputIter __last,\n              _RandomAccessIter __out_first, _RandomAccessIter __out_last) \n{\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  return __random_sample(__first, __last,\n                         __out_first, __out_last - __out_first);\n}\n\n\ntemplate <class _InputIter, class _RandomAccessIter, \n          class _RandomNumberGenerator>\ninline _RandomAccessIter\nrandom_sample(_InputIter __first, _InputIter __last,\n              _RandomAccessIter __out_first, _RandomAccessIter __out_last,\n              _RandomNumberGenerator& __rand) \n{\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  return __random_sample(__first, __last,\n                         __out_first, __rand,\n                         __out_last - __out_first);\n}\n\n// partition, stable_partition, and their auxiliary functions\n\ntemplate <class _ForwardIter, class _Predicate>\n_ForwardIter __partition(_ForwardIter __first,\n\t\t         _ForwardIter __last,\n\t\t\t _Predicate   __pred,\n\t\t\t forward_iterator_tag) {\n  if (__first == __last) return __first;\n\n  while (__pred(*__first))\n    if (++__first == __last) return __first;\n\n  _ForwardIter __next = __first;\n\n  while (++__next != __last)\n    if (__pred(*__next)) {\n      swap(*__first, *__next);\n      ++__first;\n    }\n\n  return __first;\n}\n\ntemplate <class _BidirectionalIter, class _Predicate>\n_BidirectionalIter __partition(_BidirectionalIter __first,\n                               _BidirectionalIter __last,\n\t\t\t       _Predicate __pred,\n\t\t\t       bidirectional_iterator_tag) {\n  while (true) {\n    while (true)\n      if (__first == __last)\n        return __first;\n      else if (__pred(*__first))\n        ++__first;\n      else\n        break;\n    --__last;\n    while (true)\n      if (__first == __last)\n        return __first;\n      else if (!__pred(*__last))\n        --__last;\n      else\n        break;\n    iter_swap(__first, __last);\n    ++__first;\n  }\n}\n\ntemplate <class _ForwardIter, class _Predicate>\ninline _ForwardIter partition(_ForwardIter __first,\n   \t\t\t      _ForwardIter __last,\n\t\t\t      _Predicate   __pred) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool, \n        typename iterator_traits<_ForwardIter>::value_type);\n  return __partition(__first, __last, __pred, __ITERATOR_CATEGORY(__first));\n}\n\n\ntemplate <class _ForwardIter, class _Predicate, class _Distance>\n_ForwardIter __inplace_stable_partition(_ForwardIter __first,\n                                        _ForwardIter __last,\n                                        _Predicate __pred, _Distance __len) {\n  if (__len == 1)\n    return __pred(*__first) ? __last : __first;\n  _ForwardIter __middle = __first;\n  advance(__middle, __len / 2);\n  return rotate(__inplace_stable_partition(__first, __middle, __pred, \n                                           __len / 2),\n                __middle,\n                __inplace_stable_partition(__middle, __last, __pred,\n                                           __len - __len / 2));\n}\n\ntemplate <class _ForwardIter, class _Pointer, class _Predicate, \n          class _Distance>\n_ForwardIter __stable_partition_adaptive(_ForwardIter __first,\n                                         _ForwardIter __last,\n                                         _Predicate __pred, _Distance __len,\n                                         _Pointer __buffer,\n                                         _Distance __buffer_size) \n{\n  if (__len <= __buffer_size) {\n    _ForwardIter __result1 = __first;\n    _Pointer __result2 = __buffer;\n    for ( ; __first != __last ; ++__first)\n      if (__pred(*__first)) {\n        *__result1 = *__first;\n        ++__result1;\n      }\n      else {\n        *__result2 = *__first;\n        ++__result2;\n      }\n    copy(__buffer, __result2, __result1);\n    return __result1;\n  }\n  else {\n    _ForwardIter __middle = __first;\n    advance(__middle, __len / 2);\n    return rotate(__stable_partition_adaptive(\n                          __first, __middle, __pred,\n                          __len / 2, __buffer, __buffer_size),\n                    __middle,\n                    __stable_partition_adaptive(\n                          __middle, __last, __pred,\n                          __len - __len / 2, __buffer, __buffer_size));\n  }\n}\n\ntemplate <class _ForwardIter, class _Predicate, class _Tp, class _Distance>\ninline _ForwardIter\n__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, \n                       _Predicate __pred, _Tp*, _Distance*)\n{\n  _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last);\n  if (__buf.size() > 0)\n    return __stable_partition_adaptive(__first, __last, __pred,\n                                       _Distance(__buf.requested_size()),\n                                       __buf.begin(), __buf.size());\n  else\n    return __inplace_stable_partition(__first, __last, __pred, \n                                      _Distance(__buf.requested_size()));\n}\n\ntemplate <class _ForwardIter, class _Predicate>\ninline _ForwardIter stable_partition(_ForwardIter __first,\n                                     _ForwardIter __last, \n                                     _Predicate __pred) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_UNARY_FUNCTION_CHECK(_Predicate, bool,\n      typename iterator_traits<_ForwardIter>::value_type);\n  if (__first == __last)\n    return __first;\n  else\n    return __stable_partition_aux(__first, __last, __pred,\n                                  __VALUE_TYPE(__first),\n                                  __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Tp>\n_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, \n                                        _RandomAccessIter __last, \n                                        _Tp __pivot) \n{\n  while (true) {\n    while (*__first < __pivot)\n      ++__first;\n    --__last;\n    while (__pivot < *__last)\n      --__last;\n    if (!(__first < __last))\n      return __first;\n    iter_swap(__first, __last);\n    ++__first;\n  }\n}    \n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\n_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, \n                                        _RandomAccessIter __last, \n                                        _Tp __pivot, _Compare __comp) \n{\n  while (true) {\n    while (__comp(*__first, __pivot))\n      ++__first;\n    --__last;\n    while (__comp(__pivot, *__last))\n      --__last;\n    if (!(__first < __last))\n      return __first;\n    iter_swap(__first, __last);\n    ++__first;\n  }\n}\n\nconst int __stl_threshold = 16;\n\n// sort() and its auxiliary functions. \n\ntemplate <class _RandomAccessIter, class _Tp>\nvoid __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val) {\n  _RandomAccessIter __next = __last;\n  --__next;\n  while (__val < *__next) {\n    *__last = *__next;\n    __last = __next;\n    --__next;\n  }\n  *__last = __val;\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\nvoid __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, \n                               _Compare __comp) {\n  _RandomAccessIter __next = __last;\n  --__next;  \n  while (__comp(__val, *__next)) {\n    *__last = *__next;\n    __last = __next;\n    --__next;\n  }\n  *__last = __val;\n}\n\ntemplate <class _RandomAccessIter, class _Tp>\ninline void __linear_insert(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Tp*) {\n  _Tp __val = *__last;\n  if (__val < *__first) {\n    copy_backward(__first, __last, __last + 1);\n    *__first = __val;\n  }\n  else\n    __unguarded_linear_insert(__last, __val);\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\ninline void __linear_insert(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Tp*, _Compare __comp) {\n  _Tp __val = *__last;\n  if (__comp(__val, *__first)) {\n    copy_backward(__first, __last, __last + 1);\n    *__first = __val;\n  }\n  else\n    __unguarded_linear_insert(__last, __val, __comp);\n}\n\ntemplate <class _RandomAccessIter>\nvoid __insertion_sort(_RandomAccessIter __first, _RandomAccessIter __last) {\n  if (__first == __last) return; \n  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)\n    __linear_insert(__first, __i, __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\nvoid __insertion_sort(_RandomAccessIter __first,\n                      _RandomAccessIter __last, _Compare __comp) {\n  if (__first == __last) return;\n  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)\n    __linear_insert(__first, __i, __VALUE_TYPE(__first), __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Tp>\nvoid __unguarded_insertion_sort_aux(_RandomAccessIter __first, \n                                    _RandomAccessIter __last, _Tp*) {\n  for (_RandomAccessIter __i = __first; __i != __last; ++__i)\n    __unguarded_linear_insert(__i, _Tp(*__i));\n}\n\ntemplate <class _RandomAccessIter>\ninline void __unguarded_insertion_sort(_RandomAccessIter __first, \n                                _RandomAccessIter __last) {\n  __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\nvoid __unguarded_insertion_sort_aux(_RandomAccessIter __first, \n                                    _RandomAccessIter __last,\n                                    _Tp*, _Compare __comp) {\n  for (_RandomAccessIter __i = __first; __i != __last; ++__i)\n    __unguarded_linear_insert(__i, _Tp(*__i), __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\ninline void __unguarded_insertion_sort(_RandomAccessIter __first, \n                                       _RandomAccessIter __last,\n                                       _Compare __comp) {\n  __unguarded_insertion_sort_aux(__first, __last, __VALUE_TYPE(__first),\n                                 __comp);\n}\n\ntemplate <class _RandomAccessIter>\nvoid __final_insertion_sort(_RandomAccessIter __first, \n                            _RandomAccessIter __last) {\n  if (__last - __first > __stl_threshold) {\n    __insertion_sort(__first, __first + __stl_threshold);\n    __unguarded_insertion_sort(__first + __stl_threshold, __last);\n  }\n  else\n    __insertion_sort(__first, __last);\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\nvoid __final_insertion_sort(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Compare __comp) {\n  if (__last - __first > __stl_threshold) {\n    __insertion_sort(__first, __first + __stl_threshold, __comp);\n    __unguarded_insertion_sort(__first + __stl_threshold, __last, __comp);\n  }\n  else\n    __insertion_sort(__first, __last, __comp);\n}\n\ntemplate <class _Size>\ninline _Size __lg(_Size __n) {\n  _Size __k;\n  for (__k = 0; __n != 1; __n >>= 1) ++__k;\n  return __k;\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Size>\nvoid __introsort_loop(_RandomAccessIter __first,\n                      _RandomAccessIter __last, _Tp*,\n                      _Size __depth_limit)\n{\n  while (__last - __first > __stl_threshold) {\n    if (__depth_limit == 0) {\n      partial_sort(__first, __last, __last);\n      return;\n    }\n    --__depth_limit;\n    _RandomAccessIter __cut =\n      __unguarded_partition(__first, __last,\n                            _Tp(__median(*__first,\n                                         *(__first + (__last - __first)/2),\n                                         *(__last - 1))));\n    __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit);\n    __last = __cut;\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Size, class _Compare>\nvoid __introsort_loop(_RandomAccessIter __first,\n                      _RandomAccessIter __last, _Tp*,\n                      _Size __depth_limit, _Compare __comp)\n{\n  while (__last - __first > __stl_threshold) {\n    if (__depth_limit == 0) {\n      partial_sort(__first, __last, __last, __comp);\n      return;\n    }\n    --__depth_limit;\n    _RandomAccessIter __cut =\n      __unguarded_partition(__first, __last,\n                            _Tp(__median(*__first,\n                                         *(__first + (__last - __first)/2),\n                                         *(__last - 1), __comp)),\n       __comp);\n    __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit, __comp);\n    __last = __cut;\n  }\n}\n\ntemplate <class _RandomAccessIter>\ninline void sort(_RandomAccessIter __first, _RandomAccessIter __last) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  if (__first != __last) {\n    __introsort_loop(__first, __last,\n                     __VALUE_TYPE(__first),\n                     __lg(__last - __first) * 2);\n    __final_insertion_sort(__first, __last);\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\ninline void sort(_RandomAccessIter __first, _RandomAccessIter __last,\n                 _Compare __comp) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_RandomAccessIter>::value_type,\n       typename iterator_traits<_RandomAccessIter>::value_type);\n  if (__first != __last) {\n    __introsort_loop(__first, __last,\n                     __VALUE_TYPE(__first),\n                     __lg(__last - __first) * 2,\n                     __comp);\n    __final_insertion_sort(__first, __last, __comp);\n  }\n}\n\n// stable_sort() and its auxiliary functions.\n\ntemplate <class _RandomAccessIter>\nvoid __inplace_stable_sort(_RandomAccessIter __first,\n                           _RandomAccessIter __last) {\n  if (__last - __first < 15) {\n    __insertion_sort(__first, __last);\n    return;\n  }\n  _RandomAccessIter __middle = __first + (__last - __first) / 2;\n  __inplace_stable_sort(__first, __middle);\n  __inplace_stable_sort(__middle, __last);\n  __merge_without_buffer(__first, __middle, __last,\n                         __middle - __first,\n                         __last - __middle);\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\nvoid __inplace_stable_sort(_RandomAccessIter __first,\n                           _RandomAccessIter __last, _Compare __comp) {\n  if (__last - __first < 15) {\n    __insertion_sort(__first, __last, __comp);\n    return;\n  }\n  _RandomAccessIter __middle = __first + (__last - __first) / 2;\n  __inplace_stable_sort(__first, __middle, __comp);\n  __inplace_stable_sort(__middle, __last, __comp);\n  __merge_without_buffer(__first, __middle, __last,\n                         __middle - __first,\n                         __last - __middle,\n                         __comp);\n}\n\ntemplate <class _RandomAccessIter1, class _RandomAccessIter2,\n          class _Distance>\nvoid __merge_sort_loop(_RandomAccessIter1 __first,\n                       _RandomAccessIter1 __last, \n                       _RandomAccessIter2 __result, _Distance __step_size) {\n  _Distance __two_step = 2 * __step_size;\n\n  while (__last - __first >= __two_step) {\n    __result = merge(__first, __first + __step_size,\n                     __first + __step_size, __first + __two_step,\n                     __result);\n    __first += __two_step;\n  }\n\n  __step_size = min(_Distance(__last - __first), __step_size);\n  merge(__first, __first + __step_size, __first + __step_size, __last,\n        __result);\n}\n\ntemplate <class _RandomAccessIter1, class _RandomAccessIter2,\n          class _Distance, class _Compare>\nvoid __merge_sort_loop(_RandomAccessIter1 __first,\n                       _RandomAccessIter1 __last, \n                       _RandomAccessIter2 __result, _Distance __step_size,\n                       _Compare __comp) {\n  _Distance __two_step = 2 * __step_size;\n\n  while (__last - __first >= __two_step) {\n    __result = merge(__first, __first + __step_size,\n                     __first + __step_size, __first + __two_step,\n                     __result,\n                     __comp);\n    __first += __two_step;\n  }\n  __step_size = min(_Distance(__last - __first), __step_size);\n\n  merge(__first, __first + __step_size,\n        __first + __step_size, __last,\n        __result,\n        __comp);\n}\n\nconst int __stl_chunk_size = 7;\n        \ntemplate <class _RandomAccessIter, class _Distance>\nvoid __chunk_insertion_sort(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Distance __chunk_size)\n{\n  while (__last - __first >= __chunk_size) {\n    __insertion_sort(__first, __first + __chunk_size);\n    __first += __chunk_size;\n  }\n  __insertion_sort(__first, __last);\n}\n\ntemplate <class _RandomAccessIter, class _Distance, class _Compare>\nvoid __chunk_insertion_sort(_RandomAccessIter __first, \n                            _RandomAccessIter __last,\n                            _Distance __chunk_size, _Compare __comp)\n{\n  while (__last - __first >= __chunk_size) {\n    __insertion_sort(__first, __first + __chunk_size, __comp);\n    __first += __chunk_size;\n  }\n  __insertion_sort(__first, __last, __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Pointer, class _Distance>\nvoid __merge_sort_with_buffer(_RandomAccessIter __first, \n                              _RandomAccessIter __last,\n                              _Pointer __buffer, _Distance*) {\n  _Distance __len = __last - __first;\n  _Pointer __buffer_last = __buffer + __len;\n\n  _Distance __step_size = __stl_chunk_size;\n  __chunk_insertion_sort(__first, __last, __step_size);\n\n  while (__step_size < __len) {\n    __merge_sort_loop(__first, __last, __buffer, __step_size);\n    __step_size *= 2;\n    __merge_sort_loop(__buffer, __buffer_last, __first, __step_size);\n    __step_size *= 2;\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Pointer, class _Distance,\n          class _Compare>\nvoid __merge_sort_with_buffer(_RandomAccessIter __first, \n                              _RandomAccessIter __last, _Pointer __buffer,\n                              _Distance*, _Compare __comp) {\n  _Distance __len = __last - __first;\n  _Pointer __buffer_last = __buffer + __len;\n\n  _Distance __step_size = __stl_chunk_size;\n  __chunk_insertion_sort(__first, __last, __step_size, __comp);\n\n  while (__step_size < __len) {\n    __merge_sort_loop(__first, __last, __buffer, __step_size, __comp);\n    __step_size *= 2;\n    __merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp);\n    __step_size *= 2;\n  }\n}\n\ntemplate <class _RandomAccessIter, class _Pointer, class _Distance>\nvoid __stable_sort_adaptive(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Pointer __buffer,\n                            _Distance __buffer_size) {\n  _Distance __len = (__last - __first + 1) / 2;\n  _RandomAccessIter __middle = __first + __len;\n  if (__len > __buffer_size) {\n    __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size);\n    __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size);\n  }\n  else {\n    __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0);\n    __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0);\n  }\n  __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), \n                   _Distance(__last - __middle), __buffer, __buffer_size);\n}\n\ntemplate <class _RandomAccessIter, class _Pointer, class _Distance, \n          class _Compare>\nvoid __stable_sort_adaptive(_RandomAccessIter __first, \n                            _RandomAccessIter __last, _Pointer __buffer,\n                            _Distance __buffer_size, _Compare __comp) {\n  _Distance __len = (__last - __first + 1) / 2;\n  _RandomAccessIter __middle = __first + __len;\n  if (__len > __buffer_size) {\n    __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, \n                           __comp);\n    __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, \n                           __comp);\n  }\n  else {\n    __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0,\n                               __comp);\n    __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0,\n                               __comp);\n  }\n  __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), \n                   _Distance(__last - __middle), __buffer, __buffer_size,\n                   __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Distance>\ninline void __stable_sort_aux(_RandomAccessIter __first,\n                              _RandomAccessIter __last, _Tp*, _Distance*) {\n  _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last);\n  if (buf.begin() == 0)\n    __inplace_stable_sort(__first, __last);\n  else \n    __stable_sort_adaptive(__first, __last, buf.begin(),\n                           _Distance(buf.size()));\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Distance, class _Compare>\ninline void __stable_sort_aux(_RandomAccessIter __first,\n                              _RandomAccessIter __last, _Tp*, _Distance*,\n                              _Compare __comp) {\n  _Temporary_buffer<_RandomAccessIter, _Tp> buf(__first, __last);\n  if (buf.begin() == 0)\n    __inplace_stable_sort(__first, __last, __comp);\n  else \n    __stable_sort_adaptive(__first, __last, buf.begin(),\n                           _Distance(buf.size()),\n                           __comp);\n}\n\ntemplate <class _RandomAccessIter>\ninline void stable_sort(_RandomAccessIter __first,\n                        _RandomAccessIter __last) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  __stable_sort_aux(__first, __last,\n                    __VALUE_TYPE(__first),\n                    __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\ninline void stable_sort(_RandomAccessIter __first,\n                        _RandomAccessIter __last, _Compare __comp) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_RandomAccessIter>::value_type,\n       typename iterator_traits<_RandomAccessIter>::value_type);\n  __stable_sort_aux(__first, __last,\n                    __VALUE_TYPE(__first),\n                    __DISTANCE_TYPE(__first), \n                    __comp);\n}\n\n// partial_sort, partial_sort_copy, and auxiliary functions.\n\ntemplate <class _RandomAccessIter, class _Tp>\nvoid __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle,\n                    _RandomAccessIter __last, _Tp*) {\n  make_heap(__first, __middle);\n  for (_RandomAccessIter __i = __middle; __i < __last; ++__i)\n    if (*__i < *__first) \n      __pop_heap(__first, __middle, __i, _Tp(*__i),\n                 __DISTANCE_TYPE(__first));\n  sort_heap(__first, __middle);\n}\n\ntemplate <class _RandomAccessIter>\ninline void partial_sort(_RandomAccessIter __first,\n                         _RandomAccessIter __middle,\n                         _RandomAccessIter __last) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\nvoid __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle,\n                    _RandomAccessIter __last, _Tp*, _Compare __comp) {\n  make_heap(__first, __middle, __comp);\n  for (_RandomAccessIter __i = __middle; __i < __last; ++__i)\n    if (__comp(*__i, *__first))\n      __pop_heap(__first, __middle, __i, _Tp(*__i), __comp,\n                 __DISTANCE_TYPE(__first));\n  sort_heap(__first, __middle, __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\ninline void partial_sort(_RandomAccessIter __first,\n                         _RandomAccessIter __middle,\n                         _RandomAccessIter __last, _Compare __comp) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, \n      typename iterator_traits<_RandomAccessIter>::value_type,\n      typename iterator_traits<_RandomAccessIter>::value_type);\n  __partial_sort(__first, __middle, __last, __VALUE_TYPE(__first), __comp);\n}\n\ntemplate <class _InputIter, class _RandomAccessIter, class _Distance,\n          class _Tp>\n_RandomAccessIter __partial_sort_copy(_InputIter __first,\n                                      _InputIter __last,\n                                      _RandomAccessIter __result_first,\n                                      _RandomAccessIter __result_last, \n                                      _Distance*, _Tp*) {\n  if (__result_first == __result_last) return __result_last;\n  _RandomAccessIter __result_real_last = __result_first;\n  while(__first != __last && __result_real_last != __result_last) {\n    *__result_real_last = *__first;\n    ++__result_real_last;\n    ++__first;\n  }\n  make_heap(__result_first, __result_real_last);\n  while (__first != __last) {\n    if (*__first < *__result_first) \n      __adjust_heap(__result_first, _Distance(0),\n                    _Distance(__result_real_last - __result_first),\n                    _Tp(*__first));\n    ++__first;\n  }\n  sort_heap(__result_first, __result_real_last);\n  return __result_real_last;\n}\n\ntemplate <class _InputIter, class _RandomAccessIter>\ninline _RandomAccessIter\npartial_sort_copy(_InputIter __first, _InputIter __last,\n                  _RandomAccessIter __result_first,\n                  _RandomAccessIter __result_last) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_CONVERTIBLE(typename iterator_traits<_InputIter>::value_type,\n                    typename iterator_traits<_RandomAccessIter>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  __STL_REQUIRES(typename iterator_traits<_InputIter>::value_type,\n                 _LessThanComparable);\n  return __partial_sort_copy(__first, __last, __result_first, __result_last, \n                             __DISTANCE_TYPE(__result_first),\n                             __VALUE_TYPE(__first));\n}\n\ntemplate <class _InputIter, class _RandomAccessIter, class _Compare,\n          class _Distance, class _Tp>\n_RandomAccessIter __partial_sort_copy(_InputIter __first,\n                                         _InputIter __last,\n                                         _RandomAccessIter __result_first,\n                                         _RandomAccessIter __result_last,\n                                         _Compare __comp, _Distance*, _Tp*) {\n  if (__result_first == __result_last) return __result_last;\n  _RandomAccessIter __result_real_last = __result_first;\n  while(__first != __last && __result_real_last != __result_last) {\n    *__result_real_last = *__first;\n    ++__result_real_last;\n    ++__first;\n  }\n  make_heap(__result_first, __result_real_last, __comp);\n  while (__first != __last) {\n    if (__comp(*__first, *__result_first))\n      __adjust_heap(__result_first, _Distance(0),\n                    _Distance(__result_real_last - __result_first),\n                    _Tp(*__first),\n                    __comp);\n    ++__first;\n  }\n  sort_heap(__result_first, __result_real_last, __comp);\n  return __result_real_last;\n}\n\ntemplate <class _InputIter, class _RandomAccessIter, class _Compare>\ninline _RandomAccessIter\npartial_sort_copy(_InputIter __first, _InputIter __last,\n                  _RandomAccessIter __result_first,\n                  _RandomAccessIter __result_last, _Compare __comp) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_CONVERTIBLE(typename iterator_traits<_InputIter>::value_type,\n                    typename iterator_traits<_RandomAccessIter>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n     typename iterator_traits<_RandomAccessIter>::value_type,\n     typename iterator_traits<_RandomAccessIter>::value_type);  \n  return __partial_sort_copy(__first, __last, __result_first, __result_last,\n                             __comp,\n                             __DISTANCE_TYPE(__result_first),\n                             __VALUE_TYPE(__first));\n}\n\n// nth_element() and its auxiliary functions.  \n\ntemplate <class _RandomAccessIter, class _Tp>\nvoid __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,\n                   _RandomAccessIter __last, _Tp*) {\n  while (__last - __first > 3) {\n    _RandomAccessIter __cut =\n      __unguarded_partition(__first, __last,\n                            _Tp(__median(*__first,\n                                         *(__first + (__last - __first)/2),\n                                         *(__last - 1))));\n    if (__cut <= __nth)\n      __first = __cut;\n    else \n      __last = __cut;\n  }\n  __insertion_sort(__first, __last);\n}\n\ntemplate <class _RandomAccessIter>\ninline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,\n                        _RandomAccessIter __last) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  __nth_element(__first, __nth, __last, __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIter, class _Tp, class _Compare>\nvoid __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,\n                   _RandomAccessIter __last, _Tp*, _Compare __comp) {\n  while (__last - __first > 3) {\n    _RandomAccessIter __cut =\n      __unguarded_partition(__first, __last,\n                            _Tp(__median(*__first,\n                                         *(__first + (__last - __first)/2), \n                                         *(__last - 1),\n                                         __comp)),\n                            __comp);\n    if (__cut <= __nth)\n      __first = __cut;\n    else \n      __last = __cut;\n  }\n  __insertion_sort(__first, __last, __comp);\n}\n\ntemplate <class _RandomAccessIter, class _Compare>\ninline void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,\n                        _RandomAccessIter __last, _Compare __comp) {\n  __STL_REQUIRES(_RandomAccessIter, _Mutable_RandomAccessIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n     typename iterator_traits<_RandomAccessIter>::value_type,\n     typename iterator_traits<_RandomAccessIter>::value_type);\n  __nth_element(__first, __nth, __last, __VALUE_TYPE(__first), __comp);\n}\n\n\n// Binary search (lower_bound, upper_bound, equal_range, binary_search).\n\ntemplate <class _ForwardIter, class _Tp, class _Distance>\n_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,\n                           const _Tp& __val, _Distance*) \n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (*__middle < __val) {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n    else\n      __len = __half;\n  }\n  return __first;\n}\n\ntemplate <class _ForwardIter, class _Tp>\ninline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,\n\t\t\t\tconst _Tp& __val) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n      typename iterator_traits<_ForwardIter>::value_type);\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  return __lower_bound(__first, __last, __val,\n                       __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare, class _Distance>\n_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,\n                              const _Tp& __val, _Compare __comp, _Distance*)\n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (__comp(*__middle, __val)) {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n    else\n      __len = __half;\n  }\n  return __first;\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare>\ninline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,\n                                const _Tp& __val, _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n      typename iterator_traits<_ForwardIter>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n  return __lower_bound(__first, __last, __val, __comp,\n                       __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Distance>\n_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last,\n                           const _Tp& __val, _Distance*)\n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (__val < *__middle)\n      __len = __half;\n    else {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n  }\n  return __first;\n}\n\ntemplate <class _ForwardIter, class _Tp>\ninline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,\n                                const _Tp& __val) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n      typename iterator_traits<_ForwardIter>::value_type);\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  return __upper_bound(__first, __last, __val,\n                       __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare, class _Distance>\n_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last,\n                           const _Tp& __val, _Compare __comp, _Distance*)\n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (__comp(__val, *__middle))\n      __len = __half;\n    else {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n  }\n  return __first;\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare>\ninline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,\n                                const _Tp& __val, _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n      typename iterator_traits<_ForwardIter>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n  return __upper_bound(__first, __last, __val, __comp,\n                       __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Distance>\npair<_ForwardIter, _ForwardIter>\n__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,\n              _Distance*)\n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle, __left, __right;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (*__middle < __val) {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n    else if (__val < *__middle)\n      __len = __half;\n    else {\n      __left = lower_bound(__first, __middle, __val);\n      advance(__first, __len);\n      __right = upper_bound(++__middle, __first, __val);\n      return pair<_ForwardIter, _ForwardIter>(__left, __right);\n    }\n  }\n  return pair<_ForwardIter, _ForwardIter>(__first, __first);\n}\n\ntemplate <class _ForwardIter, class _Tp>\ninline pair<_ForwardIter, _ForwardIter>\nequal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp, \n       typename iterator_traits<_ForwardIter>::value_type);\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  return __equal_range(__first, __last, __val,\n                       __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare, class _Distance>\npair<_ForwardIter, _ForwardIter>\n__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,\n              _Compare __comp, _Distance*)\n{\n  _Distance __len = 0;\n  distance(__first, __last, __len);\n  _Distance __half;\n  _ForwardIter __middle, __left, __right;\n\n  while (__len > 0) {\n    __half = __len >> 1;\n    __middle = __first;\n    advance(__middle, __half);\n    if (__comp(*__middle, __val)) {\n      __first = __middle;\n      ++__first;\n      __len = __len - __half - 1;\n    }\n    else if (__comp(__val, *__middle))\n      __len = __half;\n    else {\n      __left = lower_bound(__first, __middle, __val, __comp);\n      advance(__first, __len);\n      __right = upper_bound(++__middle, __first, __val, __comp);\n      return pair<_ForwardIter, _ForwardIter>(__left, __right);\n    }\n  }\n  return pair<_ForwardIter, _ForwardIter>(__first, __first);\n}           \n\ntemplate <class _ForwardIter, class _Tp, class _Compare>\ninline pair<_ForwardIter, _ForwardIter>\nequal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,\n            _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp, \n       typename iterator_traits<_ForwardIter>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n  return __equal_range(__first, __last, __val, __comp,\n                       __DISTANCE_TYPE(__first));\n} \n\ntemplate <class _ForwardIter, class _Tp>\nbool binary_search(_ForwardIter __first, _ForwardIter __last,\n                   const _Tp& __val) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n        typename iterator_traits<_ForwardIter>::value_type);\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  _ForwardIter __i = lower_bound(__first, __last, __val);\n  return __i != __last && !(__val < *__i);\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Compare>\nbool binary_search(_ForwardIter __first, _ForwardIter __last,\n                   const _Tp& __val,\n                   _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_SAME_TYPE(_Tp,\n        typename iterator_traits<_ForwardIter>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n  _ForwardIter __i = lower_bound(__first, __last, __val, __comp);\n  return __i != __last && !__comp(__val, *__i);\n}\n\n// merge, with and without an explicitly supplied comparison function.\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter>\n_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,\n                  _InputIter2 __first2, _InputIter2 __last2,\n                  _OutputIter __result) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n          typename iterator_traits<_InputIter1>::value_type,\n          typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2) {\n    if (*__first2 < *__first1) {\n      *__result = *__first2;\n      ++__first2;\n    }\n    else {\n      *__result = *__first1;\n      ++__first1;\n    }\n    ++__result;\n  }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter,\n          class _Compare>\n_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,\n                  _InputIter2 __first2, _InputIter2 __last2,\n                  _OutputIter __result, _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n          typename iterator_traits<_InputIter1>::value_type,\n          typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n          typename iterator_traits<_InputIter1>::value_type,\n          typename iterator_traits<_InputIter1>::value_type);\n  while (__first1 != __last1 && __first2 != __last2) {\n    if (__comp(*__first2, *__first1)) {\n      *__result = *__first2;\n      ++__first2;\n    }\n    else {\n      *__result = *__first1;\n      ++__first1;\n    }\n    ++__result;\n  }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\n// inplace_merge and its auxiliary functions. \n\ntemplate <class _BidirectionalIter, class _Distance>\nvoid __merge_without_buffer(_BidirectionalIter __first,\n                            _BidirectionalIter __middle,\n                            _BidirectionalIter __last,\n                            _Distance __len1, _Distance __len2) {\n  if (__len1 == 0 || __len2 == 0)\n    return;\n  if (__len1 + __len2 == 2) {\n    if (*__middle < *__first)\n      iter_swap(__first, __middle);\n    return;\n  }\n  _BidirectionalIter __first_cut = __first;\n  _BidirectionalIter __second_cut = __middle;\n  _Distance __len11 = 0;\n  _Distance __len22 = 0;\n  if (__len1 > __len2) {\n    __len11 = __len1 / 2;\n    advance(__first_cut, __len11);\n    __second_cut = lower_bound(__middle, __last, *__first_cut);\n    distance(__middle, __second_cut, __len22);\n  }\n  else {\n    __len22 = __len2 / 2;\n    advance(__second_cut, __len22);\n    __first_cut = upper_bound(__first, __middle, *__second_cut);\n    distance(__first, __first_cut, __len11);\n  }\n  _BidirectionalIter __new_middle\n    = rotate(__first_cut, __middle, __second_cut);\n  __merge_without_buffer(__first, __first_cut, __new_middle,\n                         __len11, __len22);\n  __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11,\n                         __len2 - __len22);\n}\n\ntemplate <class _BidirectionalIter, class _Distance, class _Compare>\nvoid __merge_without_buffer(_BidirectionalIter __first,\n                            _BidirectionalIter __middle,\n                            _BidirectionalIter __last,\n                            _Distance __len1, _Distance __len2,\n                            _Compare __comp) {\n  if (__len1 == 0 || __len2 == 0)\n    return;\n  if (__len1 + __len2 == 2) {\n    if (__comp(*__middle, *__first))\n      iter_swap(__first, __middle);\n    return;\n  }\n  _BidirectionalIter __first_cut = __first;\n  _BidirectionalIter __second_cut = __middle;\n  _Distance __len11 = 0;\n  _Distance __len22 = 0;\n  if (__len1 > __len2) {\n    __len11 = __len1 / 2;\n    advance(__first_cut, __len11);\n    __second_cut = lower_bound(__middle, __last, *__first_cut, __comp);\n    distance(__middle, __second_cut, __len22);\n  }\n  else {\n    __len22 = __len2 / 2;\n    advance(__second_cut, __len22);\n    __first_cut = upper_bound(__first, __middle, *__second_cut, __comp);\n    distance(__first, __first_cut, __len11);\n  }\n  _BidirectionalIter __new_middle\n    = rotate(__first_cut, __middle, __second_cut);\n  __merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22,\n                         __comp);\n  __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11,\n                         __len2 - __len22, __comp);\n}\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2,\n          class _Distance>\n_BidirectionalIter1 __rotate_adaptive(_BidirectionalIter1 __first,\n                                      _BidirectionalIter1 __middle,\n                                      _BidirectionalIter1 __last,\n                                      _Distance __len1, _Distance __len2,\n                                      _BidirectionalIter2 __buffer,\n                                      _Distance __buffer_size) {\n  _BidirectionalIter2 __buffer_end;\n  if (__len1 > __len2 && __len2 <= __buffer_size) {\n    __buffer_end = copy(__middle, __last, __buffer);\n    copy_backward(__first, __middle, __last);\n    return copy(__buffer, __buffer_end, __first);\n  }\n  else if (__len1 <= __buffer_size) {\n    __buffer_end = copy(__first, __middle, __buffer);\n    copy(__middle, __last, __first);\n    return copy_backward(__buffer, __buffer_end, __last);\n  }\n  else\n    return rotate(__first, __middle, __last);\n}\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2,\n          class _BidirectionalIter3>\n_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1,\n                                     _BidirectionalIter1 __last1,\n                                     _BidirectionalIter2 __first2,\n                                     _BidirectionalIter2 __last2,\n                                     _BidirectionalIter3 __result) {\n  if (__first1 == __last1)\n    return copy_backward(__first2, __last2, __result);\n  if (__first2 == __last2)\n    return copy_backward(__first1, __last1, __result);\n  --__last1;\n  --__last2;\n  while (true) {\n    if (*__last2 < *__last1) {\n      *--__result = *__last1;\n      if (__first1 == __last1)\n        return copy_backward(__first2, ++__last2, __result);\n      --__last1;\n    }\n    else {\n      *--__result = *__last2;\n      if (__first2 == __last2)\n        return copy_backward(__first1, ++__last1, __result);\n      --__last2;\n    }\n  }\n}\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2,\n          class _BidirectionalIter3, class _Compare>\n_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1,\n                                     _BidirectionalIter1 __last1,\n                                     _BidirectionalIter2 __first2,\n                                     _BidirectionalIter2 __last2,\n                                     _BidirectionalIter3 __result,\n                                     _Compare __comp) {\n  if (__first1 == __last1)\n    return copy_backward(__first2, __last2, __result);\n  if (__first2 == __last2)\n    return copy_backward(__first1, __last1, __result);\n  --__last1;\n  --__last2;\n  while (true) {\n    if (__comp(*__last2, *__last1)) {\n      *--__result = *__last1;\n      if (__first1 == __last1)\n        return copy_backward(__first2, ++__last2, __result);\n      --__last1;\n    }\n    else {\n      *--__result = *__last2;\n      if (__first2 == __last2)\n        return copy_backward(__first1, ++__last1, __result);\n      --__last2;\n    }\n  }\n}\n\ntemplate <class _BidirectionalIter, class _Distance, class _Pointer>\nvoid __merge_adaptive(_BidirectionalIter __first,\n                      _BidirectionalIter __middle, \n                      _BidirectionalIter __last,\n                      _Distance __len1, _Distance __len2,\n                      _Pointer __buffer, _Distance __buffer_size) {\n  if (__len1 <= __len2 && __len1 <= __buffer_size) {\n    _Pointer __buffer_end = copy(__first, __middle, __buffer);\n    merge(__buffer, __buffer_end, __middle, __last, __first);\n  }\n  else if (__len2 <= __buffer_size) {\n    _Pointer __buffer_end = copy(__middle, __last, __buffer);\n    __merge_backward(__first, __middle, __buffer, __buffer_end, __last);\n  }\n  else {\n    _BidirectionalIter __first_cut = __first;\n    _BidirectionalIter __second_cut = __middle;\n    _Distance __len11 = 0;\n    _Distance __len22 = 0;\n    if (__len1 > __len2) {\n      __len11 = __len1 / 2;\n      advance(__first_cut, __len11);\n      __second_cut = lower_bound(__middle, __last, *__first_cut);\n      distance(__middle, __second_cut, __len22); \n    }\n    else {\n      __len22 = __len2 / 2;\n      advance(__second_cut, __len22);\n      __first_cut = upper_bound(__first, __middle, *__second_cut);\n      distance(__first, __first_cut, __len11);\n    }\n    _BidirectionalIter __new_middle =\n      __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11,\n                        __len22, __buffer, __buffer_size);\n    __merge_adaptive(__first, __first_cut, __new_middle, __len11,\n                     __len22, __buffer, __buffer_size);\n    __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11,\n                     __len2 - __len22, __buffer, __buffer_size);\n  }\n}\n\ntemplate <class _BidirectionalIter, class _Distance, class _Pointer,\n          class _Compare>\nvoid __merge_adaptive(_BidirectionalIter __first, \n                      _BidirectionalIter __middle, \n                      _BidirectionalIter __last,\n                      _Distance __len1, _Distance __len2,\n                      _Pointer __buffer, _Distance __buffer_size,\n                      _Compare __comp) {\n  if (__len1 <= __len2 && __len1 <= __buffer_size) {\n    _Pointer __buffer_end = copy(__first, __middle, __buffer);\n    merge(__buffer, __buffer_end, __middle, __last, __first, __comp);\n  }\n  else if (__len2 <= __buffer_size) {\n    _Pointer __buffer_end = copy(__middle, __last, __buffer);\n    __merge_backward(__first, __middle, __buffer, __buffer_end, __last,\n                     __comp);\n  }\n  else {\n    _BidirectionalIter __first_cut = __first;\n    _BidirectionalIter __second_cut = __middle;\n    _Distance __len11 = 0;\n    _Distance __len22 = 0;\n    if (__len1 > __len2) {\n      __len11 = __len1 / 2;\n      advance(__first_cut, __len11);\n      __second_cut = lower_bound(__middle, __last, *__first_cut, __comp);\n      distance(__middle, __second_cut, __len22);   \n    }\n    else {\n      __len22 = __len2 / 2;\n      advance(__second_cut, __len22);\n      __first_cut = upper_bound(__first, __middle, *__second_cut, __comp);\n      distance(__first, __first_cut, __len11);\n    }\n    _BidirectionalIter __new_middle =\n      __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11,\n                        __len22, __buffer, __buffer_size);\n    __merge_adaptive(__first, __first_cut, __new_middle, __len11,\n                     __len22, __buffer, __buffer_size, __comp);\n    __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11,\n                     __len2 - __len22, __buffer, __buffer_size, __comp);\n  }\n}\n\ntemplate <class _BidirectionalIter, class _Tp, class _Distance>\ninline void __inplace_merge_aux(_BidirectionalIter __first,\n                                _BidirectionalIter __middle,\n                                _BidirectionalIter __last, _Tp*, _Distance*) {\n  _Distance __len1 = 0;\n  distance(__first, __middle, __len1);\n  _Distance __len2 = 0;\n  distance(__middle, __last, __len2);\n\n  _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last);\n  if (__buf.begin() == 0)\n    __merge_without_buffer(__first, __middle, __last, __len1, __len2);\n  else\n    __merge_adaptive(__first, __middle, __last, __len1, __len2,\n                     __buf.begin(), _Distance(__buf.size()));\n}\n\ntemplate <class _BidirectionalIter, class _Tp, \n          class _Distance, class _Compare>\ninline void __inplace_merge_aux(_BidirectionalIter __first,\n                                _BidirectionalIter __middle,\n                                _BidirectionalIter __last, _Tp*, _Distance*,\n                                _Compare __comp) {\n  _Distance __len1 = 0;\n  distance(__first, __middle, __len1);\n  _Distance __len2 = 0;\n  distance(__middle, __last, __len2);\n\n  _Temporary_buffer<_BidirectionalIter, _Tp> __buf(__first, __last);\n  if (__buf.begin() == 0)\n    __merge_without_buffer(__first, __middle, __last, __len1, __len2, __comp);\n  else\n    __merge_adaptive(__first, __middle, __last, __len1, __len2,\n                     __buf.begin(), _Distance(__buf.size()),\n                     __comp);\n}\n\ntemplate <class _BidirectionalIter>\ninline void inplace_merge(_BidirectionalIter __first,\n                          _BidirectionalIter __middle,\n                          _BidirectionalIter __last) {\n  __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator);\n  __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __middle || __middle == __last)\n    return;\n  __inplace_merge_aux(__first, __middle, __last,\n                      __VALUE_TYPE(__first), __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _BidirectionalIter, class _Compare>\ninline void inplace_merge(_BidirectionalIter __first,\n                          _BidirectionalIter __middle,\n                          _BidirectionalIter __last, _Compare __comp) {\n  __STL_REQUIRES(_BidirectionalIter, _Mutable_BidirectionalIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n           typename iterator_traits<_BidirectionalIter>::value_type,\n           typename iterator_traits<_BidirectionalIter>::value_type);\n  if (__first == __middle || __middle == __last)\n    return;\n  __inplace_merge_aux(__first, __middle, __last,\n                      __VALUE_TYPE(__first), __DISTANCE_TYPE(__first),\n                      __comp);\n}\n\n// Set algorithms: includes, set_union, set_intersection, set_difference,\n// set_symmetric_difference.  All of these algorithms have the precondition\n// that their input ranges are sorted and the postcondition that their output\n// ranges are sorted.\n\ntemplate <class _InputIter1, class _InputIter2>\nbool includes(_InputIter1 __first1, _InputIter1 __last1,\n              _InputIter2 __first2, _InputIter2 __last2) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2)\n    if (*__first2 < *__first1)\n      return false;\n    else if(*__first1 < *__first2) \n      ++__first1;\n    else\n      ++__first1, ++__first2;\n\n  return __first2 == __last2;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _Compare>\nbool includes(_InputIter1 __first1, _InputIter1 __last1,\n              _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  while (__first1 != __last1 && __first2 != __last2)\n    if (__comp(*__first2, *__first1))\n      return false;\n    else if(__comp(*__first1, *__first2)) \n      ++__first1;\n    else\n      ++__first1, ++__first2;\n\n  return __first2 == __last2;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter>\n_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,\n                      _InputIter2 __first2, _InputIter2 __last2,\n                      _OutputIter __result) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2) {\n    if (*__first1 < *__first2) {\n      *__result = *__first1;\n      ++__first1;\n    }\n    else if (*__first2 < *__first1) {\n      *__result = *__first2;\n      ++__first2;\n    }\n    else {\n      *__result = *__first1;\n      ++__first1;\n      ++__first2;\n    }\n    ++__result;\n  }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter,\n          class _Compare>\n_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,\n                      _InputIter2 __first2, _InputIter2 __last2,\n                      _OutputIter __result, _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  while (__first1 != __last1 && __first2 != __last2) {\n    if (__comp(*__first1, *__first2)) {\n      *__result = *__first1;\n      ++__first1;\n    }\n    else if (__comp(*__first2, *__first1)) {\n      *__result = *__first2;\n      ++__first2;\n    }\n    else {\n      *__result = *__first1;\n      ++__first1;\n      ++__first2;\n    }\n    ++__result;\n  }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter>\n_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,\n                             _InputIter2 __first2, _InputIter2 __last2,\n                             _OutputIter __result) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2) \n    if (*__first1 < *__first2) \n      ++__first1;\n    else if (*__first2 < *__first1) \n      ++__first2;\n    else {\n      *__result = *__first1;\n      ++__first1;\n      ++__first2;\n      ++__result;\n    }\n  return __result;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter,\n          class _Compare>\n_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,\n                             _InputIter2 __first2, _InputIter2 __last2,\n                             _OutputIter __result, _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n\n  while (__first1 != __last1 && __first2 != __last2)\n    if (__comp(*__first1, *__first2))\n      ++__first1;\n    else if (__comp(*__first2, *__first1))\n      ++__first2;\n    else {\n      *__result = *__first1;\n      ++__first1;\n      ++__first2;\n      ++__result;\n    }\n  return __result;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter>\n_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,\n                           _InputIter2 __first2, _InputIter2 __last2,\n                           _OutputIter __result) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2)\n    if (*__first1 < *__first2) {\n      *__result = *__first1;\n      ++__first1;\n      ++__result;\n    }\n    else if (*__first2 < *__first1)\n      ++__first2;\n    else {\n      ++__first1;\n      ++__first2;\n    }\n  return copy(__first1, __last1, __result);\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter, \n          class _Compare>\n_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,\n                           _InputIter2 __first2, _InputIter2 __last2, \n                           _OutputIter __result, _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n\n  while (__first1 != __last1 && __first2 != __last2)\n    if (__comp(*__first1, *__first2)) {\n      *__result = *__first1;\n      ++__first1;\n      ++__result;\n    }\n    else if (__comp(*__first2, *__first1))\n      ++__first2;\n    else {\n      ++__first1;\n      ++__first2;\n    }\n  return copy(__first1, __last1, __result);\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter>\n_OutputIter \nset_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,\n                         _InputIter2 __first2, _InputIter2 __last2,\n                         _OutputIter __result) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  while (__first1 != __last1 && __first2 != __last2)\n    if (*__first1 < *__first2) {\n      *__result = *__first1;\n      ++__first1;\n      ++__result;\n    }\n    else if (*__first2 < *__first1) {\n      *__result = *__first2;\n      ++__first2;\n      ++__result;\n    }\n    else {\n      ++__first1;\n      ++__first2;\n    }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _OutputIter,\n          class _Compare>\n_OutputIter \nset_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,\n                         _InputIter2 __first2, _InputIter2 __last2,\n                         _OutputIter __result,\n                         _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  __STL_REQUIRES_SAME_TYPE(\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n       typename iterator_traits<_InputIter1>::value_type,\n       typename iterator_traits<_InputIter2>::value_type);\n  while (__first1 != __last1 && __first2 != __last2)\n    if (__comp(*__first1, *__first2)) {\n      *__result = *__first1;\n      ++__first1;\n      ++__result;\n    }\n    else if (__comp(*__first2, *__first1)) {\n      *__result = *__first2;\n      ++__first2;\n      ++__result;\n    }\n    else {\n      ++__first1;\n      ++__first2;\n    }\n  return copy(__first2, __last2, copy(__first1, __last1, __result));\n}\n\n// min_element and max_element, with and without an explicitly supplied\n// comparison function.\n\ntemplate <class _ForwardIter>\n_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __last) return __first;\n  _ForwardIter __result = __first;\n  while (++__first != __last) \n    if (*__result < *__first)\n      __result = __first;\n  return __result;\n}\n\ntemplate <class _ForwardIter, class _Compare>\n_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last,\n\t\t\t _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n    typename iterator_traits<_ForwardIter>::value_type,\n    typename iterator_traits<_ForwardIter>::value_type);\n  if (__first == __last) return __first;\n  _ForwardIter __result = __first;\n  while (++__first != __last) \n    if (__comp(*__result, *__first)) __result = __first;\n  return __result;\n}\n\ntemplate <class _ForwardIter>\n_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __last) return __first;\n  _ForwardIter __result = __first;\n  while (++__first != __last) \n    if (*__first < *__result)\n      __result = __first;\n  return __result;\n}\n\ntemplate <class _ForwardIter, class _Compare>\n_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last,\n\t\t\t _Compare __comp) {\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n    typename iterator_traits<_ForwardIter>::value_type,\n    typename iterator_traits<_ForwardIter>::value_type);\n  if (__first == __last) return __first;\n  _ForwardIter __result = __first;\n  while (++__first != __last) \n    if (__comp(*__first, *__result))\n      __result = __first;\n  return __result;\n}\n\n// next_permutation and prev_permutation, with and without an explicitly \n// supplied comparison function.\n\ntemplate <class _BidirectionalIter>\nbool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last) {\n  __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator);\n  __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __last)\n    return false;\n  _BidirectionalIter __i = __first;\n  ++__i;\n  if (__i == __last)\n    return false;\n  __i = __last;\n  --__i;\n\n  for(;;) {\n    _BidirectionalIter __ii = __i;\n    --__i;\n    if (*__i < *__ii) {\n      _BidirectionalIter __j = __last;\n      while (!(*__i < *--__j))\n        {}\n      iter_swap(__i, __j);\n      reverse(__ii, __last);\n      return true;\n    }\n    if (__i == __first) {\n      reverse(__first, __last);\n      return false;\n    }\n  }\n}\n\ntemplate <class _BidirectionalIter, class _Compare>\nbool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last,\n                      _Compare __comp) {\n  __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n    typename iterator_traits<_BidirectionalIter>::value_type,\n    typename iterator_traits<_BidirectionalIter>::value_type);\n  if (__first == __last)\n    return false;\n  _BidirectionalIter __i = __first;\n  ++__i;\n  if (__i == __last)\n    return false;\n  __i = __last;\n  --__i;\n\n  for(;;) {\n    _BidirectionalIter __ii = __i;\n    --__i;\n    if (__comp(*__i, *__ii)) {\n      _BidirectionalIter __j = __last;\n      while (!__comp(*__i, *--__j))\n        {}\n      iter_swap(__i, __j);\n      reverse(__ii, __last);\n      return true;\n    }\n    if (__i == __first) {\n      reverse(__first, __last);\n      return false;\n    }\n  }\n}\n\ntemplate <class _BidirectionalIter>\nbool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last) {\n  __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator);\n  __STL_REQUIRES(typename iterator_traits<_BidirectionalIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __last)\n    return false;\n  _BidirectionalIter __i = __first;\n  ++__i;\n  if (__i == __last)\n    return false;\n  __i = __last;\n  --__i;\n\n  for(;;) {\n    _BidirectionalIter __ii = __i;\n    --__i;\n    if (*__ii < *__i) {\n      _BidirectionalIter __j = __last;\n      while (!(*--__j < *__i))\n        {}\n      iter_swap(__i, __j);\n      reverse(__ii, __last);\n      return true;\n    }\n    if (__i == __first) {\n      reverse(__first, __last);\n      return false;\n    }\n  }\n}\n\ntemplate <class _BidirectionalIter, class _Compare>\nbool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,\n                      _Compare __comp) {\n  __STL_REQUIRES(_BidirectionalIter, _BidirectionalIterator);\n  __STL_BINARY_FUNCTION_CHECK(_Compare, bool,\n    typename iterator_traits<_BidirectionalIter>::value_type,\n    typename iterator_traits<_BidirectionalIter>::value_type);\n  if (__first == __last)\n    return false;\n  _BidirectionalIter __i = __first;\n  ++__i;\n  if (__i == __last)\n    return false;\n  __i = __last;\n  --__i;\n\n  for(;;) {\n    _BidirectionalIter __ii = __i;\n    --__i;\n    if (__comp(*__ii, *__i)) {\n      _BidirectionalIter __j = __last;\n      while (!__comp(*--__j, *__i))\n        {}\n      iter_swap(__i, __j);\n      reverse(__ii, __last);\n      return true;\n    }\n    if (__i == __first) {\n      reverse(__first, __last);\n      return false;\n    }\n  }\n}\n\n// find_first_of, with and without an explicitly supplied comparison function.\n\ntemplate <class _InputIter, class _ForwardIter>\n_InputIter find_first_of(_InputIter __first1, _InputIter __last1,\n                         _ForwardIter __first2, _ForwardIter __last2)\n{\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool, \n     typename iterator_traits<_InputIter>::value_type,\n     typename iterator_traits<_ForwardIter>::value_type);\n\n  for ( ; __first1 != __last1; ++__first1) \n    for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter)\n      if (*__first1 == *__iter)\n        return __first1;\n  return __last1;\n}\n\ntemplate <class _InputIter, class _ForwardIter, class _BinaryPredicate>\n_InputIter find_first_of(_InputIter __first1, _InputIter __last1,\n                         _ForwardIter __first2, _ForwardIter __last2,\n                         _BinaryPredicate __comp)\n{\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool,\n     typename iterator_traits<_InputIter>::value_type,\n     typename iterator_traits<_ForwardIter>::value_type);\n\n  for ( ; __first1 != __last1; ++__first1) \n    for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter)\n      if (__comp(*__first1, *__iter))\n        return __first1;\n  return __last1;\n}\n\n\n// find_end, with and without an explicitly supplied comparison function.\n// Search [first2, last2) as a subsequence in [first1, last1), and return\n// the *last* possible match.  Note that find_end for bidirectional iterators\n// is much faster than for forward iterators.\n\n// find_end for forward iterators. \ntemplate <class _ForwardIter1, class _ForwardIter2>\n_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,\n                         _ForwardIter2 __first2, _ForwardIter2 __last2,\n                         forward_iterator_tag, forward_iterator_tag)\n{\n  if (__first2 == __last2)\n    return __last1;\n  else {\n    _ForwardIter1 __result = __last1;\n    while (1) {\n      _ForwardIter1 __new_result\n        = search(__first1, __last1, __first2, __last2);\n      if (__new_result == __last1)\n        return __result;\n      else {\n        __result = __new_result;\n        __first1 = __new_result;\n        ++__first1;\n      }\n    }\n  }\n}\n\ntemplate <class _ForwardIter1, class _ForwardIter2,\n          class _BinaryPredicate>\n_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,\n                         _ForwardIter2 __first2, _ForwardIter2 __last2,\n                         forward_iterator_tag, forward_iterator_tag,\n                         _BinaryPredicate __comp)\n{\n  if (__first2 == __last2)\n    return __last1;\n  else {\n    _ForwardIter1 __result = __last1;\n    while (1) {\n      _ForwardIter1 __new_result\n        = search(__first1, __last1, __first2, __last2, __comp);\n      if (__new_result == __last1)\n        return __result;\n      else {\n        __result = __new_result;\n        __first1 = __new_result;\n        ++__first1;\n      }\n    }\n  }\n}\n\n// find_end for bidirectional iterators.  Requires partial specialization.\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2>\n_BidirectionalIter1\n__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1,\n           _BidirectionalIter2 __first2, _BidirectionalIter2 __last2,\n           bidirectional_iterator_tag, bidirectional_iterator_tag)\n{\n  __STL_REQUIRES(_BidirectionalIter1, _BidirectionalIterator);\n  __STL_REQUIRES(_BidirectionalIter2, _BidirectionalIterator);\n  typedef reverse_iterator<_BidirectionalIter1> _RevIter1;\n  typedef reverse_iterator<_BidirectionalIter2> _RevIter2;\n\n  _RevIter1 __rlast1(__first1);\n  _RevIter2 __rlast2(__first2);\n  _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1,\n                               _RevIter2(__last2), __rlast2);\n\n  if (__rresult == __rlast1)\n    return __last1;\n  else {\n    _BidirectionalIter1 __result = __rresult.base();\n    advance(__result, -distance(__first2, __last2));\n    return __result;\n  }\n}\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2,\n          class _BinaryPredicate>\n_BidirectionalIter1\n__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1,\n           _BidirectionalIter2 __first2, _BidirectionalIter2 __last2,\n           bidirectional_iterator_tag, bidirectional_iterator_tag, \n           _BinaryPredicate __comp)\n{\n  __STL_REQUIRES(_BidirectionalIter1, _BidirectionalIterator);\n  __STL_REQUIRES(_BidirectionalIter2, _BidirectionalIterator);\n  typedef reverse_iterator<_BidirectionalIter1> _RevIter1;\n  typedef reverse_iterator<_BidirectionalIter2> _RevIter2;\n\n  _RevIter1 __rlast1(__first1);\n  _RevIter2 __rlast2(__first2);\n  _RevIter1 __rresult = search(_RevIter1(__last1), __rlast1,\n                               _RevIter2(__last2), __rlast2,\n                               __comp);\n\n  if (__rresult == __rlast1)\n    return __last1;\n  else {\n    _BidirectionalIter1 __result = __rresult.base();\n    advance(__result, -distance(__first2, __last2));\n    return __result;\n  }\n}\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Dispatching functions for find_end.\n\ntemplate <class _ForwardIter1, class _ForwardIter2>\ninline _ForwardIter1 \nfind_end(_ForwardIter1 __first1, _ForwardIter1 __last1, \n         _ForwardIter2 __first2, _ForwardIter2 __last2)\n{\n  __STL_REQUIRES(_ForwardIter1, _ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _ForwardIterator);\n  __STL_REQUIRES_BINARY_OP(_OP_EQUAL, bool,\n   typename iterator_traits<_ForwardIter1>::value_type,\n   typename iterator_traits<_ForwardIter2>::value_type);\n  return __find_end(__first1, __last1, __first2, __last2,\n                    __ITERATOR_CATEGORY(__first1),\n                    __ITERATOR_CATEGORY(__first2));\n}\n\ntemplate <class _ForwardIter1, class _ForwardIter2, \n          class _BinaryPredicate>\ninline _ForwardIter1 \nfind_end(_ForwardIter1 __first1, _ForwardIter1 __last1, \n         _ForwardIter2 __first2, _ForwardIter2 __last2,\n         _BinaryPredicate __comp)\n{\n  __STL_REQUIRES(_ForwardIter1, _ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_BinaryPredicate, bool,\n   typename iterator_traits<_ForwardIter1>::value_type,\n   typename iterator_traits<_ForwardIter2>::value_type);\n\n  return __find_end(__first1, __last1, __first2, __last2,\n                    __ITERATOR_CATEGORY(__first1),\n                    __ITERATOR_CATEGORY(__first2),\n                    __comp);\n}\n\n// is_heap, a predicate testing whether or not a range is\n// a heap.  This function is an extension, not part of the C++\n// standard.\n\ntemplate <class _RandomAccessIter, class _Distance>\nbool __is_heap(_RandomAccessIter __first, _Distance __n)\n{\n  _Distance __parent = 0;\n  for (_Distance __child = 1; __child < __n; ++__child) {\n    if (__first[__parent] < __first[__child]) \n      return false;\n    if ((__child & 1) == 0)\n      ++__parent;\n  }\n  return true;\n}\n\ntemplate <class _RandomAccessIter, class _Distance, class _StrictWeakOrdering>\nbool __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp,\n               _Distance __n)\n{\n  _Distance __parent = 0;\n  for (_Distance __child = 1; __child < __n; ++__child) {\n    if (__comp(__first[__parent], __first[__child]))\n      return false;\n    if ((__child & 1) == 0)\n      ++__parent;\n  }\n  return true;\n}\n\ntemplate <class _RandomAccessIter>\ninline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last)\n{\n  __STL_REQUIRES(_RandomAccessIter, _RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIter>::value_type,\n                 _LessThanComparable);\n  return __is_heap(__first, __last - __first);\n}\n\n\ntemplate <class _RandomAccessIter, class _StrictWeakOrdering>\ninline bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last,\n                    _StrictWeakOrdering __comp)\n{\n  __STL_REQUIRES(_RandomAccessIter, _RandomAccessIterator);\n  __STL_BINARY_FUNCTION_CHECK(_StrictWeakOrdering, bool, \n         typename iterator_traits<_RandomAccessIter>::value_type, \n         typename iterator_traits<_RandomAccessIter>::value_type);\n  return __is_heap(__first, __comp, __last - __first);\n}\n\n// is_sorted, a predicated testing whether a range is sorted in\n// nondescending order.  This is an extension, not part of the C++\n// standard.\n\ntemplate <class _ForwardIter>\nbool is_sorted(_ForwardIter __first, _ForwardIter __last)\n{\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_REQUIRES(typename iterator_traits<_ForwardIter>::value_type,\n                 _LessThanComparable);\n  if (__first == __last)\n    return true;\n\n  _ForwardIter __next = __first;\n  for (++__next; __next != __last; __first = __next, ++__next) {\n    if (*__next < *__first)\n      return false;\n  }\n\n  return true;\n}\n\ntemplate <class _ForwardIter, class _StrictWeakOrdering>\nbool is_sorted(_ForwardIter __first, _ForwardIter __last,\n               _StrictWeakOrdering __comp)\n{\n  __STL_REQUIRES(_ForwardIter, _ForwardIterator);\n  __STL_BINARY_FUNCTION_CHECK(_StrictWeakOrdering, bool, \n        typename iterator_traits<_ForwardIter>::value_type,\n        typename iterator_traits<_ForwardIter>::value_type);\n  if (__first == __last)\n    return true;\n\n  _ForwardIter __next = __first;\n  for (++__next; __next != __last; __first = __next, ++__next) {\n    if (__comp(*__next, *__first))\n      return false;\n  }\n\n  return true;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1209\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ALGO_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_algobase.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n\n#ifndef __SGI_STL_INTERNAL_ALGOBASE_H\n#define __SGI_STL_INTERNAL_ALGOBASE_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#include <stl_pair.h>\n#endif\n#ifndef __TYPE_TRAITS_H\n#include <type_traits.h>\n#endif\n\n#include <string.h>\n#include <limits.h>\n#include <stdlib.h>\n#include <stddef.h>\n#include <new.h>\n\n#ifdef __STL_USE_NEW_IOSTREAMS \n#include <iosfwd>\n#else /* __STL_USE_NEW_IOSTREAMS */\n#include <iostream.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#include <stl_iterator_base.h>\n#include <stl_iterator.h>\n#endif\n\n// We pick up concept_checks.h from stl_iterator_base.h.\n\n__STL_BEGIN_NAMESPACE\n\n// swap and iter_swap\n\ntemplate <class _ForwardIter1, class _ForwardIter2, class _Tp>\ninline void __iter_swap(_ForwardIter1 __a, _ForwardIter2 __b, _Tp*) {\n  _Tp __tmp = *__a;\n  *__a = *__b;\n  *__b = __tmp;\n}\n\ntemplate <class _ForwardIter1, class _ForwardIter2>\ninline void iter_swap(_ForwardIter1 __a, _ForwardIter2 __b) {\n  __STL_REQUIRES(_ForwardIter1, _Mutable_ForwardIterator);\n  __STL_REQUIRES(_ForwardIter2, _Mutable_ForwardIterator);\n  __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter1>::value_type,\n                    typename iterator_traits<_ForwardIter2>::value_type);\n  __STL_CONVERTIBLE(typename iterator_traits<_ForwardIter2>::value_type,\n                    typename iterator_traits<_ForwardIter1>::value_type);\n  __iter_swap(__a, __b, __VALUE_TYPE(__a));\n}\n\ntemplate <class _Tp>\ninline void swap(_Tp& __a, _Tp& __b) {\n  __STL_REQUIRES(_Tp, _Assignable);\n  _Tp __tmp = __a;\n  __a = __b;\n  __b = __tmp;\n}\n\n//--------------------------------------------------\n// min and max\n\n#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */\n\n#undef min\n#undef max\n\ntemplate <class _Tp>\ninline const _Tp& min(const _Tp& __a, const _Tp& __b) {\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  return __b < __a ? __b : __a;\n}\n\ntemplate <class _Tp>\ninline const _Tp& max(const _Tp& __a, const _Tp& __b) {\n  __STL_REQUIRES(_Tp, _LessThanComparable);\n  return  __a < __b ? __b : __a;\n}\n\n#endif /* __BORLANDC__ */\n\ntemplate <class _Tp, class _Compare>\ninline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) {\n  return __comp(__b, __a) ? __b : __a;\n}\n\ntemplate <class _Tp, class _Compare>\ninline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) {\n  return __comp(__a, __b) ? __b : __a;\n}\n\n//--------------------------------------------------\n// copy\n\n// All of these auxiliary functions serve two purposes.  (1) Replace\n// calls to copy with memmove whenever possible.  (Memmove, not memcpy,\n// because the input and output ranges are permitted to overlap.)\n// (2) If we're using random access iterators, then write the loop as\n// a for loop with an explicit count.\n\ntemplate <class _InputIter, class _OutputIter, class _Distance>\ninline _OutputIter __copy(_InputIter __first, _InputIter __last,\n                          _OutputIter __result,\n                          input_iterator_tag, _Distance*)\n{\n  for ( ; __first != __last; ++__result, ++__first)\n    *__result = *__first;\n  return __result;\n}\n\ntemplate <class _RandomAccessIter, class _OutputIter, class _Distance>\ninline _OutputIter\n__copy(_RandomAccessIter __first, _RandomAccessIter __last,\n       _OutputIter __result, random_access_iterator_tag, _Distance*)\n{\n  for (_Distance __n = __last - __first; __n > 0; --__n) {\n    *__result = *__first;\n    ++__first;\n    ++__result;\n  }\n  return __result;\n}\n\ntemplate <class _Tp>\ninline _Tp*\n__copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result) {\n  memmove(__result, __first, sizeof(_Tp) * (__last - __first));\n  return __result + (__last - __first);\n}\n\n#if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER)\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last,\n                               _OutputIter __result, __false_type) {\n  return __copy(__first, __last, __result,\n                __ITERATOR_CATEGORY(__first),\n                __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter __copy_aux2(_InputIter __first, _InputIter __last,\n                               _OutputIter __result, __true_type) {\n  return __copy(__first, __last, __result,\n                __ITERATOR_CATEGORY(__first),\n                __DISTANCE_TYPE(__first));\n}\n\n#ifndef __USLC__\n\ntemplate <class _Tp>\ninline _Tp* __copy_aux2(_Tp* __first, _Tp* __last, _Tp* __result,\n                        __true_type) {\n  return __copy_trivial(__first, __last, __result);\n}\n\n#endif /* __USLC__ */\n\ntemplate <class _Tp>\ninline _Tp* __copy_aux2(const _Tp* __first, const _Tp* __last, _Tp* __result,\n                        __true_type) {\n  return __copy_trivial(__first, __last, __result);\n}\n\n\ntemplate <class _InputIter, class _OutputIter, class _Tp>\ninline _OutputIter __copy_aux(_InputIter __first, _InputIter __last,\n                              _OutputIter __result, _Tp*) {\n  typedef typename __type_traits<_Tp>::has_trivial_assignment_operator\n          _Trivial;\n  return __copy_aux2(__first, __last, __result, _Trivial());\n}\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter copy(_InputIter __first, _InputIter __last,\n                        _OutputIter __result) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  return __copy_aux(__first, __last, __result, __VALUE_TYPE(__first));\n}\n\n// Hack for compilers that don't have partial ordering of function templates\n// but do have partial specialization of class templates.\n#elif defined(__STL_CLASS_PARTIAL_SPECIALIZATION)\n\ntemplate <class _InputIter, class _OutputIter, class _BoolType>\nstruct __copy_dispatch {\n  static _OutputIter copy(_InputIter __first, _InputIter __last,\n                          _OutputIter __result) {\n    typedef typename iterator_traits<_InputIter>::iterator_category _Category;\n    typedef typename iterator_traits<_InputIter>::difference_type _Distance;\n    return __copy(__first, __last, __result, _Category(), (_Distance*) 0);\n  }\n};\n\ntemplate <class _Tp>\nstruct __copy_dispatch<_Tp*, _Tp*, __true_type>\n{\n  static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {\n    return __copy_trivial(__first, __last, __result);\n  }\n};\n\ntemplate <class _Tp>\nstruct __copy_dispatch<const _Tp*, _Tp*, __true_type>\n{\n  static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {\n    return __copy_trivial(__first, __last, __result);\n  }\n};\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter copy(_InputIter __first, _InputIter __last,\n                        _OutputIter __result) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  typedef typename iterator_traits<_InputIter>::value_type _Tp;\n  typedef typename __type_traits<_Tp>::has_trivial_assignment_operator\n          _Trivial;\n  return __copy_dispatch<_InputIter, _OutputIter, _Trivial>\n    ::copy(__first, __last, __result);\n}\n\n// Fallback for compilers with neither partial ordering nor partial\n// specialization.  Define the faster version for the basic builtin\n// types.\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _InputIter, class _OutputIter>\ninline _OutputIter copy(_InputIter __first, _InputIter __last,\n                        _OutputIter __result)\n{\n  return __copy(__first, __last, __result,\n                __ITERATOR_CATEGORY(__first),\n                __DISTANCE_TYPE(__first));\n}\n\n#define __SGI_STL_DECLARE_COPY_TRIVIAL(_Tp)                                \\\n  inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) { \\\n    memmove(__result, __first, sizeof(_Tp) * (__last - __first));          \\\n    return __result + (__last - __first);                                  \\\n  }\n\n__SGI_STL_DECLARE_COPY_TRIVIAL(char)\n__SGI_STL_DECLARE_COPY_TRIVIAL(signed char)\n__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned char)\n__SGI_STL_DECLARE_COPY_TRIVIAL(short)\n__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned short)\n__SGI_STL_DECLARE_COPY_TRIVIAL(int)\n__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned int)\n__SGI_STL_DECLARE_COPY_TRIVIAL(long)\n__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned long)\n#ifdef __STL_HAS_WCHAR_T\n__SGI_STL_DECLARE_COPY_TRIVIAL(wchar_t)\n#endif\n#ifdef _STL_LONG_LONG\n__SGI_STL_DECLARE_COPY_TRIVIAL(long long)\n__SGI_STL_DECLARE_COPY_TRIVIAL(unsigned long long)\n#endif \n__SGI_STL_DECLARE_COPY_TRIVIAL(float)\n__SGI_STL_DECLARE_COPY_TRIVIAL(double)\n__SGI_STL_DECLARE_COPY_TRIVIAL(long double)\n\n#undef __SGI_STL_DECLARE_COPY_TRIVIAL\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n//--------------------------------------------------\n// copy_backward\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2, \n          class _Distance>\ninline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, \n                                           _BidirectionalIter1 __last, \n                                           _BidirectionalIter2 __result,\n                                           bidirectional_iterator_tag,\n                                           _Distance*)\n{\n  while (__first != __last)\n    *--__result = *--__last;\n  return __result;\n}\n\ntemplate <class _RandomAccessIter, class _BidirectionalIter, class _Distance>\ninline _BidirectionalIter __copy_backward(_RandomAccessIter __first, \n                                          _RandomAccessIter __last, \n                                          _BidirectionalIter __result,\n                                          random_access_iterator_tag,\n                                          _Distance*)\n{\n  for (_Distance __n = __last - __first; __n > 0; --__n)\n    *--__result = *--__last;\n  return __result;\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION \n\n// This dispatch class is a workaround for compilers that do not \n// have partial ordering of function templates.  All we're doing is\n// creating a specialization so that we can turn a call to copy_backward\n// into a memmove whenever possible.\n\ntemplate <class _BidirectionalIter1, class _BidirectionalIter2,\n          class _BoolType>\nstruct __copy_backward_dispatch\n{\n  typedef typename iterator_traits<_BidirectionalIter1>::iterator_category \n          _Cat;\n  typedef typename iterator_traits<_BidirectionalIter1>::difference_type\n          _Distance;\n\n  static _BidirectionalIter2 copy(_BidirectionalIter1 __first, \n                                  _BidirectionalIter1 __last, \n                                  _BidirectionalIter2 __result) {\n    return __copy_backward(__first, __last, __result, _Cat(), (_Distance*) 0);\n  }\n};\n\ntemplate <class _Tp>\nstruct __copy_backward_dispatch<_Tp*, _Tp*, __true_type>\n{\n  static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {\n    const ptrdiff_t _Num = __last - __first;\n    memmove(__result - _Num, __first, sizeof(_Tp) * _Num);\n    return __result - _Num;\n  }\n};\n\ntemplate <class _Tp>\nstruct __copy_backward_dispatch<const _Tp*, _Tp*, __true_type>\n{\n  static _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) {\n    return  __copy_backward_dispatch<_Tp*, _Tp*, __true_type>\n      ::copy(__first, __last, __result);\n  }\n};\n\ntemplate <class _BI1, class _BI2>\ninline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) {\n  __STL_REQUIRES(_BI1, _BidirectionalIterator);\n  __STL_REQUIRES(_BI2, _Mutable_BidirectionalIterator);\n  __STL_CONVERTIBLE(typename iterator_traits<_BI1>::value_type,\n                    typename iterator_traits<_BI2>::value_type);\n  typedef typename __type_traits<typename iterator_traits<_BI2>::value_type>\n                        ::has_trivial_assignment_operator\n          _Trivial;\n  return __copy_backward_dispatch<_BI1, _BI2, _Trivial>\n              ::copy(__first, __last, __result);\n}\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _BI1, class _BI2>\ninline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) {\n  return __copy_backward(__first, __last, __result,\n                         __ITERATOR_CATEGORY(__first),\n                         __DISTANCE_TYPE(__first));\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n//--------------------------------------------------\n// copy_n (not part of the C++ standard)\n\ntemplate <class _InputIter, class _Size, class _OutputIter>\npair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,\n                                       _OutputIter __result,\n                                       input_iterator_tag) {\n  for ( ; __count > 0; --__count) {\n    *__result = *__first;\n    ++__first;\n    ++__result;\n  }\n  return pair<_InputIter, _OutputIter>(__first, __result);\n}\n\ntemplate <class _RAIter, class _Size, class _OutputIter>\ninline pair<_RAIter, _OutputIter>\n__copy_n(_RAIter __first, _Size __count,\n         _OutputIter __result,\n         random_access_iterator_tag) {\n  _RAIter __last = __first + __count;\n  return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));\n}\n\ntemplate <class _InputIter, class _Size, class _OutputIter>\ninline pair<_InputIter, _OutputIter>\n__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {\n  return __copy_n(__first, __count, __result,\n                  __ITERATOR_CATEGORY(__first));\n}\n\ntemplate <class _InputIter, class _Size, class _OutputIter>\ninline pair<_InputIter, _OutputIter>\ncopy_n(_InputIter __first, _Size __count, _OutputIter __result) {\n  __STL_REQUIRES(_InputIter, _InputIterator);\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  return __copy_n(__first, __count, __result);\n}\n\n//--------------------------------------------------\n// fill and fill_n\n\n\ntemplate <class _ForwardIter, class _Tp>\nvoid fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value) {\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  for ( ; __first != __last; ++__first)\n    *__first = __value;\n}\n\ntemplate <class _OutputIter, class _Size, class _Tp>\n_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __value) {\n  __STL_REQUIRES(_OutputIter, _OutputIterator);\n  for ( ; __n > 0; --__n, ++__first)\n    *__first = __value;\n  return __first;\n}\n\n// Specialization: for one-byte types we can use memset.\n\ninline void fill(unsigned char* __first, unsigned char* __last,\n                 const unsigned char& __c) {\n  unsigned char __tmp = __c;\n  memset(__first, __tmp, __last - __first);\n}\n\ninline void fill(signed char* __first, signed char* __last,\n                 const signed char& __c) {\n  signed char __tmp = __c;\n  memset(__first, static_cast<unsigned char>(__tmp), __last - __first);\n}\n\ninline void fill(char* __first, char* __last, const char& __c) {\n  char __tmp = __c;\n  memset(__first, static_cast<unsigned char>(__tmp), __last - __first);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Size>\ninline unsigned char* fill_n(unsigned char* __first, _Size __n,\n                             const unsigned char& __c) {\n  fill(__first, __first + __n, __c);\n  return __first + __n;\n}\n\ntemplate <class _Size>\ninline signed char* fill_n(char* __first, _Size __n,\n                           const signed char& __c) {\n  fill(__first, __first + __n, __c);\n  return __first + __n;\n}\n\ntemplate <class _Size>\ninline char* fill_n(char* __first, _Size __n, const char& __c) {\n  fill(__first, __first + __n, __c);\n  return __first + __n;\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n//--------------------------------------------------\n// equal and mismatch\n\ntemplate <class _InputIter1, class _InputIter2>\npair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,\n                                        _InputIter1 __last1,\n                                        _InputIter2 __first2) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _EqualityComparable);\n  __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type,\n                 _EqualityComparable);\n  while (__first1 != __last1 && *__first1 == *__first2) {\n    ++__first1;\n    ++__first2;\n  }\n  return pair<_InputIter1, _InputIter2>(__first1, __first2);\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _BinaryPredicate>\npair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,\n                                        _InputIter1 __last1,\n                                        _InputIter2 __first2,\n                                        _BinaryPredicate __binary_pred) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {\n    ++__first1;\n    ++__first2;\n  }\n  return pair<_InputIter1, _InputIter2>(__first1, __first2);\n}\n\ntemplate <class _InputIter1, class _InputIter2>\ninline bool equal(_InputIter1 __first1, _InputIter1 __last1,\n                  _InputIter2 __first2) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _EqualityComparable);\n  __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type,\n                 _EqualityComparable);\n  for ( ; __first1 != __last1; ++__first1, ++__first2)\n    if (*__first1 != *__first2)\n      return false;\n  return true;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _BinaryPredicate>\ninline bool equal(_InputIter1 __first1, _InputIter1 __last1,\n                  _InputIter2 __first2, _BinaryPredicate __binary_pred) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  for ( ; __first1 != __last1; ++__first1, ++__first2)\n    if (!__binary_pred(*__first1, *__first2))\n      return false;\n  return true;\n}\n\n//--------------------------------------------------\n// lexicographical_compare and lexicographical_compare_3way.\n// (the latter is not part of the C++ standard.)\n\ntemplate <class _InputIter1, class _InputIter2>\nbool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,\n                             _InputIter2 __first2, _InputIter2 __last2) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type,\n                 _LessThanComparable);\n  for ( ; __first1 != __last1 && __first2 != __last2\n        ; ++__first1, ++__first2) {\n    if (*__first1 < *__first2)\n      return true;\n    if (*__first2 < *__first1)\n      return false;\n  }\n  return __first1 == __last1 && __first2 != __last2;\n}\n\ntemplate <class _InputIter1, class _InputIter2, class _Compare>\nbool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,\n                             _InputIter2 __first2, _InputIter2 __last2,\n                             _Compare __comp) {\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  for ( ; __first1 != __last1 && __first2 != __last2\n        ; ++__first1, ++__first2) {\n    if (__comp(*__first1, *__first2))\n      return true;\n    if (__comp(*__first2, *__first1))\n      return false;\n  }\n  return __first1 == __last1 && __first2 != __last2;\n}\n\ninline bool \nlexicographical_compare(const unsigned char* __first1,\n                        const unsigned char* __last1,\n                        const unsigned char* __first2,\n                        const unsigned char* __last2)\n{\n  const size_t __len1 = __last1 - __first1;\n  const size_t __len2 = __last2 - __first2;\n  const int __result = memcmp(__first1, __first2, min(__len1, __len2));\n  return __result != 0 ? __result < 0 : __len1 < __len2;\n}\n\ninline bool lexicographical_compare(const char* __first1, const char* __last1,\n                                    const char* __first2, const char* __last2)\n{\n#if CHAR_MAX == SCHAR_MAX\n  return lexicographical_compare((const signed char*) __first1,\n                                 (const signed char*) __last1,\n                                 (const signed char*) __first2,\n                                 (const signed char*) __last2);\n#else /* CHAR_MAX == SCHAR_MAX */\n  return lexicographical_compare((const unsigned char*) __first1,\n                                 (const unsigned char*) __last1,\n                                 (const unsigned char*) __first2,\n                                 (const unsigned char*) __last2);\n#endif /* CHAR_MAX == SCHAR_MAX */\n}\n\ntemplate <class _InputIter1, class _InputIter2>\nint __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,\n                                   _InputIter2 __first2, _InputIter2 __last2)\n{\n  while (__first1 != __last1 && __first2 != __last2) {\n    if (*__first1 < *__first2)\n      return -1;\n    if (*__first2 < *__first1)\n      return 1;\n    ++__first1;\n    ++__first2;\n  }\n  if (__first2 == __last2) {\n    return !(__first1 == __last1);\n  }\n  else {\n    return -1;\n  }\n}\n\ninline int\n__lexicographical_compare_3way(const unsigned char* __first1,\n                               const unsigned char* __last1,\n                               const unsigned char* __first2,\n                               const unsigned char* __last2)\n{\n  const ptrdiff_t __len1 = __last1 - __first1;\n  const ptrdiff_t __len2 = __last2 - __first2;\n  const int __result = memcmp(__first1, __first2, min(__len1, __len2));\n  return __result != 0 ? __result \n                       : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));\n}\n\ninline int \n__lexicographical_compare_3way(const char* __first1, const char* __last1,\n                               const char* __first2, const char* __last2)\n{\n#if CHAR_MAX == SCHAR_MAX\n  return __lexicographical_compare_3way(\n                                (const signed char*) __first1,\n                                (const signed char*) __last1,\n                                (const signed char*) __first2,\n                                (const signed char*) __last2);\n#else\n  return __lexicographical_compare_3way((const unsigned char*) __first1,\n                                        (const unsigned char*) __last1,\n                                        (const unsigned char*) __first2,\n                                        (const unsigned char*) __last2);\n#endif\n}\n\ntemplate <class _InputIter1, class _InputIter2>\nint lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,\n                                 _InputIter2 __first2, _InputIter2 __last2)\n{\n  __STL_REQUIRES(_InputIter1, _InputIterator);\n  __STL_REQUIRES(_InputIter2, _InputIterator);\n  __STL_REQUIRES(typename iterator_traits<_InputIter1>::value_type,\n                 _LessThanComparable);\n  __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type,\n                 _LessThanComparable);\n  return __lexicographical_compare_3way(__first1, __last1, __first2, __last2);\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ALLOC_H\n#define __SGI_STL_INTERNAL_ALLOC_H\n\n#ifdef __SUNPRO_CC\n#  define __PRIVATE public\n   // Extra access restrictions prevent us from really making some things\n   // private.\n#else\n#  define __PRIVATE private\n#endif\n\n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\n#  define __USE_MALLOC\n#endif\n\n\n// This implements some standard node allocators.  These are\n// NOT the same as the allocators in the C++ draft standard or in\n// in the original STL.  They do not encapsulate different pointer\n// types; indeed we assume that there is only one pointer type.\n// The allocation primitives are intended to allocate individual objects,\n// not larger arenas as with the original STL allocators.\n\n#ifndef __THROW_BAD_ALLOC\n#  if defined(__STL_NO_BAD_ALLOC) || !defined(__STL_USE_EXCEPTIONS)\n#    include <stdio.h>\n#    include <stdlib.h>\n#    define __THROW_BAD_ALLOC fprintf(stderr, \"out of memory\\n\"); exit(1)\n#  else /* Standard conforming out-of-memory handling */\n#    include <new>\n#    define __THROW_BAD_ALLOC throw std::bad_alloc()\n#  endif\n#endif\n\n#include <stddef.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#ifndef __RESTRICT\n#  define __RESTRICT\n#endif\n\n#ifdef __STL_THREADS\n# include <stl_threads.h>\n# define __NODE_ALLOCATOR_THREADS true\n# ifdef __STL_SGI_THREADS\n  // We test whether threads are in use before locking.\n  // Perhaps this should be moved into stl_threads.h, but that\n  // probably makes it harder to avoid the procedure call when\n  // it isn't needed.\n    extern \"C\" {\n      extern int __us_rsthread_malloc;\n    }\n\t// The above is copied from malloc.h.  Including <malloc.h>\n\t// would be cleaner but fails with certain levels of standard\n\t// conformance.\n#   define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \\\n                { _S_node_allocator_lock._M_acquire_lock(); }\n#   define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \\\n                { _S_node_allocator_lock._M_release_lock(); }\n# else /* !__STL_SGI_THREADS */\n#   define __NODE_ALLOCATOR_LOCK \\\n        { if (threads) _S_node_allocator_lock._M_acquire_lock(); }\n#   define __NODE_ALLOCATOR_UNLOCK \\\n        { if (threads) _S_node_allocator_lock._M_release_lock(); }\n# endif\n#else\n//  Thread-unsafe\n#   define __NODE_ALLOCATOR_LOCK\n#   define __NODE_ALLOCATOR_UNLOCK\n#   define __NODE_ALLOCATOR_THREADS false\n#endif\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// Malloc-based allocator.  Typically slower than default alloc below.\n// Typically thread-safe and more storage efficient.\n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\n# ifdef __DECLARE_GLOBALS_HERE\n    void (* __malloc_alloc_oom_handler)() = 0;\n    // g++ 2.7.2 does not handle static template data members.\n# else\n    extern void (* __malloc_alloc_oom_handler)();\n# endif\n#endif\n\ntemplate <int __inst>\nclass __malloc_alloc_template {\n\nprivate:\n\n  static void* _S_oom_malloc(size_t);\n  static void* _S_oom_realloc(void*, size_t);\n\n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG\n  static void (* __malloc_alloc_oom_handler)();\n#endif\n\npublic:\n\n  static void* allocate(size_t __n)\n  {\n    void* __result = malloc(__n);\n    if (0 == __result) __result = _S_oom_malloc(__n);\n    return __result;\n  }\n\n  static void deallocate(void* __p, size_t /* __n */)\n  {\n    free(__p);\n  }\n\n  static void* reallocate(void* __p, size_t /* old_sz */, size_t __new_sz)\n  {\n    void* __result = realloc(__p, __new_sz);\n    if (0 == __result) __result = _S_oom_realloc(__p, __new_sz);\n    return __result;\n  }\n\n  static void (* __set_malloc_handler(void (*__f)()))()\n  {\n    void (* __old)() = __malloc_alloc_oom_handler;\n    __malloc_alloc_oom_handler = __f;\n    return(__old);\n  }\n\n};\n\n// malloc_alloc out-of-memory handling\n\n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG\ntemplate <int __inst>\nvoid (* __malloc_alloc_template<__inst>::__malloc_alloc_oom_handler)() = 0;\n#endif\n\ntemplate <int __inst>\nvoid*\n__malloc_alloc_template<__inst>::_S_oom_malloc(size_t __n)\n{\n    void (* __my_malloc_handler)();\n    void* __result;\n\n    for (;;) {\n        __my_malloc_handler = __malloc_alloc_oom_handler;\n        if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; }\n        (*__my_malloc_handler)();\n        __result = malloc(__n);\n        if (__result) return(__result);\n    }\n}\n\ntemplate <int __inst>\nvoid* __malloc_alloc_template<__inst>::_S_oom_realloc(void* __p, size_t __n)\n{\n    void (* __my_malloc_handler)();\n    void* __result;\n\n    for (;;) {\n        __my_malloc_handler = __malloc_alloc_oom_handler;\n        if (0 == __my_malloc_handler) { __THROW_BAD_ALLOC; }\n        (*__my_malloc_handler)();\n        __result = realloc(__p, __n);\n        if (__result) return(__result);\n    }\n}\n\ntypedef __malloc_alloc_template<0> malloc_alloc;\n\ntemplate<class _Tp, class _Alloc>\nclass simple_alloc {\n\npublic:\n    static _Tp* allocate(size_t __n)\n      { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }\n    static _Tp* allocate(void)\n      { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }\n    static void deallocate(_Tp* __p, size_t __n)\n      { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }\n    static void deallocate(_Tp* __p)\n      { _Alloc::deallocate(__p, sizeof (_Tp)); }\n};\n\n// Allocator adaptor to check size arguments for debugging.\n// Reports errors using assert.  Checking can be disabled with\n// NDEBUG, but it's far better to just use the underlying allocator\n// instead when no checking is desired.\n// There is some evidence that this can confuse Purify.\ntemplate <class _Alloc>\nclass debug_alloc {\n\nprivate:\n\n  enum {_S_extra = 8};  // Size of space used to store size.  Note\n                        // that this must be large enough to preserve\n                        // alignment.\n\npublic:\n\n  static void* allocate(size_t __n)\n  {\n    char* __result = (char*)_Alloc::allocate(__n + (int) _S_extra);\n    *(size_t*)__result = __n;\n    return __result + (int) _S_extra;\n  }\n\n  static void deallocate(void* __p, size_t __n)\n  {\n    char* __real_p = (char*)__p - (int) _S_extra;\n    assert(*(size_t*)__real_p == __n);\n    _Alloc::deallocate(__real_p, __n + (int) _S_extra);\n  }\n\n  static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz)\n  {\n    char* __real_p = (char*)__p - (int) _S_extra;\n    assert(*(size_t*)__real_p == __old_sz);\n    char* __result = (char*)\n      _Alloc::reallocate(__real_p, __old_sz + (int) _S_extra,\n                                   __new_sz + (int) _S_extra);\n    *(size_t*)__result = __new_sz;\n    return __result + (int) _S_extra;\n  }\n\n};\n\n\n# ifdef __USE_MALLOC\n\ntypedef malloc_alloc alloc;\ntypedef malloc_alloc single_client_alloc;\n\n# else\n\n\n// Default node allocator.\n// With a reasonable compiler, this should be roughly as fast as the\n// original STL class-specific allocators, but with less fragmentation.\n// Default_alloc_template parameters are experimental and MAY\n// DISAPPEAR in the future.  Clients should just use alloc for now.\n//\n// Important implementation properties:\n// 1. If the client request an object of size > _MAX_BYTES, the resulting\n//    object will be obtained directly from malloc.\n// 2. In all other cases, we allocate an object of size exactly\n//    _S_round_up(requested_size).  Thus the client has enough size\n//    information that we can return the object to the proper free list\n//    without permanently losing part of the object.\n//\n\n// The first template parameter specifies whether more than one thread\n// may use this allocator.  It is safe to allocate an object from\n// one instance of a default_alloc and deallocate it with another\n// one.  This effectively transfers its ownership to the second one.\n// This may have undesirable effects on reference locality.\n// The second parameter is unreferenced and serves only to allow the\n// creation of multiple default_alloc instances.\n// Node that containers built on different allocator instances have\n// different types, limiting the utility of this approach.\n\n#if defined(__SUNPRO_CC) || defined(__GNUC__)\n// breaks if we make these template class members:\n  enum {_ALIGN = 8};\n  enum {_MAX_BYTES = 128};\n  enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN\n#endif\n\ntemplate <bool threads, int inst>\nclass __default_alloc_template {\n\nprivate:\n  // Really we should use static const int x = N\n  // instead of enum { x = N }, but few compilers accept the former.\n#if ! (defined(__SUNPRO_CC) || defined(__GNUC__))\n    enum {_ALIGN = 8};\n    enum {_MAX_BYTES = 128};\n    enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN\n# endif\n  static size_t\n  _S_round_up(size_t __bytes) \n    { return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); }\n\n__PRIVATE:\n  union _Obj {\n        union _Obj* _M_free_list_link;\n        char _M_client_data[1];    /* The client sees this.        */\n  };\nprivate:\n# if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC)\n    static _Obj* __STL_VOLATILE _S_free_list[]; \n        // Specifying a size results in duplicate def for 4.1\n# else\n    static _Obj* __STL_VOLATILE _S_free_list[_NFREELISTS]; \n# endif\n  static  size_t _S_freelist_index(size_t __bytes) {\n        return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1);\n  }\n\n  // Returns an object of size __n, and optionally adds to size __n free list.\n  static void* _S_refill(size_t __n);\n  // Allocates a chunk for nobjs of size size.  nobjs may be reduced\n  // if it is inconvenient to allocate the requested number.\n  static char* _S_chunk_alloc(size_t __size, int& __nobjs);\n\n  // Chunk allocation state.\n  static char* _S_start_free;\n  static char* _S_end_free;\n  static size_t _S_heap_size;\n\n# ifdef __STL_THREADS\n    static _STL_mutex_lock _S_node_allocator_lock;\n# endif\n\n    // It would be nice to use _STL_auto_lock here.  But we\n    // don't need the NULL check.  And we do need a test whether\n    // threads have actually been started.\n    class _Lock;\n    friend class _Lock;\n    class _Lock {\n        public:\n            _Lock() { __NODE_ALLOCATOR_LOCK; }\n            ~_Lock() { __NODE_ALLOCATOR_UNLOCK; }\n    };\n\npublic:\n\n  /* __n must be > 0      */\n  static void* allocate(size_t __n)\n  {\n    void* __ret = 0;\n\n    if (__n > (size_t) _MAX_BYTES) {\n      __ret = malloc_alloc::allocate(__n);\n    }\n    else {\n      _Obj* __STL_VOLATILE* __my_free_list\n          = _S_free_list + _S_freelist_index(__n);\n      // Acquire the lock here with a constructor call.\n      // This ensures that it is released in exit or during stack\n      // unwinding.\n#     ifndef _NOTHREADS\n      /*REFERENCED*/\n      _Lock __lock_instance;\n#     endif\n      _Obj* __RESTRICT __result = *__my_free_list;\n      if (__result == 0)\n        __ret = _S_refill(_S_round_up(__n));\n      else {\n        *__my_free_list = __result -> _M_free_list_link;\n        __ret = __result;\n      }\n    }\n\n    return __ret;\n  };\n\n  /* __p may not be 0 */\n  static void deallocate(void* __p, size_t __n)\n  {\n    if (__n > (size_t) _MAX_BYTES)\n      malloc_alloc::deallocate(__p, __n);\n    else {\n      _Obj* __STL_VOLATILE*  __my_free_list\n          = _S_free_list + _S_freelist_index(__n);\n      _Obj* __q = (_Obj*)__p;\n\n      // acquire lock\n#       ifndef _NOTHREADS\n      /*REFERENCED*/\n      _Lock __lock_instance;\n#       endif /* _NOTHREADS */\n      __q -> _M_free_list_link = *__my_free_list;\n      *__my_free_list = __q;\n      // lock is released here\n    }\n  }\n\n  static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz);\n\n} ;\n\ntypedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;\ntypedef __default_alloc_template<false, 0> single_client_alloc;\n\ntemplate <bool __threads, int __inst>\ninline bool operator==(const __default_alloc_template<__threads, __inst>&,\n                       const __default_alloc_template<__threads, __inst>&)\n{\n  return true;\n}\n\n# ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\ntemplate <bool __threads, int __inst>\ninline bool operator!=(const __default_alloc_template<__threads, __inst>&,\n                       const __default_alloc_template<__threads, __inst>&)\n{\n  return false;\n}\n# endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\n\n/* We allocate memory in large chunks in order to avoid fragmenting     */\n/* the malloc heap too much.                                            */\n/* We assume that size is properly aligned.                             */\n/* We hold the allocation lock.                                         */\ntemplate <bool __threads, int __inst>\nchar*\n__default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size, \n                                                            int& __nobjs)\n{\n    char* __result;\n    size_t __total_bytes = __size * __nobjs;\n    size_t __bytes_left = _S_end_free - _S_start_free;\n\n    if (__bytes_left >= __total_bytes) {\n        __result = _S_start_free;\n        _S_start_free += __total_bytes;\n        return(__result);\n    } else if (__bytes_left >= __size) {\n        __nobjs = (int)(__bytes_left/__size);\n        __total_bytes = __size * __nobjs;\n        __result = _S_start_free;\n        _S_start_free += __total_bytes;\n        return(__result);\n    } else {\n        size_t __bytes_to_get = \n\t  2 * __total_bytes + _S_round_up(_S_heap_size >> 4);\n        // Try to make use of the left-over piece.\n        if (__bytes_left > 0) {\n            _Obj* __STL_VOLATILE* __my_free_list =\n                        _S_free_list + _S_freelist_index(__bytes_left);\n\n            ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;\n            *__my_free_list = (_Obj*)_S_start_free;\n        }\n        _S_start_free = (char*)malloc(__bytes_to_get);\n        if (0 == _S_start_free) {\n            size_t __i;\n            _Obj* __STL_VOLATILE* __my_free_list;\n\t    _Obj* __p;\n            // Try to make do with what we have.  That can't\n            // hurt.  We do not try smaller requests, since that tends\n            // to result in disaster on multi-process machines.\n            for (__i = __size;\n                 __i <= (size_t) _MAX_BYTES;\n                 __i += (size_t) _ALIGN) {\n                __my_free_list = _S_free_list + _S_freelist_index(__i);\n                __p = *__my_free_list;\n                if (0 != __p) {\n                    *__my_free_list = __p -> _M_free_list_link;\n                    _S_start_free = (char*)__p;\n                    _S_end_free = _S_start_free + __i;\n                    return(_S_chunk_alloc(__size, __nobjs));\n                    // Any leftover piece will eventually make it to the\n                    // right free list.\n                }\n            }\n\t    _S_end_free = 0;\t// In case of exception.\n            _S_start_free = (char*)malloc_alloc::allocate(__bytes_to_get);\n            // This should either throw an\n            // exception or remedy the situation.  Thus we assume it\n            // succeeded.\n        }\n        _S_heap_size += __bytes_to_get;\n        _S_end_free = _S_start_free + __bytes_to_get;\n        return(_S_chunk_alloc(__size, __nobjs));\n    }\n}\n\n\n/* Returns an object of size __n, and optionally adds to size __n free list.*/\n/* We assume that __n is properly aligned.                                */\n/* We hold the allocation lock.                                         */\ntemplate <bool __threads, int __inst>\nvoid*\n__default_alloc_template<__threads, __inst>::_S_refill(size_t __n)\n{\n    int __nobjs = 20;\n    char* __chunk = _S_chunk_alloc(__n, __nobjs);\n    _Obj* __STL_VOLATILE* __my_free_list;\n    _Obj* __result;\n    _Obj* __current_obj;\n    _Obj* __next_obj;\n    int __i;\n\n    if (1 == __nobjs) return(__chunk);\n    __my_free_list = _S_free_list + _S_freelist_index(__n);\n\n    /* Build free list in chunk */\n      __result = (_Obj*)__chunk;\n      *__my_free_list = __next_obj = (_Obj*)(__chunk + __n);\n      for (__i = 1; ; __i++) {\n        __current_obj = __next_obj;\n        __next_obj = (_Obj*)((char*)__next_obj + __n);\n        if (__nobjs - 1 == __i) {\n            __current_obj -> _M_free_list_link = 0;\n            break;\n        } else {\n            __current_obj -> _M_free_list_link = __next_obj;\n        }\n      }\n    return(__result);\n}\n\ntemplate <bool threads, int inst>\nvoid*\n__default_alloc_template<threads, inst>::reallocate(void* __p,\n                                                    size_t __old_sz,\n                                                    size_t __new_sz)\n{\n    void* __result;\n    size_t __copy_sz;\n\n    if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) {\n        return(realloc(__p, __new_sz));\n    }\n    if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);\n    __result = allocate(__new_sz);\n    __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;\n    memcpy(__result, __p, __copy_sz);\n    deallocate(__p, __old_sz);\n    return(__result);\n}\n\n#ifdef __STL_THREADS\n    template <bool __threads, int __inst>\n    _STL_mutex_lock\n    __default_alloc_template<__threads, __inst>::_S_node_allocator_lock\n        __STL_MUTEX_INITIALIZER;\n#endif\n\n\ntemplate <bool __threads, int __inst>\nchar* __default_alloc_template<__threads, __inst>::_S_start_free = 0;\n\ntemplate <bool __threads, int __inst>\nchar* __default_alloc_template<__threads, __inst>::_S_end_free = 0;\n\ntemplate <bool __threads, int __inst>\nsize_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;\n\ntemplate <bool __threads, int __inst>\ntypename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE\n__default_alloc_template<__threads, __inst> ::_S_free_list[\n# if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC)\n    _NFREELISTS\n# else\n    __default_alloc_template<__threads, __inst>::_NFREELISTS\n# endif\n] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };\n// The 16 zeros are necessary to make version 4.1 of the SunPro\n// compiler happy.  Otherwise it appears to allocate too little\n// space for the array.\n\n#endif /* ! __USE_MALLOC */\n\n// This implements allocators as specified in the C++ standard.  \n//\n// Note that standard-conforming allocators use many language features\n// that are not yet widely implemented.  In particular, they rely on\n// member templates, partial specialization, partial ordering of function\n// templates, the typename keyword, and the use of the template keyword\n// to refer to a template member of a dependent type.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\ntemplate <class _Tp>\nclass allocator {\n  typedef alloc _Alloc;          // The underlying allocator.\npublic:\n  typedef size_t     size_type;\n  typedef ptrdiff_t  difference_type;\n  typedef _Tp*       pointer;\n  typedef const _Tp* const_pointer;\n  typedef _Tp&       reference;\n  typedef const _Tp& const_reference;\n  typedef _Tp        value_type;\n\n  template <class _Tp1> struct rebind {\n    typedef allocator<_Tp1> other;\n  };\n\n  allocator() __STL_NOTHROW {}\n  allocator(const allocator&) __STL_NOTHROW {}\n  template <class _Tp1> allocator(const allocator<_Tp1>&) __STL_NOTHROW {}\n  ~allocator() __STL_NOTHROW {}\n\n  pointer address(reference __x) const { return &__x; }\n  const_pointer address(const_reference __x) const { return &__x; }\n\n  // __n is permitted to be 0.  The C++ standard says nothing about what\n  // the return value is when __n == 0.\n  _Tp* allocate(size_type __n, const void* = 0) {\n    return __n != 0 ? static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp))) \n                    : 0;\n  }\n\n  // __p is not permitted to be a null pointer.\n  void deallocate(pointer __p, size_type __n)\n    { _Alloc::deallocate(__p, __n * sizeof(_Tp)); }\n\n  size_type max_size() const __STL_NOTHROW \n    { return size_t(-1) / sizeof(_Tp); }\n\n  void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }\n  void destroy(pointer __p) { __p->~_Tp(); }\n};\n\ntemplate<>\nclass allocator<void> {\npublic:\n  typedef size_t      size_type;\n  typedef ptrdiff_t   difference_type;\n  typedef void*       pointer;\n  typedef const void* const_pointer;\n  typedef void        value_type;\n\n  template <class _Tp1> struct rebind {\n    typedef allocator<_Tp1> other;\n  };\n};\n\n\ntemplate <class _T1, class _T2>\ninline bool operator==(const allocator<_T1>&, const allocator<_T2>&) \n{\n  return true;\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator!=(const allocator<_T1>&, const allocator<_T2>&)\n{\n  return false;\n}\n\n// Allocator adaptor to turn an SGI-style allocator (e.g. alloc, malloc_alloc)\n// into a standard-conforming allocator.   Note that this adaptor does\n// *not* assume that all objects of the underlying alloc class are\n// identical, nor does it assume that all of the underlying alloc's\n// member functions are static member functions.  Note, also, that \n// __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>.\n\ntemplate <class _Tp, class _Alloc>\nstruct __allocator {\n  _Alloc __underlying_alloc;\n\n  typedef size_t    size_type;\n  typedef ptrdiff_t difference_type;\n  typedef _Tp*       pointer;\n  typedef const _Tp* const_pointer;\n  typedef _Tp&       reference;\n  typedef const _Tp& const_reference;\n  typedef _Tp        value_type;\n\n  template <class _Tp1> struct rebind {\n    typedef __allocator<_Tp1, _Alloc> other;\n  };\n\n  __allocator() __STL_NOTHROW {}\n  __allocator(const __allocator& __a) __STL_NOTHROW\n    : __underlying_alloc(__a.__underlying_alloc) {}\n  template <class _Tp1> \n  __allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW\n    : __underlying_alloc(__a.__underlying_alloc) {}\n  ~__allocator() __STL_NOTHROW {}\n\n  pointer address(reference __x) const { return &__x; }\n  const_pointer address(const_reference __x) const { return &__x; }\n\n  // __n is permitted to be 0.\n  _Tp* allocate(size_type __n, const void* = 0) {\n    return __n != 0 \n        ? static_cast<_Tp*>(__underlying_alloc.allocate(__n * sizeof(_Tp))) \n        : 0;\n  }\n\n  // __p is not permitted to be a null pointer.\n  void deallocate(pointer __p, size_type __n)\n    { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }\n\n  size_type max_size() const __STL_NOTHROW \n    { return size_t(-1) / sizeof(_Tp); }\n\n  void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }\n  void destroy(pointer __p) { __p->~_Tp(); }\n};\n\ntemplate <class _Alloc>\nclass __allocator<void, _Alloc> {\n  typedef size_t      size_type;\n  typedef ptrdiff_t   difference_type;\n  typedef void*       pointer;\n  typedef const void* const_pointer;\n  typedef void        value_type;\n\n  template <class _Tp1> struct rebind {\n    typedef __allocator<_Tp1, _Alloc> other;\n  };\n};\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator==(const __allocator<_Tp, _Alloc>& __a1,\n                       const __allocator<_Tp, _Alloc>& __a2)\n{\n  return __a1.__underlying_alloc == __a2.__underlying_alloc;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\ntemplate <class _Tp, class _Alloc>\ninline bool operator!=(const __allocator<_Tp, _Alloc>& __a1,\n                       const __allocator<_Tp, _Alloc>& __a2)\n{\n  return __a1.__underlying_alloc != __a2.__underlying_alloc;\n}\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Comparison operators for all of the predifined SGI-style allocators.\n// This ensures that __allocator<malloc_alloc> (for example) will\n// work correctly.\n\ntemplate <int inst>\ninline bool operator==(const __malloc_alloc_template<inst>&,\n                       const __malloc_alloc_template<inst>&)\n{\n  return true;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\ntemplate <int __inst>\ninline bool operator!=(const __malloc_alloc_template<__inst>&,\n                       const __malloc_alloc_template<__inst>&)\n{\n  return false;\n}\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class _Alloc>\ninline bool operator==(const debug_alloc<_Alloc>&,\n                       const debug_alloc<_Alloc>&) {\n  return true;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\ntemplate <class _Alloc>\ninline bool operator!=(const debug_alloc<_Alloc>&,\n                       const debug_alloc<_Alloc>&) {\n  return false;\n}\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Another allocator adaptor: _Alloc_traits.  This serves two\n// purposes.  First, make it possible to write containers that can use\n// either SGI-style allocators or standard-conforming allocator.\n// Second, provide a mechanism so that containers can query whether or\n// not the allocator has distinct instances.  If not, the container\n// can avoid wasting a word of memory to store an empty object.\n\n// This adaptor uses partial specialization.  The general case of\n// _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a\n// standard-conforming allocator, possibly with non-equal instances\n// and non-static members.  (It still behaves correctly even if _Alloc\n// has static member and if all instances are equal.  Refinements\n// affect performance, not correctness.)\n\n// There are always two members: allocator_type, which is a standard-\n// conforming allocator type for allocating objects of type _Tp, and\n// _S_instanceless, a static const member of type bool.  If\n// _S_instanceless is true, this means that there is no difference\n// between any two instances of type allocator_type.  Furthermore, if\n// _S_instanceless is true, then _Alloc_traits has one additional\n// member: _Alloc_type.  This type encapsulates allocation and\n// deallocation of objects of type _Tp through a static interface; it\n// has two member functions, whose signatures are\n//    static _Tp* allocate(size_t)\n//    static void deallocate(_Tp*, size_t)\n\n// The fully general version.\n\ntemplate <class _Tp, class _Allocator>\nstruct _Alloc_traits\n{\n  static const bool _S_instanceless = false;\n  typedef typename _Allocator::__STL_TEMPLATE rebind<_Tp>::other \n          allocator_type;\n};\n\ntemplate <class _Tp, class _Allocator>\nconst bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless;\n\n// The version for the default allocator.\n\ntemplate <class _Tp, class _Tp1>\nstruct _Alloc_traits<_Tp, allocator<_Tp1> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, alloc> _Alloc_type;\n  typedef allocator<_Tp> allocator_type;\n};\n\n// Versions for the predefined SGI-style allocators.\n\ntemplate <class _Tp, int __inst>\nstruct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;\n  typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;\n};\n\ntemplate <class _Tp, bool __threads, int __inst>\nstruct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, __default_alloc_template<__threads, __inst> > \n          _Alloc_type;\n  typedef __allocator<_Tp, __default_alloc_template<__threads, __inst> > \n          allocator_type;\n};\n\ntemplate <class _Tp, class _Alloc>\nstruct _Alloc_traits<_Tp, debug_alloc<_Alloc> >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;\n  typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;\n};\n\n// Versions for the __allocator adaptor used with the predefined\n// SGI-style allocators.\n\ntemplate <class _Tp, class _Tp1, int __inst>\nstruct _Alloc_traits<_Tp, \n                     __allocator<_Tp1, __malloc_alloc_template<__inst> > >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;\n  typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;\n};\n\ntemplate <class _Tp, class _Tp1, bool __thr, int __inst>\nstruct _Alloc_traits<_Tp, \n                      __allocator<_Tp1, \n                                  __default_alloc_template<__thr, __inst> > >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, __default_alloc_template<__thr,__inst> > \n          _Alloc_type;\n  typedef __allocator<_Tp, __default_alloc_template<__thr,__inst> > \n          allocator_type;\n};\n\ntemplate <class _Tp, class _Tp1, class _Alloc>\nstruct _Alloc_traits<_Tp, __allocator<_Tp1, debug_alloc<_Alloc> > >\n{\n  static const bool _S_instanceless = true;\n  typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;\n  typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;\n};\n\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#undef __PRIVATE\n\n#endif /* __SGI_STL_INTERNAL_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_bvector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996-1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_BVECTOR_H\n#define __SGI_STL_INTERNAL_BVECTOR_H\n\n__STL_BEGIN_NAMESPACE \n\nstatic const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\nstruct _Bit_reference {\n  unsigned int* _M_p;\n  unsigned int _M_mask;\n  _Bit_reference(unsigned int* __x, unsigned int __y) \n    : _M_p(__x), _M_mask(__y) {}\n\npublic:\n  _Bit_reference() : _M_p(0), _M_mask(0) {}\n  operator bool() const { return !(!(*_M_p & _M_mask)); }\n  _Bit_reference& operator=(bool __x)\n  {\n    if (__x)  *_M_p |= _M_mask;\n    else      *_M_p &= ~_M_mask;\n    return *this;\n  }\n  _Bit_reference& operator=(const _Bit_reference& __x) \n    { return *this = bool(__x); }\n  bool operator==(const _Bit_reference& __x) const\n    { return bool(*this) == bool(__x); }\n  bool operator<(const _Bit_reference& __x) const {\n    return !bool(*this) && bool(__x);\n  }\n  void flip() { *_M_p ^= _M_mask; }\n};\n\ninline void swap(_Bit_reference __x, _Bit_reference __y)\n{\n  bool __tmp = __x;\n  __x = __y;\n  __y = __tmp;\n}\n\nstruct _Bit_iterator_base : public random_access_iterator<bool, ptrdiff_t> \n{\n  unsigned int* _M_p;\n  unsigned int _M_offset;\n\n  _Bit_iterator_base(unsigned int* __x, unsigned int __y)\n    : _M_p(__x), _M_offset(__y) {}\n\n  void _M_bump_up() {\n    if (_M_offset++ == __WORD_BIT - 1) {\n      _M_offset = 0;\n      ++_M_p;\n    }\n  }\n  void _M_bump_down() {\n    if (_M_offset-- == 0) {\n      _M_offset = __WORD_BIT - 1;\n      --_M_p;\n    }\n  }\n\n  void _M_incr(ptrdiff_t __i) {\n    difference_type __n = __i + _M_offset;\n    _M_p += __n / __WORD_BIT;\n    __n = __n % __WORD_BIT;\n    if (__n < 0) {\n      _M_offset = (unsigned int) __n + __WORD_BIT;\n      --_M_p;\n    } else\n      _M_offset = (unsigned int) __n;\n  }\n\n  bool operator==(const _Bit_iterator_base& __i) const {\n    return _M_p == __i._M_p && _M_offset == __i._M_offset;\n  }\n  bool operator<(const _Bit_iterator_base& __i) const {\n    return _M_p < __i._M_p || (_M_p == __i._M_p && _M_offset < __i._M_offset);\n  }\n  bool operator!=(const _Bit_iterator_base& __i) const {\n    return !(*this == __i);\n  }\n  bool operator>(const _Bit_iterator_base& __i) const {\n    return __i < *this;\n  }\n  bool operator<=(const _Bit_iterator_base& __i) const {\n    return !(__i < *this); \n  }\n  bool operator>=(const _Bit_iterator_base& __i) const {\n    return !(*this < __i);\n  }\n};\n\ninline ptrdiff_t\noperator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {\n  return __WORD_BIT * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;\n}\n\n\nstruct _Bit_iterator : public _Bit_iterator_base\n{\n  typedef _Bit_reference  reference;\n  typedef _Bit_reference* pointer;\n  typedef _Bit_iterator   iterator;\n\n  _Bit_iterator() : _Bit_iterator_base(0, 0) {}\n  _Bit_iterator(unsigned int* __x, unsigned int __y) \n    : _Bit_iterator_base(__x, __y) {}\n\n  reference operator*() const { return reference(_M_p, 1U << _M_offset); }\n  iterator& operator++() {\n    _M_bump_up();\n    return *this;\n  }\n  iterator operator++(int) {\n    iterator __tmp = *this;\n    _M_bump_up();\n    return __tmp;\n  }\n  iterator& operator--() {\n    _M_bump_down();\n    return *this;\n  }\n  iterator operator--(int) {\n    iterator __tmp = *this;\n    _M_bump_down();\n    return __tmp;\n  }\n  iterator& operator+=(difference_type __i) {\n    _M_incr(__i);\n    return *this;\n  }\n  iterator& operator-=(difference_type __i) {\n    *this += -__i;\n    return *this;\n  }\n  iterator operator+(difference_type __i) const {\n    iterator __tmp = *this;\n    return __tmp += __i;\n  }\n  iterator operator-(difference_type __i) const {\n    iterator __tmp = *this;\n    return __tmp -= __i;\n  }\n\n  reference operator[](difference_type __i) { return *(*this + __i); }\n};\n\ninline _Bit_iterator \noperator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; }\n\n\nstruct _Bit_const_iterator : public _Bit_iterator_base\n{\n  typedef bool                 reference;\n  typedef bool                 const_reference;\n  typedef const bool*          pointer;\n  typedef _Bit_const_iterator  const_iterator;\n\n  _Bit_const_iterator() : _Bit_iterator_base(0, 0) {}\n  _Bit_const_iterator(unsigned int* __x, unsigned int __y) \n    : _Bit_iterator_base(__x, __y) {}\n  _Bit_const_iterator(const _Bit_iterator& __x) \n    : _Bit_iterator_base(__x._M_p, __x._M_offset) {}\n\n  const_reference operator*() const {\n    return _Bit_reference(_M_p, 1U << _M_offset);\n  }\n  const_iterator& operator++() {\n    _M_bump_up();\n    return *this;\n  }\n  const_iterator operator++(int) {\n    const_iterator __tmp = *this;\n    _M_bump_up();\n    return __tmp;\n  }\n  const_iterator& operator--() {\n    _M_bump_down();\n    return *this;\n  }\n  const_iterator operator--(int) {\n    const_iterator __tmp = *this;\n    _M_bump_down();\n    return __tmp;\n  }\n  const_iterator& operator+=(difference_type __i) {\n    _M_incr(__i);\n    return *this;\n  }\n  const_iterator& operator-=(difference_type __i) {\n    *this += -__i;\n    return *this;\n  }\n  const_iterator operator+(difference_type __i) const {\n    const_iterator __tmp = *this;\n    return __tmp += __i;\n  }\n  const_iterator operator-(difference_type __i) const {\n    const_iterator __tmp = *this;\n    return __tmp -= __i;\n  }\n  const_reference operator[](difference_type __i) { \n    return *(*this + __i); \n  }\n};\n\ninline _Bit_const_iterator \noperator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; }\n\n\n// Bit-vector base class, which encapsulates the difference between\n// old SGI-style allocators and standard-conforming allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base class for ordinary allocators.\ntemplate <class _Allocator, bool __is_static>\nclass _Bvector_alloc_base {\npublic:\n  typedef typename _Alloc_traits<bool, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _M_data_allocator; }\n\n  _Bvector_alloc_base(const allocator_type& __a)\n    : _M_data_allocator(__a), _M_start(), _M_finish(), _M_end_of_storage(0) {}\n\nprotected:\n  unsigned int* _M_bit_alloc(size_t __n) \n    { return _M_data_allocator.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }\n  void _M_deallocate() {\n    if (_M_start._M_p)\n      _M_data_allocator.deallocate(_M_start._M_p, \n                                   _M_end_of_storage - _M_start._M_p);\n  }  \n\n  typename _Alloc_traits<unsigned int, _Allocator>::allocator_type \n          _M_data_allocator;\n  _Bit_iterator _M_start;\n  _Bit_iterator _M_finish;\n  unsigned int* _M_end_of_storage;\n};\n\n// Specialization for instanceless allocators.\ntemplate <class _Allocator>\nclass _Bvector_alloc_base<_Allocator, true> {\npublic:\n  typedef typename _Alloc_traits<bool, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Bvector_alloc_base(const allocator_type&)\n    : _M_start(), _M_finish(), _M_end_of_storage(0) {}\n\nprotected:\n  typedef typename _Alloc_traits<unsigned int, _Allocator>::_Alloc_type\n          _Alloc_type;\n          \n  unsigned int* _M_bit_alloc(size_t __n) \n    { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }\n  void _M_deallocate() {\n    if (_M_start._M_p)\n      _Alloc_type::deallocate(_M_start._M_p,\n                              _M_end_of_storage - _M_start._M_p);\n  }  \n\n  _Bit_iterator _M_start;\n  _Bit_iterator _M_finish;\n  unsigned int* _M_end_of_storage;\n};  \n\ntemplate <class _Alloc>\nclass _Bvector_base\n  : public _Bvector_alloc_base<_Alloc,\n                               _Alloc_traits<bool, _Alloc>::_S_instanceless>\n{\n  typedef _Bvector_alloc_base<_Alloc,\n                              _Alloc_traits<bool, _Alloc>::_S_instanceless>\n          _Base;\npublic:\n  typedef typename _Base::allocator_type allocator_type;\n\n  _Bvector_base(const allocator_type& __a) : _Base(__a) {}\n  ~_Bvector_base() { _Base::_M_deallocate(); }\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Alloc>\nclass _Bvector_base\n{\npublic:\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Bvector_base(const allocator_type&)\n    : _M_start(), _M_finish(), _M_end_of_storage(0) {}\n  ~_Bvector_base() { _M_deallocate(); }\n\nprotected:\n  typedef simple_alloc<unsigned int, _Alloc> _Alloc_type;\n  \n  unsigned int* _M_bit_alloc(size_t __n) \n    { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }\n  void _M_deallocate() {\n    if (_M_start._M_p)\n      _Alloc_type::deallocate(_M_start._M_p,\n                              _M_end_of_storage - _M_start._M_p);\n  }\n\n  _Bit_iterator _M_start;\n  _Bit_iterator _M_finish;\n  unsigned int* _M_end_of_storage;  \n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n// The next few lines are confusing.  What we're doing is declaring a\n//  partial specialization of vector<T, Alloc> if we have the necessary\n//  compiler support.  Otherwise, we define a class bit_vector which uses\n//  the default allocator. \n\n#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NO_BOOL)\n#  define __SGI_STL_VECBOOL_TEMPLATE\n#  define __BVECTOR           vector<bool, _Alloc>\n#  define __VECTOR            vector\n#  define __BVECTOR_BASE      _Bvector_base<_Alloc>\n#  define __BVECTOR_TMPL_LIST template <class _Alloc>\n   __STL_END_NAMESPACE\n#  include <stl_vector.h>\n   __STL_BEGIN_NAMESPACE\n#else  /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */\n#  undef  __SGI_STL_VECBOOL_TEMPLATE\n#  define __BVECTOR           bit_vector\n#  define __VECTOR            bit_vector\n#  define __BVECTOR_BASE      _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) >\n#  define __BVECTOR_TMPL_LIST\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */\n\n\n__BVECTOR_TMPL_LIST \nclass __BVECTOR : public __BVECTOR_BASE \n{\npublic:\n  typedef bool value_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type; \n  typedef _Bit_reference reference;\n  typedef bool const_reference;\n  typedef _Bit_reference* pointer;\n  typedef const bool* const_pointer;\n\n  typedef _Bit_iterator                iterator;\n  typedef _Bit_const_iterator          const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type> const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n  typedef typename __BVECTOR_BASE::allocator_type allocator_type;\n  allocator_type get_allocator() const {\n    return __BVECTOR_BASE::get_allocator();\n  }\n\nprotected:\n#ifdef __STL_USE_NAMESPACES  \n  using __BVECTOR_BASE::_M_bit_alloc;\n  using __BVECTOR_BASE::_M_deallocate;\n  using __BVECTOR_BASE::_M_start;\n  using __BVECTOR_BASE::_M_finish;\n  using __BVECTOR_BASE::_M_end_of_storage;\n#endif /* __STL_USE_NAMESPACES */\n\nprotected:\n  void _M_initialize(size_type __n) {\n    unsigned int* __q = _M_bit_alloc(__n);\n    _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;\n    _M_start = iterator(__q, 0);\n    _M_finish = _M_start + difference_type(__n);\n  }\n  void _M_insert_aux(iterator __position, bool __x) {\n    if (_M_finish._M_p != _M_end_of_storage) {\n      copy_backward(__position, _M_finish, _M_finish + 1);\n      *__position = __x;\n      ++_M_finish;\n    }\n    else {\n      size_type __len = size() ? 2 * size() : __WORD_BIT;\n      unsigned int* __q = _M_bit_alloc(__len);\n      iterator __i = copy(begin(), __position, iterator(__q, 0));\n      *__i++ = __x;\n      _M_finish = copy(__position, end(), __i);\n      _M_deallocate();\n      _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;\n      _M_start = iterator(__q, 0);\n    }\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void _M_initialize_range(_InputIterator __first, _InputIterator __last,\n                           input_iterator_tag) {\n    _M_start = iterator();\n    _M_finish = iterator();\n    _M_end_of_storage = 0;\n    for ( ; __first != __last; ++__first) \n      push_back(*__first);\n  }\n\n  template <class _ForwardIterator>\n  void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,\n                           forward_iterator_tag) {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    _M_initialize(__n);\n    copy(__first, __last, _M_start);\n  }\n\n  template <class _InputIterator>\n  void _M_insert_range(iterator __pos,\n                       _InputIterator __first, _InputIterator __last,\n                       input_iterator_tag) {\n    for ( ; __first != __last; ++__first) {\n      __pos = insert(__pos, *__first);\n      ++__pos;\n    }\n  }\n\n  template <class _ForwardIterator>\n  void _M_insert_range(iterator __position,\n                       _ForwardIterator __first, _ForwardIterator __last,\n                       forward_iterator_tag) {\n    if (__first != __last) {\n      size_type __n = 0;\n      distance(__first, __last, __n);\n      if (capacity() - size() >= __n) {\n        copy_backward(__position, end(), _M_finish + difference_type(__n));\n        copy(__first, __last, __position);\n        _M_finish += difference_type(__n);\n      }\n      else {\n        size_type __len = size() + max(size(), __n);\n        unsigned int* __q = _M_bit_alloc(__len);\n        iterator __i = copy(begin(), __position, iterator(__q, 0));\n        __i = copy(__first, __last, __i);\n        _M_finish = copy(__position, end(), __i);\n        _M_deallocate();\n        _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;\n        _M_start = iterator(__q, 0);\n      }\n    }\n  }      \n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n  iterator begin() { return _M_start; }\n  const_iterator begin() const { return _M_start; }\n  iterator end() { return _M_finish; }\n  const_iterator end() const { return _M_finish; }\n\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin()); \n  }\n\n  size_type size() const { return size_type(end() - begin()); }\n  size_type max_size() const { return size_type(-1); }\n  size_type capacity() const {\n    return size_type(const_iterator(_M_end_of_storage, 0) - begin());\n  }\n  bool empty() const { return begin() == end(); }\n\n  reference operator[](size_type __n)\n    { return *(begin() + difference_type(__n)); }\n  const_reference operator[](size_type __n) const\n    { return *(begin() + difference_type(__n)); }\n\n#ifdef __STL_THROW_RANGE_ERRORS\n  void _M_range_check(size_type __n) const {\n    if (__n >= this->size())\n      __stl_throw_range_error(\"vector<bool>\");\n  }\n\n  reference at(size_type __n)\n    { _M_range_check(__n); return (*this)[__n]; }\n  const_reference at(size_type __n) const\n    { _M_range_check(__n); return (*this)[__n]; }\n#endif /* __STL_THROW_RANGE_ERRORS */\n\n  explicit __VECTOR(const allocator_type& __a = allocator_type())\n    : __BVECTOR_BASE(__a) {}\n\n  __VECTOR(size_type __n, bool __value,\n            const allocator_type& __a = allocator_type())\n    : __BVECTOR_BASE(__a)\n  {\n    _M_initialize(__n);\n    fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0);\n  }\n\n  explicit __VECTOR(size_type __n)\n    : __BVECTOR_BASE(allocator_type())\n  {\n    _M_initialize(__n);\n    fill(_M_start._M_p, _M_end_of_storage, 0);\n  }\n\n  __VECTOR(const __VECTOR& __x) : __BVECTOR_BASE(__x.get_allocator()) {\n    _M_initialize(__x.size());\n    copy(__x.begin(), __x.end(), _M_start);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check whether it's an integral type.  If so, it's not an iterator.\n\n  template <class _Integer>\n  void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {\n    _M_initialize(__n);\n    fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);\n  }\n\n  template <class _InputIterator>\n  void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,\n                              __false_type) {\n    _M_initialize_range(__first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n  template <class _InputIterator>\n  __VECTOR(_InputIterator __first, _InputIterator __last,\n           const allocator_type& __a = allocator_type())\n    : __BVECTOR_BASE(__a)\n  {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_initialize_dispatch(__first, __last, _Integral());\n  }\n    \n#else /* __STL_MEMBER_TEMPLATES */\n\n  __VECTOR(const_iterator __first, const_iterator __last,\n           const allocator_type& __a = allocator_type())\n    : __BVECTOR_BASE(__a)\n  {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    _M_initialize(__n);\n    copy(__first, __last, _M_start);\n  }\n  __VECTOR(const bool* __first, const bool* __last,\n           const allocator_type& __a = allocator_type())\n    : __BVECTOR_BASE(__a)\n  {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    _M_initialize(__n);\n    copy(__first, __last, _M_start);\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  ~__VECTOR() { }\n\n  __VECTOR& operator=(const __VECTOR& __x) {\n    if (&__x == this) return *this;\n    if (__x.size() > capacity()) {\n      _M_deallocate();\n      _M_initialize(__x.size());\n    }\n    copy(__x.begin(), __x.end(), begin());\n    _M_finish = begin() + difference_type(__x.size());\n    return *this;\n  }\n\n  // assign(), a generalized assignment member function.  Two\n  // versions: one that takes a count, and one that takes a range.\n  // The range version is a member template, so we dispatch on whether\n  // or not the type is an integer.\n\n  void _M_fill_assign(size_t __n, bool __x) {\n    if (__n > size()) {\n      fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);\n      insert(end(), __n - size(), __x);\n    }\n    else {\n      erase(begin() + __n, end());\n      fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);\n    }\n  }\n\n  void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIterator>\n  void assign(_InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_assign_dispatch(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)\n    { _M_fill_assign((size_t) __n, (bool) __val); }\n\n  template <class _InputIter>\n  void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)\n    { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); }\n\n  template <class _InputIterator>\n  void _M_assign_aux(_InputIterator __first, _InputIterator __last,\n                     input_iterator_tag) {\n    iterator __cur = begin();\n    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)\n      *__cur = *__first;\n    if (__first == __last)\n      erase(__cur, end());\n    else\n      insert(end(), __first, __last);\n  }\n\n  template <class _ForwardIterator>\n  void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,\n                     forward_iterator_tag) {\n    size_type __len = 0;\n    distance(__first, __last, __len);\n    if (__len < size())\n      erase(copy(__first, __last, begin()), end());\n    else {\n      _ForwardIterator __mid = __first;\n      advance(__mid, size());\n      copy(__first, __mid, begin());\n      insert(end(), __mid, __last);\n    }\n  }    \n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void reserve(size_type __n) {\n    if (capacity() < __n) {\n      unsigned int* __q = _M_bit_alloc(__n);\n      _M_finish = copy(begin(), end(), iterator(__q, 0));\n      _M_deallocate();\n      _M_start = iterator(__q, 0);\n      _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;\n    }\n  }\n\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(end() - 1); }\n  const_reference back() const { return *(end() - 1); }\n  void push_back(bool __x) {\n    if (_M_finish._M_p != _M_end_of_storage)\n      *_M_finish++ = __x;\n    else\n      _M_insert_aux(end(), __x);\n  }\n  void swap(__BVECTOR& __x) {\n    __STD::swap(_M_start, __x._M_start);\n    __STD::swap(_M_finish, __x._M_finish);\n    __STD::swap(_M_end_of_storage, __x._M_end_of_storage);\n  }\n  iterator insert(iterator __position, bool __x = bool()) {\n    difference_type __n = __position - begin();\n    if (_M_finish._M_p != _M_end_of_storage && __position == end())\n      *_M_finish++ = __x;\n    else\n      _M_insert_aux(__position, __x);\n    return begin() + __n;\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  // Check whether it's an integral type.  If so, it's not an iterator.\n\n  template <class _Integer>\n  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,\n                          __true_type) {\n    _M_fill_insert(__pos, __n, __x);\n  }\n\n  template <class _InputIterator>\n  void _M_insert_dispatch(iterator __pos,\n                          _InputIterator __first, _InputIterator __last,\n                          __false_type) {\n    _M_insert_range(__pos, __first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n  template <class _InputIterator>\n  void insert(iterator __position,\n              _InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_insert_dispatch(__position, __first, __last, _Integral());\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator __position,\n              const_iterator __first, const_iterator __last) {\n    if (__first == __last) return;\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    if (capacity() - size() >= __n) {\n      copy_backward(__position, end(), _M_finish + __n);\n      copy(__first, __last, __position);\n      _M_finish += __n;\n    }\n    else {\n      size_type __len = size() + max(size(), __n);\n      unsigned int* __q = _M_bit_alloc(__len);\n      iterator __i = copy(begin(), __position, iterator(__q, 0));\n      __i = copy(__first, __last, __i);\n      _M_finish = copy(__position, end(), __i);\n      _M_deallocate();\n      _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;\n      _M_start = iterator(__q, 0);\n    }\n  }\n\n  void insert(iterator __position, const bool* __first, const bool* __last) {\n    if (__first == __last) return;\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    if (capacity() - size() >= __n) {\n      copy_backward(__position, end(), _M_finish + __n);\n      copy(__first, __last, __position);\n      _M_finish += __n;\n    }\n    else {\n      size_type __len = size() + max(size(), __n);\n      unsigned int* __q = _M_bit_alloc(__len);\n      iterator __i = copy(begin(), __position, iterator(__q, 0));\n      __i = copy(__first, __last, __i);\n      _M_finish = copy(__position, end(), __i);\n      _M_deallocate();\n      _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;\n      _M_start = iterator(__q, 0);\n    }\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void _M_fill_insert(iterator __position, size_type __n, bool __x) {\n    if (__n == 0) return;\n    if (capacity() - size() >= __n) {\n      copy_backward(__position, end(), _M_finish + difference_type(__n));\n      fill(__position, __position + difference_type(__n), __x);\n      _M_finish += difference_type(__n);\n    }\n    else {\n      size_type __len = size() + max(size(), __n);\n      unsigned int* __q = _M_bit_alloc(__len);\n      iterator __i = copy(begin(), __position, iterator(__q, 0));\n      fill_n(__i, __n, __x);\n      _M_finish = copy(__position, end(), __i + difference_type(__n));\n      _M_deallocate();\n      _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;\n      _M_start = iterator(__q, 0);\n    }\n  }\n\n  void insert(iterator __position, size_type __n, bool __x) {\n    _M_fill_insert(__position, __n, __x);\n  }\n\n  void pop_back() { --_M_finish; }\n  iterator erase(iterator __position) {\n    if (__position + 1 != end())\n      copy(__position + 1, end(), __position);\n      --_M_finish;\n    return __position;\n  }\n  iterator erase(iterator __first, iterator __last) {\n    _M_finish = copy(__last, end(), __first);\n    return __first;\n  }\n  void resize(size_type __new_size, bool __x = bool()) {\n    if (__new_size < size()) \n      erase(begin() + difference_type(__new_size), end());\n    else\n      insert(end(), __new_size - size(), __x);\n  }\n  void flip() {\n    for (unsigned int* __p = _M_start._M_p; __p != _M_end_of_storage; ++__p)\n      *__p = ~*__p;\n  }\n\n  void clear() { erase(begin(), end()); }\n};\n\n#ifdef __SGI_STL_VECBOOL_TEMPLATE\n\n// This typedef is non-standard.  It is provided for backward compatibility.\ntypedef vector<bool, alloc> bit_vector;\n\n#else /* __SGI_STL_VECBOOL_TEMPLATE */\n\ninline void swap(bit_vector& __x, bit_vector& __y) {\n  __x.swap(__y);\n}\n\ninline bool \noperator==(const bit_vector& __x, const bit_vector& __y)\n{\n  return (__x.size() == __y.size() && \n          equal(__x.begin(), __x.end(), __y.begin()));\n}\n\ninline bool \noperator!=(const bit_vector& __x, const bit_vector& __y)\n{\n  return !(__x == __y);\n}\n\ninline bool \noperator<(const bit_vector& __x, const bit_vector& __y)\n{\n  return lexicographical_compare(__x.begin(), __x.end(), \n                                 __y.begin(), __y.end());\n}\n\ninline bool operator>(const bit_vector& __x, const bit_vector& __y)\n{\n  return __y < __x;\n}\n\ninline bool operator<=(const bit_vector& __x, const bit_vector& __y)\n{\n  return !(__y < __x);\n}\n\ninline bool operator>=(const bit_vector& __x, const bit_vector& __y)\n{\n  return !(__x < __y);\n}\n\n#endif /* __SGI_STL_VECBOOL_TEMPLATE */\n\n#undef __SGI_STL_VECBOOL_TEMPLATE\n#undef __BVECTOR\n#undef __VECTOR\n#undef __BVECTOR_BASE\n#undef __BVECTOR_TMPL_LIST \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_BVECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_config.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __STL_CONFIG_H\n# define __STL_CONFIG_H\n\n// Flags:\n// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin\n//   type.\n// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type.\n// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48 \n//   function.\n// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle\n//   static members of template classes.\n// * __STL_STATIC_CONST_INIT_BUG: defined if the compiler can't handle a\n//   constant-initializer in the declaration of a static const data member\n//   of integer type.  (See section 9.4.2, paragraph 4, of the C++ standard.)\n// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports\n//   partial specialization of template classes.\n// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler \n//   supports partial specialization syntax for full specialization of\n//   class templates.  (Even if it doesn't actually support partial \n//   specialization itself.)\n// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports\n//   partial ordering of function templates.  (a.k.a partial specialization\n//   of function templates.)\n// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template\n//   member functions of classes.\n// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports \n//   nested classes that are member templates of other classes.\n// * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized\n//   friend declarations.\n// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler \n//   supports calling a function template by providing its template\n//   arguments explicitly.\n// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable\n//   to handle default template parameters that depend on previous template\n//   parameters.\n// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with\n//   function template argument deduction for non-type template parameters.\n// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable\n//   to support the -> operator for iterators.\n// * __STL_DEFAULT_CONSTRUCTOR_BUG: defined if T() does not work properly\n//   when T is a builtin type.\n// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation\n//   mode) supports exceptions.\n// * __STL_USE_NAMESPACES: defined if the compiler has the necessary\n//   support for namespaces.\n// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a\n//   standard-conforming header <exception>.\n// * __STL_NO_BAD_ALLOC: defined if the compiler does not have a <new>\n//   header, or if <new> does not contain a bad_alloc class.  If a bad_alloc\n//   class exists, it is assumed to be in namespace std.\n// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX\n//   system in multithreaded mode, using native SGI threads instead of \n//   pthreads.\n// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32\n//   compiler in multithreaded mode.\n// * __STL_PTHREADS: defined if we should use portable pthreads\n//   synchronization.\n// * __STL_UITHREADS: defined if we should use UI / solaris / UnixWare threads\n//   synchronization.  UIthreads are similar to pthreads, but are based \n//   on an earlier version of the Posix threads standard.\n// * __STL_LONG_LONG if the compiler has long long and unsigned long long\n//   types.  (They're not in the C++ standard, but they are expected to be \n//   included in the forthcoming C9X standard.)\n// * __STL_THREADS is defined if thread safety is needed.\n// * __STL_VOLATILE is defined to be \"volatile\" if threads are being\n//   used, and the empty string otherwise.\n// * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error\n//   checking to make sure that user-defined template arguments satisfy\n//   all of the appropriate requirements.  This may result in more\n//   comprehensible error messages.  It incurs no runtime overhead.  This \n//   feature requires member templates and partial specialization.\n// * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle \"using\"\n//   clauses inside of class definitions.\n// * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend\n//   declaractions where the friend is a template class.\n// * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not\n//   support the use of a function pointer type as the argument\n//   for a template.\n// * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template\n//   keyword in a few new places (14.2.4).  This flag is set for\n//   compilers that support (and require) this usage.\n\n\n// User-settable macros that control compilation:\n// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older\n//   SGI-style allocators, instead of standard-conforming allocators,\n//   even if the compiler supports all of the language features needed\n//   for standard-conforming allocators.\n// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace\n//   std, even if the compiler supports namespaces.\n// * __STL_NO_RELOPS_NAMESPACE: if defined, don't put the relational\n//   operator templates (>, <=. >=, !=) in namespace std::rel_ops, even\n//   if the compiler supports namespaces and partial ordering of\n//   function templates.\n// * __STL_ASSERTIONS: if defined, then enable runtime checking through the\n//   __stl_assert macro.\n// * _PTHREADS: if defined, use Posix threads for multithreading support.\n// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading \n//   support\n// * _NOTHREADS: if defined, don't use any multithreading support.  \n// * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that\n//   we get from __STL_USE_CONCEPT_CHECKS.\n// * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new,\n//   standard-conforming iostreams (e.g. the <iosfwd> header).  If not\n//   defined, the STL will use old cfront-style iostreams (e.g. the\n//   <iostream.h> header).\n\n// Other macros defined by this file:\n\n// * bool, true, and false, if __STL_NO_BOOL is defined.\n// * typename, as a null macro if it's not already a keyword.\n// * explicit, as a null macro if it's not already a keyword.\n// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)\n// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.)\n// * __stl_assert, either as a test or as a null macro, depending on\n//   whether or not __STL_ASSERTIONS is defined.\n\n# if defined(_PTHREADS) && !defined(_NOTHREADS)\n#     define __STL_PTHREADS\n# endif\n\n# if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)\n#     define __STL_UITHREADS\n# endif\n\n# if defined(__sgi) && !defined(__GNUC__)\n#   include <standards.h>\n#   if !defined(_BOOL)\n#     define __STL_NO_BOOL\n#   endif\n#   if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32\n#     define __STL_STATIC_CONST_INIT_BUG\n#   endif\n#   if defined(_WCHAR_T_IS_KEYWORD)\n#     define __STL_HAS_WCHAR_T \n#   endif\n#   if !defined(_TYPENAME_IS_KEYWORD)\n#     define __STL_NEED_TYPENAME\n#   endif\n#   ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   endif\n#   if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#   endif\n#   ifdef _MEMBER_TEMPLATES\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_TEMPLATE_FRIENDS\n#     define __STL_MEMBER_TEMPLATE_CLASSES\n#   endif\n#   if defined(_MEMBER_TEMPLATE_KEYWORD)\n#     define __STL_MEMBER_TEMPLATE_KEYWORD\n#   endif\n#   if defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#   endif\n#   if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32\n#     define __STL_MEMBER_TEMPLATE_KEYWORD\n#   endif\n#   if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32)\n#     define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   endif\n#   if !defined(_EXPLICIT_IS_KEYWORD)\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)\n#     define __STL_HAS_NAMESPACES\n#   endif \n#   if (_COMPILER_VERSION < 721) || \\\n    !defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES)\n#     define __STL_NO_EXCEPTION_HEADER\n#   endif\n#   if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \\\n      !defined(_NAMESPACES)\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)\n#     define __STL_SGI_THREADS\n#   endif\n#   if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI\n#     define __STL_LONG_LONG\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_USE_NEW_IOSTREAMS\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_CAN_THROW_RANGE_ERRORS\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __SGI_STL_USE_AUTO_PTR_CONVERSIONS\n#   endif\n# endif\n\n\n/*\n * Jochen Schlick '1999  - added new #defines (__STL)_UITHREADS (for \n *                         providing SCO / Solaris / UI thread support)\n *                       - added the necessary defines for the SCO UDK 7 \n *                         compiler (and its template friend behavior)\n *                       - all UDK7 specific STL changes are based on the \n *                         macro __USLC__ being defined\n */\n// SCO UDK 7 compiler (UnixWare 7x, OSR 5, UnixWare 2x)\n# if defined(__USLC__)\n#     define __STL_HAS_WCHAR_T \n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_MEMBER_TEMPLATE_CLASSES\n#     define __STL_USE_EXCEPTIONS\n#     define __STL_HAS_NAMESPACES\n#     define __STL_USE_NAMESPACES\n#     define __STL_LONG_LONG\n#     if defined(_REENTRANT)\n#           define _UITHREADS     /* if      UnixWare < 7.0.1 */\n#           define __STL_UITHREADS\n//   use the following defines instead of the UI threads defines when\n//   you want to use POSIX threads\n//#         define _PTHREADS      /* only if UnixWare >=7.0.1 */\n//#         define __STL_PTHREADS\n#     endif\n# endif\n\n\n\n# ifdef __GNUC__\n#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 7\n#     define __STL_STATIC_TEMPLATE_MEMBER_BUG\n#   endif\n#   if __GNUC__ < 2 \n#     define __STL_NEED_TYPENAME\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 8\n#     define __STL_NO_EXCEPTION_HEADER\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if __GNUC__ == 2 && __GNUC_MINOR__ >= 8\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_CAN_THROW_RANGE_ERRORS\n      //    g++ 2.8.1 supports member template functions, but not member\n      //    template nested classes.\n#     if __GNUC_MINOR__ >= 9\n#       define __STL_MEMBER_TEMPLATE_CLASSES\n#       define __STL_TEMPLATE_FRIENDS\n#       define __SGI_STL_USE_AUTO_PTR_CONVERSIONS\n#       define __STL_HAS_NAMESPACES\n//#       define __STL_USE_NEW_IOSTREAMS\n#     endif\n#   endif\n#   define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _REENTRANT\n#     define __STL_PTHREADS\n#   endif\n#   if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)\n#     define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE\n#   endif\n# endif\n\n# if defined(__SUNPRO_CC) \n#   define __STL_NO_BOOL\n#   define __STL_NEED_TYPENAME\n#   define __STL_NEED_EXPLICIT\n#   define __STL_USE_EXCEPTIONS\n#   ifdef _REENTRANT\n#     define __STL_PTHREADS\n#   endif\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#   define __STL_NO_EXCEPTION_HEADER\n#   define __STL_NO_BAD_ALLOC\n# endif\n\n# if defined(__COMO__)\n#   define __STL_MEMBER_TEMPLATES\n#   define __STL_MEMBER_TEMPLATE_CLASSES\n#   define __STL_TEMPLATE_FRIENDS\n#   define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_USE_EXCEPTIONS\n#   define __STL_HAS_NAMESPACES\n# endif\n\n// Intel compiler, which uses the EDG front end.\n# if defined(__ICL)\n#   define __STL_LONG_LONG \n#   define __STL_MEMBER_TEMPLATES\n#   define __STL_MEMBER_TEMPLATE_CLASSES\n#   define __STL_TEMPLATE_FRIENDS\n#   define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#   define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_NO_DRAND48\n#   define __STL_HAS_NAMESPACES\n#   define __STL_USE_EXCEPTIONS\n#   define __STL_MEMBER_TEMPLATE_KEYWORD\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n// Mingw32, egcs compiler using the Microsoft C runtime\n# if defined(__MINGW32__)\n#   define __STL_NO_DRAND48\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n// Cygwin32, egcs compiler on MS Windows\n# if defined(__CYGWIN__)\n#   define __STL_NO_DRAND48\n# endif\n\n\n\n// Microsoft compiler.\n# if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__)\n#   define __STL_NO_DRAND48\n#   define __STL_STATIC_CONST_INIT_BUG\n#   define __STL_NEED_TYPENAME\n#   define __STL_NO_USING_CLAUSE_IN_CLASS\n#   define __STL_NO_FRIEND_TEMPLATE_CLASS\n#   if _MSC_VER < 1100  /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */\n#     define __STL_NEED_EXPLICIT\n#     define __STL_NO_BOOL\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if _MSC_VER > 1000\n#     include <yvals.h>\n#     define __STL_DONT_USE_BOOL_TYPEDEF\n#   endif\n#   define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n#   if _MSC_VER >= 1200\n#     define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#     define __STL_HAS_NAMESPACES\n#     define __STL_CAN_THROW_RANGE_ERRORS\n#     define NOMINMAX\n#     undef min\n#     undef max\n// disable warning 'initializers put in unrecognized initialization area'\n#     pragma warning ( disable : 4075 )\n// disable warning 'empty controlled statement found'\n#     pragma warning ( disable : 4390 )\n// disable warning 'debug symbol greater than 255 chars'\n#     pragma warning ( disable : 4786 )\n#   endif\n#   if _MSC_VER < 1100\n#     define __STL_NO_EXCEPTION_HEADER\n#     define __STL_NO_BAD_ALLOC\n#   endif\n    // Because of a Microsoft front end bug, we must not provide a\n    // namespace qualifier when declaring a friend function.\n#   define __STD_QUALIFIER\n# endif\n\n# if defined(__BORLANDC__)\n#     define __STL_NO_BAD_ALLOC\n#     define __STL_NO_DRAND48\n#     define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_TEMPLATE_FRIENDS\n#   else\n#     define __STL_NEED_TYPENAME\n#     define __STL_LIMITED_DEFAULT_TEMPLATES\n#     define __SGI_STL_NO_ARROW_OPERATOR\n#     define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   endif\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef __MT__\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF)\n    typedef int bool;\n#   define true 1\n#   define false 0\n# endif\n\n# ifdef __STL_NEED_TYPENAME\n#   define typename\n# endif\n\n# ifdef __STL_LIMITED_DEFAULT_TEMPLATES\n#   define __STL_DEPENDENT_DEFAULT_TMPL(_Tp)\n# else\n#   define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp\n# endif\n\n# ifdef __STL_MEMBER_TEMPLATE_KEYWORD\n#   define __STL_TEMPLATE template\n# else\n#   define __STL_TEMPLATE\n# endif\n\n# ifdef __STL_NEED_EXPLICIT\n#   define explicit\n# endif\n\n# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#   define __STL_NULL_TMPL_ARGS <>\n# else\n#   define __STL_NULL_TMPL_ARGS\n# endif\n\n# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \\\n     || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX)\n#   define __STL_TEMPLATE_NULL template<>\n# else\n#   define __STL_TEMPLATE_NULL\n# endif\n\n// Use standard-conforming allocators if we have the necessary language\n// features.  __STL_USE_SGI_ALLOCATORS is a hook so that users can \n// disable new-style allocators, and continue to use the same kind of\n// allocators as before, without having to edit library headers.\n# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \\\n     defined(__STL_MEMBER_TEMPLATES) && \\\n     defined(__STL_MEMBER_TEMPLATE_CLASSES) && \\\n    !defined(__STL_NO_BOOL) && \\\n    !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \\\n    !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \\\n    !defined(__STL_USE_SGI_ALLOCATORS) \n#   define __STL_USE_STD_ALLOCATORS\n# endif\n\n# ifndef __STL_DEFAULT_ALLOCATOR\n#   ifdef __STL_USE_STD_ALLOCATORS\n#     define __STL_DEFAULT_ALLOCATOR(T) allocator< T >\n#   else\n#     define __STL_DEFAULT_ALLOCATOR(T) alloc\n#   endif\n# endif\n\n// __STL_NO_NAMESPACES is a hook so that users can disable namespaces\n// without having to edit library headers.  __STL_NO_RELOPS_NAMESPACE is\n// a hook so that users can disable the std::rel_ops namespace, keeping \n// the relational operator template in namespace std, without having to \n// edit library headers.\n# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES)\n#   define __STL_USE_NAMESPACES\n#   define __STD std\n#   define __STL_BEGIN_NAMESPACE namespace std {\n#   define __STL_END_NAMESPACE }\n#   if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \\\n       !defined(__STL_NO_RELOPS_NAMESPACE)\n#     define __STL_USE_NAMESPACE_FOR_RELOPS\n#     define __STL_BEGIN_RELOPS_NAMESPACE namespace std { namespace rel_ops {\n#     define __STL_END_RELOPS_NAMESPACE } }\n#     define __STD_RELOPS std::rel_ops\n#   else /* Use std::rel_ops namespace */\n#     define __STL_USE_NAMESPACE_FOR_RELOPS\n#     define __STL_BEGIN_RELOPS_NAMESPACE namespace std {\n#     define __STL_END_RELOPS_NAMESPACE }\n#     define __STD_RELOPS std\n#   endif /* Use std::rel_ops namespace */\n# else\n#   define __STD \n#   define __STL_BEGIN_NAMESPACE \n#   define __STL_END_NAMESPACE \n#   undef  __STL_USE_NAMESPACE_FOR_RELOPS\n#   define __STL_BEGIN_RELOPS_NAMESPACE \n#   define __STL_END_RELOPS_NAMESPACE \n#   define __STD_RELOPS \n#   undef  __STL_USE_NAMESPACES\n# endif\n\n// Some versions of the EDG front end sometimes require an explicit\n// namespace spec where they shouldn't.  This macro facilitates that.\n// If the bug becomes irrelevant, then all uses of __STD_QUALIFIER\n// should be removed.  The 7.3 beta SGI compiler has this bug, but the\n// MR version is not expected to have it.\n\n# if defined(__STL_USE_NAMESPACES) && !defined(__STD_QUALIFIER)\n#   define __STD_QUALIFIER std::\n# else\n#   define __STD_QUALIFIER\n# endif\n\n# ifdef __STL_USE_EXCEPTIONS\n#   define __STL_TRY try\n#   define __STL_CATCH_ALL catch(...)\n#   define __STL_THROW(x) throw x\n#   define __STL_RETHROW throw\n#   define __STL_NOTHROW throw()\n#   define __STL_UNWIND(action) catch(...) { action; throw; }\n# else\n#   define __STL_TRY \n#   define __STL_CATCH_ALL if (false)\n#   define __STL_THROW(x) \n#   define __STL_RETHROW \n#   define __STL_NOTHROW \n#   define __STL_UNWIND(action) \n# endif\n\n#ifdef __STL_ASSERTIONS\n# include <stdio.h>\n# define __stl_assert(expr) \\\n    if (!(expr)) { fprintf(stderr, \"%s:%d STL assertion failure: %s\\n\", \\\n\t\t\t  __FILE__, __LINE__, # expr); abort(); }\n#else\n# define __stl_assert(expr)\n#endif\n\n#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \\\n    || defined(__STL_PTHREADS)  || defined(__STL_UITHREADS)\n#   define __STL_THREADS\n#   define __STL_VOLATILE volatile\n#else\n#   define __STL_VOLATILE\n#endif\n\n#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \\\n    && defined(__STL_MEMBER_TEMPLATES) \\\n    && !defined(_STL_NO_CONCEPT_CHECKS)\n#  define __STL_USE_CONCEPT_CHECKS\n#endif\n\n\n#endif /* __STL_CONFIG_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_construct.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#define __SGI_STL_INTERNAL_CONSTRUCT_H\n\n#include <new.h>\n\n__STL_BEGIN_NAMESPACE\n\n// construct and destroy.  These functions are not part of the C++ standard,\n// and are provided for backward compatibility with the HP STL.  We also\n// provide internal names _Construct and _Destroy that can be used within\n// the library, so that standard-conforming pieces don't have to rely on\n// non-standard extensions.\n\n// Internal names\n\ntemplate <class _T1, class _T2>\ninline void _Construct(_T1* __p, const _T2& __value) {\n  new ((void*) __p) _T1(__value);\n}\n\ntemplate <class _T1>\ninline void _Construct(_T1* __p) {\n  new ((void*) __p) _T1();\n}\n\ntemplate <class _Tp>\ninline void _Destroy(_Tp* __pointer) {\n  __pointer->~_Tp();\n}\n\ntemplate <class _ForwardIterator>\nvoid\n__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)\n{\n  for ( ; __first != __last; ++__first)\n    destroy(&*__first);\n}\n\ntemplate <class _ForwardIterator> \ninline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}\n\ntemplate <class _ForwardIterator, class _Tp>\ninline void \n__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)\n{\n  typedef typename __type_traits<_Tp>::has_trivial_destructor\n          _Trivial_destructor;\n  __destroy_aux(__first, __last, _Trivial_destructor());\n}\n\ntemplate <class _ForwardIterator>\ninline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {\n  __destroy(__first, __last, __VALUE_TYPE(__first));\n}\n\ninline void _Destroy(char*, char*) {}\ninline void _Destroy(int*, int*) {}\ninline void _Destroy(long*, long*) {}\ninline void _Destroy(float*, float*) {}\ninline void _Destroy(double*, double*) {}\n#ifdef __STL_HAS_WCHAR_T\ninline void _Destroy(wchar_t*, wchar_t*) {}\n#endif /* __STL_HAS_WCHAR_T */\n\n// --------------------------------------------------\n// Old names from the HP STL.\n\ntemplate <class _T1, class _T2>\ninline void construct(_T1* __p, const _T2& __value) {\n  _Construct(__p, __value);\n}\n\ntemplate <class _T1>\ninline void construct(_T1* __p) {\n  _Construct(__p);\n}\n\ntemplate <class _Tp>\ninline void destroy(_Tp* __pointer) {\n  _Destroy(__pointer);\n}\n\ntemplate <class _ForwardIterator>\ninline void destroy(_ForwardIterator __first, _ForwardIterator __last) {\n  _Destroy(__first, __last);\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_ctraits_fns.h",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n// WARNING: This is an internal header file, included by other C++\n// standard library headers.  You should not attempt to use this header\n// file directly.\n\n#ifndef __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H\n#define __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H\n\n// This file contains a few small adapters that allow a character\n// traits class to be used as a function object.\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _Traits>\nstruct _Eq_traits\n  : public binary_function<typename _Traits::char_type,\n                           typename _Traits::char_type,\n                           bool>\n{\n  bool operator()(const typename _Traits::char_type& __x,\n                  const typename _Traits::char_type& __y) const\n    { return _Traits::eq(__x, __y); }\n};\n\ntemplate <class _Traits>\nstruct _Eq_int_traits\n  : public binary_function<typename _Traits::char_type,\n                           typename _Traits::int_type,\n                           bool>\n{\n  bool operator()(const typename _Traits::char_type& __x,\n                  const typename _Traits::int_type& __y) const\n    { return _Traits::eq_int_type(_Traits::to_int_type(__x), __y); }\n};\n\ntemplate <class _Traits>\nstruct _Lt_traits\n  : public binary_function<typename _Traits::char_type,\n                           typename _Traits::char_type,\n                           bool>\n{\n  bool operator()(const typename _Traits::char_type& __x,\n                  const typename _Traits::char_type& __y) const\n    { return _Traits::lt(__x, __y); }\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n\n\n\n\n"
  },
  {
    "path": "stl-3.3-source/stl_deque.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#include <concept_checks.h>\n\n#ifndef __SGI_STL_INTERNAL_DEQUE_H\n#define __SGI_STL_INTERNAL_DEQUE_H\n\n/* Class invariants:\n *  For any nonsingular iterator i:\n *    i.node is the address of an element in the map array.  The\n *      contents of i.node is a pointer to the beginning of a node.\n *    i.first == *(i.node) \n *    i.last  == i.first + node_size\n *    i.cur is a pointer in the range [i.first, i.last).  NOTE:\n *      the implication of this is that i.cur is always a dereferenceable\n *      pointer, even if i is a past-the-end iterator.\n *  Start and Finish are always nonsingular iterators.  NOTE: this means\n *    that an empty deque must have one node, and that a deque\n *    with N elements, where N is the buffer size, must have two nodes.\n *  For every node other than start.node and finish.node, every element\n *    in the node is an initialized object.  If start.node == finish.node,\n *    then [start.cur, finish.cur) are initialized objects, and\n *    the elements outside that range are uninitialized storage.  Otherwise,\n *    [start.cur, start.last) and [finish.first, finish.cur) are initialized\n *    objects, and [start.first, start.cur) and [finish.cur, finish.last)\n *    are uninitialized storage.\n *  [map, map + map_size) is a valid, non-empty range.  \n *  [start.node, finish.node] is a valid range contained within \n *    [map, map + map_size).  \n *  A pointer in the range [map, map + map_size) points to an allocated node\n *    if and only if the pointer is in the range [start.node, finish.node].\n */\n\n\n/*\n * In previous versions of deque, there was an extra template \n * parameter so users could control the node size.  This extension\n * turns out to violate the C++ standard (it can be detected using\n * template template parameters), and it has been removed.\n */\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Note: this function is simply a kludge to work around several compilers'\n//  bugs in handling constant expressions.\ninline size_t __deque_buf_size(size_t __size) {\n  return __size < 512 ? size_t(512 / __size) : size_t(1);\n}\n\ntemplate <class _Tp, class _Ref, class _Ptr>\nstruct _Deque_iterator {\n  typedef _Deque_iterator<_Tp, _Tp&, _Tp*>             iterator;\n  typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;\n  static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }\n\n  typedef random_access_iterator_tag iterator_category;\n  typedef _Tp value_type;\n  typedef _Ptr pointer;\n  typedef _Ref reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n  typedef _Tp** _Map_pointer;\n\n  typedef _Deque_iterator _Self;\n\n  _Tp* _M_cur;\n  _Tp* _M_first;\n  _Tp* _M_last;\n  _Map_pointer _M_node;\n\n  _Deque_iterator(_Tp* __x, _Map_pointer __y) \n    : _M_cur(__x), _M_first(*__y),\n      _M_last(*__y + _S_buffer_size()), _M_node(__y) {}\n  _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {}\n  _Deque_iterator(const iterator& __x)\n    : _M_cur(__x._M_cur), _M_first(__x._M_first), \n      _M_last(__x._M_last), _M_node(__x._M_node) {}\n\n  reference operator*() const { return *_M_cur; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return _M_cur; }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  difference_type operator-(const _Self& __x) const {\n    return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) +\n      (_M_cur - _M_first) + (__x._M_last - __x._M_cur);\n  }\n\n  _Self& operator++() {\n    ++_M_cur;\n    if (_M_cur == _M_last) {\n      _M_set_node(_M_node + 1);\n      _M_cur = _M_first;\n    }\n    return *this; \n  }\n  _Self operator++(int)  {\n    _Self __tmp = *this;\n    ++*this;\n    return __tmp;\n  }\n\n  _Self& operator--() {\n    if (_M_cur == _M_first) {\n      _M_set_node(_M_node - 1);\n      _M_cur = _M_last;\n    }\n    --_M_cur;\n    return *this;\n  }\n  _Self operator--(int) {\n    _Self __tmp = *this;\n    --*this;\n    return __tmp;\n  }\n\n  _Self& operator+=(difference_type __n)\n  {\n    difference_type __offset = __n + (_M_cur - _M_first);\n    if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))\n      _M_cur += __n;\n    else {\n      difference_type __node_offset =\n        __offset > 0 ? __offset / difference_type(_S_buffer_size())\n                   : -difference_type((-__offset - 1) / _S_buffer_size()) - 1;\n      _M_set_node(_M_node + __node_offset);\n      _M_cur = _M_first + \n        (__offset - __node_offset * difference_type(_S_buffer_size()));\n    }\n    return *this;\n  }\n\n  _Self operator+(difference_type __n) const\n  {\n    _Self __tmp = *this;\n    return __tmp += __n;\n  }\n\n  _Self& operator-=(difference_type __n) { return *this += -__n; }\n \n  _Self operator-(difference_type __n) const {\n    _Self __tmp = *this;\n    return __tmp -= __n;\n  }\n\n  reference operator[](difference_type __n) const { return *(*this + __n); }\n\n  bool operator==(const _Self& __x) const { return _M_cur == __x._M_cur; }\n  bool operator!=(const _Self& __x) const { return !(*this == __x); }\n  bool operator<(const _Self& __x) const {\n    return (_M_node == __x._M_node) ? \n      (_M_cur < __x._M_cur) : (_M_node < __x._M_node);\n  }\n  bool operator>(const _Self& __x) const  { return __x < *this; }\n  bool operator<=(const _Self& __x) const { return !(__x < *this); }\n  bool operator>=(const _Self& __x) const { return !(*this < __x); }\n\n  void _M_set_node(_Map_pointer __new_node) {\n    _M_node = __new_node;\n    _M_first = *__new_node;\n    _M_last = _M_first + difference_type(_S_buffer_size());\n  }\n};\n\ntemplate <class _Tp, class _Ref, class _Ptr>\ninline _Deque_iterator<_Tp, _Ref, _Ptr>\noperator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)\n{\n  return __x + __n;\n}\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp, class _Ref, class _Ptr>\ninline random_access_iterator_tag\niterator_category(const _Deque_iterator<_Tp,_Ref,_Ptr>&)\n{\n  return random_access_iterator_tag();\n}\n\ntemplate <class _Tp, class _Ref, class _Ptr>\ninline _Tp* value_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { return 0; }\n\ntemplate <class _Tp, class _Ref, class _Ptr>\ninline ptrdiff_t* distance_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) {\n  return 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Deque base class.  It has two purposes.  First, its constructor\n//  and destructor allocate (but don't initialize) storage.  This makes\n//  exception safety easier.  Second, the base class encapsulates all of\n//  the differences between SGI-style allocators and standard-conforming\n//  allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base class for ordinary allocators.\ntemplate <class _Tp, class _Alloc, bool __is_static>\nclass _Deque_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _M_node_allocator; }\n\n  _Deque_alloc_base(const allocator_type& __a)\n    : _M_node_allocator(__a), _M_map_allocator(__a),\n      _M_map(0), _M_map_size(0)\n  {}\n  \nprotected:\n  typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type\n          _Map_allocator_type;\n\n  allocator_type      _M_node_allocator;\n  _Map_allocator_type _M_map_allocator;\n\n  _Tp* _M_allocate_node() {\n    return _M_node_allocator.allocate(__deque_buf_size(sizeof(_Tp)));\n  }\n  void _M_deallocate_node(_Tp* __p) {\n    _M_node_allocator.deallocate(__p, __deque_buf_size(sizeof(_Tp)));\n  }\n  _Tp** _M_allocate_map(size_t __n) \n    { return _M_map_allocator.allocate(__n); }\n  void _M_deallocate_map(_Tp** __p, size_t __n) \n    { _M_map_allocator.deallocate(__p, __n); }\n\n  _Tp** _M_map;\n  size_t _M_map_size;\n};\n\n// Specialization for instanceless allocators.\ntemplate <class _Tp, class _Alloc>\nclass _Deque_alloc_base<_Tp, _Alloc, true>\n{\npublic:\n  typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Deque_alloc_base(const allocator_type&) : _M_map(0), _M_map_size(0) {}\n  \nprotected:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Node_alloc_type;\n  typedef typename _Alloc_traits<_Tp*, _Alloc>::_Alloc_type _Map_alloc_type;\n\n  _Tp* _M_allocate_node() {\n    return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp)));\n  }\n  void _M_deallocate_node(_Tp* __p) {\n    _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp)));\n  }\n  _Tp** _M_allocate_map(size_t __n) \n    { return _Map_alloc_type::allocate(__n); }\n  void _M_deallocate_map(_Tp** __p, size_t __n) \n    { _Map_alloc_type::deallocate(__p, __n); }\n\n  _Tp** _M_map;\n  size_t _M_map_size;\n};\n\ntemplate <class _Tp, class _Alloc>\nclass _Deque_base\n  : public _Deque_alloc_base<_Tp,_Alloc,\n                              _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\npublic:\n  typedef _Deque_alloc_base<_Tp,_Alloc,\n                             _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n  typedef _Deque_iterator<_Tp,_Tp&,_Tp*>             iterator;\n  typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;\n\n  _Deque_base(const allocator_type& __a, size_t __num_elements)\n    : _Base(__a), _M_start(), _M_finish()\n    { _M_initialize_map(__num_elements); }\n  _Deque_base(const allocator_type& __a) \n    : _Base(__a), _M_start(), _M_finish() {}\n  ~_Deque_base();    \n\nprotected:\n  void _M_initialize_map(size_t);\n  void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);\n  void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);\n  enum { _S_initial_map_size = 8 };\n\nprotected:\n  iterator _M_start;\n  iterator _M_finish;\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc>\nclass _Deque_base {\npublic:\n  typedef _Deque_iterator<_Tp,_Tp&,_Tp*>             iterator;\n  typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;\n\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Deque_base(const allocator_type&, size_t __num_elements)\n    : _M_map(0), _M_map_size(0),  _M_start(), _M_finish() {\n    _M_initialize_map(__num_elements);\n  }\n  _Deque_base(const allocator_type&)\n    : _M_map(0), _M_map_size(0),  _M_start(), _M_finish() {}\n  ~_Deque_base();    \n\nprotected:\n  void _M_initialize_map(size_t);\n  void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);\n  void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);\n  enum { _S_initial_map_size = 8 };\n\nprotected:\n  _Tp** _M_map;\n  size_t _M_map_size;  \n  iterator _M_start;\n  iterator _M_finish;\n\n  typedef simple_alloc<_Tp, _Alloc>  _Node_alloc_type;\n  typedef simple_alloc<_Tp*, _Alloc> _Map_alloc_type;\n\n  _Tp* _M_allocate_node()\n    { return _Node_alloc_type::allocate(__deque_buf_size(sizeof(_Tp))); }\n  void _M_deallocate_node(_Tp* __p)\n    { _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp))); }\n  _Tp** _M_allocate_map(size_t __n) \n    { return _Map_alloc_type::allocate(__n); }\n  void _M_deallocate_map(_Tp** __p, size_t __n) \n    { _Map_alloc_type::deallocate(__p, __n); }\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n// Non-inline member functions from _Deque_base.\n\ntemplate <class _Tp, class _Alloc>\n_Deque_base<_Tp,_Alloc>::~_Deque_base() {\n  if (_M_map) {\n    _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1);\n    _M_deallocate_map(_M_map, _M_map_size);\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid\n_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)\n{\n  size_t __num_nodes = \n    __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;\n\n  _M_map_size = max((size_t) _S_initial_map_size, __num_nodes + 2);\n  _M_map = _M_allocate_map(_M_map_size);\n\n  _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2;\n  _Tp** __nfinish = __nstart + __num_nodes;\n    \n  __STL_TRY {\n    _M_create_nodes(__nstart, __nfinish);\n  }\n  __STL_UNWIND((_M_deallocate_map(_M_map, _M_map_size), \n                _M_map = 0, _M_map_size = 0));\n  _M_start._M_set_node(__nstart);\n  _M_finish._M_set_node(__nfinish - 1);\n  _M_start._M_cur = _M_start._M_first;\n  _M_finish._M_cur = _M_finish._M_first +\n               __num_elements % __deque_buf_size(sizeof(_Tp));\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)\n{\n  _Tp** __cur;\n  __STL_TRY {\n    for (__cur = __nstart; __cur < __nfinish; ++__cur)\n      *__cur = _M_allocate_node();\n  }\n  __STL_UNWIND(_M_destroy_nodes(__nstart, __cur));\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid\n_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)\n{\n  for (_Tp** __n = __nstart; __n < __nfinish; ++__n)\n    _M_deallocate_node(*__n);\n}\n\ntemplate <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass deque : protected _Deque_base<_Tp, _Alloc> {\n\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n\n  typedef _Deque_base<_Tp, _Alloc> _Base;\npublic:                         // Basic types\n  typedef _Tp value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\npublic:                         // Iterators\n  typedef typename _Base::iterator       iterator;\n  typedef typename _Base::const_iterator const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type>  \n          const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator; \n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:                      // Internal typedefs\n  typedef pointer* _Map_pointer;\n  static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }\n\nprotected:\n#ifdef __STL_USE_NAMESPACES\n  using _Base::_M_initialize_map;\n  using _Base::_M_create_nodes;\n  using _Base::_M_destroy_nodes;\n  using _Base::_M_allocate_node;\n  using _Base::_M_deallocate_node;\n  using _Base::_M_allocate_map;\n  using _Base::_M_deallocate_map;\n\n  using _Base::_M_map;\n  using _Base::_M_map_size;\n  using _Base::_M_start;\n  using _Base::_M_finish;\n#endif /* __STL_USE_NAMESPACES */\n\npublic:                         // Basic accessors\n  iterator begin() { return _M_start; }\n  iterator end() { return _M_finish; }\n  const_iterator begin() const { return _M_start; }\n  const_iterator end() const { return _M_finish; }\n\n  reverse_iterator rbegin() { return reverse_iterator(_M_finish); }\n  reverse_iterator rend() { return reverse_iterator(_M_start); }\n  const_reverse_iterator rbegin() const \n    { return const_reverse_iterator(_M_finish); }\n  const_reverse_iterator rend() const \n    { return const_reverse_iterator(_M_start); }\n\n  reference operator[](size_type __n)\n    { return _M_start[difference_type(__n)]; }\n  const_reference operator[](size_type __n) const \n    { return _M_start[difference_type(__n)]; }\n\n#ifdef __STL_THROW_RANGE_ERRORS\n  void _M_range_check(size_type __n) const {\n    if (__n >= this->size())\n      __stl_throw_range_error(\"deque\");\n  }\n\n  reference at(size_type __n)\n    { _M_range_check(__n); return (*this)[__n]; }\n  const_reference at(size_type __n) const\n    { _M_range_check(__n); return (*this)[__n]; }\n#endif /* __STL_THROW_RANGE_ERRORS */\n\n  reference front() { return *_M_start; }\n  reference back() {\n    iterator __tmp = _M_finish;\n    --__tmp;\n    return *__tmp;\n  }\n  const_reference front() const { return *_M_start; }\n  const_reference back() const {\n    const_iterator __tmp = _M_finish;\n    --__tmp;\n    return *__tmp;\n  }\n\n  size_type size() const { return _M_finish - _M_start; }\n  size_type max_size() const { return size_type(-1); }\n  bool empty() const { return _M_finish == _M_start; }\n\npublic:                         // Constructor, destructor.\n  explicit deque(const allocator_type& __a = allocator_type()) \n    : _Base(__a, 0) {}\n  deque(const deque& __x) : _Base(__x.get_allocator(), __x.size()) \n    { uninitialized_copy(__x.begin(), __x.end(), _M_start); }\n  deque(size_type __n, const value_type& __value,\n        const allocator_type& __a = allocator_type()) : _Base(__a, __n)\n    { _M_fill_initialize(__value); }\n  explicit deque(size_type __n) : _Base(allocator_type(), __n)\n    { _M_fill_initialize(value_type()); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check whether it's an integral type.  If so, it's not an iterator.\n  template <class _InputIterator>\n  deque(_InputIterator __first, _InputIterator __last,\n        const allocator_type& __a = allocator_type()) : _Base(__a) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_initialize_dispatch(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {\n    _M_initialize_map(__n);\n    _M_fill_initialize(__x);\n  }\n\n  template <class _InputIter>\n  void _M_initialize_dispatch(_InputIter __first, _InputIter __last,\n                              __false_type) {\n    _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  deque(const value_type* __first, const value_type* __last,\n        const allocator_type& __a = allocator_type()) \n    : _Base(__a, __last - __first)\n    { uninitialized_copy(__first, __last, _M_start); }\n  deque(const_iterator __first, const_iterator __last,\n        const allocator_type& __a = allocator_type()) \n    : _Base(__a, __last - __first)\n    { uninitialized_copy(__first, __last, _M_start); }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  ~deque() { destroy(_M_start, _M_finish); }\n\n  deque& operator= (const deque& __x) {\n    const size_type __len = size();\n    if (&__x != this) {\n      if (__len >= __x.size())\n        erase(copy(__x.begin(), __x.end(), _M_start), _M_finish);\n      else {\n        const_iterator __mid = __x.begin() + difference_type(__len);\n        copy(__x.begin(), __mid, _M_start);\n        insert(_M_finish, __mid, __x.end());\n      }\n    }\n    return *this;\n  }        \n\n  void swap(deque& __x) {\n    __STD::swap(_M_start, __x._M_start);\n    __STD::swap(_M_finish, __x._M_finish);\n    __STD::swap(_M_map, __x._M_map);\n    __STD::swap(_M_map_size, __x._M_map_size);\n  }\n\npublic: \n  // assign(), a generalized assignment member function.  Two\n  // versions: one that takes a count, and one that takes a range.\n  // The range version is a member template, so we dispatch on whether\n  // or not the type is an integer.\n\n  void _M_fill_assign(size_type __n, const _Tp& __val) {\n    if (__n > size()) {\n      fill(begin(), end(), __val);\n      insert(end(), __n - size(), __val);\n    }\n    else {\n      erase(begin() + __n, end());\n      fill(begin(), end(), __val);\n    }\n  }\n\n  void assign(size_type __n, const _Tp& __val) {\n    _M_fill_assign(__n, __val);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIterator>\n  void assign(_InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_assign_dispatch(__first, __last, _Integral());\n  }\n\nprivate:                        // helper functions for assign() \n\n  template <class _Integer>\n  void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)\n    { _M_fill_assign((size_type) __n, (_Tp) __val); }\n\n  template <class _InputIterator>\n  void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,\n                          __false_type) {\n    _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n  template <class _InputIterator>\n  void _M_assign_aux(_InputIterator __first, _InputIterator __last,\n                     input_iterator_tag);\n\n  template <class _ForwardIterator>\n  void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,\n                     forward_iterator_tag) {\n    size_type __len = 0;\n    distance(__first, __last, __len);\n    if (__len > size()) {\n      _ForwardIterator __mid = __first;\n      advance(__mid, size());\n      copy(__first, __mid, begin());\n      insert(end(), __mid, __last);\n    }\n    else\n      erase(copy(__first, __last, begin()), end());\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:                         // push_* and pop_*\n  \n  void push_back(const value_type& __t) {\n    if (_M_finish._M_cur != _M_finish._M_last - 1) {\n      construct(_M_finish._M_cur, __t);\n      ++_M_finish._M_cur;\n    }\n    else\n      _M_push_back_aux(__t);\n  }\n\n  void push_back() {\n    if (_M_finish._M_cur != _M_finish._M_last - 1) {\n      construct(_M_finish._M_cur);\n      ++_M_finish._M_cur;\n    }\n    else\n      _M_push_back_aux();\n  }\n\n  void push_front(const value_type& __t) {\n    if (_M_start._M_cur != _M_start._M_first) {\n      construct(_M_start._M_cur - 1, __t);\n      --_M_start._M_cur;\n    }\n    else\n      _M_push_front_aux(__t);\n  }\n\n  void push_front() {\n    if (_M_start._M_cur != _M_start._M_first) {\n      construct(_M_start._M_cur - 1);\n      --_M_start._M_cur;\n    }\n    else\n      _M_push_front_aux();\n  }\n\n\n  void pop_back() {\n    if (_M_finish._M_cur != _M_finish._M_first) {\n      --_M_finish._M_cur;\n      destroy(_M_finish._M_cur);\n    }\n    else\n      _M_pop_back_aux();\n  }\n\n  void pop_front() {\n    if (_M_start._M_cur != _M_start._M_last - 1) {\n      destroy(_M_start._M_cur);\n      ++_M_start._M_cur;\n    }\n    else \n      _M_pop_front_aux();\n  }\n\npublic:                         // Insert\n\n  iterator insert(iterator position, const value_type& __x) {\n    if (position._M_cur == _M_start._M_cur) {\n      push_front(__x);\n      return _M_start;\n    }\n    else if (position._M_cur == _M_finish._M_cur) {\n      push_back(__x);\n      iterator __tmp = _M_finish;\n      --__tmp;\n      return __tmp;\n    }\n    else {\n      return _M_insert_aux(position, __x);\n    }\n  }\n\n  iterator insert(iterator __position)\n    { return insert(__position, value_type()); }\n\n  void insert(iterator __pos, size_type __n, const value_type& __x)\n    { _M_fill_insert(__pos, __n, __x); }\n\n  void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); \n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  // Check whether it's an integral type.  If so, it's not an iterator.\n  template <class _InputIterator>\n  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_insert_dispatch(__pos, __first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,\n                          __true_type) {\n    _M_fill_insert(__pos, (size_type) __n, (value_type) __x);\n  }\n\n  template <class _InputIterator>\n  void _M_insert_dispatch(iterator __pos,\n                          _InputIterator __first, _InputIterator __last,\n                          __false_type) {\n    insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void insert(iterator __pos,\n              const value_type* __first, const value_type* __last);\n  void insert(iterator __pos,\n              const_iterator __first, const_iterator __last);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void resize(size_type __new_size, const value_type& __x) {\n    const size_type __len = size();\n    if (__new_size < __len) \n      erase(_M_start + __new_size, _M_finish);\n    else\n      insert(_M_finish, __new_size - __len, __x);\n  }\n\n  void resize(size_type new_size) { resize(new_size, value_type()); }\n\npublic:                         // Erase\n  iterator erase(iterator __pos) {\n    iterator __next = __pos;\n    ++__next;\n    difference_type __index = __pos - _M_start;\n    if (size_type(__index) < (this->size() >> 1)) {\n      copy_backward(_M_start, __pos, __next);\n      pop_front();\n    }\n    else {\n      copy(__next, _M_finish, __pos);\n      pop_back();\n    }\n    return _M_start + __index;\n  }\n\n  iterator erase(iterator __first, iterator __last);\n  void clear(); \n\nprotected:                        // Internal construction/destruction\n\n  void _M_fill_initialize(const value_type& __value);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class _InputIterator>\n  void _M_range_initialize(_InputIterator __first, _InputIterator __last,\n                        input_iterator_tag);\n\n  template <class _ForwardIterator>\n  void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,\n                        forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprotected:                        // Internal push_* and pop_*\n\n  void _M_push_back_aux(const value_type&);\n  void _M_push_back_aux();\n  void _M_push_front_aux(const value_type&);\n  void _M_push_front_aux();\n  void _M_pop_back_aux();\n  void _M_pop_front_aux();\n\nprotected:                        // Internal insert functions\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class _InputIterator>\n  void insert(iterator __pos, _InputIterator __first, _InputIterator __last,\n              input_iterator_tag);\n\n  template <class _ForwardIterator>\n  void insert(iterator __pos,\n              _ForwardIterator __first, _ForwardIterator __last,\n              forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator _M_insert_aux(iterator __pos, const value_type& __x);\n  iterator _M_insert_aux(iterator __pos);\n  void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class _ForwardIterator>\n  void _M_insert_aux(iterator __pos, \n                     _ForwardIterator __first, _ForwardIterator __last,\n                     size_type __n);\n\n#else /* __STL_MEMBER_TEMPLATES */\n  \n  void _M_insert_aux(iterator __pos,\n                     const value_type* __first, const value_type* __last,\n                     size_type __n);\n\n  void _M_insert_aux(iterator __pos, \n                     const_iterator __first, const_iterator __last,\n                     size_type __n);\n \n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator _M_reserve_elements_at_front(size_type __n) {\n    size_type __vacancies = _M_start._M_cur - _M_start._M_first;\n    if (__n > __vacancies) \n      _M_new_elements_at_front(__n - __vacancies);\n    return _M_start - difference_type(__n);\n  }\n\n  iterator _M_reserve_elements_at_back(size_type __n) {\n    size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1;\n    if (__n > __vacancies)\n      _M_new_elements_at_back(__n - __vacancies);\n    return _M_finish + difference_type(__n);\n  }\n\n  void _M_new_elements_at_front(size_type __new_elements);\n  void _M_new_elements_at_back(size_type __new_elements);\n\nprotected:                      // Allocation of _M_map and nodes\n\n  // Makes sure the _M_map has space for new nodes.  Does not actually\n  //  add the nodes.  Can invalidate _M_map pointers.  (And consequently, \n  //  deque iterators.)\n\n  void _M_reserve_map_at_back (size_type __nodes_to_add = 1) {\n    if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map))\n      _M_reallocate_map(__nodes_to_add, false);\n  }\n\n  void _M_reserve_map_at_front (size_type __nodes_to_add = 1) {\n    if (__nodes_to_add > size_type(_M_start._M_node - _M_map))\n      _M_reallocate_map(__nodes_to_add, true);\n  }\n\n  void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);\n};\n\n// Non-inline member functions\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc>\ntemplate <class _InputIter>\nvoid deque<_Tp, _Alloc>\n  ::_M_assign_aux(_InputIter __first, _InputIter __last, input_iterator_tag)\n{\n  iterator __cur = begin();\n  for ( ; __first != __last && __cur != end(); ++__cur, ++__first)\n    *__cur = *__first;\n  if (__first == __last)\n    erase(__cur, end());\n  else\n    insert(end(), __first, __last);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp, _Alloc>::_M_fill_insert(iterator __pos,\n                                        size_type __n, const value_type& __x)\n{\n  if (__pos._M_cur == _M_start._M_cur) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    __STL_TRY {\n      uninitialized_fill(__new_start, _M_start, __x);\n      _M_start = __new_start;\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else if (__pos._M_cur == _M_finish._M_cur) {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    __STL_TRY {\n      uninitialized_fill(_M_finish, __new_finish, __x);\n      _M_finish = __new_finish;\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));    \n  }\n  else \n    _M_insert_aux(__pos, __n, __x);\n}\n\n#ifndef __STL_MEMBER_TEMPLATES  \n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp, _Alloc>::insert(iterator __pos,\n                                const value_type* __first,\n                                const value_type* __last) {\n  size_type __n = __last - __first;\n  if (__pos._M_cur == _M_start._M_cur) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, __new_start);\n      _M_start = __new_start;\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else if (__pos._M_cur == _M_finish._M_cur) {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, _M_finish);\n      _M_finish = __new_finish;\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));\n  }\n  else\n    _M_insert_aux(__pos, __first, __last, __n);\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::insert(iterator __pos,\n                               const_iterator __first, const_iterator __last)\n{\n  size_type __n = __last - __first;\n  if (__pos._M_cur == _M_start._M_cur) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, __new_start);\n      _M_start = __new_start;\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else if (__pos._M_cur == _M_finish._M_cur) {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, _M_finish);\n      _M_finish = __new_finish;\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                 __new_finish._M_node + 1));\n  }\n  else\n    _M_insert_aux(__pos, __first, __last, __n);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\ntypename deque<_Tp,_Alloc>::iterator \ndeque<_Tp,_Alloc>::erase(iterator __first, iterator __last)\n{\n  if (__first == _M_start && __last == _M_finish) {\n    clear();\n    return _M_finish;\n  }\n  else {\n    difference_type __n = __last - __first;\n    difference_type __elems_before = __first - _M_start;\n    if (__elems_before < difference_type((this->size() - __n) / 2)) {\n      copy_backward(_M_start, __first, __last);\n      iterator __new_start = _M_start + __n;\n      destroy(_M_start, __new_start);\n      _M_destroy_nodes(__new_start._M_node, _M_start._M_node);\n      _M_start = __new_start;\n    }\n    else {\n      copy(__last, _M_finish, __first);\n      iterator __new_finish = _M_finish - __n;\n      destroy(__new_finish, _M_finish);\n      _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1);\n      _M_finish = __new_finish;\n    }\n    return _M_start + __elems_before;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> \nvoid deque<_Tp,_Alloc>::clear()\n{\n  for (_Map_pointer __node = _M_start._M_node + 1;\n       __node < _M_finish._M_node;\n       ++__node) {\n    destroy(*__node, *__node + _S_buffer_size());\n    _M_deallocate_node(*__node);\n  }\n\n  if (_M_start._M_node != _M_finish._M_node) {\n    destroy(_M_start._M_cur, _M_start._M_last);\n    destroy(_M_finish._M_first, _M_finish._M_cur);\n    _M_deallocate_node(_M_finish._M_first);\n  }\n  else\n    destroy(_M_start._M_cur, _M_finish._M_cur);\n\n  _M_finish = _M_start;\n}\n\n// Precondition: _M_start and _M_finish have already been initialized,\n// but none of the deque's elements have yet been constructed.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __value) {\n  _Map_pointer __cur;\n  __STL_TRY {\n    for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur)\n      uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);\n    uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value);\n  }\n  __STL_UNWIND(destroy(_M_start, iterator(*__cur, __cur)));\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class _Tp, class _Alloc> template <class _InputIterator>\nvoid deque<_Tp,_Alloc>::_M_range_initialize(_InputIterator __first,\n                                            _InputIterator __last,\n                                            input_iterator_tag)\n{\n  _M_initialize_map(0);\n  __STL_TRY {\n    for ( ; __first != __last; ++__first)\n      push_back(*__first);\n  }\n  __STL_UNWIND(clear());\n}\n\ntemplate <class _Tp, class _Alloc> template <class _ForwardIterator>\nvoid deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIterator __first,\n                                            _ForwardIterator __last,\n                                            forward_iterator_tag)\n{\n  size_type __n = 0;\n  distance(__first, __last, __n);\n  _M_initialize_map(__n);\n\n  _Map_pointer __cur_node;\n  __STL_TRY {\n    for (__cur_node = _M_start._M_node; \n         __cur_node < _M_finish._M_node; \n         ++__cur_node) {\n      _ForwardIterator __mid = __first;\n      advance(__mid, _S_buffer_size());\n      uninitialized_copy(__first, __mid, *__cur_node);\n      __first = __mid;\n    }\n    uninitialized_copy(__first, __last, _M_finish._M_first);\n  }\n  __STL_UNWIND(destroy(_M_start, iterator(*__cur_node, __cur_node)));\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n// Called only if _M_finish._M_cur == _M_finish._M_last - 1.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_push_back_aux(const value_type& __t)\n{\n  value_type __t_copy = __t;\n  _M_reserve_map_at_back();\n  *(_M_finish._M_node + 1) = _M_allocate_node();\n  __STL_TRY {\n    construct(_M_finish._M_cur, __t_copy);\n    _M_finish._M_set_node(_M_finish._M_node + 1);\n    _M_finish._M_cur = _M_finish._M_first;\n  }\n  __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1)));\n}\n\n// Called only if _M_finish._M_cur == _M_finish._M_last - 1.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_push_back_aux()\n{\n  _M_reserve_map_at_back();\n  *(_M_finish._M_node + 1) = _M_allocate_node();\n  __STL_TRY {\n    construct(_M_finish._M_cur);\n    _M_finish._M_set_node(_M_finish._M_node + 1);\n    _M_finish._M_cur = _M_finish._M_first;\n  }\n  __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1)));\n}\n\n// Called only if _M_start._M_cur == _M_start._M_first.\ntemplate <class _Tp, class _Alloc>\nvoid  deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t)\n{\n  value_type __t_copy = __t;\n  _M_reserve_map_at_front();\n  *(_M_start._M_node - 1) = _M_allocate_node();\n  __STL_TRY {\n    _M_start._M_set_node(_M_start._M_node - 1);\n    _M_start._M_cur = _M_start._M_last - 1;\n    construct(_M_start._M_cur, __t_copy);\n  }\n  __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));\n} \n\n// Called only if _M_start._M_cur == _M_start._M_first.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_push_front_aux()\n{\n  _M_reserve_map_at_front();\n  *(_M_start._M_node - 1) = _M_allocate_node();\n  __STL_TRY {\n    _M_start._M_set_node(_M_start._M_node - 1);\n    _M_start._M_cur = _M_start._M_last - 1;\n    construct(_M_start._M_cur);\n  }\n  __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));\n} \n\n// Called only if _M_finish._M_cur == _M_finish._M_first.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_pop_back_aux()\n{\n  _M_deallocate_node(_M_finish._M_first);\n  _M_finish._M_set_node(_M_finish._M_node - 1);\n  _M_finish._M_cur = _M_finish._M_last - 1;\n  destroy(_M_finish._M_cur);\n}\n\n// Called only if _M_start._M_cur == _M_start._M_last - 1.  Note that \n// if the deque has at least one element (a precondition for this member \n// function), and if _M_start._M_cur == _M_start._M_last, then the deque \n// must have at least two nodes.\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_pop_front_aux()\n{\n  destroy(_M_start._M_cur);\n  _M_deallocate_node(_M_start._M_first);\n  _M_start._M_set_node(_M_start._M_node + 1);\n  _M_start._M_cur = _M_start._M_first;\n}      \n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class _Tp, class _Alloc> template <class _InputIterator>\nvoid deque<_Tp,_Alloc>::insert(iterator __pos,\n                               _InputIterator __first, _InputIterator __last,\n                               input_iterator_tag)\n{\n  copy(__first, __last, inserter(*this, __pos));\n}\n\ntemplate <class _Tp, class _Alloc> template <class _ForwardIterator>\nvoid\ndeque<_Tp,_Alloc>::insert(iterator __pos,\n                          _ForwardIterator __first, _ForwardIterator __last,\n                          forward_iterator_tag) {\n  size_type __n = 0;\n  distance(__first, __last, __n);\n  if (__pos._M_cur == _M_start._M_cur) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, __new_start);\n      _M_start = __new_start;\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else if (__pos._M_cur == _M_finish._M_cur) {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, _M_finish);\n      _M_finish = __new_finish;\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));\n  }\n  else\n    _M_insert_aux(__pos, __first, __last, __n);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\ntypename deque<_Tp, _Alloc>::iterator\ndeque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, const value_type& __x)\n{\n  difference_type __index = __pos - _M_start;\n  value_type __x_copy = __x;\n  if (size_type(__index) < this->size() / 2) {\n    push_front(front());\n    iterator __front1 = _M_start;\n    ++__front1;\n    iterator __front2 = __front1;\n    ++__front2;\n    __pos = _M_start + __index;\n    iterator __pos1 = __pos;\n    ++__pos1;\n    copy(__front2, __pos1, __front1);\n  }\n  else {\n    push_back(back());\n    iterator __back1 = _M_finish;\n    --__back1;\n    iterator __back2 = __back1;\n    --__back2;\n    __pos = _M_start + __index;\n    copy_backward(__pos, __back2, __back1);\n  }\n  *__pos = __x_copy;\n  return __pos;\n}\n\ntemplate <class _Tp, class _Alloc>\ntypename deque<_Tp,_Alloc>::iterator \ndeque<_Tp,_Alloc>::_M_insert_aux(iterator __pos)\n{\n  difference_type __index = __pos - _M_start;\n  if (__index < size() / 2) {\n    push_front(front());\n    iterator __front1 = _M_start;\n    ++__front1;\n    iterator __front2 = __front1;\n    ++__front2;\n    __pos = _M_start + __index;\n    iterator __pos1 = __pos;\n    ++__pos1;\n    copy(__front2, __pos1, __front1);\n  }\n  else {\n    push_back(back());\n    iterator __back1 = _M_finish;\n    --__back1;\n    iterator __back2 = __back1;\n    --__back2;\n    __pos = _M_start + __index;\n    copy_backward(__pos, __back2, __back1);\n  }\n  *__pos = value_type();\n  return __pos;\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,\n                                      size_type __n,\n                                      const value_type& __x)\n{\n  const difference_type __elems_before = __pos - _M_start;\n  size_type __length = this->size();\n  value_type __x_copy = __x;\n  if (__elems_before < difference_type(__length / 2)) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    iterator __old_start = _M_start;\n    __pos = _M_start + __elems_before;\n    __STL_TRY {\n      if (__elems_before >= difference_type(__n)) {\n        iterator __start_n = _M_start + difference_type(__n);\n        uninitialized_copy(_M_start, __start_n, __new_start);\n        _M_start = __new_start;\n        copy(__start_n, __pos, __old_start);\n        fill(__pos - difference_type(__n), __pos, __x_copy);\n      }\n      else {\n        __uninitialized_copy_fill(_M_start, __pos, __new_start, \n                                  _M_start, __x_copy);\n        _M_start = __new_start;\n        fill(__old_start, __pos, __x_copy);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    iterator __old_finish = _M_finish;\n    const difference_type __elems_after = \n      difference_type(__length) - __elems_before;\n    __pos = _M_finish - __elems_after;\n    __STL_TRY {\n      if (__elems_after > difference_type(__n)) {\n        iterator __finish_n = _M_finish - difference_type(__n);\n        uninitialized_copy(__finish_n, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy_backward(__pos, __finish_n, __old_finish);\n        fill(__pos, __pos + difference_type(__n), __x_copy);\n      }\n      else {\n        __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n),\n                                  __x_copy, __pos, _M_finish);\n        _M_finish = __new_finish;\n        fill(__pos, __old_finish, __x_copy);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class _Tp, class _Alloc> template <class _ForwardIterator>\nvoid deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,\n                                      _ForwardIterator __first,\n                                      _ForwardIterator __last,\n                                      size_type __n)\n{\n  const difference_type __elemsbefore = __pos - _M_start;\n  size_type __length = size();\n  if (__elemsbefore < __length / 2) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    iterator __old_start = _M_start;\n    __pos = _M_start + __elemsbefore;\n    __STL_TRY {\n      if (__elemsbefore >= difference_type(__n)) {\n        iterator __start_n = _M_start + difference_type(__n); \n        uninitialized_copy(_M_start, __start_n, __new_start);\n        _M_start = __new_start;\n        copy(__start_n, __pos, __old_start);\n        copy(__first, __last, __pos - difference_type(__n));\n      }\n      else {\n        _ForwardIterator __mid = __first;\n        advance(__mid, difference_type(__n) - __elemsbefore);\n        __uninitialized_copy_copy(_M_start, __pos, __first, __mid,\n                                  __new_start);\n        _M_start = __new_start;\n        copy(__mid, __last, __old_start);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    iterator __old_finish = _M_finish;\n    const difference_type __elemsafter = \n      difference_type(__length) - __elemsbefore;\n    __pos = _M_finish - __elemsafter;\n    __STL_TRY {\n      if (__elemsafter > difference_type(__n)) {\n        iterator __finish_n = _M_finish - difference_type(__n);\n        uninitialized_copy(__finish_n, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy_backward(__pos, __finish_n, __old_finish);\n        copy(__first, __last, __pos);\n      }\n      else {\n        _ForwardIterator __mid = __first;\n        advance(__mid, __elemsafter);\n        __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy(__first, __mid, __pos);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));\n  }\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,\n                                      const value_type* __first,\n                                      const value_type* __last,\n                                      size_type __n)\n{\n  const difference_type __elemsbefore = __pos - _M_start;\n  size_type __length = size();\n  if (__elemsbefore < __length / 2) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    iterator __old_start = _M_start;\n    __pos = _M_start + __elemsbefore;\n    __STL_TRY {\n      if (__elemsbefore >= difference_type(__n)) {\n        iterator __start_n = _M_start + difference_type(__n);\n        uninitialized_copy(_M_start, __start_n, __new_start);\n        _M_start = __new_start;\n        copy(__start_n, __pos, __old_start);\n        copy(__first, __last, __pos - difference_type(__n));\n      }\n      else {\n        const value_type* __mid = \n          __first + (difference_type(__n) - __elemsbefore);\n        __uninitialized_copy_copy(_M_start, __pos, __first, __mid,\n                                  __new_start);\n        _M_start = __new_start;\n        copy(__mid, __last, __old_start);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    iterator __old_finish = _M_finish;\n    const difference_type __elemsafter = \n      difference_type(__length) - __elemsbefore;\n    __pos = _M_finish - __elemsafter;\n    __STL_TRY {\n      if (__elemsafter > difference_type(__n)) {\n        iterator __finish_n = _M_finish - difference_type(__n);\n        uninitialized_copy(__finish_n, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy_backward(__pos, __finish_n, __old_finish);\n        copy(__first, __last, __pos);\n      }\n      else {\n        const value_type* __mid = __first + __elemsafter;\n        __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy(__first, __mid, __pos);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                                  __new_finish._M_node + 1));\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,\n                                      const_iterator __first,\n                                      const_iterator __last,\n                                      size_type __n)\n{\n  const difference_type __elemsbefore = __pos - _M_start;\n  size_type __length = size();\n  if (__elemsbefore < __length / 2) {\n    iterator __new_start = _M_reserve_elements_at_front(__n);\n    iterator __old_start = _M_start;\n    __pos = _M_start + __elemsbefore;\n    __STL_TRY {\n      if (__elemsbefore >= __n) {\n        iterator __start_n = _M_start + __n;\n        uninitialized_copy(_M_start, __start_n, __new_start);\n        _M_start = __new_start;\n        copy(__start_n, __pos, __old_start);\n        copy(__first, __last, __pos - difference_type(__n));\n      }\n      else {\n        const_iterator __mid = __first + (__n - __elemsbefore);\n        __uninitialized_copy_copy(_M_start, __pos, __first, __mid,\n                                  __new_start);\n        _M_start = __new_start;\n        copy(__mid, __last, __old_start);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));\n  }\n  else {\n    iterator __new_finish = _M_reserve_elements_at_back(__n);\n    iterator __old_finish = _M_finish;\n    const difference_type __elemsafter = __length - __elemsbefore;\n    __pos = _M_finish - __elemsafter;\n    __STL_TRY {\n      if (__elemsafter > __n) {\n        iterator __finish_n = _M_finish - difference_type(__n);\n        uninitialized_copy(__finish_n, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy_backward(__pos, __finish_n, __old_finish);\n        copy(__first, __last, __pos);\n      }\n      else {\n        const_iterator __mid = __first + __elemsafter;\n        __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);\n        _M_finish = __new_finish;\n        copy(__first, __mid, __pos);\n      }\n    }\n    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, \n                 __new_finish._M_node + 1));\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems)\n{\n  size_type __new_nodes\n      = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();\n  _M_reserve_map_at_front(__new_nodes);\n  size_type __i;\n  __STL_TRY {\n    for (__i = 1; __i <= __new_nodes; ++__i)\n      *(_M_start._M_node - __i) = _M_allocate_node();\n  }\n#       ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    for (size_type __j = 1; __j < __i; ++__j)\n      _M_deallocate_node(*(_M_start._M_node - __j));      \n    throw;\n  }\n#       endif /* __STL_USE_EXCEPTIONS */\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems)\n{\n  size_type __new_nodes\n      = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();\n  _M_reserve_map_at_back(__new_nodes);\n  size_type __i;\n  __STL_TRY {\n    for (__i = 1; __i <= __new_nodes; ++__i)\n      *(_M_finish._M_node + __i) = _M_allocate_node();\n  }\n#       ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    for (size_type __j = 1; __j < __i; ++__j)\n      _M_deallocate_node(*(_M_finish._M_node + __j));      \n    throw;\n  }\n#       endif /* __STL_USE_EXCEPTIONS */\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,\n                                          bool __add_at_front)\n{\n  size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1;\n  size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;\n\n  _Map_pointer __new_nstart;\n  if (_M_map_size > 2 * __new_num_nodes) {\n    __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2 \n                     + (__add_at_front ? __nodes_to_add : 0);\n    if (__new_nstart < _M_start._M_node)\n      copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);\n    else\n      copy_backward(_M_start._M_node, _M_finish._M_node + 1, \n                    __new_nstart + __old_num_nodes);\n  }\n  else {\n    size_type __new_map_size = \n      _M_map_size + max(_M_map_size, __nodes_to_add) + 2;\n\n    _Map_pointer __new_map = _M_allocate_map(__new_map_size);\n    __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2\n                         + (__add_at_front ? __nodes_to_add : 0);\n    copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);\n    _M_deallocate_map(_M_map, _M_map_size);\n\n    _M_map = __new_map;\n    _M_map_size = __new_map_size;\n  }\n\n  _M_start._M_set_node(__new_nstart);\n  _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);\n}\n\n\n// Nonmember functions.\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator==(const deque<_Tp, _Alloc>& __x,\n                       const deque<_Tp, _Alloc>& __y) {\n  return __x.size() == __y.size() &&\n         equal(__x.begin(), __x.end(), __y.begin());\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator<(const deque<_Tp, _Alloc>& __x,\n                      const deque<_Tp, _Alloc>& __y) {\n  return lexicographical_compare(__x.begin(), __x.end(), \n                                 __y.begin(), __y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator!=(const deque<_Tp, _Alloc>& __x,\n                       const deque<_Tp, _Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator>(const deque<_Tp, _Alloc>& __x,\n                      const deque<_Tp, _Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator<=(const deque<_Tp, _Alloc>& __x,\n                       const deque<_Tp, _Alloc>& __y) {\n  return !(__y < __x);\n}\ntemplate <class _Tp, class _Alloc>\ninline bool operator>=(const deque<_Tp, _Alloc>& __x,\n                       const deque<_Tp, _Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n          \n__STL_END_NAMESPACE \n  \n#endif /* __SGI_STL_INTERNAL_DEQUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_exception.h",
    "content": "/*\n * Copyright (c) 1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_EXCEPTION_H\n#define __SGI_STL_EXCEPTION_H\n\n// This header exists solely for portability.  Normally it just includes\n// the header <exception>.\n\n// The header <exception> contains low-level functions that interact\n// with a compiler's exception-handling mechanism.  It is assumed to\n// be supplied with the compiler, rather than with the library, because\n// it is inherently tied very closely to the compiler itself.\n\n// On platforms where <exception> does not exist, this header defines\n// an exception base class.  This is *not* a substitute for everything\n// in <exception>, but it suffices to support a bare minimum of STL\n// functionality.\n\n#include <stl_config.h>\n\n#ifndef __STL_NO_EXCEPTION_HEADER\n\n#include <exception>\n#define __STL_EXCEPTION_BASE exception\n\n#else /* __STL_NO_EXCEPTION_HEADER */\n\n__STL_BEGIN_NAMESPACE\n\nclass _Exception {\npublic:\n  virtual ~_Exception() __STL_NOTHROW {}\n  virtual const char* what() const __STL_NOTHROW { return \"\"; }\n};\n\n#define __STL_EXCEPTION_BASE _Exception\n\n__STL_END_NAMESPACE\n\n#endif /* __STL_NO_EXCEPTION_HEADER */\n\n#endif /* __SGI_STL_EXCEPTION_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_function.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_FUNCTION_H\n#define __SGI_STL_INTERNAL_FUNCTION_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _Arg, class _Result>\nstruct unary_function {\n  typedef _Arg argument_type;\n  typedef _Result result_type;\n};\n\ntemplate <class _Arg1, class _Arg2, class _Result>\nstruct binary_function {\n  typedef _Arg1 first_argument_type;\n  typedef _Arg2 second_argument_type;\n  typedef _Result result_type;\n};      \n\ntemplate <class _Tp>\nstruct plus : public binary_function<_Tp,_Tp,_Tp> {\n  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }\n};\n\ntemplate <class _Tp>\nstruct minus : public binary_function<_Tp,_Tp,_Tp> {\n  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }\n};\n\ntemplate <class _Tp>\nstruct multiplies : public binary_function<_Tp,_Tp,_Tp> {\n  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }\n};\n\ntemplate <class _Tp>\nstruct divides : public binary_function<_Tp,_Tp,_Tp> {\n  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }\n};\n\n// identity_element (not part of the C++ standard).\n\ntemplate <class _Tp> inline _Tp identity_element(plus<_Tp>) {\n  return _Tp(0);\n}\ntemplate <class _Tp> inline _Tp identity_element(multiplies<_Tp>) {\n  return _Tp(1);\n}\n\ntemplate <class _Tp>\nstruct modulus : public binary_function<_Tp,_Tp,_Tp> \n{\n  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }\n};\n\ntemplate <class _Tp>\nstruct negate : public unary_function<_Tp,_Tp> \n{\n  _Tp operator()(const _Tp& __x) const { return -__x; }\n};\n\ntemplate <class _Tp>\nstruct equal_to : public binary_function<_Tp,_Tp,bool> \n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }\n};\n\ntemplate <class _Tp>\nstruct not_equal_to : public binary_function<_Tp,_Tp,bool> \n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }\n};\n\ntemplate <class _Tp>\nstruct greater : public binary_function<_Tp,_Tp,bool> \n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }\n};\n\ntemplate <class _Tp>\nstruct less : public binary_function<_Tp,_Tp,bool> \n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }\n};\n\ntemplate <class _Tp>\nstruct greater_equal : public binary_function<_Tp,_Tp,bool>\n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }\n};\n\ntemplate <class _Tp>\nstruct less_equal : public binary_function<_Tp,_Tp,bool> \n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }\n};\n\ntemplate <class _Tp>\nstruct logical_and : public binary_function<_Tp,_Tp,bool>\n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }\n};\n\ntemplate <class _Tp>\nstruct logical_or : public binary_function<_Tp,_Tp,bool>\n{\n  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }\n};\n\ntemplate <class _Tp>\nstruct logical_not : public unary_function<_Tp,bool>\n{\n  bool operator()(const _Tp& __x) const { return !__x; }\n};\n\ntemplate <class _Predicate>\nclass unary_negate\n  : public unary_function<typename _Predicate::argument_type, bool> {\nprotected:\n  _Predicate _M_pred;\npublic:\n  explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {}\n  bool operator()(const typename _Predicate::argument_type& __x) const {\n    return !_M_pred(__x);\n  }\n};\n\ntemplate <class _Predicate>\ninline unary_negate<_Predicate> \nnot1(const _Predicate& __pred)\n{\n  return unary_negate<_Predicate>(__pred);\n}\n\ntemplate <class _Predicate> \nclass binary_negate \n  : public binary_function<typename _Predicate::first_argument_type,\n                           typename _Predicate::second_argument_type,\n                           bool> {\nprotected:\n  _Predicate _M_pred;\npublic:\n  explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {}\n  bool operator()(const typename _Predicate::first_argument_type& __x, \n                  const typename _Predicate::second_argument_type& __y) const\n  {\n    return !_M_pred(__x, __y); \n  }\n};\n\ntemplate <class _Predicate>\ninline binary_negate<_Predicate> \nnot2(const _Predicate& __pred)\n{\n  return binary_negate<_Predicate>(__pred);\n}\n\ntemplate <class _Operation> \nclass binder1st\n  : public unary_function<typename _Operation::second_argument_type,\n                          typename _Operation::result_type> {\nprotected:\n  _Operation op;\n  typename _Operation::first_argument_type value;\npublic:\n  binder1st(const _Operation& __x,\n            const typename _Operation::first_argument_type& __y)\n      : op(__x), value(__y) {}\n  typename _Operation::result_type\n  operator()(const typename _Operation::second_argument_type& __x) const {\n    return op(value, __x); \n  }\n};\n\ntemplate <class _Operation, class _Tp>\ninline binder1st<_Operation> \nbind1st(const _Operation& __fn, const _Tp& __x) \n{\n  typedef typename _Operation::first_argument_type _Arg1_type;\n  return binder1st<_Operation>(__fn, _Arg1_type(__x));\n}\n\ntemplate <class _Operation> \nclass binder2nd\n  : public unary_function<typename _Operation::first_argument_type,\n                          typename _Operation::result_type> {\nprotected:\n  _Operation op;\n  typename _Operation::second_argument_type value;\npublic:\n  binder2nd(const _Operation& __x,\n            const typename _Operation::second_argument_type& __y) \n      : op(__x), value(__y) {}\n  typename _Operation::result_type\n  operator()(const typename _Operation::first_argument_type& __x) const {\n    return op(__x, value); \n  }\n};\n\ntemplate <class _Operation, class _Tp>\ninline binder2nd<_Operation> \nbind2nd(const _Operation& __fn, const _Tp& __x) \n{\n  typedef typename _Operation::second_argument_type _Arg2_type;\n  return binder2nd<_Operation>(__fn, _Arg2_type(__x));\n}\n\n// unary_compose and binary_compose (extensions, not part of the standard).\n\ntemplate <class _Operation1, class _Operation2>\nclass unary_compose\n  : public unary_function<typename _Operation2::argument_type,\n                          typename _Operation1::result_type> \n{\nprotected:\n  _Operation1 _M_fn1;\n  _Operation2 _M_fn2;\npublic:\n  unary_compose(const _Operation1& __x, const _Operation2& __y) \n    : _M_fn1(__x), _M_fn2(__y) {}\n  typename _Operation1::result_type\n  operator()(const typename _Operation2::argument_type& __x) const {\n    return _M_fn1(_M_fn2(__x));\n  }\n};\n\ntemplate <class _Operation1, class _Operation2>\ninline unary_compose<_Operation1,_Operation2> \ncompose1(const _Operation1& __fn1, const _Operation2& __fn2)\n{\n  return unary_compose<_Operation1,_Operation2>(__fn1, __fn2);\n}\n\ntemplate <class _Operation1, class _Operation2, class _Operation3>\nclass binary_compose\n  : public unary_function<typename _Operation2::argument_type,\n                          typename _Operation1::result_type> {\nprotected:\n  _Operation1 _M_fn1;\n  _Operation2 _M_fn2;\n  _Operation3 _M_fn3;\npublic:\n  binary_compose(const _Operation1& __x, const _Operation2& __y, \n                 const _Operation3& __z) \n    : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }\n  typename _Operation1::result_type\n  operator()(const typename _Operation2::argument_type& __x) const {\n    return _M_fn1(_M_fn2(__x), _M_fn3(__x));\n  }\n};\n\ntemplate <class _Operation1, class _Operation2, class _Operation3>\ninline binary_compose<_Operation1, _Operation2, _Operation3> \ncompose2(const _Operation1& __fn1, const _Operation2& __fn2, \n         const _Operation3& __fn3)\n{\n  return binary_compose<_Operation1,_Operation2,_Operation3>\n    (__fn1, __fn2, __fn3);\n}\n\ntemplate <class _Arg, class _Result>\nclass pointer_to_unary_function : public unary_function<_Arg, _Result> {\nprotected:\n  _Result (*_M_ptr)(_Arg);\npublic:\n  pointer_to_unary_function() {}\n  explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}\n  _Result operator()(_Arg __x) const { return _M_ptr(__x); }\n};\n\ntemplate <class _Arg, class _Result>\ninline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg))\n{\n  return pointer_to_unary_function<_Arg, _Result>(__x);\n}\n\ntemplate <class _Arg1, class _Arg2, class _Result>\nclass pointer_to_binary_function : \n  public binary_function<_Arg1,_Arg2,_Result> {\nprotected:\n    _Result (*_M_ptr)(_Arg1, _Arg2);\npublic:\n    pointer_to_binary_function() {}\n    explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) \n      : _M_ptr(__x) {}\n    _Result operator()(_Arg1 __x, _Arg2 __y) const {\n      return _M_ptr(__x, __y);\n    }\n};\n\ntemplate <class _Arg1, class _Arg2, class _Result>\ninline pointer_to_binary_function<_Arg1,_Arg2,_Result> \nptr_fun(_Result (*__x)(_Arg1, _Arg2)) {\n  return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__x);\n}\n\n// identity is an extensions: it is not part of the standard.\ntemplate <class _Tp>\nstruct _Identity : public unary_function<_Tp,_Tp> {\n  const _Tp& operator()(const _Tp& __x) const { return __x; }\n};\n\ntemplate <class _Tp> struct identity : public _Identity<_Tp> {};\n\n// select1st and select2nd are extensions: they are not part of the standard.\ntemplate <class _Pair>\nstruct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {\n  const typename _Pair::first_type& operator()(const _Pair& __x) const {\n    return __x.first;\n  }\n};\n\ntemplate <class _Pair>\nstruct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>\n{\n  const typename _Pair::second_type& operator()(const _Pair& __x) const {\n    return __x.second;\n  }\n};\n\ntemplate <class _Pair> struct select1st : public _Select1st<_Pair> {};\ntemplate <class _Pair> struct select2nd : public _Select2nd<_Pair> {};\n\n// project1st and project2nd are extensions: they are not part of the standard\ntemplate <class _Arg1, class _Arg2>\nstruct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {\n  _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }\n};\n\ntemplate <class _Arg1, class _Arg2>\nstruct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {\n  _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }\n};\n\ntemplate <class _Arg1, class _Arg2> \nstruct project1st : public _Project1st<_Arg1, _Arg2> {};\n\ntemplate <class _Arg1, class _Arg2>\nstruct project2nd : public _Project2nd<_Arg1, _Arg2> {};\n\n// constant_void_fun, constant_unary_fun, and constant_binary_fun are\n// extensions: they are not part of the standard.  (The same, of course,\n// is true of the helper functions constant0, constant1, and constant2.)\n\ntemplate <class _Result>\nstruct _Constant_void_fun {\n  typedef _Result result_type;\n  result_type _M_val;\n\n  _Constant_void_fun(const result_type& __v) : _M_val(__v) {}\n  const result_type& operator()() const { return _M_val; }\n};  \n\ntemplate <class _Result, class _Argument>\nstruct _Constant_unary_fun {\n  typedef _Argument argument_type;\n  typedef  _Result  result_type;\n  result_type _M_val;\n\n  _Constant_unary_fun(const result_type& __v) : _M_val(__v) {}\n  const result_type& operator()(const _Argument&) const { return _M_val; }\n};\n\ntemplate <class _Result, class _Arg1, class _Arg2>\nstruct _Constant_binary_fun {\n  typedef  _Arg1   first_argument_type;\n  typedef  _Arg2   second_argument_type;\n  typedef  _Result result_type;\n  _Result _M_val;\n\n  _Constant_binary_fun(const _Result& __v) : _M_val(__v) {}\n  const result_type& operator()(const _Arg1&, const _Arg2&) const {\n    return _M_val;\n  }\n};\n\ntemplate <class _Result>\nstruct constant_void_fun : public _Constant_void_fun<_Result> {\n  constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {}\n};  \n\n\ntemplate <class _Result,\n          class _Argument __STL_DEPENDENT_DEFAULT_TMPL(_Result)>\nstruct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument>\n{\n  constant_unary_fun(const _Result& __v)\n    : _Constant_unary_fun<_Result, _Argument>(__v) {}\n};\n\n\ntemplate <class _Result,\n          class _Arg1 __STL_DEPENDENT_DEFAULT_TMPL(_Result),\n          class _Arg2 __STL_DEPENDENT_DEFAULT_TMPL(_Arg1)>\nstruct constant_binary_fun\n  : public _Constant_binary_fun<_Result, _Arg1, _Arg2>\n{\n  constant_binary_fun(const _Result& __v)\n    : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}\n};\n\ntemplate <class _Result>\ninline constant_void_fun<_Result> constant0(const _Result& __val)\n{\n  return constant_void_fun<_Result>(__val);\n}\n\ntemplate <class _Result>\ninline constant_unary_fun<_Result,_Result> constant1(const _Result& __val)\n{\n  return constant_unary_fun<_Result,_Result>(__val);\n}\n\ntemplate <class _Result>\ninline constant_binary_fun<_Result,_Result,_Result> \nconstant2(const _Result& __val)\n{\n  return constant_binary_fun<_Result,_Result,_Result>(__val);\n}\n\n// subtractive_rng is an extension: it is not part of the standard.\n// Note: this code assumes that int is 32 bits.\nclass subtractive_rng : public unary_function<unsigned int, unsigned int> {\nprivate:\n  unsigned int _M_table[55];\n  size_t _M_index1;\n  size_t _M_index2;\npublic:\n  unsigned int operator()(unsigned int __limit) {\n    _M_index1 = (_M_index1 + 1) % 55;\n    _M_index2 = (_M_index2 + 1) % 55;\n    _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];\n    return _M_table[_M_index1] % __limit;\n  }\n\n  void _M_initialize(unsigned int __seed)\n  {\n    unsigned int __k = 1;\n    _M_table[54] = __seed;\n    size_t __i;\n    for (__i = 0; __i < 54; __i++) {\n        size_t __ii = (21 * (__i + 1) % 55) - 1;\n        _M_table[__ii] = __k;\n        __k = __seed - __k;\n        __seed = _M_table[__ii];\n    }\n    for (int __loop = 0; __loop < 4; __loop++) {\n        for (__i = 0; __i < 55; __i++)\n            _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];\n    }\n    _M_index1 = 0;\n    _M_index2 = 31;\n  }\n\n  subtractive_rng(unsigned int __seed) { _M_initialize(__seed); }\n  subtractive_rng() { _M_initialize(161803398u); }\n};\n\n\n// Adaptor function objects: pointers to member functions.\n\n// There are a total of 16 = 2^4 function objects in this family.\n//  (1) Member functions taking no arguments vs member functions taking\n//       one argument.\n//  (2) Call through pointer vs call through reference.\n//  (3) Member function with void return type vs member function with\n//      non-void return type.\n//  (4) Const vs non-const member function.\n\n// Note that choice (3) is nothing more than a workaround: according\n//  to the draft, compilers should handle void and non-void the same way.\n//  This feature is not yet widely implemented, though.  You can only use\n//  member functions returning void if your compiler supports partial\n//  specialization.\n\n// All of this complexity is in the function objects themselves.  You can\n//  ignore it by using the helper function mem_fun and mem_fun_ref,\n//  which create whichever type of adaptor is appropriate.\n//  (mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,\n//  but they are provided for backward compatibility.)\n\n\ntemplate <class _Ret, class _Tp>\nclass mem_fun_t : public unary_function<_Tp*,_Ret> {\npublic:\n  explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}\n  _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }\nprivate:\n  _Ret (_Tp::*_M_f)();\n};\n\ntemplate <class _Ret, class _Tp>\nclass const_mem_fun_t : public unary_function<const _Tp*,_Ret> {\npublic:\n  explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}\n  _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }\nprivate:\n  _Ret (_Tp::*_M_f)() const;\n};\n\n\ntemplate <class _Ret, class _Tp>\nclass mem_fun_ref_t : public unary_function<_Tp,_Ret> {\npublic:\n  explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}\n  _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }\nprivate:\n  _Ret (_Tp::*_M_f)();\n};\n\ntemplate <class _Ret, class _Tp>\nclass const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {\npublic:\n  explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}\n  _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }\nprivate:\n  _Ret (_Tp::*_M_f)() const;\n};\n\ntemplate <class _Ret, class _Tp, class _Arg>\nclass mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {\npublic:\n  explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}\n  _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }\nprivate:\n  _Ret (_Tp::*_M_f)(_Arg);\n};\n\ntemplate <class _Ret, class _Tp, class _Arg>\nclass const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {\npublic:\n  explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}\n  _Ret operator()(const _Tp* __p, _Arg __x) const\n    { return (__p->*_M_f)(__x); }\nprivate:\n  _Ret (_Tp::*_M_f)(_Arg) const;\n};\n\ntemplate <class _Ret, class _Tp, class _Arg>\nclass mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {\npublic:\n  explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}\n  _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }\nprivate:\n  _Ret (_Tp::*_M_f)(_Arg);\n};\n\ntemplate <class _Ret, class _Tp, class _Arg>\nclass const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {\npublic:\n  explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}\n  _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }\nprivate:\n  _Ret (_Tp::*_M_f)(_Arg) const;\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp>\nclass mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {\npublic:\n  explicit mem_fun_t(void (_Tp::*__pf)()) : _M_f(__pf) {}\n  void operator()(_Tp* __p) const { (__p->*_M_f)(); }\nprivate:\n  void (_Tp::*_M_f)();\n};\n\ntemplate <class _Tp>\nclass const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {\npublic:\n  explicit const_mem_fun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}\n  void operator()(const _Tp* __p) const { (__p->*_M_f)(); }\nprivate:\n  void (_Tp::*_M_f)() const;\n};\n\ntemplate <class _Tp>\nclass mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {\npublic:\n  explicit mem_fun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {}\n  void operator()(_Tp& __r) const { (__r.*_M_f)(); }\nprivate:\n  void (_Tp::*_M_f)();\n};\n\ntemplate <class _Tp>\nclass const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {\npublic:\n  explicit const_mem_fun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}\n  void operator()(const _Tp& __r) const { (__r.*_M_f)(); }\nprivate:\n  void (_Tp::*_M_f)() const;\n};\n\ntemplate <class _Tp, class _Arg>\nclass mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {\npublic:\n  explicit mem_fun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}\n  void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }\nprivate:\n  void (_Tp::*_M_f)(_Arg);\n};\n\ntemplate <class _Tp, class _Arg>\nclass const_mem_fun1_t<void, _Tp, _Arg> \n  : public binary_function<const _Tp*,_Arg,void> {\npublic:\n  explicit const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}\n  void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }\nprivate:\n  void (_Tp::*_M_f)(_Arg) const;\n};\n\ntemplate <class _Tp, class _Arg>\nclass mem_fun1_ref_t<void, _Tp, _Arg>\n  : public binary_function<_Tp,_Arg,void> {\npublic:\n  explicit mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}\n  void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }\nprivate:\n  void (_Tp::*_M_f)(_Arg);\n};\n\ntemplate <class _Tp, class _Arg>\nclass const_mem_fun1_ref_t<void, _Tp, _Arg>\n  : public binary_function<_Tp,_Arg,void> {\npublic:\n  explicit const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}\n  void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }\nprivate:\n  void (_Tp::*_M_f)(_Arg) const;\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Mem_fun adaptor helper functions.  There are only two:\n//  mem_fun and mem_fun_ref.  (mem_fun1 and mem_fun1_ref \n//  are provided for backward compatibility, but they are no longer\n//  part of the C++ standard.)\n\ntemplate <class _Ret, class _Tp>\ninline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)())\n  { return mem_fun_t<_Ret,_Tp>(__f); }\n\ntemplate <class _Ret, class _Tp>\ninline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const)\n  { return const_mem_fun_t<_Ret,_Tp>(__f); }\n\ntemplate <class _Ret, class _Tp>\ninline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)()) \n  { return mem_fun_ref_t<_Ret,_Tp>(__f); }\n\ntemplate <class _Ret, class _Tp>\ninline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)\n  { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg))\n  { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const)\n  { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg))\n  { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>\nmem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)\n  { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg))\n  { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const)\n  { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))\n  { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }\n\ntemplate <class _Ret, class _Tp, class _Arg>\ninline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>\nmem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)\n  { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_FUNCTION_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_hash_fun.h",
    "content": "/*\n * Copyright (c) 1996-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_HASH_FUN_H\n#define __SGI_STL_HASH_FUN_H\n\n#include <stddef.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _Key> struct hash { };\n\ninline size_t __stl_hash_string(const char* __s)\n{\n  unsigned long __h = 0; \n  for ( ; *__s; ++__s)\n    __h = 5*__h + *__s;\n  \n  return size_t(__h);\n}\n\n__STL_TEMPLATE_NULL struct hash<char*>\n{\n  size_t operator()(const char* __s) const { return __stl_hash_string(__s); }\n};\n\n__STL_TEMPLATE_NULL struct hash<const char*>\n{\n  size_t operator()(const char* __s) const { return __stl_hash_string(__s); }\n};\n\n__STL_TEMPLATE_NULL struct hash<char> {\n  size_t operator()(char __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned char> {\n  size_t operator()(unsigned char __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<signed char> {\n  size_t operator()(unsigned char __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<short> {\n  size_t operator()(short __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned short> {\n  size_t operator()(unsigned short __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<int> {\n  size_t operator()(int __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned int> {\n  size_t operator()(unsigned int __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<long> {\n  size_t operator()(long __x) const { return __x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned long> {\n  size_t operator()(unsigned long __x) const { return __x; }\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_HASH_FUN_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_hash_map.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASH_MAP_H\n#define __SGI_STL_INTERNAL_HASH_MAP_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declaration of equality operator; needed for friend declaration.\n\ntemplate <class _Key, class _Tp,\n          class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),\n          class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),\n          class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass hash_map;\n\ntemplate <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>\ninline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,\n                       const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey,\n          class _Alloc>\nclass hash_map\n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Key, _Assignable);\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);\n\nprivate:\n  typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,\n                    _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;\n  _Ht _M_ht;\n\npublic:\n  typedef typename _Ht::key_type key_type;\n  typedef _Tp data_type;\n  typedef _Tp mapped_type;\n  typedef typename _Ht::value_type value_type;\n  typedef typename _Ht::hasher hasher;\n  typedef typename _Ht::key_equal key_equal;\n  \n  typedef typename _Ht::size_type size_type;\n  typedef typename _Ht::difference_type difference_type;\n  typedef typename _Ht::pointer pointer;\n  typedef typename _Ht::const_pointer const_pointer;\n  typedef typename _Ht::reference reference;\n  typedef typename _Ht::const_reference const_reference;\n\n  typedef typename _Ht::iterator iterator;\n  typedef typename _Ht::const_iterator const_iterator;\n\n  typedef typename _Ht::allocator_type allocator_type;\n\n  hasher hash_funct() const { return _M_ht.hash_funct(); }\n  key_equal key_eq() const { return _M_ht.key_eq(); }\n  allocator_type get_allocator() const { return _M_ht.get_allocator(); }\n\npublic:\n  hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}\n  explicit hash_map(size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}\n  hash_map(size_type __n, const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}\n  hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  hash_map(_InputIterator __f, _InputIterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_map(_InputIterator __f, _InputIterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n\n#else\n  hash_map(const value_type* __f, const value_type* __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const value_type* __f, const value_type* __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const value_type* __f, const value_type* __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const value_type* __f, const value_type* __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n\n  hash_map(const_iterator __f, const_iterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const_iterator __f, const_iterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const_iterator __f, const_iterator __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_map(const_iterator __f, const_iterator __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return _M_ht.size(); }\n  size_type max_size() const { return _M_ht.max_size(); }\n  bool empty() const { return _M_ht.empty(); }\n  void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _K1, class _T1, class _HF, class _EqK, class _Al>\n  friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,\n                          const hash_map<_K1, _T1, _HF, _EqK, _Al>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n\n  iterator begin() { return _M_ht.begin(); }\n  iterator end() { return _M_ht.end(); }\n  const_iterator begin() const { return _M_ht.begin(); }\n  const_iterator end() const { return _M_ht.end(); }\n\npublic:\n  pair<iterator,bool> insert(const value_type& __obj)\n    { return _M_ht.insert_unique(__obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __f, _InputIterator __l)\n    { _M_ht.insert_unique(__f,__l); }\n#else\n  void insert(const value_type* __f, const value_type* __l) {\n    _M_ht.insert_unique(__f,__l);\n  }\n  void insert(const_iterator __f, const_iterator __l)\n    { _M_ht.insert_unique(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  pair<iterator,bool> insert_noresize(const value_type& __obj)\n    { return _M_ht.insert_unique_noresize(__obj); }    \n\n  iterator find(const key_type& __key) { return _M_ht.find(__key); }\n  const_iterator find(const key_type& __key) const \n    { return _M_ht.find(__key); }\n\n  _Tp& operator[](const key_type& __key) {\n    return _M_ht.find_or_insert(value_type(__key, _Tp())).second;\n  }\n\n  size_type count(const key_type& __key) const { return _M_ht.count(__key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& __key)\n    { return _M_ht.equal_range(__key); }\n  pair<const_iterator, const_iterator>\n  equal_range(const key_type& __key) const\n    { return _M_ht.equal_range(__key); }\n\n  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }\n  void erase(iterator __it) { _M_ht.erase(__it); }\n  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }\n  void clear() { _M_ht.clear(); }\n\n  void resize(size_type __hint) { _M_ht.resize(__hint); }\n  size_type bucket_count() const { return _M_ht.bucket_count(); }\n  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }\n  size_type elems_in_bucket(size_type __n) const\n    { return _M_ht.elems_in_bucket(__n); }\n};\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>\ninline bool \noperator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,\n           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)\n{\n  return __hm1._M_ht == __hm2._M_ht;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>\ninline bool \noperator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,\n           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {\n  return !(__hm1 == __hm2);\n}\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>\ninline void \nswap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,\n     hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)\n{\n  __hm1.swap(__hm2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Forward declaration of equality operator; needed for friend declaration.\n\ntemplate <class _Key, class _Tp,\n          class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),\n          class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),\n          class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass hash_multimap;\n\ntemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>\ninline bool \noperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,\n           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2);\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey, \n          class _Alloc>\nclass hash_multimap\n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Key, _Assignable);\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);\n\nprivate:\n  typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,\n                    _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> \n          _Ht;\n  _Ht _M_ht;\n\npublic:\n  typedef typename _Ht::key_type key_type;\n  typedef _Tp data_type;\n  typedef _Tp mapped_type;\n  typedef typename _Ht::value_type value_type;\n  typedef typename _Ht::hasher hasher;\n  typedef typename _Ht::key_equal key_equal;\n\n  typedef typename _Ht::size_type size_type;\n  typedef typename _Ht::difference_type difference_type;\n  typedef typename _Ht::pointer pointer;\n  typedef typename _Ht::const_pointer const_pointer;\n  typedef typename _Ht::reference reference;\n  typedef typename _Ht::const_reference const_reference;\n\n  typedef typename _Ht::iterator iterator;\n  typedef typename _Ht::const_iterator const_iterator;\n\n  typedef typename _Ht::allocator_type allocator_type;\n\n  hasher hash_funct() const { return _M_ht.hash_funct(); }\n  key_equal key_eq() const { return _M_ht.key_eq(); }\n  allocator_type get_allocator() const { return _M_ht.get_allocator(); }\n\npublic:\n  hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}\n  explicit hash_multimap(size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}\n  hash_multimap(size_type __n, const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}\n  hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  hash_multimap(_InputIterator __f, _InputIterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n\n#else\n  hash_multimap(const value_type* __f, const value_type* __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const value_type* __f, const value_type* __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const value_type* __f, const value_type* __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const value_type* __f, const value_type* __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n\n  hash_multimap(const_iterator __f, const_iterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const_iterator __f, const_iterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const_iterator __f, const_iterator __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multimap(const_iterator __f, const_iterator __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return _M_ht.size(); }\n  size_type max_size() const { return _M_ht.max_size(); }\n  bool empty() const { return _M_ht.empty(); }\n  void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _K1, class _T1, class _HF, class _EqK, class _Al>\n  friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,\n                          const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,const hash_multimap&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator begin() { return _M_ht.begin(); }\n  iterator end() { return _M_ht.end(); }\n  const_iterator begin() const { return _M_ht.begin(); }\n  const_iterator end() const { return _M_ht.end(); }\n\npublic:\n  iterator insert(const value_type& __obj) \n    { return _M_ht.insert_equal(__obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __f, _InputIterator __l) \n    { _M_ht.insert_equal(__f,__l); }\n#else\n  void insert(const value_type* __f, const value_type* __l) {\n    _M_ht.insert_equal(__f,__l);\n  }\n  void insert(const_iterator __f, const_iterator __l) \n    { _M_ht.insert_equal(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  iterator insert_noresize(const value_type& __obj)\n    { return _M_ht.insert_equal_noresize(__obj); }    \n\n  iterator find(const key_type& __key) { return _M_ht.find(__key); }\n  const_iterator find(const key_type& __key) const \n    { return _M_ht.find(__key); }\n\n  size_type count(const key_type& __key) const { return _M_ht.count(__key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& __key)\n    { return _M_ht.equal_range(__key); }\n  pair<const_iterator, const_iterator>\n  equal_range(const key_type& __key) const\n    { return _M_ht.equal_range(__key); }\n\n  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }\n  void erase(iterator __it) { _M_ht.erase(__it); }\n  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }\n  void clear() { _M_ht.clear(); }\n\npublic:\n  void resize(size_type __hint) { _M_ht.resize(__hint); }\n  size_type bucket_count() const { return _M_ht.bucket_count(); }\n  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }\n  size_type elems_in_bucket(size_type __n) const\n    { return _M_ht.elems_in_bucket(__n); }\n};\n\ntemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>\ninline bool \noperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,\n           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)\n{\n  return __hm1._M_ht == __hm2._M_ht;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>\ninline bool \noperator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,\n           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {\n  return !(__hm1 == __hm2);\n}\n\ntemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>\ninline void \nswap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,\n     hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)\n{\n  __hm1.swap(__hm2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Specialization of insert_iterator so that it will work for hash_map\n// and hash_multimap.\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>\nclass insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {\nprotected:\n  typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;\n  _Container* container;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x) : container(&__x) {}\n  insert_iterator(_Container& __x, typename _Container::iterator)\n    : container(&__x) {}\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->insert(__value);\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\ntemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>\nclass insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {\nprotected:\n  typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;\n  _Container* container;\n  typename _Container::iterator iter;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x) : container(&__x) {}\n  insert_iterator(_Container& __x, typename _Container::iterator)\n    : container(&__x) {}\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->insert(__value);\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASH_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_hash_set.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASH_SET_H\n#define __SGI_STL_INTERNAL_HASH_SET_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declaration of equality operator; needed for friend declaration.\n\ntemplate <class _Value,\n          class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Value>),\n          class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>),\n          class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Value) >\nclass hash_set;\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2);\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\nclass hash_set\n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Value, _Assignable);\n  __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);\n\nprivate:\n  typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, \n                    _EqualKey, _Alloc> _Ht;\n  _Ht _M_ht;\n\npublic:\n  typedef typename _Ht::key_type key_type;\n  typedef typename _Ht::value_type value_type;\n  typedef typename _Ht::hasher hasher;\n  typedef typename _Ht::key_equal key_equal;\n\n  typedef typename _Ht::size_type size_type;\n  typedef typename _Ht::difference_type difference_type;\n  typedef typename _Ht::const_pointer pointer;\n  typedef typename _Ht::const_pointer const_pointer;\n  typedef typename _Ht::const_reference reference;\n  typedef typename _Ht::const_reference const_reference;\n\n  typedef typename _Ht::const_iterator iterator;\n  typedef typename _Ht::const_iterator const_iterator;\n\n  typedef typename _Ht::allocator_type allocator_type;\n\n  hasher hash_funct() const { return _M_ht.hash_funct(); }\n  key_equal key_eq() const { return _M_ht.key_eq(); }\n  allocator_type get_allocator() const { return _M_ht.get_allocator(); }\n\npublic:\n  hash_set()\n    : _M_ht(100, hasher(), key_equal(), allocator_type()) {}\n  explicit hash_set(size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}\n  hash_set(size_type __n, const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}\n  hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  hash_set(_InputIterator __f, _InputIterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_set(_InputIterator __f, _InputIterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_set(_InputIterator __f, _InputIterator __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  template <class _InputIterator>\n  hash_set(_InputIterator __f, _InputIterator __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n#else\n\n  hash_set(const value_type* __f, const value_type* __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const value_type* __f, const value_type* __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const value_type* __f, const value_type* __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const value_type* __f, const value_type* __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n\n  hash_set(const_iterator __f, const_iterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const_iterator __f, const_iterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const_iterator __f, const_iterator __l, size_type __n,\n           const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_unique(__f, __l); }\n  hash_set(const_iterator __f, const_iterator __l, size_type __n,\n           const hasher& __hf, const key_equal& __eql,\n           const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_unique(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return _M_ht.size(); }\n  size_type max_size() const { return _M_ht.max_size(); }\n  bool empty() const { return _M_ht.empty(); }\n  void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Val, class _HF, class _EqK, class _Al>  \n  friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&,\n                          const hash_set<_Val, _HF, _EqK, _Al>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const hash_set&, const hash_set&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator begin() const { return _M_ht.begin(); }\n  iterator end() const { return _M_ht.end(); }\n\npublic:\n  pair<iterator, bool> insert(const value_type& __obj)\n    {\n      pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);\n      return pair<iterator,bool>(__p.first, __p.second);\n    }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __f, _InputIterator __l) \n    { _M_ht.insert_unique(__f,__l); }\n#else\n  void insert(const value_type* __f, const value_type* __l) {\n    _M_ht.insert_unique(__f,__l);\n  }\n  void insert(const_iterator __f, const_iterator __l) \n    {_M_ht.insert_unique(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  pair<iterator, bool> insert_noresize(const value_type& __obj)\n  {\n    pair<typename _Ht::iterator, bool> __p = \n      _M_ht.insert_unique_noresize(__obj);\n    return pair<iterator, bool>(__p.first, __p.second);\n  }\n\n  iterator find(const key_type& __key) const { return _M_ht.find(__key); }\n\n  size_type count(const key_type& __key) const { return _M_ht.count(__key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& __key) const\n    { return _M_ht.equal_range(__key); }\n\n  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }\n  void erase(iterator __it) { _M_ht.erase(__it); }\n  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }\n  void clear() { _M_ht.clear(); }\n\npublic:\n  void resize(size_type __hint) { _M_ht.resize(__hint); }\n  size_type bucket_count() const { return _M_ht.bucket_count(); }\n  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }\n  size_type elems_in_bucket(size_type __n) const\n    { return _M_ht.elems_in_bucket(__n); }\n};\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2)\n{\n  return __hs1._M_ht == __hs2._M_ht;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) {\n  return !(__hs1 == __hs2);\n}\n\ntemplate <class _Val, class _HashFcn, class _EqualKey, class _Alloc>\ninline void \nswap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,\n     hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)\n{\n  __hs1.swap(__hs2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class _Value,\n          class _HashFcn  __STL_DEPENDENT_DEFAULT_TMPL(hash<_Value>),\n          class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>),\n          class _Alloc =  __STL_DEFAULT_ALLOCATOR(_Value) >\nclass hash_multiset;\n\ntemplate <class _Val, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2);\n\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\nclass hash_multiset\n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Value, _Assignable);\n  __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);\n\nprivate:\n  typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, \n                    _EqualKey, _Alloc> _Ht;\n  _Ht _M_ht;\n\npublic:\n  typedef typename _Ht::key_type key_type;\n  typedef typename _Ht::value_type value_type;\n  typedef typename _Ht::hasher hasher;\n  typedef typename _Ht::key_equal key_equal;\n\n  typedef typename _Ht::size_type size_type;\n  typedef typename _Ht::difference_type difference_type;\n  typedef typename _Ht::const_pointer pointer;\n  typedef typename _Ht::const_pointer const_pointer;\n  typedef typename _Ht::const_reference reference;\n  typedef typename _Ht::const_reference const_reference;\n\n  typedef typename _Ht::const_iterator iterator;\n  typedef typename _Ht::const_iterator const_iterator;\n\n  typedef typename _Ht::allocator_type allocator_type;\n\n  hasher hash_funct() const { return _M_ht.hash_funct(); }\n  key_equal key_eq() const { return _M_ht.key_eq(); }\n  allocator_type get_allocator() const { return _M_ht.get_allocator(); }\n\npublic:\n  hash_multiset()\n    : _M_ht(100, hasher(), key_equal(), allocator_type()) {}\n  explicit hash_multiset(size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}\n  hash_multiset(size_type __n, const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}\n  hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  hash_multiset(_InputIterator __f, _InputIterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  template <class _InputIterator>\n  hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n#else\n\n  hash_multiset(const value_type* __f, const value_type* __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const value_type* __f, const value_type* __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const value_type* __f, const value_type* __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const value_type* __f, const value_type* __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n\n  hash_multiset(const_iterator __f, const_iterator __l)\n    : _M_ht(100, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const_iterator __f, const_iterator __l, size_type __n)\n    : _M_ht(__n, hasher(), key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const_iterator __f, const_iterator __l, size_type __n,\n                const hasher& __hf)\n    : _M_ht(__n, __hf, key_equal(), allocator_type())\n    { _M_ht.insert_equal(__f, __l); }\n  hash_multiset(const_iterator __f, const_iterator __l, size_type __n,\n                const hasher& __hf, const key_equal& __eql,\n                const allocator_type& __a = allocator_type())\n    : _M_ht(__n, __hf, __eql, __a)\n    { _M_ht.insert_equal(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return _M_ht.size(); }\n  size_type max_size() const { return _M_ht.max_size(); }\n  bool empty() const { return _M_ht.empty(); }\n  void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Val, class _HF, class _EqK, class _Al>  \n  friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&,\n                          const hash_multiset<_Val, _HF, _EqK, _Al>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,const hash_multiset&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator begin() const { return _M_ht.begin(); }\n  iterator end() const { return _M_ht.end(); }\n\npublic:\n  iterator insert(const value_type& __obj)\n    { return _M_ht.insert_equal(__obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __f, _InputIterator __l) \n    { _M_ht.insert_equal(__f,__l); }\n#else\n  void insert(const value_type* __f, const value_type* __l) {\n    _M_ht.insert_equal(__f,__l);\n  }\n  void insert(const_iterator __f, const_iterator __l) \n    { _M_ht.insert_equal(__f, __l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  iterator insert_noresize(const value_type& __obj)\n    { return _M_ht.insert_equal_noresize(__obj); }    \n\n  iterator find(const key_type& __key) const { return _M_ht.find(__key); }\n\n  size_type count(const key_type& __key) const { return _M_ht.count(__key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& __key) const\n    { return _M_ht.equal_range(__key); }\n\n  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }\n  void erase(iterator __it) { _M_ht.erase(__it); }\n  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }\n  void clear() { _M_ht.clear(); }\n\npublic:\n  void resize(size_type __hint) { _M_ht.resize(__hint); }\n  size_type bucket_count() const { return _M_ht.bucket_count(); }\n  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }\n  size_type elems_in_bucket(size_type __n) const\n    { return _M_ht.elems_in_bucket(__n); }\n};\n\ntemplate <class _Val, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)\n{\n  return __hs1._M_ht == __hs2._M_ht;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Val, class _HashFcn, class _EqualKey, class _Alloc>\ninline bool \noperator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,\n           const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {\n  return !(__hs1 == __hs2);\n}\n\ntemplate <class _Val, class _HashFcn, class _EqualKey, class _Alloc>\ninline void \nswap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,\n     hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {\n  __hs1.swap(__hs2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Specialization of insert_iterator so that it will work for hash_set\n// and hash_multiset.\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\nclass insert_iterator<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > {\nprotected:\n  typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container;\n  _Container* container;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x) : container(&__x) {}\n  insert_iterator(_Container& __x, typename _Container::iterator)\n    : container(&__x) {}\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->insert(__value);\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\ntemplate <class _Value, class _HashFcn, class _EqualKey, class _Alloc>\nclass insert_iterator<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > {\nprotected:\n  typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;\n  _Container* container;\n  typename _Container::iterator iter;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x) : container(&__x) {}\n  insert_iterator(_Container& __x, typename _Container::iterator)\n    : container(&__x) {}\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->insert(__value);\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASH_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_hashtable.h",
    "content": "/*\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#define __SGI_STL_INTERNAL_HASHTABLE_H\n\n// Hashtable class, used to implement the hashed associative containers\n// hash_set, hash_map, hash_multiset, and hash_multimap.\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_tempbuf.h>\n#include <stl_algo.h>\n#include <stl_uninitialized.h>\n#include <stl_function.h>\n#include <stl_vector.h>\n#include <stl_hash_fun.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _Val>\nstruct _Hashtable_node\n{\n  _Hashtable_node* _M_next;\n  _Val _M_val;\n};  \n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc = alloc>\nclass hashtable;\n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc>\nstruct _Hashtable_iterator;\n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc>\nstruct _Hashtable_const_iterator;\n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc>\nstruct _Hashtable_iterator {\n  typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>\n          _Hashtable;\n  typedef _Hashtable_iterator<_Val, _Key, _HashFcn, \n                              _ExtractKey, _EqualKey, _Alloc>\n          iterator;\n  typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, \n                                    _ExtractKey, _EqualKey, _Alloc>\n          const_iterator;\n  typedef _Hashtable_node<_Val> _Node;\n\n  typedef forward_iterator_tag iterator_category;\n  typedef _Val value_type;\n  typedef ptrdiff_t difference_type;\n  typedef size_t size_type;\n  typedef _Val& reference;\n  typedef _Val* pointer;\n\n  _Node* _M_cur;\n  _Hashtable* _M_ht;\n\n  _Hashtable_iterator(_Node* __n, _Hashtable* __tab) \n    : _M_cur(__n), _M_ht(__tab) {}\n  _Hashtable_iterator() {}\n  reference operator*() const { return _M_cur->_M_val; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  iterator& operator++();\n  iterator operator++(int);\n  bool operator==(const iterator& __it) const\n    { return _M_cur == __it._M_cur; }\n  bool operator!=(const iterator& __it) const\n    { return _M_cur != __it._M_cur; }\n};\n\n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc>\nstruct _Hashtable_const_iterator {\n  typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>\n          _Hashtable;\n  typedef _Hashtable_iterator<_Val,_Key,_HashFcn, \n                              _ExtractKey,_EqualKey,_Alloc>\n          iterator;\n  typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, \n                                    _ExtractKey, _EqualKey, _Alloc>\n          const_iterator;\n  typedef _Hashtable_node<_Val> _Node;\n\n  typedef forward_iterator_tag iterator_category;\n  typedef _Val value_type;\n  typedef ptrdiff_t difference_type;\n  typedef size_t size_type;\n  typedef const _Val& reference;\n  typedef const _Val* pointer;\n\n  const _Node* _M_cur;\n  const _Hashtable* _M_ht;\n\n  _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab)\n    : _M_cur(__n), _M_ht(__tab) {}\n  _Hashtable_const_iterator() {}\n  _Hashtable_const_iterator(const iterator& __it) \n    : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {}\n  reference operator*() const { return _M_cur->_M_val; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  const_iterator& operator++();\n  const_iterator operator++(int);\n  bool operator==(const const_iterator& __it) const \n    { return _M_cur == __it._M_cur; }\n  bool operator!=(const const_iterator& __it) const \n    { return _M_cur != __it._M_cur; }\n};\n\n// Note: assumes long is at least 32 bits.\nenum { __stl_num_primes = 28 };\n\nstatic const unsigned long __stl_prime_list[__stl_num_primes] =\n{\n  53ul,         97ul,         193ul,       389ul,       769ul,\n  1543ul,       3079ul,       6151ul,      12289ul,     24593ul,\n  49157ul,      98317ul,      196613ul,    393241ul,    786433ul,\n  1572869ul,    3145739ul,    6291469ul,   12582917ul,  25165843ul,\n  50331653ul,   100663319ul,  201326611ul, 402653189ul, 805306457ul, \n  1610612741ul, 3221225473ul, 4294967291ul\n};\n\ninline unsigned long __stl_next_prime(unsigned long __n)\n{\n  const unsigned long* __first = __stl_prime_list;\n  const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes;\n  const unsigned long* pos = lower_bound(__first, __last, __n);\n  return pos == __last ? *(__last - 1) : *pos;\n}\n\n// Forward declaration of operator==.\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nclass hashtable;\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nbool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,\n                const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2);\n\n\n// Hashtables handle allocators a bit differently than other containers\n//  do.  If we're using standard-conforming allocators, then a hashtable\n//  unconditionally has a member variable to hold its allocator, even if\n//  it so happens that all instances of the allocator type are identical.\n// This is because, for hashtables, this extra storage is negligible.  \n//  Additionally, a base class wouldn't serve any other purposes; it \n//  wouldn't, for example, simplify the exception-handling code.\n\ntemplate <class _Val, class _Key, class _HashFcn,\n          class _ExtractKey, class _EqualKey, class _Alloc>\nclass hashtable {\npublic:\n  typedef _Key key_type;\n  typedef _Val value_type;\n  typedef _HashFcn hasher;\n  typedef _EqualKey key_equal;\n\n  typedef size_t            size_type;\n  typedef ptrdiff_t         difference_type;\n  typedef value_type*       pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type&       reference;\n  typedef const value_type& const_reference;\n\n  hasher hash_funct() const { return _M_hash; }\n  key_equal key_eq() const { return _M_equals; }\n\nprivate:\n  typedef _Hashtable_node<_Val> _Node;\n\n#ifdef __STL_USE_STD_ALLOCATORS\npublic:\n  typedef typename _Alloc_traits<_Val,_Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _M_node_allocator; }\nprivate:\n  typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator;\n  _Node* _M_get_node() { return _M_node_allocator.allocate(1); }\n  void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); }\n# define __HASH_ALLOC_INIT(__a) _M_node_allocator(__a), \n#else /* __STL_USE_STD_ALLOCATORS */\npublic:\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\nprivate:\n  typedef simple_alloc<_Node, _Alloc> _M_node_allocator_type;\n  _Node* _M_get_node() { return _M_node_allocator_type::allocate(1); }\n  void _M_put_node(_Node* __p) { _M_node_allocator_type::deallocate(__p, 1); }\n# define __HASH_ALLOC_INIT(__a)\n#endif /* __STL_USE_STD_ALLOCATORS */\n\nprivate:\n  hasher                _M_hash;\n  key_equal             _M_equals;\n  _ExtractKey           _M_get_key;\n  vector<_Node*,_Alloc> _M_buckets;\n  size_type             _M_num_elements;\n\npublic:\n  typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>\n          iterator;\n  typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,\n                                    _Alloc>\n          const_iterator;\n\n  friend struct\n  _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>;\n  friend struct\n  _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>;\n\npublic:\n  hashtable(size_type __n,\n            const _HashFcn&    __hf,\n            const _EqualKey&   __eql,\n            const _ExtractKey& __ext,\n            const allocator_type& __a = allocator_type())\n    : __HASH_ALLOC_INIT(__a)\n      _M_hash(__hf),\n      _M_equals(__eql),\n      _M_get_key(__ext),\n      _M_buckets(__a),\n      _M_num_elements(0)\n  {\n    _M_initialize_buckets(__n);\n  }\n\n  hashtable(size_type __n,\n            const _HashFcn&    __hf,\n            const _EqualKey&   __eql,\n            const allocator_type& __a = allocator_type())\n    : __HASH_ALLOC_INIT(__a)\n      _M_hash(__hf),\n      _M_equals(__eql),\n      _M_get_key(_ExtractKey()),\n      _M_buckets(__a),\n      _M_num_elements(0)\n  {\n    _M_initialize_buckets(__n);\n  }\n\n  hashtable(const hashtable& __ht)\n    : __HASH_ALLOC_INIT(__ht.get_allocator())\n      _M_hash(__ht._M_hash),\n      _M_equals(__ht._M_equals),\n      _M_get_key(__ht._M_get_key),\n      _M_buckets(__ht.get_allocator()),\n      _M_num_elements(0)\n  {\n    _M_copy_from(__ht);\n  }\n\n#undef __HASH_ALLOC_INIT\n\n  hashtable& operator= (const hashtable& __ht)\n  {\n    if (&__ht != this) {\n      clear();\n      _M_hash = __ht._M_hash;\n      _M_equals = __ht._M_equals;\n      _M_get_key = __ht._M_get_key;\n      _M_copy_from(__ht);\n    }\n    return *this;\n  }\n\n  ~hashtable() { clear(); }\n\n  size_type size() const { return _M_num_elements; }\n  size_type max_size() const { return size_type(-1); }\n  bool empty() const { return size() == 0; }\n\n  void swap(hashtable& __ht)\n  {\n    __STD::swap(_M_hash, __ht._M_hash);\n    __STD::swap(_M_equals, __ht._M_equals);\n    __STD::swap(_M_get_key, __ht._M_get_key);\n    _M_buckets.swap(__ht._M_buckets);\n    __STD::swap(_M_num_elements, __ht._M_num_elements);\n  }\n\n  iterator begin()\n  { \n    for (size_type __n = 0; __n < _M_buckets.size(); ++__n)\n      if (_M_buckets[__n])\n        return iterator(_M_buckets[__n], this);\n    return end();\n  }\n\n  iterator end() { return iterator(0, this); }\n\n  const_iterator begin() const\n  {\n    for (size_type __n = 0; __n < _M_buckets.size(); ++__n)\n      if (_M_buckets[__n])\n        return const_iterator(_M_buckets[__n], this);\n    return end();\n  }\n\n  const_iterator end() const { return const_iterator(0, this); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Vl, class _Ky, class _HF, class _Ex, class _Eq, class _Al>\n  friend bool operator== (const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&,\n                          const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const hashtable&, const hashtable&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n\n  size_type bucket_count() const { return _M_buckets.size(); }\n\n  size_type max_bucket_count() const\n    { return __stl_prime_list[(int)__stl_num_primes - 1]; } \n\n  size_type elems_in_bucket(size_type __bucket) const\n  {\n    size_type __result = 0;\n    for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next)\n      __result += 1;\n    return __result;\n  }\n\n  pair<iterator, bool> insert_unique(const value_type& __obj)\n  {\n    resize(_M_num_elements + 1);\n    return insert_unique_noresize(__obj);\n  }\n\n  iterator insert_equal(const value_type& __obj)\n  {\n    resize(_M_num_elements + 1);\n    return insert_equal_noresize(__obj);\n  }\n\n  pair<iterator, bool> insert_unique_noresize(const value_type& __obj);\n  iterator insert_equal_noresize(const value_type& __obj);\n \n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert_unique(_InputIterator __f, _InputIterator __l)\n  {\n    insert_unique(__f, __l, __ITERATOR_CATEGORY(__f));\n  }\n\n  template <class _InputIterator>\n  void insert_equal(_InputIterator __f, _InputIterator __l)\n  {\n    insert_equal(__f, __l, __ITERATOR_CATEGORY(__f));\n  }\n\n  template <class _InputIterator>\n  void insert_unique(_InputIterator __f, _InputIterator __l,\n                     input_iterator_tag)\n  {\n    for ( ; __f != __l; ++__f)\n      insert_unique(*__f);\n  }\n\n  template <class _InputIterator>\n  void insert_equal(_InputIterator __f, _InputIterator __l,\n                    input_iterator_tag)\n  {\n    for ( ; __f != __l; ++__f)\n      insert_equal(*__f);\n  }\n\n  template <class _ForwardIterator>\n  void insert_unique(_ForwardIterator __f, _ForwardIterator __l,\n                     forward_iterator_tag)\n  {\n    size_type __n = 0;\n    distance(__f, __l, __n);\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_unique_noresize(*__f);\n  }\n\n  template <class _ForwardIterator>\n  void insert_equal(_ForwardIterator __f, _ForwardIterator __l,\n                    forward_iterator_tag)\n  {\n    size_type __n = 0;\n    distance(__f, __l, __n);\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_equal_noresize(*__f);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert_unique(const value_type* __f, const value_type* __l)\n  {\n    size_type __n = __l - __f;\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_unique_noresize(*__f);\n  }\n\n  void insert_equal(const value_type* __f, const value_type* __l)\n  {\n    size_type __n = __l - __f;\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_equal_noresize(*__f);\n  }\n\n  void insert_unique(const_iterator __f, const_iterator __l)\n  {\n    size_type __n = 0;\n    distance(__f, __l, __n);\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_unique_noresize(*__f);\n  }\n\n  void insert_equal(const_iterator __f, const_iterator __l)\n  {\n    size_type __n = 0;\n    distance(__f, __l, __n);\n    resize(_M_num_elements + __n);\n    for ( ; __n > 0; --__n, ++__f)\n      insert_equal_noresize(*__f);\n  }\n#endif /*__STL_MEMBER_TEMPLATES */\n\n  reference find_or_insert(const value_type& __obj);\n\n  iterator find(const key_type& __key) \n  {\n    size_type __n = _M_bkt_num_key(__key);\n    _Node* __first;\n    for ( __first = _M_buckets[__n];\n          __first && !_M_equals(_M_get_key(__first->_M_val), __key);\n          __first = __first->_M_next)\n      {}\n    return iterator(__first, this);\n  } \n\n  const_iterator find(const key_type& __key) const\n  {\n    size_type __n = _M_bkt_num_key(__key);\n    const _Node* __first;\n    for ( __first = _M_buckets[__n];\n          __first && !_M_equals(_M_get_key(__first->_M_val), __key);\n          __first = __first->_M_next)\n      {}\n    return const_iterator(__first, this);\n  } \n\n  size_type count(const key_type& __key) const\n  {\n    const size_type __n = _M_bkt_num_key(__key);\n    size_type __result = 0;\n\n    for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next)\n      if (_M_equals(_M_get_key(__cur->_M_val), __key))\n        ++__result;\n    return __result;\n  }\n\n  pair<iterator, iterator> \n  equal_range(const key_type& __key);\n\n  pair<const_iterator, const_iterator> \n  equal_range(const key_type& __key) const;\n\n  size_type erase(const key_type& __key);\n  void erase(const iterator& __it);\n  void erase(iterator __first, iterator __last);\n\n  void erase(const const_iterator& __it);\n  void erase(const_iterator __first, const_iterator __last);\n\n  void resize(size_type __num_elements_hint);\n  void clear();\n\nprivate:\n  size_type _M_next_size(size_type __n) const\n    { return __stl_next_prime(__n); }\n\n  void _M_initialize_buckets(size_type __n)\n  {\n    const size_type __n_buckets = _M_next_size(__n);\n    _M_buckets.reserve(__n_buckets);\n    _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0);\n    _M_num_elements = 0;\n  }\n\n  size_type _M_bkt_num_key(const key_type& __key) const\n  {\n    return _M_bkt_num_key(__key, _M_buckets.size());\n  }\n\n  size_type _M_bkt_num(const value_type& __obj) const\n  {\n    return _M_bkt_num_key(_M_get_key(__obj));\n  }\n\n  size_type _M_bkt_num_key(const key_type& __key, size_t __n) const\n  {\n    return _M_hash(__key) % __n;\n  }\n\n  size_type _M_bkt_num(const value_type& __obj, size_t __n) const\n  {\n    return _M_bkt_num_key(_M_get_key(__obj), __n);\n  }\n\n  _Node* _M_new_node(const value_type& __obj)\n  {\n    _Node* __n = _M_get_node();\n    __n->_M_next = 0;\n    __STL_TRY {\n      construct(&__n->_M_val, __obj);\n      return __n;\n    }\n    __STL_UNWIND(_M_put_node(__n));\n  }\n  \n  void _M_delete_node(_Node* __n)\n  {\n    destroy(&__n->_M_val);\n    _M_put_node(__n);\n  }\n\n  void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last);\n  void _M_erase_bucket(const size_type __n, _Node* __last);\n\n  void _M_copy_from(const hashtable& __ht);\n\n};\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\n_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&\n_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++()\n{\n  const _Node* __old = _M_cur;\n  _M_cur = _M_cur->_M_next;\n  if (!_M_cur) {\n    size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);\n    while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())\n      _M_cur = _M_ht->_M_buckets[__bucket];\n  }\n  return *this;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>\n_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int)\n{\n  iterator __tmp = *this;\n  ++*this;\n  return __tmp;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\n_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&\n_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++()\n{\n  const _Node* __old = _M_cur;\n  _M_cur = _M_cur->_M_next;\n  if (!_M_cur) {\n    size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);\n    while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())\n      _M_cur = _M_ht->_M_buckets[__bucket];\n  }\n  return *this;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>\n_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int)\n{\n  const_iterator __tmp = *this;\n  ++*this;\n  return __tmp;\n}\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline forward_iterator_tag\niterator_category(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&)\n{\n  return forward_iterator_tag();\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline _Val* \nvalue_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&)\n{\n  return (_Val*) 0;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*\ndistance_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&)\n{\n  return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline forward_iterator_tag\niterator_category(const _Hashtable_const_iterator<_Val,_Key,_HF,\n                                                  _ExK,_EqK,_All>&)\n{\n  return forward_iterator_tag();\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline _Val* \nvalue_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&)\n{\n  return (_Val*) 0;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _ExK, class _EqK, \n          class _All>\ninline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*\ndistance_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&)\n{\n  return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::difference_type*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nbool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,\n                const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2)\n{\n  typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node;\n  if (__ht1._M_buckets.size() != __ht2._M_buckets.size())\n    return false;\n  for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) {\n    _Node* __cur1 = __ht1._M_buckets[__n];\n    _Node* __cur2 = __ht2._M_buckets[__n];\n    for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val;\n          __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next)\n      {}\n    if (__cur1 || __cur2)\n      return false;\n  }\n  return true;\n}  \n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ninline bool operator!=(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,\n                       const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) {\n  return !(__ht1 == __ht2);\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Extract, class _EqKey, \n          class _All>\ninline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1,\n                 hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) {\n  __ht1.swap(__ht2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\npair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator, bool> \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::insert_unique_noresize(const value_type& __obj)\n{\n  const size_type __n = _M_bkt_num(__obj);\n  _Node* __first = _M_buckets[__n];\n\n  for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) \n    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))\n      return pair<iterator, bool>(iterator(__cur, this), false);\n\n  _Node* __tmp = _M_new_node(__obj);\n  __tmp->_M_next = __first;\n  _M_buckets[__n] = __tmp;\n  ++_M_num_elements;\n  return pair<iterator, bool>(iterator(__tmp, this), true);\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ntypename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::insert_equal_noresize(const value_type& __obj)\n{\n  const size_type __n = _M_bkt_num(__obj);\n  _Node* __first = _M_buckets[__n];\n\n  for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) \n    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) {\n      _Node* __tmp = _M_new_node(__obj);\n      __tmp->_M_next = __cur->_M_next;\n      __cur->_M_next = __tmp;\n      ++_M_num_elements;\n      return iterator(__tmp, this);\n    }\n\n  _Node* __tmp = _M_new_node(__obj);\n  __tmp->_M_next = __first;\n  _M_buckets[__n] = __tmp;\n  ++_M_num_elements;\n  return iterator(__tmp, this);\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ntypename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_insert(const value_type& __obj)\n{\n  resize(_M_num_elements + 1);\n\n  size_type __n = _M_bkt_num(__obj);\n  _Node* __first = _M_buckets[__n];\n\n  for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)\n    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))\n      return __cur->_M_val;\n\n  _Node* __tmp = _M_new_node(__obj);\n  __tmp->_M_next = __first;\n  _M_buckets[__n] = __tmp;\n  ++_M_num_elements;\n  return __tmp->_M_val;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\npair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator,\n     typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator> \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range(const key_type& __key)\n{\n  typedef pair<iterator, iterator> _Pii;\n  const size_type __n = _M_bkt_num_key(__key);\n\n  for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next)\n    if (_M_equals(_M_get_key(__first->_M_val), __key)) {\n      for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next)\n        if (!_M_equals(_M_get_key(__cur->_M_val), __key))\n          return _Pii(iterator(__first, this), iterator(__cur, this));\n      for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)\n        if (_M_buckets[__m])\n          return _Pii(iterator(__first, this),\n                     iterator(_M_buckets[__m], this));\n      return _Pii(iterator(__first, this), end());\n    }\n  return _Pii(end(), end());\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\npair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator, \n     typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator> \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::equal_range(const key_type& __key) const\n{\n  typedef pair<const_iterator, const_iterator> _Pii;\n  const size_type __n = _M_bkt_num_key(__key);\n\n  for (const _Node* __first = _M_buckets[__n] ;\n       __first; \n       __first = __first->_M_next) {\n    if (_M_equals(_M_get_key(__first->_M_val), __key)) {\n      for (const _Node* __cur = __first->_M_next;\n           __cur;\n           __cur = __cur->_M_next)\n        if (!_M_equals(_M_get_key(__cur->_M_val), __key))\n          return _Pii(const_iterator(__first, this),\n                      const_iterator(__cur, this));\n      for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)\n        if (_M_buckets[__m])\n          return _Pii(const_iterator(__first, this),\n                      const_iterator(_M_buckets[__m], this));\n      return _Pii(const_iterator(__first, this), end());\n    }\n  }\n  return _Pii(end(), end());\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ntypename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type \nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key)\n{\n  const size_type __n = _M_bkt_num_key(__key);\n  _Node* __first = _M_buckets[__n];\n  size_type __erased = 0;\n\n  if (__first) {\n    _Node* __cur = __first;\n    _Node* __next = __cur->_M_next;\n    while (__next) {\n      if (_M_equals(_M_get_key(__next->_M_val), __key)) {\n        __cur->_M_next = __next->_M_next;\n        _M_delete_node(__next);\n        __next = __cur->_M_next;\n        ++__erased;\n        --_M_num_elements;\n      }\n      else {\n        __cur = __next;\n        __next = __cur->_M_next;\n      }\n    }\n    if (_M_equals(_M_get_key(__first->_M_val), __key)) {\n      _M_buckets[__n] = __first->_M_next;\n      _M_delete_node(__first);\n      ++__erased;\n      --_M_num_elements;\n    }\n  }\n  return __erased;\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it)\n{\n  _Node* __p = __it._M_cur;\n  if (__p) {\n    const size_type __n = _M_bkt_num(__p->_M_val);\n    _Node* __cur = _M_buckets[__n];\n\n    if (__cur == __p) {\n      _M_buckets[__n] = __cur->_M_next;\n      _M_delete_node(__cur);\n      --_M_num_elements;\n    }\n    else {\n      _Node* __next = __cur->_M_next;\n      while (__next) {\n        if (__next == __p) {\n          __cur->_M_next = __next->_M_next;\n          _M_delete_node(__next);\n          --_M_num_elements;\n          break;\n        }\n        else {\n          __cur = __next;\n          __next = __cur->_M_next;\n        }\n      }\n    }\n  }\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::erase(iterator __first, iterator __last)\n{\n  size_type __f_bucket = __first._M_cur ? \n    _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size();\n  size_type __l_bucket = __last._M_cur ? \n    _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size();\n\n  if (__first._M_cur == __last._M_cur)\n    return;\n  else if (__f_bucket == __l_bucket)\n    _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);\n  else {\n    _M_erase_bucket(__f_bucket, __first._M_cur, 0);\n    for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)\n      _M_erase_bucket(__n, 0);\n    if (__l_bucket != _M_buckets.size())\n      _M_erase_bucket(__l_bucket, __last._M_cur);\n  }\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ninline void\nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const_iterator __first,\n                                             const_iterator __last)\n{\n  erase(iterator(const_cast<_Node*>(__first._M_cur),\n                 const_cast<hashtable*>(__first._M_ht)),\n        iterator(const_cast<_Node*>(__last._M_cur),\n                 const_cast<hashtable*>(__last._M_ht)));\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\ninline void\nhashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it)\n{\n  erase(iterator(const_cast<_Node*>(__it._M_cur),\n                 const_cast<hashtable*>(__it._M_ht)));\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::resize(size_type __num_elements_hint)\n{\n  const size_type __old_n = _M_buckets.size();\n  if (__num_elements_hint > __old_n) {\n    const size_type __n = _M_next_size(__num_elements_hint);\n    if (__n > __old_n) {\n      vector<_Node*, _All> __tmp(__n, (_Node*)(0),\n                                 _M_buckets.get_allocator());\n      __STL_TRY {\n        for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {\n          _Node* __first = _M_buckets[__bucket];\n          while (__first) {\n            size_type __new_bucket = _M_bkt_num(__first->_M_val, __n);\n            _M_buckets[__bucket] = __first->_M_next;\n            __first->_M_next = __tmp[__new_bucket];\n            __tmp[__new_bucket] = __first;\n            __first = _M_buckets[__bucket];          \n          }\n        }\n        _M_buckets.swap(__tmp);\n      }\n#         ifdef __STL_USE_EXCEPTIONS\n      catch(...) {\n        for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) {\n          while (__tmp[__bucket]) {\n            _Node* __next = __tmp[__bucket]->_M_next;\n            _M_delete_node(__tmp[__bucket]);\n            __tmp[__bucket] = __next;\n          }\n        }\n        throw;\n      }\n#         endif /* __STL_USE_EXCEPTIONS */\n    }\n  }\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last)\n{\n  _Node* __cur = _M_buckets[__n];\n  if (__cur == __first)\n    _M_erase_bucket(__n, __last);\n  else {\n    _Node* __next;\n    for (__next = __cur->_M_next; \n         __next != __first; \n         __cur = __next, __next = __cur->_M_next)\n      ;\n    while (__next != __last) {\n      __cur->_M_next = __next->_M_next;\n      _M_delete_node(__next);\n      __next = __cur->_M_next;\n      --_M_num_elements;\n    }\n  }\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::_M_erase_bucket(const size_type __n, _Node* __last)\n{\n  _Node* __cur = _M_buckets[__n];\n  while (__cur != __last) {\n    _Node* __next = __cur->_M_next;\n    _M_delete_node(__cur);\n    __cur = __next;\n    _M_buckets[__n] = __cur;\n    --_M_num_elements;\n  }\n}\n\ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear()\n{\n  for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {\n    _Node* __cur = _M_buckets[__i];\n    while (__cur != 0) {\n      _Node* __next = __cur->_M_next;\n      _M_delete_node(__cur);\n      __cur = __next;\n    }\n    _M_buckets[__i] = 0;\n  }\n  _M_num_elements = 0;\n}\n\n    \ntemplate <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>\nvoid hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>\n  ::_M_copy_from(const hashtable& __ht)\n{\n  _M_buckets.clear();\n  _M_buckets.reserve(__ht._M_buckets.size());\n  _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0);\n  __STL_TRY {\n    for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {\n      const _Node* __cur = __ht._M_buckets[__i];\n      if (__cur) {\n        _Node* __copy = _M_new_node(__cur->_M_val);\n        _M_buckets[__i] = __copy;\n\n        for (_Node* __next = __cur->_M_next; \n             __next; \n             __cur = __next, __next = __cur->_M_next) {\n          __copy->_M_next = _M_new_node(__next->_M_val);\n          __copy = __copy->_M_next;\n        }\n      }\n    }\n    _M_num_elements = __ht._M_num_elements;\n  }\n  __STL_UNWIND(clear());\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASHTABLE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_heap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HEAP_H\n#define __SGI_STL_INTERNAL_HEAP_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1209\n#endif\n\n// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.\n\ntemplate <class _RandomAccessIterator, class _Distance, class _Tp>\nvoid \n__push_heap(_RandomAccessIterator __first,\n            _Distance __holeIndex, _Distance __topIndex, _Tp __value)\n{\n  _Distance __parent = (__holeIndex - 1) / 2;\n  while (__holeIndex > __topIndex && *(__first + __parent) < __value) {\n    *(__first + __holeIndex) = *(__first + __parent);\n    __holeIndex = __parent;\n    __parent = (__holeIndex - 1) / 2;\n  }    \n  *(__first + __holeIndex) = __value;\n}\n\ntemplate <class _RandomAccessIterator, class _Distance, class _Tp>\ninline void \n__push_heap_aux(_RandomAccessIterator __first,\n                _RandomAccessIterator __last, _Distance*, _Tp*)\n{\n  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), \n              _Tp(*(__last - 1)));\n}\n\ntemplate <class _RandomAccessIterator>\ninline void \npush_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,\n                 _LessThanComparable);\n  __push_heap_aux(__first, __last,\n                  __DISTANCE_TYPE(__first), __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator, class _Distance, class _Tp, \n          class _Compare>\nvoid\n__push_heap(_RandomAccessIterator __first, _Distance __holeIndex,\n            _Distance __topIndex, _Tp __value, _Compare __comp)\n{\n  _Distance __parent = (__holeIndex - 1) / 2;\n  while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) {\n    *(__first + __holeIndex) = *(__first + __parent);\n    __holeIndex = __parent;\n    __parent = (__holeIndex - 1) / 2;\n  }\n  *(__first + __holeIndex) = __value;\n}\n\ntemplate <class _RandomAccessIterator, class _Compare,\n          class _Distance, class _Tp>\ninline void \n__push_heap_aux(_RandomAccessIterator __first,\n                _RandomAccessIterator __last, _Compare __comp,\n                _Distance*, _Tp*) \n{\n  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), \n              _Tp(*(__last - 1)), __comp);\n}\n\ntemplate <class _RandomAccessIterator, class _Compare>\ninline void \npush_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\n          _Compare __comp)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __push_heap_aux(__first, __last, __comp,\n                  __DISTANCE_TYPE(__first), __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator, class _Distance, class _Tp>\nvoid \n__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,\n              _Distance __len, _Tp __value)\n{\n  _Distance __topIndex = __holeIndex;\n  _Distance __secondChild = 2 * __holeIndex + 2;\n  while (__secondChild < __len) {\n    if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))\n      __secondChild--;\n    *(__first + __holeIndex) = *(__first + __secondChild);\n    __holeIndex = __secondChild;\n    __secondChild = 2 * (__secondChild + 1);\n  }\n  if (__secondChild == __len) {\n    *(__first + __holeIndex) = *(__first + (__secondChild - 1));\n    __holeIndex = __secondChild - 1;\n  }\n  __push_heap(__first, __holeIndex, __topIndex, __value);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp, class _Distance>\ninline void \n__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\n           _RandomAccessIterator __result, _Tp __value, _Distance*)\n{\n  *__result = *__first;\n  __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp>\ninline void \n__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last,\n               _Tp*)\n{\n  __pop_heap(__first, __last - 1, __last - 1, \n             _Tp(*(__last - 1)), __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator>\ninline void pop_heap(_RandomAccessIterator __first, \n                     _RandomAccessIterator __last)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,\n                 _LessThanComparable);\n  __pop_heap_aux(__first, __last, __VALUE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator, class _Distance,\n          class _Tp, class _Compare>\nvoid\n__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,\n              _Distance __len, _Tp __value, _Compare __comp)\n{\n  _Distance __topIndex = __holeIndex;\n  _Distance __secondChild = 2 * __holeIndex + 2;\n  while (__secondChild < __len) {\n    if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1))))\n      __secondChild--;\n    *(__first + __holeIndex) = *(__first + __secondChild);\n    __holeIndex = __secondChild;\n    __secondChild = 2 * (__secondChild + 1);\n  }\n  if (__secondChild == __len) {\n    *(__first + __holeIndex) = *(__first + (__secondChild - 1));\n    __holeIndex = __secondChild - 1;\n  }\n  __push_heap(__first, __holeIndex, __topIndex, __value, __comp);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp, class _Compare, \n          class _Distance>\ninline void \n__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\n           _RandomAccessIterator __result, _Tp __value, _Compare __comp,\n           _Distance*)\n{\n  *__result = *__first;\n  __adjust_heap(__first, _Distance(0), _Distance(__last - __first), \n                __value, __comp);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp, class _Compare>\ninline void \n__pop_heap_aux(_RandomAccessIterator __first,\n               _RandomAccessIterator __last, _Tp*, _Compare __comp)\n{\n  __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp,\n             __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator, class _Compare>\ninline void \npop_heap(_RandomAccessIterator __first,\n         _RandomAccessIterator __last, _Compare __comp)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp, class _Distance>\nvoid \n__make_heap(_RandomAccessIterator __first,\n            _RandomAccessIterator __last, _Tp*, _Distance*)\n{\n  if (__last - __first < 2) return;\n  _Distance __len = __last - __first;\n  _Distance __parent = (__len - 2)/2;\n    \n  while (true) {\n    __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)));\n    if (__parent == 0) return;\n    __parent--;\n  }\n}\n\ntemplate <class _RandomAccessIterator>\ninline void \nmake_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,\n                 _LessThanComparable);\n  __make_heap(__first, __last,\n              __VALUE_TYPE(__first), __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator, class _Compare,\n          class _Tp, class _Distance>\nvoid\n__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,\n            _Compare __comp, _Tp*, _Distance*)\n{\n  if (__last - __first < 2) return;\n  _Distance __len = __last - __first;\n  _Distance __parent = (__len - 2)/2;\n    \n  while (true) {\n    __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)),\n                  __comp);\n    if (__parent == 0) return;\n    __parent--;\n  }\n}\n\ntemplate <class _RandomAccessIterator, class _Compare>\ninline void \nmake_heap(_RandomAccessIterator __first, \n          _RandomAccessIterator __last, _Compare __comp)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __make_heap(__first, __last, __comp,\n              __VALUE_TYPE(__first), __DISTANCE_TYPE(__first));\n}\n\ntemplate <class _RandomAccessIterator>\nvoid sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,\n                 _LessThanComparable);\n  while (__last - __first > 1)\n    pop_heap(__first, __last--);\n}\n\ntemplate <class _RandomAccessIterator, class _Compare>\nvoid \nsort_heap(_RandomAccessIterator __first,\n          _RandomAccessIterator __last, _Compare __comp)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);\n  while (__last - __first > 1)\n    pop_heap(__first, __last--, __comp);\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1209\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HEAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_iterator.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#define __SGI_STL_INTERNAL_ITERATOR_H\n\n__STL_BEGIN_NAMESPACE\n\n\ntemplate <class _Container>\nclass back_insert_iterator {\nprotected:\n  _Container* container;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit back_insert_iterator(_Container& __x) : container(&__x) {}\n  back_insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->push_back(__value);\n    return *this;\n  }\n  back_insert_iterator<_Container>& operator*() { return *this; }\n  back_insert_iterator<_Container>& operator++() { return *this; }\n  back_insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Container>\ninline output_iterator_tag\niterator_category(const back_insert_iterator<_Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Container>\ninline back_insert_iterator<_Container> back_inserter(_Container& __x) {\n  return back_insert_iterator<_Container>(__x);\n}\n\ntemplate <class _Container>\nclass front_insert_iterator {\nprotected:\n  _Container* container;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit front_insert_iterator(_Container& __x) : container(&__x) {}\n  front_insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    container->push_front(__value);\n    return *this;\n  }\n  front_insert_iterator<_Container>& operator*() { return *this; }\n  front_insert_iterator<_Container>& operator++() { return *this; }\n  front_insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Container>\ninline output_iterator_tag\niterator_category(const front_insert_iterator<_Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Container>\ninline front_insert_iterator<_Container> front_inserter(_Container& __x) {\n  return front_insert_iterator<_Container>(__x);\n}\n\ntemplate <class _Container>\nclass insert_iterator {\nprotected:\n  _Container* container;\n  typename _Container::iterator iter;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x, typename _Container::iterator __i) \n    : container(&__x), iter(__i) {}\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    iter = container->insert(iter, __value);\n    ++iter;\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Container>\ninline output_iterator_tag\niterator_category(const insert_iterator<_Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Container, class _Iterator>\ninline \ninsert_iterator<_Container> inserter(_Container& __x, _Iterator __i)\n{\n  typedef typename _Container::iterator __iter;\n  return insert_iterator<_Container>(__x, __iter(__i));\n}\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class _BidirectionalIterator, class _Tp, class _Reference = _Tp&, \n          class _Distance = ptrdiff_t> \n#else\ntemplate <class _BidirectionalIterator, class _Tp, class _Reference, \n          class _Distance> \n#endif\nclass reverse_bidirectional_iterator {\n  typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, \n                                         _Reference, _Distance>  _Self;\nprotected:\n  _BidirectionalIterator current;\npublic:\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef _Tp                        value_type;\n  typedef _Distance                  difference_type;\n  typedef _Tp*                       pointer;\n  typedef _Reference                 reference;\n\n  reverse_bidirectional_iterator() {}\n  explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)\n    : current(__x) {}\n  _BidirectionalIterator base() const { return current; }\n  _Reference operator*() const {\n    _BidirectionalIterator __tmp = current;\n    return *--__tmp;\n  }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  _Self& operator++() {\n    --current;\n    return *this;\n  }\n  _Self operator++(int) {\n    _Self __tmp = *this;\n    --current;\n    return __tmp;\n  }\n  _Self& operator--() {\n    ++current;\n    return *this;\n  }\n  _Self operator--(int) {\n    _Self __tmp = *this;\n    ++current;\n    return __tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _BidirectionalIterator, class _Tp, class _Reference, \n          class _Distance>\ninline bidirectional_iterator_tag\niterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator,\n                                                       _Tp, _Reference, \n                                                       _Distance>&) \n{\n  return bidirectional_iterator_tag();\n}\n\ntemplate <class _BidirectionalIterator, class _Tp, class _Reference, \n          class _Distance>\ninline _Tp*\nvalue_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,\n                                               _Reference, _Distance>&)\n{\n  return (_Tp*) 0;\n}\n\ntemplate <class _BidirectionalIterator, class _Tp, class _Reference, \n          class _Distance>\ninline _Distance*\ndistance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, \n                                                   _Tp,\n                                                   _Reference, _Distance>&)\n{\n  return (_Distance*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _BiIter, class _Tp, class _Ref, class _Distance>\ninline bool operator==(\n    const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, \n    const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y)\n{\n  return __x.base() == __y.base();\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _BiIter, class _Tp, class _Ref, class _Distance>\ninline bool operator!=(\n    const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, \n    const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y)\n{\n  return !(__x == __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\n// This is the new version of reverse_iterator, as defined in the\n//  draft C++ standard.  It relies on the iterator_traits template,\n//  which in turn relies on partial specialization.  The class\n//  reverse_bidirectional_iterator is no longer part of the draft\n//  standard, but it is retained for backward compatibility.\n\ntemplate <class _Iterator>\nclass reverse_iterator \n{\nprotected:\n  _Iterator current;\npublic:\n  typedef typename iterator_traits<_Iterator>::iterator_category\n          iterator_category;\n  typedef typename iterator_traits<_Iterator>::value_type\n          value_type;\n  typedef typename iterator_traits<_Iterator>::difference_type\n          difference_type;\n  typedef typename iterator_traits<_Iterator>::pointer\n          pointer;\n  typedef typename iterator_traits<_Iterator>::reference\n          reference;\n\n  typedef _Iterator iterator_type;\n  typedef reverse_iterator<_Iterator> _Self;\n\npublic:\n  reverse_iterator() {}\n  explicit reverse_iterator(iterator_type __x) : current(__x) {}\n\n  reverse_iterator(const _Self& __x) : current(__x.current) {}\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Iter>\n  reverse_iterator(const reverse_iterator<_Iter>& __x)\n    : current(__x.base()) {}\n#endif /* __STL_MEMBER_TEMPLATES */\n    \n  iterator_type base() const { return current; }\n  reference operator*() const {\n    _Iterator __tmp = current;\n    return *--__tmp;\n  }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  _Self& operator++() {\n    --current;\n    return *this;\n  }\n  _Self operator++(int) {\n    _Self __tmp = *this;\n    --current;\n    return __tmp;\n  }\n  _Self& operator--() {\n    ++current;\n    return *this;\n  }\n  _Self operator--(int) {\n    _Self __tmp = *this;\n    ++current;\n    return __tmp;\n  }\n\n  _Self operator+(difference_type __n) const {\n    return _Self(current - __n);\n  }\n  _Self& operator+=(difference_type __n) {\n    current -= __n;\n    return *this;\n  }\n  _Self operator-(difference_type __n) const {\n    return _Self(current + __n);\n  }\n  _Self& operator-=(difference_type __n) {\n    current += __n;\n    return *this;\n  }\n  reference operator[](difference_type __n) const { return *(*this + __n); }  \n}; \n \ntemplate <class _Iterator>\ninline bool operator==(const reverse_iterator<_Iterator>& __x, \n                       const reverse_iterator<_Iterator>& __y) {\n  return __x.base() == __y.base();\n}\n\ntemplate <class _Iterator>\ninline bool operator<(const reverse_iterator<_Iterator>& __x, \n                      const reverse_iterator<_Iterator>& __y) {\n  return __y.base() < __x.base();\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Iterator>\ninline bool operator!=(const reverse_iterator<_Iterator>& __x, \n                       const reverse_iterator<_Iterator>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Iterator>\ninline bool operator>(const reverse_iterator<_Iterator>& __x, \n                      const reverse_iterator<_Iterator>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Iterator>\ninline bool operator<=(const reverse_iterator<_Iterator>& __x, \n                       const reverse_iterator<_Iterator>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Iterator>\ninline bool operator>=(const reverse_iterator<_Iterator>& __x, \n                      const reverse_iterator<_Iterator>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Iterator>\ninline typename reverse_iterator<_Iterator>::difference_type\noperator-(const reverse_iterator<_Iterator>& __x, \n          const reverse_iterator<_Iterator>& __y) {\n  return __y.base() - __x.base();\n}\n\ntemplate <class _Iterator>\ninline reverse_iterator<_Iterator> \noperator+(typename reverse_iterator<_Iterator>::difference_type __n,\n          const reverse_iterator<_Iterator>& __x) {\n  return reverse_iterator<_Iterator>(__x.base() - __n);\n}\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// This is the old version of reverse_iterator, as found in the original\n//  HP STL.  It does not use partial specialization.\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class _RandomAccessIterator, class _Tp, class _Reference = _Tp&,\n          class _Distance = ptrdiff_t> \n#else\ntemplate <class _RandomAccessIterator, class _Tp, class _Reference,\n          class _Distance> \n#endif\nclass reverse_iterator {\n  typedef reverse_iterator<_RandomAccessIterator, _Tp, _Reference, _Distance>\n        _Self;\nprotected:\n  _RandomAccessIterator current;\npublic:\n  typedef random_access_iterator_tag iterator_category;\n  typedef _Tp                        value_type;\n  typedef _Distance                  difference_type;\n  typedef _Tp*                       pointer;\n  typedef _Reference                 reference;\n\n  reverse_iterator() {}\n  explicit reverse_iterator(_RandomAccessIterator __x) : current(__x) {}\n  _RandomAccessIterator base() const { return current; }\n  _Reference operator*() const { return *(current - 1); }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  _Self& operator++() {\n    --current;\n    return *this;\n  }\n  _Self operator++(int) {\n    _Self __tmp = *this;\n    --current;\n    return __tmp;\n  }\n  _Self& operator--() {\n    ++current;\n    return *this;\n  }\n  _Self operator--(int) {\n    _Self __tmp = *this;\n    ++current;\n    return __tmp;\n  }\n  _Self operator+(_Distance __n) const {\n    return _Self(current - __n);\n  }\n  _Self& operator+=(_Distance __n) {\n    current -= __n;\n    return *this;\n  }\n  _Self operator-(_Distance __n) const {\n    return _Self(current + __n);\n  }\n  _Self& operator-=(_Distance __n) {\n    current += __n;\n    return *this;\n  }\n  _Reference operator[](_Distance __n) const { return *(*this + __n); }\n};\n\ntemplate <class _RandomAccessIterator, class _Tp, \n          class _Reference, class _Distance>\ninline random_access_iterator_tag\niterator_category(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                         _Reference, _Distance>&)\n{\n  return random_access_iterator_tag();\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline _Tp* value_type(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                              _Reference, _Distance>&)\n{\n  return (_Tp*) 0;\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline _Distance* \ndistance_type(const reverse_iterator<_RandomAccessIterator, \n                                     _Tp, _Reference, _Distance>&)\n{\n  return (_Distance*) 0;\n}\n\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator==(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __x, \n           const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __y)\n{\n  return __x.base() == __y.base();\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator<(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __x, \n          const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __y)\n{\n  return __y.base() < __x.base();\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator!=(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __x, \n           const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator>(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __x, \n          const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator<=(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __x, \n           const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline bool \noperator>=(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __x, \n           const reverse_iterator<_RandomAccessIterator, _Tp,\n                                  _Reference, _Distance>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _RandomAccessIterator, class _Tp,\n          class _Reference, class _Distance>\ninline _Distance \noperator-(const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __x, \n          const reverse_iterator<_RandomAccessIterator, _Tp,\n                                 _Reference, _Distance>& __y)\n{\n  return __y.base() - __x.base();\n}\n\ntemplate <class _RandAccIter, class _Tp, class _Ref, class _Dist>\ninline reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist> \noperator+(_Dist __n,\n          const reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>& __x)\n{\n  return reverse_iterator<_RandAccIter, _Tp, _Ref, _Dist>(__x.base() - __n);\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// istream_iterator and ostream_iterator look very different if we're\n// using new, templatized iostreams than if we're using the old cfront\n// version.\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n\ntemplate <class _Tp, \n          class _CharT = char, class _Traits = char_traits<_CharT>,\n          class _Dist = ptrdiff_t> \nclass istream_iterator {\npublic:\n  typedef _CharT                         char_type;\n  typedef _Traits                        traits_type;\n  typedef basic_istream<_CharT, _Traits> istream_type;\n\n  typedef input_iterator_tag             iterator_category;\n  typedef _Tp                            value_type;\n  typedef _Dist                          difference_type;\n  typedef const _Tp*                     pointer;\n  typedef const _Tp&                     reference;\n\n  istream_iterator() : _M_stream(0), _M_ok(false) {}\n  istream_iterator(istream_type& __s) : _M_stream(&__s) { _M_read(); }\n\n  reference operator*() const { return _M_value; }\n  pointer operator->() const { return &(operator*()); }\n\n  istream_iterator& operator++() { \n    _M_read(); \n    return *this;\n  }\n  istream_iterator operator++(int)  {\n    istream_iterator __tmp = *this;\n    _M_read();\n    return __tmp;\n  }\n\n  bool _M_equal(const istream_iterator& __x) const\n    { return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }\n\nprivate:\n  istream_type* _M_stream;\n  _Tp _M_value;\n  bool _M_ok;\n\n  void _M_read() {\n    _M_ok = (_M_stream && *_M_stream) ? true : false;\n    if (_M_ok) {\n      *_M_stream >> _M_value;\n      _M_ok = *_M_stream ? true : false;\n    }\n  }\n};\n\ntemplate <class _Tp, class _CharT, class _Traits, class _Dist>\ninline bool \noperator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,\n           const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) {\n  return __x._M_equal(__y);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _CharT, class _Traits, class _Dist>\ninline bool \noperator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,\n           const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) {\n  return !__x._M_equal(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Tp,\n          class _CharT = char, class _Traits = char_traits<_CharT> >\nclass ostream_iterator {\npublic:\n  typedef _CharT                         char_type;\n  typedef _Traits                        traits_type;\n  typedef basic_ostream<_CharT, _Traits> ostream_type;\n\n  typedef output_iterator_tag            iterator_category;\n  typedef void                           value_type;\n  typedef void                           difference_type;\n  typedef void                           pointer;\n  typedef void                           reference;\n\n  ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}\n  ostream_iterator(ostream_type& __s, const _CharT* __c) \n    : _M_stream(&__s), _M_string(__c)  {}\n  ostream_iterator<_Tp>& operator=(const _Tp& __value) { \n    *_M_stream << __value;\n    if (_M_string) *_M_stream << _M_string;\n    return *this;\n  }\n  ostream_iterator<_Tp>& operator*() { return *this; }\n  ostream_iterator<_Tp>& operator++() { return *this; } \n  ostream_iterator<_Tp>& operator++(int) { return *this; } \nprivate:\n  ostream_type* _M_stream;\n  const _CharT* _M_string;\n};\n\n// The default template argument is declared in iosfwd\n\n// We do not read any characters until operator* is called.  The first\n// time operator* is called, it calls getc.  Subsequent calls to getc \n// return a cached character, and calls to operator++ use snextc.  Before\n// operator* or operator++ has been called, _M_is_initialized is false.\ntemplate<class _CharT, class _Traits>\nclass istreambuf_iterator\n  : public iterator<input_iterator_tag, _CharT,\n                    typename _Traits::off_type, _CharT*, _CharT&>\n{\npublic:\n  typedef _CharT                           char_type;\n  typedef _Traits                          traits_type;\n  typedef typename _Traits::int_type       int_type;\n  typedef basic_streambuf<_CharT, _Traits> streambuf_type;\n  typedef basic_istream<_CharT, _Traits>   istream_type;\n\npublic:\n  istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); }\n  istreambuf_iterator(istream_type& __is) { this->_M_init(__is.rdbuf()); }\n\n  char_type operator*() const \n    { return _M_is_initialized ? _M_c : _M_dereference_aux(); }\n\n  istreambuf_iterator& operator++() { this->_M_nextc(); return *this; }\n  istreambuf_iterator  operator++(int) {\n    if (!_M_is_initialized)\n      _M_postincr_aux();\n    istreambuf_iterator __tmp = *this;\n    this->_M_nextc();\n    return __tmp;\n  }\n\n  bool equal(const istreambuf_iterator& __i) const {\n    return this->_M_is_initialized && __i._M_is_initialized\n      ? this->_M_eof == __i._M_eof\n      : this->_M_equal_aux(__i);\n  }\n\nprivate:\n  void _M_init(streambuf_type* __p) {\n    _M_buf = __p;\n    _M_eof = !__p;\n    _M_is_initialized = _M_eof;\n  }\n\n  char_type _M_dereference_aux() const;\n  bool _M_equal_aux(const istreambuf_iterator&) const;\n  void _M_postincr_aux();\n\n  void _M_nextc() {\n    int_type __c = _M_buf->snextc();\n    _M_c = traits_type::to_char_type(__c);    \n    _M_eof = traits_type::eq_int_type(__c, traits_type::eof());\n    _M_is_initialized = true;\n  }\n\n  void _M_getc() const {\n    int_type __c = _M_buf->sgetc();\n    _M_c = traits_type::to_char_type(__c);\n    _M_eof = traits_type::eq_int_type(__c, traits_type::eof());\n    _M_is_initialized = true;\n  }\n\nprivate:\n  streambuf_type* _M_buf;\n  mutable _CharT _M_c;\n  mutable bool _M_eof : 1;\n  mutable bool _M_is_initialized : 1;\n};\n\ntemplate<class _CharT, class _Traits>\n_CharT istreambuf_iterator<_CharT, _Traits>::_M_dereference_aux() const\n{\n  this->_M_getc();\n  return _M_c;\n}\n\ntemplate<class _CharT, class _Traits>\nbool istreambuf_iterator<_CharT, _Traits>\n  ::_M_equal_aux(const istreambuf_iterator& __i) const\n{\n  if (!this->_M_is_initialized)\n    this->_M_getc();\n  if (!__i._M_is_initialized)\n    __i._M_getc();\n\n  return this->_M_eof == __i._M_eof;\n}\n\ntemplate<class _CharT, class _Traits>\nvoid istreambuf_iterator<_CharT, _Traits>::_M_postincr_aux()\n{\n  this->_M_getc();\n}\n\ntemplate<class _CharT, class _Traits>\ninline bool operator==(const istreambuf_iterator<_CharT, _Traits>& __x,\n                       const istreambuf_iterator<_CharT, _Traits>& __y) {\n  return __x.equal(__y);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate<class _CharT, class _Traits>\ninline bool operator!=(const istreambuf_iterator<_CharT, _Traits>& __x,\n                       const istreambuf_iterator<_CharT, _Traits>& __y) {\n  return !__x.equal(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// The default template argument is declared in iosfwd\ntemplate<class _CharT, class _Traits>\nclass ostreambuf_iterator\n  : public iterator<output_iterator_tag, void, void, void, void>\n{\npublic:\n  typedef _CharT                           char_type;\n  typedef _Traits                          traits_type;\n  typedef typename _Traits::int_type       int_type;\n  typedef basic_streambuf<_CharT, _Traits> streambuf_type;\n  typedef basic_ostream<_CharT, _Traits>   ostream_type;\n\npublic:\n  ostreambuf_iterator(streambuf_type* __buf) : _M_buf(__buf), _M_ok(__buf) {}\n  ostreambuf_iterator(ostream_type& __o)\n    : _M_buf(__o.rdbuf()), _M_ok(__o.rdbuf() != 0) {}\n\n  ostreambuf_iterator& operator=(char_type __c) {\n    _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),\n                                               traits_type::eof());\n    return *this;\n  }    \n  \n  ostreambuf_iterator& operator*()     { return *this; }\n  ostreambuf_iterator& operator++()    { return *this; }\n  ostreambuf_iterator& operator++(int) { return *this; }\n\n  bool failed() const { return !_M_ok; }\n\nprivate:\n  streambuf_type* _M_buf;\n  bool _M_ok;\n};\n\n#else /* __STL_USE_NEW_IOSTREAMS */\n\ntemplate <class _Tp, class _Dist = ptrdiff_t> class istream_iterator;\n\ntemplate <class _Tp, class _Dist>\ninline bool operator==(const istream_iterator<_Tp, _Dist>&,\n                       const istream_iterator<_Tp, _Dist>&);\n\ntemplate <class _Tp, class _Dist>\nclass istream_iterator {\n#ifdef __STL_TEMPLATE_FRIENDS\n  template <class _T1, class _D1>\n  friend bool operator==(const istream_iterator<_T1, _D1>&,\n                         const istream_iterator<_T1, _D1>&);\n#else /* __STL_TEMPLATE_FRIENDS */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const istream_iterator&,\n                                   const istream_iterator&);\n#endif /* __STL_TEMPLATE_FRIENDS */\n\nprotected:\n  istream* _M_stream;\n  _Tp _M_value;\n  bool _M_end_marker;\n  void _M_read() {\n    _M_end_marker = (*_M_stream) ? true : false;\n    if (_M_end_marker) *_M_stream >> _M_value;\n    _M_end_marker = (*_M_stream) ? true : false;\n  }\npublic:\n  typedef input_iterator_tag  iterator_category;\n  typedef _Tp                 value_type;\n  typedef _Dist               difference_type;\n  typedef const _Tp*          pointer;\n  typedef const _Tp&          reference;\n\n  istream_iterator() : _M_stream(&cin), _M_end_marker(false) {}\n  istream_iterator(istream& __s) : _M_stream(&__s) { _M_read(); }\n  reference operator*() const { return _M_value; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  istream_iterator<_Tp, _Dist>& operator++() { \n    _M_read(); \n    return *this;\n  }\n  istream_iterator<_Tp, _Dist> operator++(int)  {\n    istream_iterator<_Tp, _Dist> __tmp = *this;\n    _M_read();\n    return __tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp, class _Dist>\ninline input_iterator_tag \niterator_category(const istream_iterator<_Tp, _Dist>&)\n{\n  return input_iterator_tag();\n}\n\ntemplate <class _Tp, class _Dist>\ninline _Tp* \nvalue_type(const istream_iterator<_Tp, _Dist>&) { return (_Tp*) 0; }\n\ntemplate <class _Tp, class _Dist>\ninline _Dist* \ndistance_type(const istream_iterator<_Tp, _Dist>&) { return (_Dist*)0; }\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Tp, class _Distance>\ninline bool operator==(const istream_iterator<_Tp, _Distance>& __x,\n                       const istream_iterator<_Tp, _Distance>& __y) {\n  return (__x._M_stream == __y._M_stream &&\n          __x._M_end_marker == __y._M_end_marker) ||\n         __x._M_end_marker == false && __y._M_end_marker == false;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Distance>\ninline bool operator!=(const istream_iterator<_Tp, _Distance>& __x,\n                       const istream_iterator<_Tp, _Distance>& __y) {\n  return !(__x == __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Tp>\nclass ostream_iterator {\nprotected:\n  ostream* _M_stream;\n  const char* _M_string;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  ostream_iterator(ostream& __s) : _M_stream(&__s), _M_string(0) {}\n  ostream_iterator(ostream& __s, const char* __c) \n    : _M_stream(&__s), _M_string(__c)  {}\n  ostream_iterator<_Tp>& operator=(const _Tp& __value) { \n    *_M_stream << __value;\n    if (_M_string) *_M_stream << _M_string;\n    return *this;\n  }\n  ostream_iterator<_Tp>& operator*() { return *this; }\n  ostream_iterator<_Tp>& operator++() { return *this; } \n  ostream_iterator<_Tp>& operator++(int) { return *this; } \n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp>\ninline output_iterator_tag \niterator_category(const ostream_iterator<_Tp>&) {\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ITERATOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_iterator_base.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_H\n#define __SGI_STL_INTERNAL_ITERATOR_BASE_H\n\n// This file contains all of the general iterator-related utilities.\n// The internal file stl_iterator.h contains predefined iterators, \n// such as front_insert_iterator and istream_iterator.\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\nstruct input_iterator_tag {};\nstruct output_iterator_tag {};\nstruct forward_iterator_tag : public input_iterator_tag {};\nstruct bidirectional_iterator_tag : public forward_iterator_tag {};\nstruct random_access_iterator_tag : public bidirectional_iterator_tag {};\n\n// The base classes input_iterator, output_iterator, forward_iterator,\n// bidirectional_iterator, and random_access_iterator are not part of\n// the C++ standard.  (They have been replaced by struct iterator.)\n// They are included for backward compatibility with the HP STL.\n\ntemplate <class _Tp, class _Distance> struct input_iterator {\n  typedef input_iterator_tag iterator_category;\n  typedef _Tp                value_type;\n  typedef _Distance          difference_type;\n  typedef _Tp*               pointer;\n  typedef _Tp&               reference;\n};\n\nstruct output_iterator {\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n};\n\ntemplate <class _Tp, class _Distance> struct forward_iterator {\n  typedef forward_iterator_tag iterator_category;\n  typedef _Tp                  value_type;\n  typedef _Distance            difference_type;\n  typedef _Tp*                 pointer;\n  typedef _Tp&                 reference;\n};\n\n\ntemplate <class _Tp, class _Distance> struct bidirectional_iterator {\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef _Tp                        value_type;\n  typedef _Distance                  difference_type;\n  typedef _Tp*                       pointer;\n  typedef _Tp&                       reference;\n};\n\ntemplate <class _Tp, class _Distance> struct random_access_iterator {\n  typedef random_access_iterator_tag iterator_category;\n  typedef _Tp                        value_type;\n  typedef _Distance                  difference_type;\n  typedef _Tp*                       pointer;\n  typedef _Tp&                       reference;\n};\n\n#ifdef __STL_USE_NAMESPACES\ntemplate <class _Category, class _Tp, class _Distance = ptrdiff_t,\n          class _Pointer = _Tp*, class _Reference = _Tp&>\nstruct iterator {\n  typedef _Category  iterator_category;\n  typedef _Tp        value_type;\n  typedef _Distance  difference_type;\n  typedef _Pointer   pointer;\n  typedef _Reference reference;\n};\n#endif /* __STL_USE_NAMESPACES */\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Iterator>\nstruct iterator_traits {\n  typedef typename _Iterator::iterator_category iterator_category;\n  typedef typename _Iterator::value_type        value_type;\n  typedef typename _Iterator::difference_type   difference_type;\n  typedef typename _Iterator::pointer           pointer;\n  typedef typename _Iterator::reference         reference;\n};\n\ntemplate <class _Tp>\nstruct iterator_traits<_Tp*> {\n  typedef random_access_iterator_tag iterator_category;\n  typedef _Tp                         value_type;\n  typedef ptrdiff_t                   difference_type;\n  typedef _Tp*                        pointer;\n  typedef _Tp&                        reference;\n};\n\ntemplate <class _Tp>\nstruct iterator_traits<const _Tp*> {\n  typedef random_access_iterator_tag iterator_category;\n  typedef _Tp                         value_type;\n  typedef ptrdiff_t                   difference_type;\n  typedef const _Tp*                  pointer;\n  typedef const _Tp&                  reference;\n};\n\n// The overloaded functions iterator_category, distance_type, and\n// value_type are not part of the C++ standard.  (They have been\n// replaced by struct iterator_traits.)  They are included for\n// backward compatibility with the HP STL.\n\n// We introduce internal names for these functions.\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::iterator_category\n__iterator_category(const _Iter&)\n{\n  typedef typename iterator_traits<_Iter>::iterator_category _Category;\n  return _Category();\n}\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::difference_type*\n__distance_type(const _Iter&)\n{\n  return static_cast<typename iterator_traits<_Iter>::difference_type*>(0);\n}\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::value_type*\n__value_type(const _Iter&)\n{\n  return static_cast<typename iterator_traits<_Iter>::value_type*>(0);\n}\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::iterator_category\niterator_category(const _Iter& __i) { return __iterator_category(__i); }\n\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::difference_type*\ndistance_type(const _Iter& __i) { return __distance_type(__i); }\n\ntemplate <class _Iter>\ninline typename iterator_traits<_Iter>::value_type*\nvalue_type(const _Iter& __i) { return __value_type(__i); }\n\n#define __ITERATOR_CATEGORY(__i) __iterator_category(__i)\n#define __DISTANCE_TYPE(__i)     __distance_type(__i)\n#define __VALUE_TYPE(__i)        __value_type(__i)\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _Tp, class _Distance> \ninline input_iterator_tag \niterator_category(const input_iterator<_Tp, _Distance>&)\n  { return input_iterator_tag(); }\n\ninline output_iterator_tag iterator_category(const output_iterator&)\n  { return output_iterator_tag(); }\n\ntemplate <class _Tp, class _Distance> \ninline forward_iterator_tag\niterator_category(const forward_iterator<_Tp, _Distance>&)\n  { return forward_iterator_tag(); }\n\ntemplate <class _Tp, class _Distance> \ninline bidirectional_iterator_tag\niterator_category(const bidirectional_iterator<_Tp, _Distance>&)\n  { return bidirectional_iterator_tag(); }\n\ntemplate <class _Tp, class _Distance> \ninline random_access_iterator_tag\niterator_category(const random_access_iterator<_Tp, _Distance>&)\n  { return random_access_iterator_tag(); }\n\ntemplate <class _Tp>\ninline random_access_iterator_tag iterator_category(const _Tp*)\n  { return random_access_iterator_tag(); }\n\ntemplate <class _Tp, class _Distance> \ninline _Tp* value_type(const input_iterator<_Tp, _Distance>&)\n  { return (_Tp*)(0); }\n\ntemplate <class _Tp, class _Distance> \ninline _Tp* value_type(const forward_iterator<_Tp, _Distance>&)\n  { return (_Tp*)(0); }\n\ntemplate <class _Tp, class _Distance> \ninline _Tp* value_type(const bidirectional_iterator<_Tp, _Distance>&)\n  { return (_Tp*)(0); }\n\ntemplate <class _Tp, class _Distance> \ninline _Tp* value_type(const random_access_iterator<_Tp, _Distance>&)\n  { return (_Tp*)(0); }\n\ntemplate <class _Tp>\ninline _Tp* value_type(const _Tp*) { return (_Tp*)(0); }\n\ntemplate <class _Tp, class _Distance> \ninline _Distance* distance_type(const input_iterator<_Tp, _Distance>&)\n{\n  return (_Distance*)(0);\n}\n\ntemplate <class _Tp, class _Distance> \ninline _Distance* distance_type(const forward_iterator<_Tp, _Distance>&)\n{\n  return (_Distance*)(0);\n}\n\ntemplate <class _Tp, class _Distance> \ninline _Distance* \ndistance_type(const bidirectional_iterator<_Tp, _Distance>&)\n{\n  return (_Distance*)(0);\n}\n\ntemplate <class _Tp, class _Distance> \ninline _Distance* \ndistance_type(const random_access_iterator<_Tp, _Distance>&)\n{\n  return (_Distance*)(0);\n}\n\ntemplate <class _Tp>\ninline ptrdiff_t* distance_type(const _Tp*) { return (ptrdiff_t*)(0); }\n\n// Without partial specialization we can't use iterator_traits, so\n// we must keep the old iterator query functions around.  \n\n#define __ITERATOR_CATEGORY(__i) iterator_category(__i)\n#define __DISTANCE_TYPE(__i)     distance_type(__i)\n#define __VALUE_TYPE(__i)        value_type(__i)\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _InputIterator, class _Distance>\ninline void __distance(_InputIterator __first, _InputIterator __last,\n                       _Distance& __n, input_iterator_tag)\n{\n  while (__first != __last) { ++__first; ++__n; }\n}\n\ntemplate <class _RandomAccessIterator, class _Distance>\ninline void __distance(_RandomAccessIterator __first, \n                       _RandomAccessIterator __last, \n                       _Distance& __n, random_access_iterator_tag)\n{\n  __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);\n  __n += __last - __first;\n}\n\ntemplate <class _InputIterator, class _Distance>\ninline void distance(_InputIterator __first, \n                     _InputIterator __last, _Distance& __n)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __distance(__first, __last, __n, iterator_category(__first));\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _InputIterator>\ninline typename iterator_traits<_InputIterator>::difference_type\n__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)\n{\n  typename iterator_traits<_InputIterator>::difference_type __n = 0;\n  while (__first != __last) {\n    ++__first; ++__n;\n  }\n  return __n;\n}\n\ntemplate <class _RandomAccessIterator>\ninline typename iterator_traits<_RandomAccessIterator>::difference_type\n__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,\n           random_access_iterator_tag) {\n  __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);\n  return __last - __first;\n}\n\ntemplate <class _InputIterator>\ninline typename iterator_traits<_InputIterator>::difference_type\ndistance(_InputIterator __first, _InputIterator __last) {\n  typedef typename iterator_traits<_InputIterator>::iterator_category \n    _Category;\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  return __distance(__first, __last, _Category());\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class _InputIter, class _Distance>\ninline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) {\n  while (__n--) ++__i;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1183\n#endif\n\ntemplate <class _BidirectionalIterator, class _Distance>\ninline void __advance(_BidirectionalIterator& __i, _Distance __n, \n                      bidirectional_iterator_tag) {\n  __STL_REQUIRES(_BidirectionalIterator, _BidirectionalIterator);\n  if (__n >= 0)\n    while (__n--) ++__i;\n  else\n    while (__n++) --__i;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1183\n#endif\n\ntemplate <class _RandomAccessIterator, class _Distance>\ninline void __advance(_RandomAccessIterator& __i, _Distance __n, \n                      random_access_iterator_tag) {\n  __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);\n  __i += __n;\n}\n\ntemplate <class _InputIterator, class _Distance>\ninline void advance(_InputIterator& __i, _Distance __n) {\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __advance(__i, __n, iterator_category(__i));\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ITERATOR_BASE_H */\n\n\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_list.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_LIST_H\n#define __SGI_STL_INTERNAL_LIST_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\nstruct _List_node_base {\n  _List_node_base* _M_next;\n  _List_node_base* _M_prev;\n};\n\ntemplate <class _Tp>\nstruct _List_node : public _List_node_base {\n  _Tp _M_data;\n};\n\nstruct _List_iterator_base {\n  typedef size_t                     size_type;\n  typedef ptrdiff_t                  difference_type;\n  typedef bidirectional_iterator_tag iterator_category;\n\n  _List_node_base* _M_node;\n\n  _List_iterator_base(_List_node_base* __x) : _M_node(__x) {}\n  _List_iterator_base() {}\n\n  void _M_incr() { _M_node = _M_node->_M_next; }\n  void _M_decr() { _M_node = _M_node->_M_prev; }\n\n  bool operator==(const _List_iterator_base& __x) const {\n    return _M_node == __x._M_node;\n  }\n  bool operator!=(const _List_iterator_base& __x) const {\n    return _M_node != __x._M_node;\n  }\n};  \n\ntemplate<class _Tp, class _Ref, class _Ptr>\nstruct _List_iterator : public _List_iterator_base {\n  typedef _List_iterator<_Tp,_Tp&,_Tp*>             iterator;\n  typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;\n  typedef _List_iterator<_Tp,_Ref,_Ptr>             _Self;\n\n  typedef _Tp value_type;\n  typedef _Ptr pointer;\n  typedef _Ref reference;\n  typedef _List_node<_Tp> _Node;\n\n  _List_iterator(_Node* __x) : _List_iterator_base(__x) {}\n  _List_iterator() {}\n  _List_iterator(const iterator& __x) : _List_iterator_base(__x._M_node) {}\n\n  reference operator*() const { return ((_Node*) _M_node)->_M_data; }\n\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  _Self& operator++() { \n    this->_M_incr();\n    return *this;\n  }\n  _Self operator++(int) { \n    _Self __tmp = *this;\n    this->_M_incr();\n    return __tmp;\n  }\n  _Self& operator--() { \n    this->_M_decr();\n    return *this;\n  }\n  _Self operator--(int) { \n    _Self __tmp = *this;\n    this->_M_decr();\n    return __tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ninline bidirectional_iterator_tag\niterator_category(const _List_iterator_base&)\n{\n  return bidirectional_iterator_tag();\n}\n\ntemplate <class _Tp, class _Ref, class _Ptr>\ninline _Tp*\nvalue_type(const _List_iterator<_Tp, _Ref, _Ptr>&)\n{\n  return 0;\n}\n\ninline ptrdiff_t*\ndistance_type(const _List_iterator_base&)\n{\n  return 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n\n// Base class that encapsulates details of allocators.  Three cases:\n// an ordinary standard-conforming allocator, a standard-conforming\n// allocator with no non-static data, and an SGI-style allocator.\n// This complexity is necessary only because we're worrying about backward\n// compatibility and because we want to avoid wasting storage on an \n// allocator instance if it isn't necessary.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base for general standard-conforming allocators.\ntemplate <class _Tp, class _Allocator, bool _IsStatic>\nclass _List_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _Node_allocator; }\n\n  _List_alloc_base(const allocator_type& __a) : _Node_allocator(__a) {}\n\nprotected:\n  _List_node<_Tp>* _M_get_node()\n   { return _Node_allocator.allocate(1); }\n  void _M_put_node(_List_node<_Tp>* __p)\n    { _Node_allocator.deallocate(__p, 1); }\n\nprotected:\n  typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type\n           _Node_allocator;\n  _List_node<_Tp>* _M_node;\n};\n\n// Specialization for instanceless allocators.\n\ntemplate <class _Tp, class _Allocator>\nclass _List_alloc_base<_Tp, _Allocator, true> {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _List_alloc_base(const allocator_type&) {}\n\nprotected:\n  typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type\n          _Alloc_type;\n  _List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }\n  void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); }\n\nprotected:\n  _List_node<_Tp>* _M_node;\n};\n\ntemplate <class _Tp, class _Alloc>\nclass _List_base \n  : public _List_alloc_base<_Tp, _Alloc,\n                            _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\npublic:\n  typedef _List_alloc_base<_Tp, _Alloc,\n                           _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base; \n  typedef typename _Base::allocator_type allocator_type;\n\n  _List_base(const allocator_type& __a) : _Base(__a) {\n    _M_node = _M_get_node();\n    _M_node->_M_next = _M_node;\n    _M_node->_M_prev = _M_node;\n  }\n  ~_List_base() {\n    clear();\n    _M_put_node(_M_node);\n  }\n\n  void clear();\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc>\nclass _List_base \n{\npublic:\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _List_base(const allocator_type&) {\n    _M_node = _M_get_node();\n    _M_node->_M_next = _M_node;\n    _M_node->_M_prev = _M_node;\n  }\n  ~_List_base() {\n    clear();\n    _M_put_node(_M_node);\n  }\n\n  void clear();\n\nprotected:\n  typedef simple_alloc<_List_node<_Tp>, _Alloc> _Alloc_type;\n  _List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }\n  void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); } \n\nprotected:\n  _List_node<_Tp>* _M_node;\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc>\nvoid \n_List_base<_Tp,_Alloc>::clear() \n{\n  _List_node<_Tp>* __cur = (_List_node<_Tp>*) _M_node->_M_next;\n  while (__cur != _M_node) {\n    _List_node<_Tp>* __tmp = __cur;\n    __cur = (_List_node<_Tp>*) __cur->_M_next;\n    _Destroy(&__tmp->_M_data);\n    _M_put_node(__tmp);\n  }\n  _M_node->_M_next = _M_node;\n  _M_node->_M_prev = _M_node;\n}\n\ntemplate <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass list : protected _List_base<_Tp, _Alloc> {\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n\n  typedef _List_base<_Tp, _Alloc> _Base;\nprotected:\n  typedef void* _Void_pointer;\n\npublic:      \n  typedef _Tp value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef _List_node<_Tp> _Node;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\npublic:\n  typedef _List_iterator<_Tp,_Tp&,_Tp*>             iterator;\n  typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator>       reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_bidirectional_iterator<const_iterator,value_type,\n                                         const_reference,difference_type>\n          const_reverse_iterator;\n  typedef reverse_bidirectional_iterator<iterator,value_type,reference,\n                                         difference_type>\n          reverse_iterator; \n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:\n#ifdef __STL_HAS_NAMESPACES\n  using _Base::_M_node;\n  using _Base::_M_put_node;\n  using _Base::_M_get_node;\n#endif /* __STL_HAS_NAMESPACES */\n\nprotected:\n  _Node* _M_create_node(const _Tp& __x)\n  {\n    _Node* __p = _M_get_node();\n    __STL_TRY {\n      _Construct(&__p->_M_data, __x);\n    }\n    __STL_UNWIND(_M_put_node(__p));\n    return __p;\n  }\n\n  _Node* _M_create_node()\n  {\n    _Node* __p = _M_get_node();\n    __STL_TRY {\n      _Construct(&__p->_M_data);\n    }\n    __STL_UNWIND(_M_put_node(__p));\n    return __p;\n  }\n\npublic:\n  explicit list(const allocator_type& __a = allocator_type()) : _Base(__a) {}\n\n  iterator begin()             { return (_Node*)(_M_node->_M_next); }\n  const_iterator begin() const { return (_Node*)(_M_node->_M_next); }\n\n  iterator end()             { return _M_node; }\n  const_iterator end() const { return _M_node; }\n\n  reverse_iterator rbegin() \n    { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const \n    { return const_reverse_iterator(end()); }\n\n  reverse_iterator rend()\n    { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const\n    { return const_reverse_iterator(begin()); }\n\n  bool empty() const { return _M_node->_M_next == _M_node; }\n  size_type size() const {\n    size_type __result = 0;\n    distance(begin(), end(), __result);\n    return __result;\n  }\n  size_type max_size() const { return size_type(-1); }\n\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(--end()); }\n  const_reference back() const { return *(--end()); }\n\n  void swap(list<_Tp, _Alloc>& __x) { __STD::swap(_M_node, __x._M_node); }\n\n  iterator insert(iterator __position, const _Tp& __x) {\n    _Node* __tmp = _M_create_node(__x);\n    __tmp->_M_next = __position._M_node;\n    __tmp->_M_prev = __position._M_node->_M_prev;\n    __position._M_node->_M_prev->_M_next = __tmp;\n    __position._M_node->_M_prev = __tmp;\n    return __tmp;\n  }\n  iterator insert(iterator __position) { return insert(__position, _Tp()); }\n#ifdef __STL_MEMBER_TEMPLATES\n  // Check whether it's an integral type.  If so, it's not an iterator.\n\n  template<class _Integer>\n  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,\n                          __true_type) {\n    _M_fill_insert(__pos, (size_type) __n, (_Tp) __x);\n  }\n\n  template <class _InputIterator>\n  void _M_insert_dispatch(iterator __pos,\n                          _InputIterator __first, _InputIterator __last,\n                          __false_type);\n\n  template <class _InputIterator>\n  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_insert_dispatch(__pos, __first, __last, _Integral());\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator __position, const _Tp* __first, const _Tp* __last);\n  void insert(iterator __position,\n              const_iterator __first, const_iterator __last);\n#endif /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator __pos, size_type __n, const _Tp& __x)\n    { _M_fill_insert(__pos, __n, __x); }\n  void _M_fill_insert(iterator __pos, size_type __n, const _Tp& __x); \n\n  void push_front(const _Tp& __x) { insert(begin(), __x); }\n  void push_front() {insert(begin());}\n  void push_back(const _Tp& __x) { insert(end(), __x); }\n  void push_back() {insert(end());}\n\n  iterator erase(iterator __position) {\n    _List_node_base* __next_node = __position._M_node->_M_next;\n    _List_node_base* __prev_node = __position._M_node->_M_prev;\n    _Node* __n = (_Node*) __position._M_node;\n    __prev_node->_M_next = __next_node;\n    __next_node->_M_prev = __prev_node;\n    _Destroy(&__n->_M_data);\n    _M_put_node(__n);\n    return iterator((_Node*) __next_node);\n  }\n  iterator erase(iterator __first, iterator __last);\n  void clear() { _Base::clear(); }\n\n  void resize(size_type __new_size, const _Tp& __x);\n  void resize(size_type __new_size) { this->resize(__new_size, _Tp()); }\n\n  void pop_front() { erase(begin()); }\n  void pop_back() { \n    iterator __tmp = end();\n    erase(--__tmp);\n  }\n  list(size_type __n, const _Tp& __value,\n       const allocator_type& __a = allocator_type())\n    : _Base(__a)\n    { insert(begin(), __n, __value); }\n  explicit list(size_type __n)\n    : _Base(allocator_type())\n    { insert(begin(), __n, _Tp()); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // We don't need any dispatching tricks here, because insert does all of\n  // that anyway.  \n  template <class _InputIterator>\n  list(_InputIterator __first, _InputIterator __last,\n       const allocator_type& __a = allocator_type())\n    : _Base(__a)\n    { insert(begin(), __first, __last); }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  list(const _Tp* __first, const _Tp* __last,\n       const allocator_type& __a = allocator_type())\n    : _Base(__a)\n    { this->insert(begin(), __first, __last); }\n  list(const_iterator __first, const_iterator __last,\n       const allocator_type& __a = allocator_type())\n    : _Base(__a)\n    { this->insert(begin(), __first, __last); }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n  list(const list<_Tp, _Alloc>& __x) : _Base(__x.get_allocator())\n    { insert(begin(), __x.begin(), __x.end()); }\n\n  ~list() { }\n\n  list<_Tp, _Alloc>& operator=(const list<_Tp, _Alloc>& __x);\n\npublic:\n  // assign(), a generalized assignment member function.  Two\n  // versions: one that takes a count, and one that takes a range.\n  // The range version is a member template, so we dispatch on whether\n  // or not the type is an integer.\n\n  void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }\n\n  void _M_fill_assign(size_type __n, const _Tp& __val);\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIterator>\n  void assign(_InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_assign_dispatch(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)\n    { _M_fill_assign((size_type) __n, (_Tp) __val); }\n\n  template <class _InputIterator>\n  void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,\n                          __false_type);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprotected:\n  void transfer(iterator __position, iterator __first, iterator __last) {\n    if (__position != __last) {\n      // Remove [first, last) from its old position.\n      __last._M_node->_M_prev->_M_next     = __position._M_node;\n      __first._M_node->_M_prev->_M_next    = __last._M_node;\n      __position._M_node->_M_prev->_M_next = __first._M_node; \n\n      // Splice [first, last) into its new position.\n      _List_node_base* __tmp      = __position._M_node->_M_prev;\n      __position._M_node->_M_prev = __last._M_node->_M_prev;\n      __last._M_node->_M_prev     = __first._M_node->_M_prev; \n      __first._M_node->_M_prev    = __tmp;\n    }\n  }\n\npublic:\n  void splice(iterator __position, list& __x) {\n    if (!__x.empty()) \n      this->transfer(__position, __x.begin(), __x.end());\n  }\n  void splice(iterator __position, list&, iterator __i) {\n    iterator __j = __i;\n    ++__j;\n    if (__position == __i || __position == __j) return;\n    this->transfer(__position, __i, __j);\n  }\n  void splice(iterator __position, list&, iterator __first, iterator __last) {\n    if (__first != __last) \n      this->transfer(__position, __first, __last);\n  }\n  void remove(const _Tp& __value);\n  void unique();\n  void merge(list& __x);\n  void reverse();\n  void sort();\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Predicate> void remove_if(_Predicate);\n  template <class _BinaryPredicate> void unique(_BinaryPredicate);\n  template <class _StrictWeakOrdering> void merge(list&, _StrictWeakOrdering);\n  template <class _StrictWeakOrdering> void sort(_StrictWeakOrdering);\n#endif /* __STL_MEMBER_TEMPLATES */\n};\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)\n{\n  typedef typename list<_Tp,_Alloc>::const_iterator const_iterator;\n  const_iterator __end1 = __x.end();\n  const_iterator __end2 = __y.end();\n\n  const_iterator __i1 = __x.begin();\n  const_iterator __i2 = __y.begin();\n  while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {\n    ++__i1;\n    ++__i2;\n  }\n  return __i1 == __end1 && __i2 == __end2;\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator<(const list<_Tp,_Alloc>& __x,\n                      const list<_Tp,_Alloc>& __y)\n{\n  return lexicographical_compare(__x.begin(), __x.end(),\n                                 __y.begin(), __y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator!=(const list<_Tp,_Alloc>& __x,\n                       const list<_Tp,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator>(const list<_Tp,_Alloc>& __x,\n                      const list<_Tp,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator<=(const list<_Tp,_Alloc>& __x,\n                       const list<_Tp,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool operator>=(const list<_Tp,_Alloc>& __x,\n                       const list<_Tp,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline void \nswap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)\n{\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _InputIter>\nvoid \nlist<_Tp, _Alloc>::_M_insert_dispatch(iterator __position,\n                                      _InputIter __first, _InputIter __last,\n                                      __false_type)\n{\n  for ( ; __first != __last; ++__first)\n    insert(__position, *__first);\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid \nlist<_Tp, _Alloc>::insert(iterator __position, \n                          const _Tp* __first, const _Tp* __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert(__position, *__first);\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid \nlist<_Tp, _Alloc>::insert(iterator __position,\n                         const_iterator __first, const_iterator __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert(__position, *__first);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid \nlist<_Tp, _Alloc>::_M_fill_insert(iterator __position,\n                                  size_type __n, const _Tp& __x)\n{\n  for ( ; __n > 0; --__n)\n    insert(__position, __x);\n}\n\ntemplate <class _Tp, class _Alloc>\ntypename list<_Tp,_Alloc>::iterator list<_Tp, _Alloc>::erase(iterator __first, \n                                                             iterator __last)\n{\n  while (__first != __last)\n    erase(__first++);\n  return __last;\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x)\n{\n  iterator __i = begin();\n  size_type __len = 0;\n  for ( ; __i != end() && __len < __new_size; ++__i, ++__len)\n    ;\n  if (__len == __new_size)\n    erase(__i, end());\n  else                          // __i == end()\n    insert(end(), __new_size - __len, __x);\n}\n\ntemplate <class _Tp, class _Alloc>\nlist<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x)\n{\n  if (this != &__x) {\n    iterator __first1 = begin();\n    iterator __last1 = end();\n    const_iterator __first2 = __x.begin();\n    const_iterator __last2 = __x.end();\n    while (__first1 != __last1 && __first2 != __last2) \n      *__first1++ = *__first2++;\n    if (__first2 == __last2)\n      erase(__first1, __last1);\n    else\n      insert(__last1, __first2, __last2);\n  }\n  return *this;\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {\n  iterator __i = begin();\n  for ( ; __i != end() && __n > 0; ++__i, --__n)\n    *__i = __val;\n  if (__n > 0)\n    insert(end(), __n, __val);\n  else\n    erase(__i, end());\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _InputIter>\nvoid\nlist<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first2, _InputIter __last2,\n                                      __false_type)\n{\n  iterator __first1 = begin();\n  iterator __last1 = end();\n  for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)\n    *__first1 = *__first2;\n  if (__first2 == __last2)\n    erase(__first1, __last1);\n  else\n    insert(__last1, __first2, __last2);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::remove(const _Tp& __value)\n{\n  iterator __first = begin();\n  iterator __last = end();\n  while (__first != __last) {\n    iterator __next = __first;\n    ++__next;\n    if (*__first == __value) erase(__first);\n    __first = __next;\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::unique()\n{\n  iterator __first = begin();\n  iterator __last = end();\n  if (__first == __last) return;\n  iterator __next = __first;\n  while (++__next != __last) {\n    if (*__first == *__next)\n      erase(__next);\n    else\n      __first = __next;\n    __next = __first;\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x)\n{\n  iterator __first1 = begin();\n  iterator __last1 = end();\n  iterator __first2 = __x.begin();\n  iterator __last2 = __x.end();\n  while (__first1 != __last1 && __first2 != __last2)\n    if (*__first2 < *__first1) {\n      iterator __next = __first2;\n      transfer(__first1, __first2, ++__next);\n      __first2 = __next;\n    }\n    else\n      ++__first1;\n  if (__first2 != __last2) transfer(__last1, __first2, __last2);\n}\n\ninline void __List_base_reverse(_List_node_base* __p)\n{\n  _List_node_base* __tmp = __p;\n  do {\n    __STD::swap(__tmp->_M_next, __tmp->_M_prev);\n    __tmp = __tmp->_M_prev;     // Old next node is now prev.\n  } while (__tmp != __p);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline void list<_Tp, _Alloc>::reverse() \n{\n  __List_base_reverse(this->_M_node);\n}    \n\ntemplate <class _Tp, class _Alloc>\nvoid list<_Tp, _Alloc>::sort()\n{\n  // Do nothing if the list has length 0 or 1.\n  if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) {\n    list<_Tp, _Alloc> __carry;\n    list<_Tp, _Alloc> __counter[64];\n    int __fill = 0;\n    while (!empty()) {\n      __carry.splice(__carry.begin(), *this, begin());\n      int __i = 0;\n      while(__i < __fill && !__counter[__i].empty()) {\n        __counter[__i].merge(__carry);\n        __carry.swap(__counter[__i++]);\n      }\n      __carry.swap(__counter[__i]);         \n      if (__i == __fill) ++__fill;\n    } \n\n    for (int __i = 1; __i < __fill; ++__i)\n      __counter[__i].merge(__counter[__i-1]);\n    swap(__counter[__fill-1]);\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _Predicate>\nvoid list<_Tp, _Alloc>::remove_if(_Predicate __pred)\n{\n  iterator __first = begin();\n  iterator __last = end();\n  while (__first != __last) {\n    iterator __next = __first;\n    ++__next;\n    if (__pred(*__first)) erase(__first);\n    __first = __next;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _BinaryPredicate>\nvoid list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)\n{\n  iterator __first = begin();\n  iterator __last = end();\n  if (__first == __last) return;\n  iterator __next = __first;\n  while (++__next != __last) {\n    if (__binary_pred(*__first, *__next))\n      erase(__next);\n    else\n      __first = __next;\n    __next = __first;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _StrictWeakOrdering>\nvoid list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x,\n                              _StrictWeakOrdering __comp)\n{\n  iterator __first1 = begin();\n  iterator __last1 = end();\n  iterator __first2 = __x.begin();\n  iterator __last2 = __x.end();\n  while (__first1 != __last1 && __first2 != __last2)\n    if (__comp(*__first2, *__first1)) {\n      iterator __next = __first2;\n      transfer(__first1, __first2, ++__next);\n      __first2 = __next;\n    }\n    else\n      ++__first1;\n  if (__first2 != __last2) transfer(__last1, __first2, __last2);\n}\n\ntemplate <class _Tp, class _Alloc> template <class _StrictWeakOrdering>\nvoid list<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp)\n{\n  // Do nothing if the list has length 0 or 1.\n  if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) {\n    list<_Tp, _Alloc> __carry;\n    list<_Tp, _Alloc> __counter[64];\n    int __fill = 0;\n    while (!empty()) {\n      __carry.splice(__carry.begin(), *this, begin());\n      int __i = 0;\n      while(__i < __fill && !__counter[__i].empty()) {\n        __counter[__i].merge(__carry, __comp);\n        __carry.swap(__counter[__i++]);\n      }\n      __carry.swap(__counter[__i]);         \n      if (__i == __fill) ++__fill;\n    } \n\n    for (int __i = 1; __i < __fill; ++__i) \n      __counter[__i].merge(__counter[__i-1], __comp);\n    swap(__counter[__fill-1]);\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_LIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_map.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MAP_H\n#define __SGI_STL_INTERNAL_MAP_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declarations of operators == and <, needed for friend declarations.\ntemplate <class _Key, class _Tp, \n          class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass map;\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const map<_Key,_Tp,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const map<_Key,_Tp,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\nclass map {\npublic:\n\n// requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);\n\n// typedefs:\n\n  typedef _Key                  key_type;\n  typedef _Tp                   data_type;\n  typedef _Tp                   mapped_type;\n  typedef pair<const _Key, _Tp> value_type;\n  typedef _Compare              key_compare;\n    \n  class value_compare\n    : public binary_function<value_type, value_type, bool> {\n  friend class map<_Key,_Tp,_Compare,_Alloc>;\n  protected :\n    _Compare comp;\n    value_compare(_Compare __c) : comp(__c) {}\n  public:\n    bool operator()(const value_type& __x, const value_type& __y) const {\n      return comp(__x.first, __y.first);\n    }\n  };\n\nprivate:\n  typedef _Rb_tree<key_type, value_type, \n                   _Select1st<value_type>, key_compare, _Alloc> _Rep_type;\n  _Rep_type _M_t;  // red-black tree representing map\npublic:\n  typedef typename _Rep_type::pointer pointer;\n  typedef typename _Rep_type::const_pointer const_pointer;\n  typedef typename _Rep_type::reference reference;\n  typedef typename _Rep_type::const_reference const_reference;\n  typedef typename _Rep_type::iterator iterator;\n  typedef typename _Rep_type::const_iterator const_iterator;\n  typedef typename _Rep_type::reverse_iterator reverse_iterator;\n  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename _Rep_type::size_type size_type;\n  typedef typename _Rep_type::difference_type difference_type;\n  typedef typename _Rep_type::allocator_type allocator_type;\n\n  // allocation/deallocation\n\n  map() : _M_t(_Compare(), allocator_type()) {}\n  explicit map(const _Compare& __comp,\n               const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  map(_InputIterator __first, _InputIterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_unique(__first, __last); }\n\n  template <class _InputIterator>\n  map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n#else\n  map(const value_type* __first, const value_type* __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_unique(__first, __last); }\n\n  map(const value_type* __first,\n      const value_type* __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n\n  map(const_iterator __first, const_iterator __last)\n    : _M_t(_Compare(), allocator_type()) \n    { _M_t.insert_unique(__first, __last); }\n\n  map(const_iterator __first, const_iterator __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  map(const map<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}\n  map<_Key,_Tp,_Compare,_Alloc>&\n  operator=(const map<_Key, _Tp, _Compare, _Alloc>& __x)\n  {\n    _M_t = __x._M_t;\n    return *this; \n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return _M_t.key_comp(); }\n  value_compare value_comp() const { return value_compare(_M_t.key_comp()); }\n  allocator_type get_allocator() const { return _M_t.get_allocator(); }\n\n  iterator begin() { return _M_t.begin(); }\n  const_iterator begin() const { return _M_t.begin(); }\n  iterator end() { return _M_t.end(); }\n  const_iterator end() const { return _M_t.end(); }\n  reverse_iterator rbegin() { return _M_t.rbegin(); }\n  const_reverse_iterator rbegin() const { return _M_t.rbegin(); }\n  reverse_iterator rend() { return _M_t.rend(); }\n  const_reverse_iterator rend() const { return _M_t.rend(); }\n  bool empty() const { return _M_t.empty(); }\n  size_type size() const { return _M_t.size(); }\n  size_type max_size() const { return _M_t.max_size(); }\n  _Tp& operator[](const key_type& __k) {\n    iterator __i = lower_bound(__k);\n    // __i->first is greater than or equivalent to __k.\n    if (__i == end() || key_comp()(__k, (*__i).first))\n      __i = insert(__i, value_type(__k, _Tp()));\n    return (*__i).second;\n  }\n  void swap(map<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }\n\n  // insert/erase\n\n  pair<iterator,bool> insert(const value_type& __x) \n    { return _M_t.insert_unique(__x); }\n  iterator insert(iterator position, const value_type& __x)\n    { return _M_t.insert_unique(position, __x); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __first, _InputIterator __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n#else\n  void insert(const value_type* __first, const value_type* __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n  void insert(const_iterator __first, const_iterator __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void erase(iterator __position) { _M_t.erase(__position); }\n  size_type erase(const key_type& __x) { return _M_t.erase(__x); }\n  void erase(iterator __first, iterator __last)\n    { _M_t.erase(__first, __last); }\n  void clear() { _M_t.clear(); }\n\n  // map operations:\n\n  iterator find(const key_type& __x) { return _M_t.find(__x); }\n  const_iterator find(const key_type& __x) const { return _M_t.find(__x); }\n  size_type count(const key_type& __x) const {\n    return _M_t.find(__x) == _M_t.end() ? 0 : 1; \n  }\n  iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }\n  const_iterator lower_bound(const key_type& __x) const {\n    return _M_t.lower_bound(__x); \n  }\n  iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }\n  const_iterator upper_bound(const key_type& __x) const {\n    return _M_t.upper_bound(__x); \n  }\n  \n  pair<iterator,iterator> equal_range(const key_type& __x) {\n    return _M_t.equal_range(__x);\n  }\n  pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {\n    return _M_t.equal_range(__x);\n  }\n\n#ifdef __STL_TEMPLATE_FRIENDS \n  template <class _K1, class _T1, class _C1, class _A1>\n  friend bool operator== (const map<_K1, _T1, _C1, _A1>&,\n                          const map<_K1, _T1, _C1, _A1>&);\n  template <class _K1, class _T1, class _C1, class _A1>\n  friend bool operator< (const map<_K1, _T1, _C1, _A1>&,\n                         const map<_K1, _T1, _C1, _A1>&);\n#else /* __STL_TEMPLATE_FRIENDS */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const map&, const map&);\n  friend bool __STD_QUALIFIER\n  operator< __STL_NULL_TMPL_ARGS (const map&, const map&);\n#endif /* __STL_TEMPLATE_FRIENDS */\n};\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __x._M_t == __y._M_t;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __x._M_t < __y._M_t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x, \n                 map<_Key,_Tp,_Compare,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_multimap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MULTIMAP_H\n#define __SGI_STL_INTERNAL_MULTIMAP_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declaration of operators < and ==, needed for friend declaration.\n\ntemplate <class _Key, class _Tp, \n          class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass multimap;\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\nclass multimap {\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);\n\npublic:\n\n// typedefs:\n\n  typedef _Key                  key_type;\n  typedef _Tp                   data_type;\n  typedef _Tp                   mapped_type;\n  typedef pair<const _Key, _Tp> value_type;\n  typedef _Compare              key_compare;\n\n  class value_compare : public binary_function<value_type, value_type, bool> {\n  friend class multimap<_Key,_Tp,_Compare,_Alloc>;\n  protected:\n    _Compare comp;\n    value_compare(_Compare __c) : comp(__c) {}\n  public:\n    bool operator()(const value_type& __x, const value_type& __y) const {\n      return comp(__x.first, __y.first);\n    }\n  };\n\nprivate:\n  typedef _Rb_tree<key_type, value_type, \n                  _Select1st<value_type>, key_compare, _Alloc> _Rep_type;\n  _Rep_type _M_t;  // red-black tree representing multimap\npublic:\n  typedef typename _Rep_type::pointer pointer;\n  typedef typename _Rep_type::const_pointer const_pointer;\n  typedef typename _Rep_type::reference reference;\n  typedef typename _Rep_type::const_reference const_reference;\n  typedef typename _Rep_type::iterator iterator;\n  typedef typename _Rep_type::const_iterator const_iterator; \n  typedef typename _Rep_type::reverse_iterator reverse_iterator;\n  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename _Rep_type::size_type size_type;\n  typedef typename _Rep_type::difference_type difference_type;\n  typedef typename _Rep_type::allocator_type allocator_type;\n\n// allocation/deallocation\n\n  multimap() : _M_t(_Compare(), allocator_type()) { }\n  explicit multimap(const _Compare& __comp,\n                    const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { }\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class _InputIterator>\n  multimap(_InputIterator __first, _InputIterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n\n  template <class _InputIterator>\n  multimap(_InputIterator __first, _InputIterator __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n#else\n  multimap(const value_type* __first, const value_type* __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n  multimap(const value_type* __first, const value_type* __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n\n  multimap(const_iterator __first, const_iterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n  multimap(const_iterator __first, const_iterator __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { }\n  multimap<_Key,_Tp,_Compare,_Alloc>&\n  operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) {\n    _M_t = __x._M_t;\n    return *this; \n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return _M_t.key_comp(); }\n  value_compare value_comp() const { return value_compare(_M_t.key_comp()); }\n  allocator_type get_allocator() const { return _M_t.get_allocator(); }\n\n  iterator begin() { return _M_t.begin(); }\n  const_iterator begin() const { return _M_t.begin(); }\n  iterator end() { return _M_t.end(); }\n  const_iterator end() const { return _M_t.end(); }\n  reverse_iterator rbegin() { return _M_t.rbegin(); }\n  const_reverse_iterator rbegin() const { return _M_t.rbegin(); }\n  reverse_iterator rend() { return _M_t.rend(); }\n  const_reverse_iterator rend() const { return _M_t.rend(); }\n  bool empty() const { return _M_t.empty(); }\n  size_type size() const { return _M_t.size(); }\n  size_type max_size() const { return _M_t.max_size(); }\n  void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }\n\n  // insert/erase\n\n  iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }\n  iterator insert(iterator __position, const value_type& __x) {\n    return _M_t.insert_equal(__position, __x);\n  }\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class _InputIterator>\n  void insert(_InputIterator __first, _InputIterator __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n#else\n  void insert(const value_type* __first, const value_type* __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n  void insert(const_iterator __first, const_iterator __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator __position) { _M_t.erase(__position); }\n  size_type erase(const key_type& __x) { return _M_t.erase(__x); }\n  void erase(iterator __first, iterator __last)\n    { _M_t.erase(__first, __last); }\n  void clear() { _M_t.clear(); }\n\n  // multimap operations:\n\n  iterator find(const key_type& __x) { return _M_t.find(__x); }\n  const_iterator find(const key_type& __x) const { return _M_t.find(__x); }\n  size_type count(const key_type& __x) const { return _M_t.count(__x); }\n  iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }\n  const_iterator lower_bound(const key_type& __x) const {\n    return _M_t.lower_bound(__x); \n  }\n  iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }\n  const_iterator upper_bound(const key_type& __x) const {\n    return _M_t.upper_bound(__x); \n  }\n   pair<iterator,iterator> equal_range(const key_type& __x) {\n    return _M_t.equal_range(__x);\n  }\n  pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {\n    return _M_t.equal_range(__x);\n  }\n\n#ifdef __STL_TEMPLATE_FRIENDS \n  template <class _K1, class _T1, class _C1, class _A1>\n  friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&,\n                          const multimap<_K1, _T1, _C1, _A1>&);\n  template <class _K1, class _T1, class _C1, class _A1>\n  friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&,\n                         const multimap<_K1, _T1, _C1, _A1>&);\n#else /* __STL_TEMPLATE_FRIENDS */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);\n  friend bool __STD_QUALIFIER\n  operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);\n#endif /* __STL_TEMPLATE_FRIENDS */\n};\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __x._M_t == __y._M_t;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __x._M_t < __y._M_t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Alloc>\ninline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, \n                 multimap<_Key,_Tp,_Compare,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_multiset.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MULTISET_H\n#define __SGI_STL_INTERNAL_MULTISET_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declaration of operators < and ==, needed for friend declaration.\n\ntemplate <class _Key, class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >\nclass multiset;\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, \n                       const multiset<_Key,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, \n                      const multiset<_Key,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Compare, class _Alloc>\nclass multiset {\n  // requirements:\n  \n  __STL_CLASS_REQUIRES(_Key, _Assignable);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);\n\npublic:\n\n  // typedefs:\n\n  typedef _Key     key_type;\n  typedef _Key     value_type;\n  typedef _Compare key_compare;\n  typedef _Compare value_compare;\nprivate:\n  typedef _Rb_tree<key_type, value_type, \n                  _Identity<value_type>, key_compare, _Alloc> _Rep_type;\n  _Rep_type _M_t;  // red-black tree representing multiset\npublic:\n  typedef typename _Rep_type::const_pointer pointer;\n  typedef typename _Rep_type::const_pointer const_pointer;\n  typedef typename _Rep_type::const_reference reference;\n  typedef typename _Rep_type::const_reference const_reference;\n  typedef typename _Rep_type::const_iterator iterator;\n  typedef typename _Rep_type::const_iterator const_iterator;\n  typedef typename _Rep_type::const_reverse_iterator reverse_iterator;\n  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename _Rep_type::size_type size_type;\n  typedef typename _Rep_type::difference_type difference_type;\n  typedef typename _Rep_type::allocator_type allocator_type;\n\n  // allocation/deallocation\n\n  multiset() : _M_t(_Compare(), allocator_type()) {}\n  explicit multiset(const _Compare& __comp,\n                    const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIterator>\n  multiset(_InputIterator __first, _InputIterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n\n  template <class _InputIterator>\n  multiset(_InputIterator __first, _InputIterator __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n\n#else\n\n  multiset(const value_type* __first, const value_type* __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n\n  multiset(const value_type* __first, const value_type* __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n\n  multiset(const_iterator __first, const_iterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_equal(__first, __last); }\n\n  multiset(const_iterator __first, const_iterator __last,\n           const _Compare& __comp,\n           const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }\n   \n#endif /* __STL_MEMBER_TEMPLATES */\n\n  multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}\n  multiset<_Key,_Compare,_Alloc>&\n  operator=(const multiset<_Key,_Compare,_Alloc>& __x) {\n    _M_t = __x._M_t; \n    return *this;\n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return _M_t.key_comp(); }\n  value_compare value_comp() const { return _M_t.key_comp(); }\n  allocator_type get_allocator() const { return _M_t.get_allocator(); }\n\n  iterator begin() const { return _M_t.begin(); }\n  iterator end() const { return _M_t.end(); }\n  reverse_iterator rbegin() const { return _M_t.rbegin(); } \n  reverse_iterator rend() const { return _M_t.rend(); }\n  bool empty() const { return _M_t.empty(); }\n  size_type size() const { return _M_t.size(); }\n  size_type max_size() const { return _M_t.max_size(); }\n  void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }\n\n  // insert/erase\n  iterator insert(const value_type& __x) { \n    return _M_t.insert_equal(__x);\n  }\n  iterator insert(iterator __position, const value_type& __x) {\n    typedef typename _Rep_type::iterator _Rep_iterator;\n    return _M_t.insert_equal((_Rep_iterator&)__position, __x);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class _InputIterator>\n  void insert(_InputIterator __first, _InputIterator __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n#else\n  void insert(const value_type* __first, const value_type* __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n  void insert(const_iterator __first, const_iterator __last) {\n    _M_t.insert_equal(__first, __last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator __position) { \n    typedef typename _Rep_type::iterator _Rep_iterator;\n    _M_t.erase((_Rep_iterator&)__position); \n  }\n  size_type erase(const key_type& __x) { \n    return _M_t.erase(__x); \n  }\n  void erase(iterator __first, iterator __last) { \n    typedef typename _Rep_type::iterator _Rep_iterator;\n    _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); \n  }\n  void clear() { _M_t.clear(); }\n\n  // multiset operations:\n\n  iterator find(const key_type& __x) const { return _M_t.find(__x); }\n  size_type count(const key_type& __x) const { return _M_t.count(__x); }\n  iterator lower_bound(const key_type& __x) const {\n    return _M_t.lower_bound(__x);\n  }\n  iterator upper_bound(const key_type& __x) const {\n    return _M_t.upper_bound(__x); \n  }\n  pair<iterator,iterator> equal_range(const key_type& __x) const {\n    return _M_t.equal_range(__x);\n  }\n\n#ifdef __STL_TEMPLATE_FRIENDS\n  template <class _K1, class _C1, class _A1>\n  friend bool operator== (const multiset<_K1,_C1,_A1>&,\n                          const multiset<_K1,_C1,_A1>&);\n  template <class _K1, class _C1, class _A1>\n  friend bool operator< (const multiset<_K1,_C1,_A1>&,\n                         const multiset<_K1,_C1,_A1>&);\n#else /* __STL_TEMPLATE_FRIENDS */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const multiset&, const multiset&);\n  friend bool __STD_QUALIFIER\n  operator< __STL_NULL_TMPL_ARGS (const multiset&, const multiset&);\n#endif /* __STL_TEMPLATE_FRIENDS */\n};\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, \n                       const multiset<_Key,_Compare,_Alloc>& __y) {\n  return __x._M_t == __y._M_t;\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, \n                      const multiset<_Key,_Compare,_Alloc>& __y) {\n  return __x._M_t < __y._M_t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator!=(const multiset<_Key,_Compare,_Alloc>& __x, \n                       const multiset<_Key,_Compare,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator>(const multiset<_Key,_Compare,_Alloc>& __x, \n                      const multiset<_Key,_Compare,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<=(const multiset<_Key,_Compare,_Alloc>& __x, \n                       const multiset<_Key,_Compare,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator>=(const multiset<_Key,_Compare,_Alloc>& __x, \n                       const multiset<_Key,_Compare,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline void swap(multiset<_Key,_Compare,_Alloc>& __x, \n                 multiset<_Key,_Compare,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MULTISET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_numeric.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n\n#ifndef __SGI_STL_INTERNAL_NUMERIC_H\n#define __SGI_STL_INTERNAL_NUMERIC_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _InputIterator, class _Tp>\n_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  for ( ; __first != __last; ++__first)\n    __init = __init + *__first;\n  return __init;\n}\n\ntemplate <class _InputIterator, class _Tp, class _BinaryOperation>\n_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,\n               _BinaryOperation __binary_op)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  for ( ; __first != __last; ++__first)\n    __init = __binary_op(__init, *__first);\n  return __init;\n}\n\ntemplate <class _InputIterator1, class _InputIterator2, class _Tp>\n_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,\n                  _InputIterator2 __first2, _Tp __init)\n{\n  __STL_REQUIRES(_InputIterator2, _InputIterator);\n  __STL_REQUIRES(_InputIterator2, _InputIterator);\n  for ( ; __first1 != __last1; ++__first1, ++__first2)\n    __init = __init + (*__first1 * *__first2);\n  return __init;\n}\n\ntemplate <class _InputIterator1, class _InputIterator2, class _Tp,\n          class _BinaryOperation1, class _BinaryOperation2>\n_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,\n                  _InputIterator2 __first2, _Tp __init, \n                  _BinaryOperation1 __binary_op1,\n                  _BinaryOperation2 __binary_op2)\n{\n  __STL_REQUIRES(_InputIterator2, _InputIterator);\n  __STL_REQUIRES(_InputIterator2, _InputIterator);\n  for ( ; __first1 != __last1; ++__first1, ++__first2)\n    __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));\n  return __init;\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _Tp>\n_OutputIterator \n__partial_sum(_InputIterator __first, _InputIterator __last,\n              _OutputIterator __result, _Tp*)\n{\n  _Tp __value = *__first;\n  while (++__first != __last) {\n    __value = __value + *__first;\n    *++__result = __value;\n  }\n  return ++__result;\n}\n\ntemplate <class _InputIterator, class _OutputIterator>\n_OutputIterator \npartial_sum(_InputIterator __first, _InputIterator __last,\n            _OutputIterator __result)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __STL_REQUIRES(_OutputIterator, _OutputIterator);\n  if (__first == __last) return __result;\n  *__result = *__first;\n  return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first));\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _Tp,\n          class _BinaryOperation>\n_OutputIterator \n__partial_sum(_InputIterator __first, _InputIterator __last, \n              _OutputIterator __result, _Tp*, _BinaryOperation __binary_op)\n{\n  _Tp __value = *__first;\n  while (++__first != __last) {\n    __value = __binary_op(__value, *__first);\n    *++__result = __value;\n  }\n  return ++__result;\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _BinaryOperation>\n_OutputIterator \npartial_sum(_InputIterator __first, _InputIterator __last,\n            _OutputIterator __result, _BinaryOperation __binary_op)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __STL_REQUIRES(_OutputIterator, _OutputIterator);\n  if (__first == __last) return __result;\n  *__result = *__first;\n  return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first), \n                       __binary_op);\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _Tp>\n_OutputIterator \n__adjacent_difference(_InputIterator __first, _InputIterator __last,\n                      _OutputIterator __result, _Tp*)\n{\n  _Tp __value = *__first;\n  while (++__first != __last) {\n    _Tp __tmp = *__first;\n    *++__result = __tmp - __value;\n    __value = __tmp;\n  }\n  return ++__result;\n}\n\ntemplate <class _InputIterator, class _OutputIterator>\n_OutputIterator\nadjacent_difference(_InputIterator __first,\n                    _InputIterator __last, _OutputIterator __result)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __STL_REQUIRES(_OutputIterator, _OutputIterator);\n  if (__first == __last) return __result;\n  *__result = *__first;\n  return __adjacent_difference(__first, __last, __result,\n                               __VALUE_TYPE(__first));\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _Tp, \n          class _BinaryOperation>\n_OutputIterator\n__adjacent_difference(_InputIterator __first, _InputIterator __last, \n                      _OutputIterator __result, _Tp*,\n                      _BinaryOperation __binary_op) {\n  _Tp __value = *__first;\n  while (++__first != __last) {\n    _Tp __tmp = *__first;\n    *++__result = __binary_op(__tmp, __value);\n    __value = __tmp;\n  }\n  return ++__result;\n}\n\ntemplate <class _InputIterator, class _OutputIterator, class _BinaryOperation>\n_OutputIterator \nadjacent_difference(_InputIterator __first, _InputIterator __last,\n                    _OutputIterator __result, _BinaryOperation __binary_op)\n{\n  __STL_REQUIRES(_InputIterator, _InputIterator);\n  __STL_REQUIRES(_OutputIterator, _OutputIterator);\n  if (__first == __last) return __result;\n  *__result = *__first;\n  return __adjacent_difference(__first, __last, __result,\n                               __VALUE_TYPE(__first),\n                               __binary_op);\n}\n\n// Returns __x ** __n, where __n >= 0.  _Note that \"multiplication\"\n// is required to be associative, but not necessarily commutative.\n\n \ntemplate <class _Tp, class _Integer, class _MonoidOperation>\n_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr)\n{\n  if (__n == 0)\n    return identity_element(__opr);\n  else {\n    while ((__n & 1) == 0) {\n      __n >>= 1;\n      __x = __opr(__x, __x);\n    }\n\n    _Tp __result = __x;\n    __n >>= 1;\n    while (__n != 0) {\n      __x = __opr(__x, __x);\n      if ((__n & 1) != 0)\n        __result = __opr(__result, __x);\n      __n >>= 1;\n    }\n    return __result;\n  }\n}\n\ntemplate <class _Tp, class _Integer>\ninline _Tp __power(_Tp __x, _Integer __n)\n{\n  return __power(__x, __n, multiplies<_Tp>());\n}\n\n// Alias for the internal name __power.  Note that power is an extension,\n// not part of the C++ standard.\n\ntemplate <class _Tp, class _Integer, class _MonoidOperation>\ninline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr)\n{\n  return __power(__x, __n, __opr);\n}\n\ntemplate <class _Tp, class _Integer>\ninline _Tp power(_Tp __x, _Integer __n)\n{\n  return __power(__x, __n);\n}\n\n// iota is not part of the C++ standard.  It is an extension.\n\ntemplate <class _ForwardIter, class _Tp>\nvoid \niota(_ForwardIter __first, _ForwardIter __last, _Tp __value)\n{\n  __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);\n  __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);\n  while (__first != __last)\n    *__first++ = __value++;\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_NUMERIC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_pair.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#define __SGI_STL_INTERNAL_PAIR_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _T1, class _T2>\nstruct pair {\n  typedef _T1 first_type;\n  typedef _T2 second_type;\n\n  _T1 first;\n  _T2 second;\n  pair() : first(_T1()), second(_T2()) {}\n  pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _U1, class _U2>\n  pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}\n#endif\n};\n\ntemplate <class _T1, class _T2>\ninline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)\n{ \n  return __x.first == __y.first && __x.second == __y.second; \n}\n\ntemplate <class _T1, class _T2>\ninline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)\n{ \n  return __x.first < __y.first || \n         (!(__y.first < __x.first) && __x.second < __y.second); \n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _T1, class _T2>\ninline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _T1, class _T2>\ninline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _T1, class _T2>\ninline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y)\n{\n  return pair<_T1, _T2>(__x, __y);\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_PAIR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_queue.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_QUEUE_H\n#define __SGI_STL_INTERNAL_QUEUE_H\n\n#include <sequence_concepts.h>\n\n__STL_BEGIN_NAMESPACE\n\n// Forward declarations of operators < and ==, needed for friend declaration.\n\ntemplate <class _Tp, \n          class _Sequence __STL_DEPENDENT_DEFAULT_TMPL(deque<_Tp>) >\nclass queue;\n\ntemplate <class _Tp, class _Seq>\ninline bool operator==(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&);\n\ntemplate <class _Tp, class _Seq>\ninline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&);\n\n\ntemplate <class _Tp, class _Sequence>\nclass queue {\n\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_REQUIRES(_Sequence, _FrontInsertionSequence);\n  __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence);\n  typedef typename _Sequence::value_type _Sequence_value_type;\n  __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);\n\n\n#ifdef __STL_MEMBER_TEMPLATES \n  template <class _Tp1, class _Seq1>\n  friend bool operator== (const queue<_Tp1, _Seq1>&,\n                          const queue<_Tp1, _Seq1>&);\n  template <class _Tp1, class _Seq1>\n  friend bool operator< (const queue<_Tp1, _Seq1>&,\n                         const queue<_Tp1, _Seq1>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const queue&, const queue&);\n  friend bool __STD_QUALIFIER\n  operator<  __STL_NULL_TMPL_ARGS (const queue&, const queue&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n  typedef typename _Sequence::value_type      value_type;\n  typedef typename _Sequence::size_type       size_type;\n  typedef          _Sequence                  container_type;\n\n  typedef typename _Sequence::reference       reference;\n  typedef typename _Sequence::const_reference const_reference;\nprotected:\n  _Sequence c;\npublic:\n  queue() : c() {}\n  explicit queue(const _Sequence& __c) : c(__c) {}\n\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  reference front() { return c.front(); }\n  const_reference front() const { return c.front(); }\n  reference back() { return c.back(); }\n  const_reference back() const { return c.back(); }\n  void push(const value_type& __x) { c.push_back(__x); }\n  void pop() { c.pop_front(); }\n};\n\ntemplate <class _Tp, class _Sequence>\nbool \noperator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return __x.c == __y.c;\n}\n\ntemplate <class _Tp, class _Sequence>\nbool\noperator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return __x.c < __y.c;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Sequence>\nbool\noperator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return !(__x == __y);\n}\n\ntemplate <class _Tp, class _Sequence>\nbool \noperator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return __y < __x;\n}\n\ntemplate <class _Tp, class _Sequence>\nbool \noperator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return !(__y < __x);\n}\n\ntemplate <class _Tp, class _Sequence>\nbool \noperator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)\n{\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Tp, \n          class _Sequence __STL_DEPENDENT_DEFAULT_TMPL(vector<_Tp>),\n          class _Compare\n          __STL_DEPENDENT_DEFAULT_TMPL(less<typename _Sequence::value_type>) >\nclass priority_queue {\n\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_REQUIRES(_Sequence, _Sequence);\n  __STL_CLASS_REQUIRES(_Sequence, _RandomAccessContainer);\n  typedef typename _Sequence::value_type _Sequence_value_type;\n  __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);\n\npublic:\n  typedef typename _Sequence::value_type      value_type;\n  typedef typename _Sequence::size_type       size_type;\n  typedef          _Sequence                  container_type;\n\n  typedef typename _Sequence::reference       reference;\n  typedef typename _Sequence::const_reference const_reference;\nprotected:\n  _Sequence c;\n  _Compare comp;\npublic:\n  priority_queue() : c() {}\n  explicit priority_queue(const _Compare& __x) :  c(), comp(__x) {}\n  priority_queue(const _Compare& __x, const _Sequence& __s) \n    : c(__s), comp(__x) \n    { make_heap(c.begin(), c.end(), comp); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  priority_queue(_InputIterator __first, _InputIterator __last) \n    : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }\n\n  template <class _InputIterator>\n  priority_queue(_InputIterator __first, \n                 _InputIterator __last, const _Compare& __x)\n    : c(__first, __last), comp(__x) \n    { make_heap(c.begin(), c.end(), comp); }\n\n  template <class _InputIterator>\n  priority_queue(_InputIterator __first, _InputIterator __last,\n                 const _Compare& __x, const _Sequence& __s)\n  : c(__s), comp(__x)\n  { \n    c.insert(c.end(), __first, __last);\n    make_heap(c.begin(), c.end(), comp);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  priority_queue(const value_type* __first, const value_type* __last) \n    : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }\n\n  priority_queue(const value_type* __first, const value_type* __last, \n                 const _Compare& __x) \n    : c(__first, __last), comp(__x)\n    { make_heap(c.begin(), c.end(), comp); }\n\n  priority_queue(const value_type* __first, const value_type* __last, \n                 const _Compare& __x, const _Sequence& __c)\n    : c(__c), comp(__x) \n  { \n    c.insert(c.end(), __first, __last);\n    make_heap(c.begin(), c.end(), comp);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  const_reference top() const { return c.front(); }\n  void push(const value_type& __x) {\n    __STL_TRY {\n      c.push_back(__x); \n      push_heap(c.begin(), c.end(), comp);\n    }\n    __STL_UNWIND(c.clear());\n  }\n  void pop() {\n    __STL_TRY {\n      pop_heap(c.begin(), c.end(), comp);\n      c.pop_back();\n    }\n    __STL_UNWIND(c.clear());\n  }\n};\n\n// no equality is provided\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_QUEUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_range_errors.h",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __STL_RANGE_ERRORS_H\n#define __STL_RANGE_ERRORS_H\n\n// A few places in the STL throw range errors, using standard exception\n// classes defined in <stdexcept>.  This header file provides functions\n// to throw those exception objects.\n\n// __STL_DONT_THROW_RANGE_ERRORS is a hook so that users can disable\n// this exception throwing.\n\n#include <stl_config.h>\n\n#if defined(__STL_CAN_THROW_RANGE_ERRORS) && \\\n    defined(__STL_USE_EXCEPTIONS) && \\\n    !defined(__STL_DONT_THROW_RANGE_ERRORS)\n# define __STL_THROW_RANGE_ERRORS\n#endif\n\n// For the SGI 7.3 compiler, declare these functions here and define them\n// elsewhere.\n#if defined(__STL_THROW_RANGE_ERRORS) && \\\n    defined(__sgi) && !defined(__GNUC__) && \\\n    _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n\n__STL_BEGIN_NAMESPACE\nvoid __stl_throw_range_error(const char* __msg);\nvoid __stl_throw_length_error(const char* __msg);\n__STL_END_NAMESPACE\n\n// For other compilers where we're throwing range errors, include the\n// stdexcept header and throw the appropriate exceptions directly.\n#elif defined(__STL_THROW_RANGE_ERRORS)\n\n#include <stdexcept>\n\n__STL_BEGIN_NAMESPACE\ninline void __stl_throw_range_error(const char* __msg) \n  { throw range_error(__msg); }\ninline void __stl_throw_length_error(const char* __msg)\n  { throw length_error(__msg); }\n__STL_END_NAMESPACE\n\n// Otherwise, define inline functions that do nothing.\n#else \n\n__STL_BEGIN_NAMESPACE\ninline void __stl_throw_range_error(const char*) {}\ninline void __stl_throw_length_error(const char*) {}\n__STL_END_NAMESPACE\n\n#endif\n\n#endif /* __STL_RANGE_ERRORS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_raw_storage_iter.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n * You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n#define __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _ForwardIterator, class _Tp>\nclass raw_storage_iterator {\nprotected:\n  _ForwardIterator _M_iter;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {}\n  raw_storage_iterator& operator*() { return *this; }\n  raw_storage_iterator& operator=(const _Tp& __element) {\n    construct(&*_M_iter, __element);\n    return *this;\n  }        \n  raw_storage_iterator<_ForwardIterator, _Tp>& operator++() {\n    ++_M_iter;\n    return *this;\n  }\n  raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) {\n    raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this;\n    ++_M_iter;\n    return __tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _ForwardIterator, class _Tp>\ninline output_iterator_tag\niterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_relops.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#define __SGI_STL_INTERNAL_RELOPS\n\n__STL_BEGIN_RELOPS_NAMESPACE\n\ntemplate <class _Tp>\ninline bool operator!=(const _Tp& __x, const _Tp& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Tp>\ninline bool operator>(const _Tp& __x, const _Tp& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Tp>\ninline bool operator<=(const _Tp& __x, const _Tp& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Tp>\ninline bool operator>=(const _Tp& __x, const _Tp& __y) {\n  return !(__x < __y);\n}\n\n__STL_END_RELOPS_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_RELOPS */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_rope.h",
    "content": "/*\n * Copyright (c) 1997-1998\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n// rope<_CharT,_Alloc> is a sequence of _CharT.\n// Ropes appear to be mutable, but update operations\n// really copy enough of the data structure to leave the original\n// valid.  Thus ropes can be logically copied by just copying\n// a pointer value.\n\n#ifndef __SGI_STL_INTERNAL_ROPE_H\n# define __SGI_STL_INTERNAL_ROPE_H\n\n# ifdef __GC\n#   define __GC_CONST const\n# else\n#   include <stl_threads.h>\n#   define __GC_CONST   // constant except for deallocation\n# endif\n# ifdef __STL_SGI_THREADS\n#    include <mutex.h>\n# endif\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// The _S_eos function is used for those functions that\n// convert to/from C-like strings to detect the end of the string.\n\n// The end-of-C-string character.\n// This is what the draft standard says it should be.\ntemplate <class _CharT>\ninline _CharT _S_eos(_CharT*) { return _CharT(); }\n\n// Test for basic character types.\n// For basic character types leaves having a trailing eos.\ntemplate <class _CharT>\ninline bool _S_is_basic_char_type(_CharT*) { return false; }\ntemplate <class _CharT>\ninline bool _S_is_one_byte_char_type(_CharT*) { return false; }\n\ninline bool _S_is_basic_char_type(char*) { return true; }\ninline bool _S_is_one_byte_char_type(char*) { return true; }\ninline bool _S_is_basic_char_type(wchar_t*) { return true; }\n\n// Store an eos iff _CharT is a basic character type.\n// Do not reference _S_eos if it isn't.\ntemplate <class _CharT>\ninline void _S_cond_store_eos(_CharT&) {}\n\ninline void _S_cond_store_eos(char& __c) { __c = 0; }\ninline void _S_cond_store_eos(wchar_t& __c) { __c = 0; }\n\n// char_producers are logically functions that generate a section of\n// a string.  These can be convereted to ropes.  The resulting rope\n// invokes the char_producer on demand.  This allows, for example,\n// files to be viewed as ropes without reading the entire file.\ntemplate <class _CharT>\nclass char_producer {\n    public:\n        virtual ~char_producer() {};\n        virtual void operator()(size_t __start_pos, size_t __len, \n                                _CharT* __buffer) = 0;\n        // Buffer should really be an arbitrary output iterator.\n        // That way we could flatten directly into an ostream, etc.\n        // This is thoroughly impossible, since iterator types don't\n        // have runtime descriptions.\n};\n\n// Sequence buffers:\n//\n// Sequence must provide an append operation that appends an\n// array to the sequence.  Sequence buffers are useful only if\n// appending an entire array is cheaper than appending element by element.\n// This is true for many string representations.\n// This should  perhaps inherit from ostream<sequence::value_type>\n// and be implemented correspondingly, so that they can be used\n// for formatted.  For the sake of portability, we don't do this yet.\n//\n// For now, sequence buffers behave as output iterators.  But they also\n// behave a little like basic_ostringstream<sequence::value_type> and a\n// little like containers.\n\ntemplate<class _Sequence, size_t _Buf_sz = 100\n#   if defined(__sgi) && !defined(__GNUC__)\n#        define __TYPEDEF_WORKAROUND\n         ,class _V = typename _Sequence::value_type\n#   endif\n        >\n// The 3rd parameter works around a common compiler bug.\nclass sequence_buffer : public output_iterator {\n    public:\n#       ifndef __TYPEDEF_WORKAROUND\n            typedef typename _Sequence::value_type value_type;\n#       else\n            typedef _V value_type;\n#       endif\n    protected:\n        _Sequence* _M_prefix;\n        value_type _M_buffer[_Buf_sz];\n        size_t     _M_buf_count;\n    public:\n        void flush() {\n            _M_prefix->append(_M_buffer, _M_buffer + _M_buf_count);\n            _M_buf_count = 0;\n        }\n        ~sequence_buffer() { flush(); }\n        sequence_buffer() : _M_prefix(0), _M_buf_count(0) {}\n        sequence_buffer(const sequence_buffer& __x) {\n            _M_prefix = __x._M_prefix;\n            _M_buf_count = __x._M_buf_count;\n            copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);\n        }\n        sequence_buffer(sequence_buffer& __x) {\n            __x.flush();\n            _M_prefix = __x._M_prefix;\n            _M_buf_count = 0;\n        }\n        sequence_buffer(_Sequence& __s) : _M_prefix(&__s), _M_buf_count(0) {}\n        sequence_buffer& operator= (sequence_buffer& __x) {\n            __x.flush();\n            _M_prefix = __x._M_prefix;\n            _M_buf_count = 0;\n            return *this;\n        }\n        sequence_buffer& operator= (const sequence_buffer& __x) {\n            _M_prefix = __x._M_prefix;\n            _M_buf_count = __x._M_buf_count;\n            copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);\n            return *this;\n        }\n        void push_back(value_type __x)\n        {\n            if (_M_buf_count < _Buf_sz) {\n                _M_buffer[_M_buf_count] = __x;\n                ++_M_buf_count;\n            } else {\n                flush();\n                _M_buffer[0] = __x;\n                _M_buf_count = 1;\n            }\n        }\n        void append(value_type* __s, size_t __len)\n        {\n            if (__len + _M_buf_count <= _Buf_sz) {\n                size_t __i = _M_buf_count;\n                size_t __j = 0;\n                for (; __j < __len; __i++, __j++) {\n                    _M_buffer[__i] = __s[__j];\n                }\n                _M_buf_count += __len;\n            } else if (0 == _M_buf_count) {\n                _M_prefix->append(__s, __s + __len);\n            } else {\n                flush();\n                append(__s, __len);\n            }\n        }\n        sequence_buffer& write(value_type* __s, size_t __len)\n        {\n            append(__s, __len);\n            return *this;\n        }\n        sequence_buffer& put(value_type __x)\n        {\n            push_back(__x);\n            return *this;\n        }\n        sequence_buffer& operator=(const value_type& __rhs)\n        {\n            push_back(__rhs);\n            return *this;\n        }\n        sequence_buffer& operator*() { return *this; }\n        sequence_buffer& operator++() { return *this; }\n        sequence_buffer& operator++(int) { return *this; }\n};\n\n// The following should be treated as private, at least for now.\ntemplate<class _CharT>\nclass _Rope_char_consumer {\n    public:\n        // If we had member templates, these should not be virtual.\n        // For now we need to use run-time parametrization where\n        // compile-time would do.  Hence this should all be private\n        // for now.\n        // The symmetry with char_producer is accidental and temporary.\n        virtual ~_Rope_char_consumer() {};\n        virtual bool operator()(const _CharT* __buffer, size_t __len) = 0;\n};\n\n// First a lot of forward declarations.  The standard seems to require\n// much stricter \"declaration before use\" than many of the implementations\n// that preceded it.\ntemplate<class _CharT, class _Alloc=__STL_DEFAULT_ALLOCATOR(_CharT)> class rope;\ntemplate<class _CharT, class _Alloc> struct _Rope_RopeConcatenation;\ntemplate<class _CharT, class _Alloc> struct _Rope_RopeLeaf;\ntemplate<class _CharT, class _Alloc> struct _Rope_RopeFunction;\ntemplate<class _CharT, class _Alloc> struct _Rope_RopeSubstring;\ntemplate<class _CharT, class _Alloc> class _Rope_iterator;\ntemplate<class _CharT, class _Alloc> class _Rope_const_iterator;\ntemplate<class _CharT, class _Alloc> class _Rope_char_ref_proxy;\ntemplate<class _CharT, class _Alloc> class _Rope_char_ptr_proxy;\n\ntemplate<class _CharT, class _Alloc>\nbool operator== (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,\n                 const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_const_iterator<_CharT,_Alloc> operator-\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_const_iterator<_CharT,_Alloc> operator+\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_const_iterator<_CharT,_Alloc> operator+\n        (ptrdiff_t __n,\n         const _Rope_const_iterator<_CharT,_Alloc>& __x);\n\ntemplate<class _CharT, class _Alloc>\nbool operator== \n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\nbool operator< \n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\nptrdiff_t operator- \n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_iterator<_CharT,_Alloc> operator-\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_iterator<_CharT,_Alloc> operator+\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n\ntemplate<class _CharT, class _Alloc>\n_Rope_iterator<_CharT,_Alloc> operator+\n        (ptrdiff_t __n,\n         const _Rope_iterator<_CharT,_Alloc>& __x);\n\ntemplate<class _CharT, class _Alloc>\nbool operator== \n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\nbool operator< \n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\nptrdiff_t operator- \n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n\ntemplate<class _CharT, class _Alloc>\nrope<_CharT,_Alloc> operator+ (const rope<_CharT,_Alloc>& __left,\n                               const rope<_CharT,_Alloc>& __right);\n        \ntemplate<class _CharT, class _Alloc>\nrope<_CharT,_Alloc> operator+ (const rope<_CharT,_Alloc>& __left,\n                               const _CharT* __right);\n        \ntemplate<class _CharT, class _Alloc>\nrope<_CharT,_Alloc> operator+ (const rope<_CharT,_Alloc>& __left,\n                               _CharT __right);\n        \n// Some helpers, so we can use power on ropes.\n// See below for why this isn't local to the implementation.\n\n// This uses a nonstandard refcount convention.\n// The result has refcount 0.\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_Concat_fn\n       : public binary_function<rope<_CharT,_Alloc>, rope<_CharT,_Alloc>,\n                                     rope<_CharT,_Alloc> > {\n        rope<_CharT,_Alloc> operator() (const rope<_CharT,_Alloc>& __x,\n                                const rope<_CharT,_Alloc>& __y) {\n                    return __x + __y;\n        }\n};\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>\nidentity_element(_Rope_Concat_fn<_CharT, _Alloc>)\n{\n    return rope<_CharT,_Alloc>();\n}\n\n\n//\n// What follows should really be local to rope.  Unfortunately,\n// that doesn't work, since it makes it impossible to define generic\n// equality on rope iterators.  According to the draft standard, the\n// template parameters for such an equality operator cannot be inferred\n// from the occurence of a member class as a parameter.\n// (SGI compilers in fact allow this, but the __result wouldn't be\n// portable.)\n// Similarly, some of the static member functions are member functions\n// only to avoid polluting the global namespace, and to circumvent\n// restrictions on type inference for template functions.\n//\n\n//\n// The internal data structure for representing a rope.  This is\n// private to the implementation.  A rope is really just a pointer\n// to one of these.\n//\n// A few basic functions for manipulating this data structure\n// are members of _RopeRep.  Most of the more complex algorithms\n// are implemented as rope members.\n//\n// Some of the static member functions of _RopeRep have identically\n// named functions in rope that simply invoke the _RopeRep versions.\n//\n// A macro to introduce various allocation and deallocation functions\n// These need to be defined differently depending on whether or not\n// we are using standard conforming allocators, and whether the allocator\n// instances have real state.  Thus this macro is invoked repeatedly\n// with different definitions of __ROPE_DEFINE_ALLOC.\n// __ROPE_DEFINE_ALLOC(type,name) defines \n//   type * name_allocate(size_t) and\n//   void name_deallocate(tipe *, size_t)\n// Both functions may or may not be static.\n\n#define __ROPE_DEFINE_ALLOCS(__a) \\\n        __ROPE_DEFINE_ALLOC(_CharT,_Data) /* character data */ \\\n        typedef _Rope_RopeConcatenation<_CharT,__a> __C; \\\n        __ROPE_DEFINE_ALLOC(__C,_C) \\\n        typedef _Rope_RopeLeaf<_CharT,__a> __L; \\\n        __ROPE_DEFINE_ALLOC(__L,_L) \\\n        typedef _Rope_RopeFunction<_CharT,__a> __F; \\\n        __ROPE_DEFINE_ALLOC(__F,_F) \\\n        typedef _Rope_RopeSubstring<_CharT,__a> __S; \\\n        __ROPE_DEFINE_ALLOC(__S,_S)\n\n//  Internal rope nodes potentially store a copy of the allocator\n//  instance used to allocate them.  This is mostly redundant.\n//  But the alternative would be to pass allocator instances around\n//  in some form to nearly all internal functions, since any pointer\n//  assignment may result in a zero reference count and thus require\n//  deallocation.\n//  The _Rope_rep_base class encapsulates\n//  the differences between SGI-style allocators and standard-conforming\n//  allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n#define __STATIC_IF_SGI_ALLOC  /* not static */\n\n// Base class for ordinary allocators.\ntemplate <class _CharT, class _Allocator, bool _IsStatic>\nclass _Rope_rep_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _M_data_allocator; }\n  _Rope_rep_alloc_base(size_t __size, const allocator_type& __a)\n        : _M_size(__size), _M_data_allocator(__a) {}\n  size_t _M_size;       // This is here only to avoid wasting space\n                // for an otherwise empty base class.\n\n  \nprotected:\n    allocator_type _M_data_allocator;\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \\\n        /*static*/ _Tp * __name##_allocate(size_t __n) \\\n          { return __name##Allocator(_M_data_allocator).allocate(__n); } \\\n        void __name##_deallocate(_Tp* __p, size_t __n) \\\n          { __name##Allocator(_M_data_allocator).deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Allocator);\n# undef __ROPE_DEFINE_ALLOC\n};\n\n// Specialization for allocators that have the property that we don't\n//  actually have to store an allocator object.  \ntemplate <class _CharT, class _Allocator>\nclass _Rope_rep_alloc_base<_CharT,_Allocator,true> {\npublic:\n  typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n  _Rope_rep_alloc_base(size_t __size, const allocator_type&)\n                : _M_size(__size) {}\n  size_t _M_size;\n  \nprotected:\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::_Alloc_type __name##Alloc; \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \\\n        static _Tp* __name##_allocate(size_t __n) \\\n                { return __name##Alloc::allocate(__n); } \\\n        void __name##_deallocate(_Tp *__p, size_t __n) \\\n                { __name##Alloc::deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Allocator);\n# undef __ROPE_DEFINE_ALLOC\n};\n\ntemplate <class _CharT, class _Alloc>\nstruct _Rope_rep_base\n  : public _Rope_rep_alloc_base<_CharT,_Alloc,\n                                _Alloc_traits<_CharT,_Alloc>::_S_instanceless>\n{\n  typedef _Rope_rep_alloc_base<_CharT,_Alloc,\n                               _Alloc_traits<_CharT,_Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n  _Rope_rep_base(size_t __size, const allocator_type& __a)\n    : _Base(__size, __a) {}\n};    \n\n#else /* !__STL_USE_STD_ALLOCATORS */\n\n#define __STATIC_IF_SGI_ALLOC static\n\ntemplate <class _CharT, class _Alloc> \nclass _Rope_rep_base {\npublic:\n  typedef _Alloc allocator_type;\n  static allocator_type get_allocator() { return allocator_type(); }\n  _Rope_rep_base(size_t __size, const allocator_type&) : _M_size(__size) {}\n  size_t _M_size;\n\nprotected:\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef simple_alloc<_Tp, _Alloc> __name##Alloc; \\\n        static _Tp* __name##_allocate(size_t __n) \\\n                { return __name##Alloc::allocate(__n); } \\\n        static void __name##_deallocate(_Tp* __p, size_t __n) \\\n                { __name##Alloc::deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Alloc);\n# undef __ROPE_DEFINE_ALLOC\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_RopeRep : public _Rope_rep_base<_CharT,_Alloc>\n# ifndef __GC\n    , _Refcount_Base\n# endif\n{\n    public:\n    enum { _S_max_rope_depth = 45 };\n    enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function};\n    _Tag _M_tag:8;\n    bool _M_is_balanced:8;\n    unsigned char _M_depth;\n    __GC_CONST _CharT* _M_c_string;\n                        /* Flattened version of string, if needed.  */\n                        /* typically 0.                             */\n                        /* If it's not 0, then the memory is owned  */\n                        /* by this node.                            */\n                        /* In the case of a leaf, this may point to */\n                        /* the same memory as the data field.       */\n    typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type\n                        allocator_type;\n    _Rope_RopeRep(_Tag __t, int __d, bool __b, size_t __size,\n                  allocator_type __a)\n        : _Rope_rep_base<_CharT,_Alloc>(__size, __a),\n#         ifndef __GC\n          _Refcount_Base(1),\n#         endif\n          _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)\n    { }\n#   ifdef __GC\n        void _M_incr () {}\n#   endif\n#   ifdef __STL_USE_STD_ALLOCATORS\n        static void _S_free_string(__GC_CONST _CharT*, size_t __len,\n                                   allocator_type __a);\n#       define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a);\n#   else\n        static void _S_free_string(__GC_CONST _CharT*, size_t __len);\n#       define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l);\n#   endif\n                        // Deallocate data section of a leaf.\n                        // This shouldn't be a member function.\n                        // But its hard to do anything else at the\n                        // moment, because it's templatized w.r.t.\n                        // an allocator.\n                        // Does nothing if __GC is defined.\n#   ifndef __GC\n          void _M_free_c_string();\n          void _M_free_tree();\n                        // Deallocate t. Assumes t is not 0.\n          void _M_unref_nonnil()\n          {\n              if (0 == _M_decr()) _M_free_tree();\n          }\n          void _M_ref_nonnil()\n          {\n              _M_incr();\n          }\n          static void _S_unref(_Rope_RopeRep* __t)\n          {\n              if (0 != __t) {\n                  __t->_M_unref_nonnil();\n              }\n          }\n          static void _S_ref(_Rope_RopeRep* __t)\n          {\n              if (0 != __t) __t->_M_incr();\n          }\n          static void _S_free_if_unref(_Rope_RopeRep* __t)\n          {\n              if (0 != __t && 0 == __t->_M_ref_count) __t->_M_free_tree();\n          }\n#   else /* __GC */\n          void _M_unref_nonnil() {}\n          void _M_ref_nonnil() {}\n          static void _S_unref(_Rope_RopeRep*) {}\n          static void _S_ref(_Rope_RopeRep*) {}\n          static void _S_free_if_unref(_Rope_RopeRep*) {}\n#   endif\n\n};\n\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> {\n  public:\n    // Apparently needed by VC++\n    // The data fields of leaves are allocated with some\n    // extra space, to accomodate future growth and for basic\n    // character types, to hold a trailing eos character.\n    enum { _S_alloc_granularity = 8 };\n    static size_t _S_rounded_up_size(size_t __n) {\n        size_t __size_with_eos;\n             \n        if (_S_is_basic_char_type((_CharT*)0)) {\n            __size_with_eos = __n + 1;\n        } else {\n            __size_with_eos = __n;\n        }\n#       ifdef __GC\n           return __size_with_eos;\n#       else\n           // Allow slop for in-place expansion.\n           return (__size_with_eos + _S_alloc_granularity-1)\n                        &~ (_S_alloc_granularity-1);\n#       endif\n    }\n    __GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */\n                                /* The allocated size is         */\n                                /* _S_rounded_up_size(size), except */\n                                /* in the GC case, in which it   */\n                                /* doesn't matter.               */\n    typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type\n                        allocator_type;\n    _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size, allocator_type __a)\n        : _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a),\n          _M_data(__d)\n        {\n        __stl_assert(__size > 0);\n        if (_S_is_basic_char_type((_CharT *)0)) {\n            // already eos terminated.\n            _M_c_string = __d;\n        }\n    }\n        // The constructor assumes that d has been allocated with\n        // the proper allocator and the properly padded size.\n        // In contrast, the destructor deallocates the data:\n# ifndef __GC\n    ~_Rope_RopeLeaf() {\n        if (_M_data != _M_c_string) {\n            _M_free_c_string();\n        }\n        __STL_FREE_STRING(_M_data, _M_size, get_allocator());\n    }\n# endif\n};\n\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> {\n  public:\n    _Rope_RopeRep<_CharT,_Alloc>* _M_left;\n    _Rope_RopeRep<_CharT,_Alloc>* _M_right;\n    typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type\n                        allocator_type;\n    _Rope_RopeConcatenation(_Rope_RopeRep<_CharT,_Alloc>* __l,\n                             _Rope_RopeRep<_CharT,_Alloc>* __r,\n                             allocator_type __a)\n\n      : _Rope_RopeRep<_CharT,_Alloc>(_S_concat,\n                                     max(__l->_M_depth, __r->_M_depth) + 1,\n                                     false,\n                                     __l->_M_size + __r->_M_size, __a),\n        _M_left(__l), _M_right(__r)\n      {}\n# ifndef __GC\n    ~_Rope_RopeConcatenation() {\n        _M_free_c_string();\n        _M_left->_M_unref_nonnil();\n        _M_right->_M_unref_nonnil();\n    }\n# endif\n};\n\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> {\n  public:\n    char_producer<_CharT>* _M_fn;\n#   ifndef __GC\n      bool _M_delete_when_done; // Char_producer is owned by the\n                                // rope and should be explicitly\n                                // deleted when the rope becomes\n                                // inaccessible.\n#   else\n      // In the GC case, we either register the rope for\n      // finalization, or not.  Thus the field is unnecessary;\n      // the information is stored in the collector data structures.\n      // We do need a finalization procedure to be invoked by the\n      // collector.\n      static void _S_fn_finalization_proc(void * __tree, void *) {\n        delete ((_Rope_RopeFunction *)__tree) -> _M_fn;\n      }\n#   endif\n    typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type\n                                        allocator_type;\n    _Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size,\n                        bool __d, allocator_type __a)\n      : _Rope_RopeRep<_CharT,_Alloc>(_S_function, 0, true, __size, __a)\n      , _M_fn(__f)\n#       ifndef __GC\n      , _M_delete_when_done(__d)\n#       endif\n    {\n        __stl_assert(__size > 0);\n#       ifdef __GC\n            if (__d) {\n                GC_REGISTER_FINALIZER(\n                  this, _Rope_RopeFunction::_S_fn_finalization_proc, 0, 0, 0);\n            }\n#       endif\n    }\n# ifndef __GC\n    ~_Rope_RopeFunction() {\n          _M_free_c_string();\n          if (_M_delete_when_done) {\n              delete _M_fn;\n          }\n    }\n# endif\n};\n// Substring results are usually represented using just\n// concatenation nodes.  But in the case of very long flat ropes\n// or ropes with a functional representation that isn't practical.\n// In that case, we represent the __result as a special case of\n// RopeFunction, whose char_producer points back to the rope itself.\n// In all cases except repeated substring operations and\n// deallocation, we treat the __result as a RopeFunction.\ntemplate<class _CharT, class _Alloc>\nstruct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,\n                             public char_producer<_CharT> {\n  public:\n    // XXX this whole class should be rewritten.\n    _Rope_RopeRep<_CharT,_Alloc>* _M_base;      // not 0\n    size_t _M_start;\n    virtual void operator()(size_t __start_pos, size_t __req_len,\n                            _CharT* __buffer) {\n        switch(_M_base->_M_tag) {\n            case _S_function:\n            case _S_substringfn:\n              {\n                char_producer<_CharT>* __fn =\n                        ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;\n                __stl_assert(__start_pos + __req_len <= _M_size);\n                __stl_assert(_M_start + _M_size <= _M_base->_M_size);\n                (*__fn)(__start_pos + _M_start, __req_len, __buffer);\n              }\n              break;\n            case _S_leaf:\n              {\n                __GC_CONST _CharT* __s =\n                        ((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data;\n                uninitialized_copy_n(__s + __start_pos + _M_start, __req_len,\n                                     __buffer);\n              }\n              break;\n            default:\n              __stl_assert(false);\n        }\n    }\n    typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type\n        allocator_type;\n    _Rope_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,\n                          size_t __l, allocator_type __a)\n      : _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a),\n        char_producer<_CharT>(),\n        _M_base(__b),\n        _M_start(__s)\n    {\n        __stl_assert(__l > 0);\n        __stl_assert(__s + __l <= __b->_M_size);\n#       ifndef __GC\n            _M_base->_M_ref_nonnil();\n#       endif\n        _M_tag = _S_substringfn;\n    }\n    virtual ~_Rope_RopeSubstring()\n      { \n#       ifndef __GC\n          _M_base->_M_unref_nonnil();\n          // _M_free_c_string();  -- done by parent class\n#       endif\n      }\n};\n\n\n// Self-destructing pointers to Rope_rep.\n// These are not conventional smart pointers.  Their\n// only purpose in life is to ensure that unref is called\n// on the pointer either at normal exit or if an exception\n// is raised.  It is the caller's responsibility to\n// adjust reference counts when these pointers are initialized\n// or assigned to.  (This convention significantly reduces\n// the number of potentially expensive reference count\n// updates.)\n#ifndef __GC\n  template<class _CharT, class _Alloc>\n  struct _Rope_self_destruct_ptr {\n    _Rope_RopeRep<_CharT,_Alloc>* _M_ptr;\n    ~_Rope_self_destruct_ptr() \n      { _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); }\n#   ifdef __STL_USE_EXCEPTIONS\n        _Rope_self_destruct_ptr() : _M_ptr(0) {};\n#   else\n        _Rope_self_destruct_ptr() {};\n#   endif\n    _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {}\n    _Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; }\n    _Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; }\n    operator _Rope_RopeRep<_CharT,_Alloc>*() { return _M_ptr; }\n    _Rope_self_destruct_ptr& operator= (_Rope_RopeRep<_CharT,_Alloc>* __x)\n        { _M_ptr = __x; return *this; }\n  };\n#endif\n\n// Dereferencing a nonconst iterator has to return something\n// that behaves almost like a reference.  It's not possible to\n// return an actual reference since assignment requires extra\n// work.  And we would get into the same problems as with the\n// CD2 version of basic_string.\ntemplate<class _CharT, class _Alloc>\nclass _Rope_char_ref_proxy {\n    friend class rope<_CharT,_Alloc>;\n    friend class _Rope_iterator<_CharT,_Alloc>;\n    friend class _Rope_char_ptr_proxy<_CharT,_Alloc>;\n#   ifdef __GC\n        typedef _Rope_RopeRep<_CharT,_Alloc>* _Self_destruct_ptr;\n#   else\n        typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr;\n#   endif\n    typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;\n    typedef rope<_CharT,_Alloc> _My_rope;\n    size_t _M_pos;\n    _CharT _M_current;\n    bool _M_current_valid;\n    _My_rope* _M_root;     // The whole rope.\n  public:\n    _Rope_char_ref_proxy(_My_rope* __r, size_t __p)\n      :  _M_pos(__p), _M_current_valid(false), _M_root(__r) {}\n    _Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x)\n      : _M_pos(__x._M_pos), _M_current_valid(false), _M_root(__x._M_root) {}\n        // Don't preserve cache if the reference can outlive the\n        // expression.  We claim that's not possible without calling\n        // a copy constructor or generating reference to a proxy\n        // reference.  We declare the latter to have undefined semantics.\n    _Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c)\n      : _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) {}\n    inline operator _CharT () const;\n    _Rope_char_ref_proxy& operator= (_CharT __c);\n    _Rope_char_ptr_proxy<_CharT,_Alloc> operator& () const;\n    _Rope_char_ref_proxy& operator= (const _Rope_char_ref_proxy& __c) {\n        return operator=((_CharT)__c); \n    }\n};\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n    template<class _CharT, class __Alloc>\n    inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a,\n                     _Rope_char_ref_proxy <_CharT, __Alloc > __b) {\n        _CharT __tmp = __a;\n        __a = __b;\n        __b = __tmp;\n    }\n#else\n// There is no really acceptable way to handle this.  The default\n// definition of swap doesn't work for proxy references.\n// It can't really be made to work, even with ugly hacks, since\n// the only unusual operation it uses is the copy constructor, which\n// is needed for other purposes.  We provide a macro for\n// full specializations, and instantiate the most common case.\n# define _ROPE_SWAP_SPECIALIZATION(_CharT, __Alloc) \\\n    inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, \\\n                     _Rope_char_ref_proxy <_CharT, __Alloc > __b) { \\\n        _CharT __tmp = __a; \\\n        __a = __b; \\\n        __b = __tmp; \\\n    }\n\n_ROPE_SWAP_SPECIALIZATION(char,__STL_DEFAULT_ALLOCATOR(char))\n\n#endif /* !__STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate<class _CharT, class _Alloc>\nclass _Rope_char_ptr_proxy {\n    // XXX this class should be rewritten.\n    friend class _Rope_char_ref_proxy<_CharT,_Alloc>;\n    size_t _M_pos;\n    rope<_CharT,_Alloc>* _M_root;     // The whole rope.\n  public:\n    _Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x) \n      : _M_pos(__x._M_pos), _M_root(__x._M_root) {}\n    _Rope_char_ptr_proxy(const _Rope_char_ptr_proxy& __x)\n      : _M_pos(__x._M_pos), _M_root(__x._M_root) {}\n    _Rope_char_ptr_proxy() {}\n    _Rope_char_ptr_proxy(_CharT* __x) : _M_root(0), _M_pos(0) {\n        __stl_assert(0 == __x);\n    }\n    _Rope_char_ptr_proxy& \n    operator= (const _Rope_char_ptr_proxy& __x) {\n        _M_pos = __x._M_pos;\n        _M_root = __x._M_root;\n        return *this;\n    }\n#ifdef __STL_MEMBER_TEMPLATES\n    template<class _CharT2, class _Alloc2>\n    friend bool operator== (const _Rope_char_ptr_proxy<_CharT2,_Alloc2>& __x,\n                            const _Rope_char_ptr_proxy<_CharT2,_Alloc2>& __y);\n#else\n    friend bool operator==  __STL_NULL_TMPL_ARGS\n                (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,\n                 const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y);\n#endif\n    _Rope_char_ref_proxy<_CharT,_Alloc> operator*() const {\n        return _Rope_char_ref_proxy<_CharT,_Alloc>(_M_root, _M_pos);\n    }\n};\n\n\n// Rope iterators:\n// Unlike in the C version, we cache only part of the stack\n// for rope iterators, since they must be efficiently copyable.\n// When we run out of cache, we have to reconstruct the iterator\n// value.\n// Pointers from iterators are not included in reference counts.\n// Iterators are assumed to be thread private.  Ropes can\n// be shared.\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1375\n#endif\n\ntemplate<class _CharT, class _Alloc>\nclass _Rope_iterator_base\n  : public random_access_iterator<_CharT, ptrdiff_t> {\n    friend class rope<_CharT,_Alloc>;\n  public:\n    typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround\n    typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;\n        // Borland doesnt want this to be protected.\n  protected:\n    enum { _S_path_cache_len = 4 }; // Must be <= 9.\n    enum { _S_iterator_buf_len = 15 };\n    size_t _M_current_pos;\n    _RopeRep* _M_root;     // The whole rope.\n    size_t _M_leaf_pos;    // Starting position for current leaf\n    __GC_CONST _CharT* _M_buf_start;\n                        // Buffer possibly\n                        // containing current char.\n    __GC_CONST _CharT* _M_buf_ptr;\n                        // Pointer to current char in buffer.\n                        // != 0 ==> buffer valid.\n    __GC_CONST _CharT* _M_buf_end;\n                        // One past __last valid char in buffer.\n    // What follows is the path cache.  We go out of our\n    // way to make this compact.\n    // Path_end contains the bottom section of the path from\n    // the root to the current leaf.\n    const _RopeRep* _M_path_end[_S_path_cache_len];\n    int _M_leaf_index;     // Last valid __pos in path_end;\n                        // _M_path_end[0] ... _M_path_end[leaf_index-1]\n                        // point to concatenation nodes.\n    unsigned char _M_path_directions;\n                          // (path_directions >> __i) & 1 is 1\n                          // iff we got from _M_path_end[leaf_index - __i - 1]\n                          // to _M_path_end[leaf_index - __i] by going to the\n                          // __right. Assumes path_cache_len <= 9.\n    _CharT _M_tmp_buf[_S_iterator_buf_len];\n                        // Short buffer for surrounding chars.\n                        // This is useful primarily for \n                        // RopeFunctions.  We put the buffer\n                        // here to avoid locking in the\n                        // multithreaded case.\n    // The cached path is generally assumed to be valid\n    // only if the buffer is valid.\n    static void _S_setbuf(_Rope_iterator_base& __x);\n                                        // Set buffer contents given\n                                        // path cache.\n    static void _S_setcache(_Rope_iterator_base& __x);\n                                        // Set buffer contents and\n                                        // path cache.\n    static void _S_setcache_for_incr(_Rope_iterator_base& __x);\n                                        // As above, but assumes path\n                                        // cache is valid for previous posn.\n    _Rope_iterator_base() {}\n    _Rope_iterator_base(_RopeRep* __root, size_t __pos)\n      : _M_current_pos(__pos), _M_root(__root), _M_buf_ptr(0) {}\n    void _M_incr(size_t __n);\n    void _M_decr(size_t __n);\n  public:\n    size_t index() const { return _M_current_pos; }\n    _Rope_iterator_base(const _Rope_iterator_base& __x) {\n        if (0 != __x._M_buf_ptr) {\n            *this = __x;\n        } else {\n            _M_current_pos = __x._M_current_pos;\n            _M_root = __x._M_root;\n            _M_buf_ptr = 0;\n        }\n    }\n};\n\ntemplate<class _CharT, class _Alloc> class _Rope_iterator;\n\ntemplate<class _CharT, class _Alloc>\nclass _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> {\n    friend class rope<_CharT,_Alloc>;\n  protected:\n#   ifdef __STL_HAS_NAMESPACES\n      typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;\n      // The one from the base class may not be directly visible.\n#   endif\n    _Rope_const_iterator(const _RopeRep* __root, size_t __pos):\n                   _Rope_iterator_base<_CharT,_Alloc>(\n                     const_cast<_RopeRep*>(__root), __pos)\n                   // Only nonconst iterators modify root ref count\n    {}\n  public:\n    typedef _CharT reference;   // Really a value.  Returning a reference\n                                // Would be a mess, since it would have\n                                // to be included in refcount.\n    typedef const _CharT* pointer;\n\n  public:\n    _Rope_const_iterator() {};\n    _Rope_const_iterator(const _Rope_const_iterator& __x) :\n                                _Rope_iterator_base<_CharT,_Alloc>(__x) { }\n    _Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x);\n    _Rope_const_iterator(const rope<_CharT,_Alloc>& __r, size_t __pos) :\n        _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) {}\n    _Rope_const_iterator& operator= (const _Rope_const_iterator& __x) {\n        if (0 != __x._M_buf_ptr) {\n            *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x;\n        } else {\n            _M_current_pos = __x._M_current_pos;\n            _M_root = __x._M_root;\n            _M_buf_ptr = 0;\n        }\n        return(*this);\n    }\n    reference operator*() {\n        if (0 == _M_buf_ptr) _S_setcache(*this);\n        return *_M_buf_ptr;\n    }\n    _Rope_const_iterator& operator++() {\n        __GC_CONST _CharT* __next;\n        if (0 != _M_buf_ptr && (__next = _M_buf_ptr + 1) < _M_buf_end) {\n            _M_buf_ptr = __next;\n            ++_M_current_pos;\n        } else {\n            _M_incr(1);\n        }\n        return *this;\n    }\n    _Rope_const_iterator& operator+=(ptrdiff_t __n) {\n        if (__n >= 0) {\n            _M_incr(__n);\n        } else {\n            _M_decr(-__n);\n        }\n        return *this;\n    }\n    _Rope_const_iterator& operator--() {\n        _M_decr(1);\n        return *this;\n    }\n    _Rope_const_iterator& operator-=(ptrdiff_t __n) {\n        if (__n >= 0) {\n            _M_decr(__n);\n        } else {\n            _M_incr(-__n);\n        }\n        return *this;\n    }\n    _Rope_const_iterator operator++(int) {\n        size_t __old_pos = _M_current_pos;\n        _M_incr(1);\n        return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos);\n        // This makes a subsequent dereference expensive.\n        // Perhaps we should instead copy the iterator\n        // if it has a valid cache?\n    }\n    _Rope_const_iterator operator--(int) {\n        size_t __old_pos = _M_current_pos;\n        _M_decr(1);\n        return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos);\n    }\n#if defined(__STL_MEMBER_TEMPLATES) && defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER)\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_const_iterator<_CharT2,_Alloc2> operator-\n        (const _Rope_const_iterator<_CharT2,_Alloc2>& __x,\n         ptrdiff_t __n);\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_const_iterator<_CharT2,_Alloc2> operator+\n        (const _Rope_const_iterator<_CharT2,_Alloc2>& __x,\n         ptrdiff_t __n);\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_const_iterator<_CharT2,_Alloc2> operator+\n        (ptrdiff_t __n,\n         const _Rope_const_iterator<_CharT2,_Alloc2>& __x);\n#else\n    friend _Rope_const_iterator<_CharT,_Alloc> operator- __STL_NULL_TMPL_ARGS\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n    friend _Rope_const_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n    friend _Rope_const_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS\n        (ptrdiff_t __n,\n         const _Rope_const_iterator<_CharT,_Alloc>& __x);\n#endif\n\n    reference operator[](size_t __n) {\n        return rope<_CharT,_Alloc>::_S_fetch(_M_root, _M_current_pos + __n);\n    }\n\n#if defined(__STL_MEMBER_TEMPLATES) && defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER)\n    template<class _CharT2, class _Alloc2>\n    friend bool operator==\n        (const _Rope_const_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_const_iterator<_CharT2,_Alloc2>& __y);\n    template<class _CharT2, class _Alloc2>\n    friend bool operator< \n        (const _Rope_const_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_const_iterator<_CharT2,_Alloc2>& __y);\n    template<class _CharT2, class _Alloc2>\n    friend ptrdiff_t operator-\n        (const _Rope_const_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_const_iterator<_CharT2,_Alloc2>& __y);\n#else\n    friend bool operator== __STL_NULL_TMPL_ARGS\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n    friend bool operator< __STL_NULL_TMPL_ARGS\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n    friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS\n        (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n         const _Rope_const_iterator<_CharT,_Alloc>& __y);\n#endif\n};\n\ntemplate<class _CharT, class _Alloc>\nclass _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> {\n    friend class rope<_CharT,_Alloc>;\n  protected:\n    rope<_CharT,_Alloc>* _M_root_rope;\n        // root is treated as a cached version of this,\n        // and is used to detect changes to the underlying\n        // rope.\n        // Root is included in the reference count.\n        // This is necessary so that we can detect changes reliably.\n        // Unfortunately, it requires careful bookkeeping for the\n        // nonGC case.\n    _Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos)\n      : _Rope_iterator_base<_CharT,_Alloc>(__r->_M_tree_ptr, __pos),\n        _M_root_rope(__r) \n       { _RopeRep::_S_ref(_M_root); if (!(__r -> empty()))_S_setcache(*this); }\n\n    void _M_check();\n  public:\n    typedef _Rope_char_ref_proxy<_CharT,_Alloc>  reference;\n    typedef _Rope_char_ref_proxy<_CharT,_Alloc>* pointer;\n\n  public:\n    rope<_CharT,_Alloc>& container() { return *_M_root_rope; }\n    _Rope_iterator() {\n        _M_root = 0;  // Needed for reference counting.\n    };\n    _Rope_iterator(const _Rope_iterator& __x) :\n        _Rope_iterator_base<_CharT,_Alloc>(__x) {\n        _M_root_rope = __x._M_root_rope;\n        _RopeRep::_S_ref(_M_root);\n    }\n    _Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos);\n    ~_Rope_iterator() {\n        _RopeRep::_S_unref(_M_root);\n    }\n    _Rope_iterator& operator= (const _Rope_iterator& __x) {\n        _RopeRep* __old = _M_root;\n\n        _RopeRep::_S_ref(__x._M_root);\n        if (0 != __x._M_buf_ptr) {\n            _M_root_rope = __x._M_root_rope;\n            *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x;\n        } else {\n            _M_current_pos = __x._M_current_pos;\n            _M_root = __x._M_root;\n            _M_root_rope = __x._M_root_rope;\n            _M_buf_ptr = 0;\n        }\n        _RopeRep::_S_unref(__old);\n        return(*this);\n    }\n    reference operator*() {\n        _M_check();\n        if (0 == _M_buf_ptr) {\n            return _Rope_char_ref_proxy<_CharT,_Alloc>(\n               _M_root_rope, _M_current_pos);\n        } else {\n            return _Rope_char_ref_proxy<_CharT,_Alloc>(\n               _M_root_rope, _M_current_pos, *_M_buf_ptr);\n        }\n    }\n    _Rope_iterator& operator++() {\n        _M_incr(1);\n        return *this;\n    }\n    _Rope_iterator& operator+=(ptrdiff_t __n) {\n        if (__n >= 0) {\n            _M_incr(__n);\n        } else {\n            _M_decr(-__n);\n        }\n        return *this;\n    }\n    _Rope_iterator& operator--() {\n        _M_decr(1);\n        return *this;\n    }\n    _Rope_iterator& operator-=(ptrdiff_t __n) {\n        if (__n >= 0) {\n            _M_decr(__n);\n        } else {\n            _M_incr(-__n);\n        }\n        return *this;\n    }\n    _Rope_iterator operator++(int) {\n        size_t __old_pos = _M_current_pos;\n        _M_incr(1);\n        return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);\n    }\n    _Rope_iterator operator--(int) {\n        size_t __old_pos = _M_current_pos;\n        _M_decr(1);\n        return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);\n    }\n    reference operator[](ptrdiff_t __n) {\n        return _Rope_char_ref_proxy<_CharT,_Alloc>(\n          _M_root_rope, _M_current_pos + __n);\n    }\n\n#if defined(__STL_MEMBER_TEMPLATES) && defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER)\n    template<class _CharT2, class _Alloc2>\n    friend bool operator==\n        (const _Rope_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_iterator<_CharT2,_Alloc2>& __y);\n    template<class _CharT2, class _Alloc2>\n    friend bool operator<\n        (const _Rope_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_iterator<_CharT2,_Alloc2>& __y);\n    template<class _CharT2, class _Alloc2>\n    friend ptrdiff_t operator-\n        (const _Rope_iterator<_CharT2,_Alloc2>& __x,\n         const _Rope_iterator<_CharT2,_Alloc2>& __y);\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_iterator<_CharT2,_Alloc2> operator-\n        (const _Rope_iterator<_CharT2,_Alloc2>& __x,\n         ptrdiff_t __n);\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_iterator<_CharT2,_Alloc2> operator+\n        (const _Rope_iterator<_CharT2,_Alloc2>& __x,\n         ptrdiff_t __n);\n    template<class _CharT2, class _Alloc2>\n    friend _Rope_iterator<_CharT2,_Alloc2> operator+\n        (ptrdiff_t __n,\n         const _Rope_iterator<_CharT2,_Alloc2>& __x);\n#else\n    friend bool operator== __STL_NULL_TMPL_ARGS\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n    friend bool operator< __STL_NULL_TMPL_ARGS\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n    friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         const _Rope_iterator<_CharT,_Alloc>& __y);\n    friend _Rope_iterator<_CharT,_Alloc> operator- __STL_NULL_TMPL_ARGS\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n    friend _Rope_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS\n        (const _Rope_iterator<_CharT,_Alloc>& __x,\n         ptrdiff_t __n);\n    friend _Rope_iterator<_CharT,_Alloc> operator+ __STL_NULL_TMPL_ARGS\n        (ptrdiff_t __n,\n         const _Rope_iterator<_CharT,_Alloc>& __x);\n#endif\n};\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1375\n#endif\n\n//  The rope base class encapsulates\n//  the differences between SGI-style allocators and standard-conforming\n//  allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base class for ordinary allocators.\ntemplate <class _CharT, class _Allocator, bool _IsStatic>\nclass _Rope_alloc_base {\npublic:\n  typedef _Rope_RopeRep<_CharT,_Allocator> _RopeRep;\n  typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _M_data_allocator; }\n  _Rope_alloc_base(_RopeRep *__t, const allocator_type& __a)\n        : _M_tree_ptr(__t), _M_data_allocator(__a) {}\n  _Rope_alloc_base(const allocator_type& __a)\n        : _M_data_allocator(__a) {}\n  \nprotected:\n  // The only data members of a rope:\n    allocator_type _M_data_allocator;\n    _RopeRep* _M_tree_ptr;\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \\\n        _Tp* __name##_allocate(size_t __n) const \\\n          { return __name##Allocator(_M_data_allocator).allocate(__n); } \\\n        void __name##_deallocate(_Tp *__p, size_t __n) const \\\n                { __name##Allocator(_M_data_allocator).deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Allocator)\n# undef __ROPE_DEFINE_ALLOC\n};\n\n// Specialization for allocators that have the property that we don't\n//  actually have to store an allocator object.  \ntemplate <class _CharT, class _Allocator>\nclass _Rope_alloc_base<_CharT,_Allocator,true> {\npublic:\n  typedef _Rope_RopeRep<_CharT,_Allocator> _RopeRep;\n  typedef typename _Alloc_traits<_CharT,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n  _Rope_alloc_base(_RopeRep *__t, const allocator_type&)\n                : _M_tree_ptr(__t) {}\n  _Rope_alloc_base(const allocator_type&) {}\n  \nprotected:\n  // The only data member of a rope:\n    _RopeRep *_M_tree_ptr;\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::_Alloc_type __name##Alloc; \\\n        typedef typename \\\n          _Alloc_traits<_Tp,_Allocator>::allocator_type __name##Allocator; \\\n        static _Tp* __name##_allocate(size_t __n) \\\n          { return __name##Alloc::allocate(__n); } \\\n        static void __name##_deallocate(_Tp *__p, size_t __n) \\\n          { __name##Alloc::deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Allocator)\n# undef __ROPE_DEFINE_ALLOC\n};\n\ntemplate <class _CharT, class _Alloc>\nstruct _Rope_base \n  : public _Rope_alloc_base<_CharT,_Alloc,\n                            _Alloc_traits<_CharT,_Alloc>::_S_instanceless>\n{\n  typedef _Rope_alloc_base<_CharT,_Alloc,\n                            _Alloc_traits<_CharT,_Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n  typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;\n        // The one in _Base may not be visible due to template rules.\n  _Rope_base(_RopeRep* __t, const allocator_type& __a) : _Base(__t, __a) {}\n  _Rope_base(const allocator_type& __a) : _Base(__a) {}\n};    \n\n#else /* !__STL_USE_STD_ALLOCATORS */\n\ntemplate <class _CharT, class _Alloc> \nclass _Rope_base {\npublic:\n  typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;\n  typedef _Alloc allocator_type;\n  static allocator_type get_allocator() { return allocator_type(); }\n  _Rope_base(_RopeRep * __t, const allocator_type&) : _M_tree_ptr(__t) {}\n  _Rope_base(const allocator_type&) {}\n\nprotected:\n  // The only data member of a rope:\n    _RopeRep* _M_tree_ptr;\n\n# define __ROPE_DEFINE_ALLOC(_Tp, __name) \\\n        typedef simple_alloc<_Tp, _Alloc> __name##Alloc; \\\n        static _Tp* __name##_allocate(size_t __n) \\\n                { return __name##Alloc::allocate(__n); } \\\n        static void __name##_deallocate(_Tp *__p, size_t __n) \\\n                { __name##Alloc::deallocate(__p, __n); }\n  __ROPE_DEFINE_ALLOCS(_Alloc)\n# undef __ROPE_DEFINE_ALLOC\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n\ntemplate <class _CharT, class _Alloc>\nclass rope : public _Rope_base<_CharT,_Alloc> {\n    public:\n        typedef _CharT value_type;\n        typedef ptrdiff_t difference_type;\n        typedef size_t size_type;\n        typedef _CharT const_reference;\n        typedef const _CharT* const_pointer;\n        typedef _Rope_iterator<_CharT,_Alloc> iterator;\n        typedef _Rope_const_iterator<_CharT,_Alloc> const_iterator;\n        typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference;\n        typedef _Rope_char_ptr_proxy<_CharT,_Alloc> pointer;\n\n        friend class _Rope_iterator<_CharT,_Alloc>;\n        friend class _Rope_const_iterator<_CharT,_Alloc>;\n        friend struct _Rope_RopeRep<_CharT,_Alloc>;\n        friend class _Rope_iterator_base<_CharT,_Alloc>;\n        friend class _Rope_char_ptr_proxy<_CharT,_Alloc>;\n        friend class _Rope_char_ref_proxy<_CharT,_Alloc>;\n        friend struct _Rope_RopeSubstring<_CharT,_Alloc>;\n\n    protected:\n        typedef _Rope_base<_CharT,_Alloc> _Base;\n        typedef typename _Base::allocator_type allocator_type;\n#       ifdef __STL_USE_NAMESPACES\n          using _Base::_M_tree_ptr;\n#       endif\n        typedef __GC_CONST _CharT* _Cstrptr;\n\n        static _CharT _S_empty_c_str[1];\n\n        static bool _S_is0(_CharT __c) { return __c == _S_eos((_CharT*)0); }\n        enum { _S_copy_max = 23 };\n                // For strings shorter than _S_copy_max, we copy to\n                // concatenate.\n\n        typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;\n        typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcatenation;\n        typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf;\n        typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction;\n        typedef _Rope_RopeSubstring<_CharT,_Alloc> _RopeSubstring;\n\n        // Retrieve a character at the indicated position.\n        static _CharT _S_fetch(_RopeRep* __r, size_type __pos);\n\n#       ifndef __GC\n            // Obtain a pointer to the character at the indicated position.\n            // The pointer can be used to change the character.\n            // If such a pointer cannot be produced, as is frequently the\n            // case, 0 is returned instead.\n            // (Returns nonzero only if all nodes in the path have a refcount\n            // of 1.)\n            static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos);\n#       endif\n\n        static bool _S_apply_to_pieces(\n                                // should be template parameter\n                                _Rope_char_consumer<_CharT>& __c,\n                                const _RopeRep* __r,\n                                size_t __begin, size_t __end);\n                                // begin and end are assumed to be in range.\n\n#       ifndef __GC\n          static void _S_unref(_RopeRep* __t)\n          {\n              _RopeRep::_S_unref(__t);\n          }\n          static void _S_ref(_RopeRep* __t)\n          {\n              _RopeRep::_S_ref(__t);\n          }\n#       else /* __GC */\n          static void _S_unref(_RopeRep*) {}\n          static void _S_ref(_RopeRep*) {}\n#       endif\n\n\n#       ifdef __GC\n            typedef _Rope_RopeRep<_CharT,_Alloc>* _Self_destruct_ptr;\n#       else\n            typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr;\n#       endif\n\n        // _Result is counted in refcount.\n        static _RopeRep* _S_substring(_RopeRep* __base,\n                                    size_t __start, size_t __endp1);\n\n        static _RopeRep* _S_concat_char_iter(_RopeRep* __r,\n                                          const _CharT* __iter, size_t __slen);\n                // Concatenate rope and char ptr, copying __s.\n                // Should really take an arbitrary iterator.\n                // Result is counted in refcount.\n        static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r,\n                                          const _CharT* __iter, size_t __slen)\n                // As above, but one reference to __r is about to be\n                // destroyed.  Thus the pieces may be recycled if all\n                // relevent reference counts are 1.\n#           ifdef __GC\n                // We can't really do anything since refcounts are unavailable.\n                { return _S_concat_char_iter(__r, __iter, __slen); }\n#           else\n                ;\n#           endif\n\n        static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right);\n                // General concatenation on _RopeRep.  _Result\n                // has refcount of 1.  Adjusts argument refcounts.\n\n   public:\n        void apply_to_pieces( size_t __begin, size_t __end,\n                              _Rope_char_consumer<_CharT>& __c) const {\n            _S_apply_to_pieces(__c, _M_tree_ptr, __begin, __end);\n        }\n\n\n   protected:\n\n        static size_t _S_rounded_up_size(size_t __n) {\n            return _RopeLeaf::_S_rounded_up_size(__n);\n        }\n\n        static size_t _S_allocated_capacity(size_t __n) {\n            if (_S_is_basic_char_type((_CharT*)0)) {\n                return _S_rounded_up_size(__n) - 1;\n            } else {\n                return _S_rounded_up_size(__n);\n            }\n        }\n                \n        // Allocate and construct a RopeLeaf using the supplied allocator\n        // Takes ownership of s instead of copying.\n        static _RopeLeaf* _S_new_RopeLeaf(__GC_CONST _CharT *__s,\n                                          size_t __size, allocator_type __a)\n        {\n#           ifdef __STL_USE_STD_ALLOCATORS\n              _RopeLeaf* __space = _LAllocator(__a).allocate(1);\n#           else\n              _RopeLeaf* __space = _L_allocate(1);\n#           endif\n            return new(__space) _RopeLeaf(__s, __size, __a);\n        }\n\n        static _RopeConcatenation* _S_new_RopeConcatenation(\n                        _RopeRep* __left, _RopeRep* __right,\n                        allocator_type __a)\n        {\n#           ifdef __STL_USE_STD_ALLOCATORS\n              _RopeConcatenation* __space = _CAllocator(__a).allocate(1);\n#           else\n              _RopeConcatenation* __space = _C_allocate(1);\n#           endif\n            return new(__space) _RopeConcatenation(__left, __right, __a);\n        }\n\n        static _RopeFunction* _S_new_RopeFunction(char_producer<_CharT>* __f,\n                size_t __size, bool __d, allocator_type __a)\n        {\n#           ifdef __STL_USE_STD_ALLOCATORS\n              _RopeFunction* __space = _FAllocator(__a).allocate(1);\n#           else\n              _RopeFunction* __space = _F_allocate(1);\n#           endif\n            return new(__space) _RopeFunction(__f, __size, __d, __a);\n        }\n\n        static _RopeSubstring* _S_new_RopeSubstring(\n                _Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,\n                size_t __l, allocator_type __a)\n        {\n#           ifdef __STL_USE_STD_ALLOCATORS\n              _RopeSubstring* __space = _SAllocator(__a).allocate(1);\n#           else\n              _RopeSubstring* __space = _S_allocate(1);\n#           endif\n            return new(__space) _RopeSubstring(__b, __s, __l, __a);\n        }\n\n#       ifdef __STL_USE_STD_ALLOCATORS\n          static\n          _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s,\n                       size_t __size, allocator_type __a)\n#         define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \\\n                _S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a)     \n#       else\n          static\n          _RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr2(const _CharT* __s,\n                                                        size_t __size)\n#         define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \\\n               _S_RopeLeaf_from_unowned_char_ptr2(__s, __size)\n#       endif\n        {\n            if (0 == __size) return 0;\n#           ifdef __STL_USE_STD_ALLOCATORS\n              _CharT* __buf = __a.allocate(_S_rounded_up_size(__size));\n#           else\n              _CharT* __buf = _Data_allocate(_S_rounded_up_size(__size));\n              allocator_type __a = allocator_type();\n#           endif\n\n            uninitialized_copy_n(__s, __size, __buf);\n            _S_cond_store_eos(__buf[__size]);\n            __STL_TRY {\n              return _S_new_RopeLeaf(__buf, __size, __a);\n            }\n            __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, __size, __a))\n        }\n            \n\n        // Concatenation of nonempty strings.\n        // Always builds a concatenation node.\n        // Rebalances if the result is too deep.\n        // Result has refcount 1.\n        // Does not increment left and right ref counts even though\n        // they are referenced.\n        static _RopeRep*\n        _S_tree_concat(_RopeRep* __left, _RopeRep* __right);\n\n        // Concatenation helper functions\n        static _RopeLeaf*\n        _S_leaf_concat_char_iter(_RopeLeaf* __r,\n                                 const _CharT* __iter, size_t __slen);\n                // Concatenate by copying leaf.\n                // should take an arbitrary iterator\n                // result has refcount 1.\n#       ifndef __GC\n          static _RopeLeaf* _S_destr_leaf_concat_char_iter\n                        (_RopeLeaf* __r, const _CharT* __iter, size_t __slen);\n          // A version that potentially clobbers __r if __r->_M_ref_count == 1.\n#       endif\n\n        private:\n\n        static size_t _S_char_ptr_len(const _CharT* __s);\n                        // slightly generalized strlen\n\n        rope(_RopeRep* __t, const allocator_type& __a = allocator_type())\n          : _Base(__t,__a) { }\n\n\n        // Copy __r to the _CharT buffer.\n        // Returns __buffer + __r->_M_size.\n        // Assumes that buffer is uninitialized.\n        static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer);\n\n        // Again, with explicit starting position and length.\n        // Assumes that buffer is uninitialized.\n        static _CharT* _S_flatten(_RopeRep* __r,\n                                  size_t __start, size_t __len,\n                                  _CharT* __buffer);\n\n        static const unsigned long \n          _S_min_len[_RopeRep::_S_max_rope_depth + 1];\n\n        static bool _S_is_balanced(_RopeRep* __r)\n                { return (__r->_M_size >= _S_min_len[__r->_M_depth]); }\n\n        static bool _S_is_almost_balanced(_RopeRep* __r)\n                { return (__r->_M_depth == 0 ||\n                          __r->_M_size >= _S_min_len[__r->_M_depth - 1]); }\n\n        static bool _S_is_roughly_balanced(_RopeRep* __r)\n                { return (__r->_M_depth <= 1 ||\n                          __r->_M_size >= _S_min_len[__r->_M_depth - 2]); }\n\n        // Assumes the result is not empty.\n        static _RopeRep* _S_concat_and_set_balanced(_RopeRep* __left,\n                                                     _RopeRep* __right)\n        {\n            _RopeRep* __result = _S_concat(__left, __right);\n            if (_S_is_balanced(__result)) __result->_M_is_balanced = true;\n            return __result;\n        }\n\n        // The basic rebalancing operation.  Logically copies the\n        // rope.  The result has refcount of 1.  The client will\n        // usually decrement the reference count of __r.\n        // The result is within height 2 of balanced by the above\n        // definition.\n        static _RopeRep* _S_balance(_RopeRep* __r);\n\n        // Add all unbalanced subtrees to the forest of balanceed trees.\n        // Used only by balance.\n        static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest);\n        \n        // Add __r to forest, assuming __r is already balanced.\n        static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest);\n\n        // Print to stdout, exposing structure\n        static void _S_dump(_RopeRep* __r, int __indent = 0);\n\n        // Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp.\n        static int _S_compare(const _RopeRep* __x, const _RopeRep* __y);\n\n   public:\n        bool empty() const { return 0 == _M_tree_ptr; }\n\n        // Comparison member function.  This is public only for those\n        // clients that need a ternary comparison.  Others\n        // should use the comparison operators below.\n        int compare(const rope& __y) const {\n            return _S_compare(_M_tree_ptr, __y._M_tree_ptr);\n        }\n\n        rope(const _CharT* __s, const allocator_type& __a = allocator_type())\n        : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s),\n                                                 __a),__a)\n        { }\n\n        rope(const _CharT* __s, size_t __len,\n             const allocator_type& __a = allocator_type())\n        : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, __a), __a)\n        { }\n\n        // Should perhaps be templatized with respect to the iterator type\n        // and use Sequence_buffer.  (It should perhaps use sequence_buffer\n        // even now.)\n        rope(const _CharT *__s, const _CharT *__e,\n             const allocator_type& __a = allocator_type())\n        : _Base(__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, __a), __a)\n        { }\n\n        rope(const const_iterator& __s, const const_iterator& __e,\n             const allocator_type& __a = allocator_type())\n        : _Base(_S_substring(__s._M_root, __s._M_current_pos,\n                             __e._M_current_pos), __a)\n        { }\n\n        rope(const iterator& __s, const iterator& __e,\n             const allocator_type& __a = allocator_type())\n        : _Base(_S_substring(__s._M_root, __s._M_current_pos,\n                             __e._M_current_pos), __a)\n        { }\n\n        rope(_CharT __c, const allocator_type& __a = allocator_type())\n        : _Base(__a)\n        {\n            _CharT* __buf = _Data_allocate(_S_rounded_up_size(1));\n\n            construct(__buf, __c);\n            __STL_TRY {\n                _M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);\n            }\n            __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, 1, __a))\n        }\n\n        rope(size_t __n, _CharT __c,\n             const allocator_type& __a = allocator_type());\n\n        rope(const allocator_type& __a = allocator_type())\n        : _Base(0, __a) {}\n\n        // Construct a rope from a function that can compute its members\n        rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn,\n             const allocator_type& __a = allocator_type())\n            : _Base(__a)\n        {\n            _M_tree_ptr = (0 == __len) ?\n               0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a);\n        }\n\n        rope(const rope& __x, const allocator_type& __a = allocator_type())\n        : _Base(__x._M_tree_ptr, __a)\n        {\n            _S_ref(_M_tree_ptr);\n        }\n\n        ~rope()\n        {\n            _S_unref(_M_tree_ptr);\n        }\n\n        rope& operator=(const rope& __x)\n        {\n            _RopeRep* __old = _M_tree_ptr;\n#           ifdef __STL_USE_STD_ALLOCATORS\n              __stl_assert(get_allocator() == __x.get_allocator());\n#           endif\n            _M_tree_ptr = __x._M_tree_ptr;\n            _S_ref(_M_tree_ptr);\n            _S_unref(__old);\n            return(*this);\n        }\n\n        void clear()\n        {\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = 0;\n        }\n\n        void push_back(_CharT __x)\n        {\n            _RopeRep* __old = _M_tree_ptr;\n            _M_tree_ptr = _S_destr_concat_char_iter(_M_tree_ptr, &__x, 1);\n            _S_unref(__old);\n        }\n\n        void pop_back()\n        {\n            _RopeRep* __old = _M_tree_ptr;\n            _M_tree_ptr = \n              _S_substring(_M_tree_ptr, 0, _M_tree_ptr->_M_size - 1);\n            _S_unref(__old);\n        }\n\n        _CharT back() const\n        {\n            return _S_fetch(_M_tree_ptr, _M_tree_ptr->_M_size - 1);\n        }\n\n        void push_front(_CharT __x)\n        {\n            _RopeRep* __old = _M_tree_ptr;\n            _RopeRep* __left =\n              __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, get_allocator());\n            __STL_TRY {\n              _M_tree_ptr = _S_concat(__left, _M_tree_ptr);\n              _S_unref(__old);\n              _S_unref(__left);\n            }\n            __STL_UNWIND(_S_unref(__left))\n        }\n\n        void pop_front()\n        {\n            _RopeRep* __old = _M_tree_ptr;\n            _M_tree_ptr = _S_substring(_M_tree_ptr, 1, _M_tree_ptr->_M_size);\n            _S_unref(__old);\n        }\n\n        _CharT front() const\n        {\n            return _S_fetch(_M_tree_ptr, 0);\n        }\n\n        void balance()\n        {\n            _RopeRep* __old = _M_tree_ptr;\n            _M_tree_ptr = _S_balance(_M_tree_ptr);\n            _S_unref(__old);\n        }\n\n        void copy(_CharT* __buffer) const {\n            destroy(__buffer, __buffer + size());\n            _S_flatten(_M_tree_ptr, __buffer);\n        }\n\n        // This is the copy function from the standard, but\n        // with the arguments reordered to make it consistent with the\n        // rest of the interface.\n        // Note that this guaranteed not to compile if the draft standard\n        // order is assumed.\n        size_type copy(size_type __pos, size_type __n, _CharT* __buffer) const \n        {\n            size_t __size = size();\n            size_t __len = (__pos + __n > __size? __size - __pos : __n);\n\n            destroy(__buffer, __buffer + __len);\n            _S_flatten(_M_tree_ptr, __pos, __len, __buffer);\n            return __len;\n        }\n\n        // Print to stdout, exposing structure.  May be useful for\n        // performance debugging.\n        void dump() {\n            _S_dump(_M_tree_ptr);\n        }\n\n        // Convert to 0 terminated string in new allocated memory.\n        // Embedded 0s in the input do not terminate the copy.\n        const _CharT* c_str() const;\n\n        // As above, but lso use the flattened representation as the\n        // the new rope representation.\n        const _CharT* replace_with_c_str();\n\n        // Reclaim memory for the c_str generated flattened string.\n        // Intentionally undocumented, since it's hard to say when this\n        // is safe for multiple threads.\n        void delete_c_str () {\n            if (0 == _M_tree_ptr) return;\n            if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && \n                ((_RopeLeaf*)_M_tree_ptr)->_M_data == \n                      _M_tree_ptr->_M_c_string) {\n                // Representation shared\n                return;\n            }\n#           ifndef __GC\n              _M_tree_ptr->_M_free_c_string();\n#           endif\n            _M_tree_ptr->_M_c_string = 0;\n        }\n\n        _CharT operator[] (size_type __pos) const {\n            return _S_fetch(_M_tree_ptr, __pos);\n        }\n\n        _CharT at(size_type __pos) const {\n           // if (__pos >= size()) throw out_of_range;  // XXX\n           return (*this)[__pos];\n        }\n\n        const_iterator begin() const {\n            return(const_iterator(_M_tree_ptr, 0));\n        }\n\n        // An easy way to get a const iterator from a non-const container.\n        const_iterator const_begin() const {\n            return(const_iterator(_M_tree_ptr, 0));\n        }\n\n        const_iterator end() const {\n            return(const_iterator(_M_tree_ptr, size()));\n        }\n\n        const_iterator const_end() const {\n            return(const_iterator(_M_tree_ptr, size()));\n        }\n\n        size_type size() const { \n            return(0 == _M_tree_ptr? 0 : _M_tree_ptr->_M_size);\n        }\n\n        size_type length() const {\n            return size();\n        }\n\n        size_type max_size() const {\n            return _S_min_len[_RopeRep::_S_max_rope_depth-1] - 1;\n            //  Guarantees that the result can be sufficirntly\n            //  balanced.  Longer ropes will probably still work,\n            //  but it's harder to make guarantees.\n        }\n\n#     ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n        typedef reverse_iterator<const_iterator> const_reverse_iterator;\n#     else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n        typedef reverse_iterator<const_iterator, value_type, const_reference,\n                                 difference_type>  const_reverse_iterator;\n#     endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \n\n        const_reverse_iterator rbegin() const {\n            return const_reverse_iterator(end());\n        }\n\n        const_reverse_iterator const_rbegin() const {\n            return const_reverse_iterator(end());\n        }\n\n        const_reverse_iterator rend() const {\n            return const_reverse_iterator(begin());\n        }\n\n        const_reverse_iterator const_rend() const {\n            return const_reverse_iterator(begin());\n        }\n\n#if defined(__STL_MEMBER_TEMPLATES) && defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER)\n        template<class _CharT2, class _Alloc2>\n        friend rope<_CharT2,_Alloc2>\n        operator+ (const rope<_CharT2,_Alloc2>& __left,\n                   const rope<_CharT2,_Alloc2>& __right);\n        \n        template<class _CharT2, class _Alloc2>\n        friend rope<_CharT2,_Alloc2>\n        operator+ (const rope<_CharT2,_Alloc2>& __left,\n                   const _CharT2* __right);\n        \n        template<class _CharT2, class _Alloc2>\n        friend rope<_CharT2,_Alloc2>\n        operator+ (const rope<_CharT2,_Alloc2>& __left, _CharT2 __right);\n#else\n        friend rope<_CharT,_Alloc> __STD_QUALIFIER\n        operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left,\n                                        const rope<_CharT,_Alloc>& __right);\n        \n        friend rope<_CharT,_Alloc> __STD_QUALIFIER\n        operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left,\n                                        const _CharT* __right);\n        \n        friend rope<_CharT,_Alloc> __STD_QUALIFIER\n        operator+ __STL_NULL_TMPL_ARGS (const rope<_CharT,_Alloc>& __left,\n                                        _CharT __right);\n#endif        \n        // The symmetric cases are intentionally omitted, since they're presumed\n        // to be less common, and we don't handle them as well.\n\n        // The following should really be templatized.\n        // The first argument should be an input iterator or\n        // forward iterator with value_type _CharT.\n        rope& append(const _CharT* __iter, size_t __n) {\n            _RopeRep* __result = \n              _S_destr_concat_char_iter(_M_tree_ptr, __iter, __n);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n            return *this;\n        }\n\n        rope& append(const _CharT* __c_string) {\n            size_t __len = _S_char_ptr_len(__c_string);\n            append(__c_string, __len);\n            return(*this);\n        }\n\n        rope& append(const _CharT* __s, const _CharT* __e) {\n            _RopeRep* __result =\n                _S_destr_concat_char_iter(_M_tree_ptr, __s, __e - __s);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n            return *this;\n        }\n\n        rope& append(const_iterator __s, const_iterator __e) {\n            __stl_assert(__s._M_root == __e._M_root);\n#           ifdef __STL_USE_STD_ALLOCATORS\n                __stl_assert(get_allocator() == __s._M_root->get_allocator());\n#           endif\n            _Self_destruct_ptr __appendee(_S_substring(\n              __s._M_root, __s._M_current_pos, __e._M_current_pos));\n            _RopeRep* __result = \n              _S_concat(_M_tree_ptr, (_RopeRep*)__appendee);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n            return *this;\n        }\n\n        rope& append(_CharT __c) {\n            _RopeRep* __result = \n              _S_destr_concat_char_iter(_M_tree_ptr, &__c, 1);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n            return *this;\n        }\n\n        rope& append() { return append(_CharT()); }  // XXX why?\n\n        rope& append(const rope& __y) {\n#           ifdef __STL_USE_STD_ALLOCATORS\n              __stl_assert(__y.get_allocator() == get_allocator());\n#           endif\n            _RopeRep* __result = _S_concat(_M_tree_ptr, __y._M_tree_ptr);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n            return *this;\n        }\n\n        rope& append(size_t __n, _CharT __c) {\n            rope<_CharT,_Alloc> __last(__n, __c);\n            return append(__last);\n        }\n\n        void swap(rope& __b) {\n#           ifdef __STL_USE_STD_ALLOCATORS\n                __stl_assert(get_allocator() == __b.get_allocator());\n#           endif\n            _RopeRep* __tmp = _M_tree_ptr;\n            _M_tree_ptr = __b._M_tree_ptr;\n            __b._M_tree_ptr = __tmp;\n        }\n\n\n    protected:\n        // Result is included in refcount.\n        static _RopeRep* replace(_RopeRep* __old, size_t __pos1,\n                                  size_t __pos2, _RopeRep* __r) {\n            if (0 == __old) { _S_ref(__r); return __r; }\n            _Self_destruct_ptr __left(\n              _S_substring(__old, 0, __pos1));\n            _Self_destruct_ptr __right(\n              _S_substring(__old, __pos2, __old->_M_size));\n            _RopeRep* __result;\n\n#           ifdef __STL_USE_STD_ALLOCATORS\n                __stl_assert(__old->get_allocator() == __r->get_allocator());\n#           endif\n            if (0 == __r) {\n                __result = _S_concat(__left, __right);\n            } else {\n                _Self_destruct_ptr __left_result(_S_concat(__left, __r));\n                __result = _S_concat(__left_result, __right);\n            }\n            return __result;\n        }\n\n    public:\n        void insert(size_t __p, const rope& __r) {\n            _RopeRep* __result = \n              replace(_M_tree_ptr, __p, __p, __r._M_tree_ptr);\n#           ifdef __STL_USE_STD_ALLOCATORS\n                __stl_assert(get_allocator() == __r.get_allocator());\n#           endif\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n        }\n\n        void insert(size_t __p, size_t __n, _CharT __c) {\n            rope<_CharT,_Alloc> __r(__n,__c);\n            insert(__p, __r);\n        }\n\n        void insert(size_t __p, const _CharT* __i, size_t __n) {\n            _Self_destruct_ptr __left(_S_substring(_M_tree_ptr, 0, __p));\n            _Self_destruct_ptr __right(_S_substring(_M_tree_ptr, __p, size()));\n            _Self_destruct_ptr __left_result(\n              _S_concat_char_iter(__left, __i, __n));\n                // _S_ destr_concat_char_iter should be safe here.\n                // But as it stands it's probably not a win, since __left\n                // is likely to have additional references.\n            _RopeRep* __result = _S_concat(__left_result, __right);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n        }\n\n        void insert(size_t __p, const _CharT* __c_string) {\n            insert(__p, __c_string, _S_char_ptr_len(__c_string));\n        }\n\n        void insert(size_t __p, _CharT __c) {\n            insert(__p, &__c, 1);\n        }\n\n        void insert(size_t __p) {\n            _CharT __c = _CharT();\n            insert(__p, &__c, 1);\n        }\n\n        void insert(size_t __p, const _CharT* __i, const _CharT* __j) {\n            rope __r(__i, __j);\n            insert(__p, __r);\n        }\n\n        void insert(size_t __p, const const_iterator& __i,\n                              const const_iterator& __j) {\n            rope __r(__i, __j);\n            insert(__p, __r);\n        }\n\n        void insert(size_t __p, const iterator& __i,\n                              const iterator& __j) {\n            rope __r(__i, __j);\n            insert(__p, __r);\n        }\n\n        // (position, length) versions of replace operations:\n\n        void replace(size_t __p, size_t __n, const rope& __r) {\n            _RopeRep* __result = \n              replace(_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n        }\n\n        void replace(size_t __p, size_t __n, \n                     const _CharT* __i, size_t __i_len) {\n            rope __r(__i, __i_len);\n            replace(__p, __n, __r);\n        }\n\n        void replace(size_t __p, size_t __n, _CharT __c) {\n            rope __r(__c);\n            replace(__p, __n, __r);\n        }\n\n        void replace(size_t __p, size_t __n, const _CharT* __c_string) {\n            rope __r(__c_string);\n            replace(__p, __n, __r);\n        }\n\n        void replace(size_t __p, size_t __n, \n                     const _CharT* __i, const _CharT* __j) {\n            rope __r(__i, __j);\n            replace(__p, __n, __r);\n        }\n\n        void replace(size_t __p, size_t __n,\n                     const const_iterator& __i, const const_iterator& __j) {\n            rope __r(__i, __j);\n            replace(__p, __n, __r);\n        }\n\n        void replace(size_t __p, size_t __n,\n                     const iterator& __i, const iterator& __j) {\n            rope __r(__i, __j);\n            replace(__p, __n, __r);\n        }\n\n        // Single character variants:\n        void replace(size_t __p, _CharT __c) {\n            iterator __i(this, __p);\n            *__i = __c;\n        }\n\n        void replace(size_t __p, const rope& __r) {\n            replace(__p, 1, __r);\n        }\n\n        void replace(size_t __p, const _CharT* __i, size_t __i_len) {\n            replace(__p, 1, __i, __i_len);\n        }\n\n        void replace(size_t __p, const _CharT* __c_string) {\n            replace(__p, 1, __c_string);\n        }\n\n        void replace(size_t __p, const _CharT* __i, const _CharT* __j) {\n            replace(__p, 1, __i, __j);\n        }\n\n        void replace(size_t __p, const const_iterator& __i,\n                               const const_iterator& __j) {\n            replace(__p, 1, __i, __j);\n        }\n\n        void replace(size_t __p, const iterator& __i,\n                               const iterator& __j) {\n            replace(__p, 1, __i, __j);\n        }\n\n        // Erase, (position, size) variant.\n        void erase(size_t __p, size_t __n) {\n            _RopeRep* __result = replace(_M_tree_ptr, __p, __p + __n, 0);\n            _S_unref(_M_tree_ptr);\n            _M_tree_ptr = __result;\n        }\n\n        // Erase, single character\n        void erase(size_t __p) {\n            erase(__p, __p + 1);\n        }\n\n        // Insert, iterator variants.  \n        iterator insert(const iterator& __p, const rope& __r)\n                { insert(__p.index(), __r); return __p; }\n        iterator insert(const iterator& __p, size_t __n, _CharT __c)\n                { insert(__p.index(), __n, __c); return __p; }\n        iterator insert(const iterator& __p, _CharT __c) \n                { insert(__p.index(), __c); return __p; }\n        iterator insert(const iterator& __p ) \n                { insert(__p.index()); return __p; }\n        iterator insert(const iterator& __p, const _CharT* c_string) \n                { insert(__p.index(), c_string); return __p; }\n        iterator insert(const iterator& __p, const _CharT* __i, size_t __n)\n                { insert(__p.index(), __i, __n); return __p; }\n        iterator insert(const iterator& __p, const _CharT* __i, \n                        const _CharT* __j)\n                { insert(__p.index(), __i, __j);  return __p; }\n        iterator insert(const iterator& __p,\n                        const const_iterator& __i, const const_iterator& __j)\n                { insert(__p.index(), __i, __j); return __p; }\n        iterator insert(const iterator& __p,\n                        const iterator& __i, const iterator& __j)\n                { insert(__p.index(), __i, __j); return __p; }\n\n        // Replace, range variants.\n        void replace(const iterator& __p, const iterator& __q,\n                     const rope& __r)\n                { replace(__p.index(), __q.index() - __p.index(), __r); }\n        void replace(const iterator& __p, const iterator& __q, _CharT __c)\n                { replace(__p.index(), __q.index() - __p.index(), __c); }\n        void replace(const iterator& __p, const iterator& __q,\n                     const _CharT* __c_string)\n                { replace(__p.index(), __q.index() - __p.index(), __c_string); }\n        void replace(const iterator& __p, const iterator& __q,\n                     const _CharT* __i, size_t __n)\n                { replace(__p.index(), __q.index() - __p.index(), __i, __n); }\n        void replace(const iterator& __p, const iterator& __q,\n                     const _CharT* __i, const _CharT* __j)\n                { replace(__p.index(), __q.index() - __p.index(), __i, __j); }\n        void replace(const iterator& __p, const iterator& __q,\n                     const const_iterator& __i, const const_iterator& __j)\n                { replace(__p.index(), __q.index() - __p.index(), __i, __j); }\n        void replace(const iterator& __p, const iterator& __q,\n                     const iterator& __i, const iterator& __j)\n                { replace(__p.index(), __q.index() - __p.index(), __i, __j); }\n\n        // Replace, iterator variants.\n        void replace(const iterator& __p, const rope& __r)\n                { replace(__p.index(), __r); }\n        void replace(const iterator& __p, _CharT __c)\n                { replace(__p.index(), __c); }\n        void replace(const iterator& __p, const _CharT* __c_string)\n                { replace(__p.index(), __c_string); }\n        void replace(const iterator& __p, const _CharT* __i, size_t __n)\n                { replace(__p.index(), __i, __n); }\n        void replace(const iterator& __p, const _CharT* __i, const _CharT* __j)\n                { replace(__p.index(), __i, __j); }\n        void replace(const iterator& __p, const_iterator __i, \n                     const_iterator __j)\n                { replace(__p.index(), __i, __j); }\n        void replace(const iterator& __p, iterator __i, iterator __j)\n                { replace(__p.index(), __i, __j); }\n\n        // Iterator and range variants of erase\n        iterator erase(const iterator& __p, const iterator& __q) {\n            size_t __p_index = __p.index();\n            erase(__p_index, __q.index() - __p_index);\n            return iterator(this, __p_index);\n        }\n        iterator erase(const iterator& __p) {\n            size_t __p_index = __p.index();\n            erase(__p_index, 1);\n            return iterator(this, __p_index);\n        }\n\n        rope substr(size_t __start, size_t __len = 1) const {\n            return rope<_CharT,_Alloc>(\n                        _S_substring(_M_tree_ptr, __start, __start + __len));\n        }\n\n        rope substr(iterator __start, iterator __end) const {\n            return rope<_CharT,_Alloc>(\n                _S_substring(_M_tree_ptr, __start.index(), __end.index()));\n        }\n        \n        rope substr(iterator __start) const {\n            size_t __pos = __start.index();\n            return rope<_CharT,_Alloc>(\n                        _S_substring(_M_tree_ptr, __pos, __pos + 1));\n        }\n        \n        rope substr(const_iterator __start, const_iterator __end) const {\n            // This might eventually take advantage of the cache in the\n            // iterator.\n            return rope<_CharT,_Alloc>(\n              _S_substring(_M_tree_ptr, __start.index(), __end.index()));\n        }\n\n        rope<_CharT,_Alloc> substr(const_iterator __start) {\n            size_t __pos = __start.index();\n            return rope<_CharT,_Alloc>(\n              _S_substring(_M_tree_ptr, __pos, __pos + 1));\n        }\n\n        static const size_type npos;\n\n        size_type find(_CharT __c, size_type __pos = 0) const;\n        size_type find(const _CharT* __s, size_type __pos = 0) const {\n            size_type __result_pos;\n            const_iterator __result = search(const_begin() + __pos, const_end(),\n                                           __s, __s + _S_char_ptr_len(__s));\n            __result_pos = __result.index();\n#           ifndef __STL_OLD_ROPE_SEMANTICS\n                if (__result_pos == size()) __result_pos = npos;\n#           endif\n            return __result_pos;\n        }\n\n        iterator mutable_begin() {\n            return(iterator(this, 0));\n        }\n\n        iterator mutable_end() {\n            return(iterator(this, size()));\n        }\n\n#     ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n        typedef reverse_iterator<iterator> reverse_iterator;\n#     else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n        typedef reverse_iterator<iterator, value_type, reference,\n                                 difference_type>  reverse_iterator;\n#     endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \n\n        reverse_iterator mutable_rbegin() {\n            return reverse_iterator(mutable_end());\n        }\n\n        reverse_iterator mutable_rend() {\n            return reverse_iterator(mutable_begin());\n        }\n\n        reference mutable_reference_at(size_type __pos) {\n            return reference(this, __pos);\n        }\n\n#       ifdef __STD_STUFF\n            reference operator[] (size_type __pos) {\n                return _char_ref_proxy(this, __pos);\n            }\n\n            reference at(size_type __pos) {\n                // if (__pos >= size()) throw out_of_range;  // XXX\n                return (*this)[__pos];\n            }\n\n            void resize(size_type __n, _CharT __c) {}\n            void resize(size_type __n) {}\n            void reserve(size_type __res_arg = 0) {}\n            size_type capacity() const {\n                return max_size();\n            }\n\n          // Stuff below this line is dangerous because it's error prone.\n          // I would really like to get rid of it.\n            // copy function with funny arg ordering.\n              size_type copy(_CharT* __buffer, size_type __n, \n                             size_type __pos = 0) const {\n                return copy(__pos, __n, __buffer);\n              }\n\n            iterator end() { return mutable_end(); }\n\n            iterator begin() { return mutable_begin(); }\n\n            reverse_iterator rend() { return mutable_rend(); }\n\n            reverse_iterator rbegin() { return mutable_rbegin(); }\n\n#       else\n\n            const_iterator end() { return const_end(); }\n\n            const_iterator begin() { return const_begin(); }\n\n            const_reverse_iterator rend() { return const_rend(); }\n  \n            const_reverse_iterator rbegin() { return const_rbegin(); }\n\n#       endif\n        \n};\n\ntemplate <class _CharT, class _Alloc>\nconst rope<_CharT, _Alloc>::size_type rope<_CharT, _Alloc>::npos =\n                        (size_type)(-1);\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator== (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return (__x._M_current_pos == __y._M_current_pos && \n          __x._M_root == __y._M_root);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator< (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                       const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return (__x._M_current_pos < __y._M_current_pos);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator!= (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator> (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                       const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator<= (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator>= (const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _CharT, class _Alloc>\ninline ptrdiff_t operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x,\n                           const _Rope_const_iterator<_CharT,_Alloc>& __y) {\n  return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_const_iterator<_CharT,_Alloc>\noperator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) {\n  return _Rope_const_iterator<_CharT,_Alloc>(\n            __x._M_root, __x._M_current_pos - __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_const_iterator<_CharT,_Alloc>\noperator+(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n) {\n  return _Rope_const_iterator<_CharT,_Alloc>(\n           __x._M_root, __x._M_current_pos + __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_const_iterator<_CharT,_Alloc>\noperator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT,_Alloc>& __x) {\n  return _Rope_const_iterator<_CharT,_Alloc>(\n           __x._M_root, __x._M_current_pos + __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator== (const _Rope_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return (__x._M_current_pos == __y._M_current_pos && \n          __x._M_root_rope == __y._M_root_rope);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator< (const _Rope_iterator<_CharT,_Alloc>& __x,\n                       const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return (__x._M_current_pos < __y._M_current_pos);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator!= (const _Rope_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator> (const _Rope_iterator<_CharT,_Alloc>& __x,\n                       const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator<= (const _Rope_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator>= (const _Rope_iterator<_CharT,_Alloc>& __x,\n                        const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _CharT, class _Alloc>\ninline ptrdiff_t operator-(const _Rope_iterator<_CharT,_Alloc>& __x,\n                           const _Rope_iterator<_CharT,_Alloc>& __y) {\n  return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_iterator<_CharT,_Alloc>\noperator-(const _Rope_iterator<_CharT,_Alloc>& __x,\n          ptrdiff_t __n) {\n  return _Rope_iterator<_CharT,_Alloc>(\n    __x._M_root_rope, __x._M_current_pos - __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_iterator<_CharT,_Alloc>\noperator+(const _Rope_iterator<_CharT,_Alloc>& __x,\n          ptrdiff_t __n) {\n  return _Rope_iterator<_CharT,_Alloc>(\n    __x._M_root_rope, __x._M_current_pos + __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline _Rope_iterator<_CharT,_Alloc>\noperator+(ptrdiff_t __n, const _Rope_iterator<_CharT,_Alloc>& __x) {\n  return _Rope_iterator<_CharT,_Alloc>(\n    __x._M_root_rope, __x._M_current_pos + __n);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>\noperator+ (const rope<_CharT,_Alloc>& __left,\n           const rope<_CharT,_Alloc>& __right)\n{\n#   ifdef __STL_USE_STD_ALLOCATORS\n        __stl_assert(__left.get_allocator() == __right.get_allocator());\n#   endif\n    return rope<_CharT,_Alloc>(\n      rope<_CharT,_Alloc>::_S_concat(__left._M_tree_ptr, __right._M_tree_ptr));\n    // Inlining this should make it possible to keep __left and\n    // __right in registers.\n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>&\noperator+= (rope<_CharT,_Alloc>& __left, \n      const rope<_CharT,_Alloc>& __right)\n{\n    __left.append(__right);\n    return __left;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>\noperator+ (const rope<_CharT,_Alloc>& __left,\n           const _CharT* __right) {\n    size_t __rlen = rope<_CharT,_Alloc>::_S_char_ptr_len(__right);\n    return rope<_CharT,_Alloc>(\n      rope<_CharT,_Alloc>::_S_concat_char_iter(\n        __left._M_tree_ptr, __right, __rlen)); \n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>&\noperator+= (rope<_CharT,_Alloc>& __left,\n            const _CharT* __right) {\n    __left.append(__right);\n    return __left;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>\noperator+ (const rope<_CharT,_Alloc>& __left, _CharT __right) {\n    return rope<_CharT,_Alloc>(\n      rope<_CharT,_Alloc>::_S_concat_char_iter(\n        __left._M_tree_ptr, &__right, 1));\n}\n\ntemplate <class _CharT, class _Alloc>\ninline\nrope<_CharT,_Alloc>&\noperator+= (rope<_CharT,_Alloc>& __left, _CharT __right) {\n    __left.append(__right);\n    return __left;\n}\n\ntemplate <class _CharT, class _Alloc>\nbool\noperator< (const rope<_CharT,_Alloc>& __left, \n           const rope<_CharT,_Alloc>& __right) {\n    return __left.compare(__right) < 0;\n}\n        \ntemplate <class _CharT, class _Alloc>\nbool\noperator== (const rope<_CharT,_Alloc>& __left, \n            const rope<_CharT,_Alloc>& __right) {\n    return __left.compare(__right) == 0;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator== (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,\n                        const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) {\n        return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Alloc>\ninline bool\noperator!= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool\noperator> (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool\noperator<= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool\noperator>= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _CharT, class _Alloc>\ninline bool operator!= (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,\n                        const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n  template<class _CharT, class _Traits, class _Alloc>\n  basic_ostream<_CharT, _Traits>& operator<<\n                                        (basic_ostream<_CharT, _Traits>& __o,\n                                         const rope<_CharT, _Alloc>& __r);\n#else\n  template<class _CharT, class _Alloc>\n  ostream& operator<< (ostream& __o, const rope<_CharT, _Alloc>& __r);\n#endif\n        \ntypedef rope<char> crope;\ntypedef rope<wchar_t> wrope;\n\ninline crope::reference __mutable_reference_at(crope& __c, size_t __i)\n{\n    return __c.mutable_reference_at(__i);\n}\n\ninline wrope::reference __mutable_reference_at(wrope& __c, size_t __i)\n{\n    return __c.mutable_reference_at(__i);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Alloc>\ninline void swap(rope<_CharT,_Alloc>& __x, rope<_CharT,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#else\n\ninline void swap(crope __x, crope __y) { __x.swap(__y); }\ninline void swap(wrope __x, wrope __y) { __x.swap(__y); }\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Hash functions should probably be revisited later:\n__STL_TEMPLATE_NULL struct hash<crope>\n{\n  size_t operator()(const crope& __str) const\n  {\n    size_t __size = __str.size();\n\n    if (0 == __size) return 0;\n    return 13*__str[0] + 5*__str[__size - 1] + __size;\n  }\n};\n\n\n__STL_TEMPLATE_NULL struct hash<wrope>\n{\n  size_t operator()(const wrope& __str) const\n  {\n    size_t __size = __str.size();\n\n    if (0 == __size) return 0;\n    return 13*__str[0] + 5*__str[__size - 1] + __size;\n  }\n};\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n# include <ropeimpl.h>\n\n# endif /* __SGI_STL_INTERNAL_ROPE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_set.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_SET_H\n#define __SGI_STL_INTERNAL_SET_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// Forward declarations of operators < and ==, needed for friend declaration.\n\ntemplate <class _Key, class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) >\nclass set;\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator==(const set<_Key,_Compare,_Alloc>& __x, \n                       const set<_Key,_Compare,_Alloc>& __y);\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<(const set<_Key,_Compare,_Alloc>& __x, \n                      const set<_Key,_Compare,_Alloc>& __y);\n\n\ntemplate <class _Key, class _Compare, class _Alloc>\nclass set {\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Key, _Assignable);\n  __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);\n\npublic:\n  // typedefs:\n\n  typedef _Key     key_type;\n  typedef _Key     value_type;\n  typedef _Compare key_compare;\n  typedef _Compare value_compare;\nprivate:\n  typedef _Rb_tree<key_type, value_type, \n                  _Identity<value_type>, key_compare, _Alloc> _Rep_type;\n  _Rep_type _M_t;  // red-black tree representing set\npublic:\n  typedef typename _Rep_type::const_pointer pointer;\n  typedef typename _Rep_type::const_pointer const_pointer;\n  typedef typename _Rep_type::const_reference reference;\n  typedef typename _Rep_type::const_reference const_reference;\n  typedef typename _Rep_type::const_iterator iterator;\n  typedef typename _Rep_type::const_iterator const_iterator;\n  typedef typename _Rep_type::const_reverse_iterator reverse_iterator;\n  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename _Rep_type::size_type size_type;\n  typedef typename _Rep_type::difference_type difference_type;\n  typedef typename _Rep_type::allocator_type allocator_type;\n\n  // allocation/deallocation\n\n  set() : _M_t(_Compare(), allocator_type()) {}\n  explicit set(const _Compare& __comp,\n               const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  set(_InputIterator __first, _InputIterator __last)\n    : _M_t(_Compare(), allocator_type())\n    { _M_t.insert_unique(__first, __last); }\n\n  template <class _InputIterator>\n  set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n#else\n  set(const value_type* __first, const value_type* __last) \n    : _M_t(_Compare(), allocator_type()) \n    { _M_t.insert_unique(__first, __last); }\n\n  set(const value_type* __first, \n      const value_type* __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n\n  set(const_iterator __first, const_iterator __last)\n    : _M_t(_Compare(), allocator_type()) \n    { _M_t.insert_unique(__first, __last); }\n\n  set(const_iterator __first, const_iterator __last, const _Compare& __comp,\n      const allocator_type& __a = allocator_type())\n    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}\n  set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x)\n  { \n    _M_t = __x._M_t; \n    return *this;\n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return _M_t.key_comp(); }\n  value_compare value_comp() const { return _M_t.key_comp(); }\n  allocator_type get_allocator() const { return _M_t.get_allocator(); }\n\n  iterator begin() const { return _M_t.begin(); }\n  iterator end() const { return _M_t.end(); }\n  reverse_iterator rbegin() const { return _M_t.rbegin(); } \n  reverse_iterator rend() const { return _M_t.rend(); }\n  bool empty() const { return _M_t.empty(); }\n  size_type size() const { return _M_t.size(); }\n  size_type max_size() const { return _M_t.max_size(); }\n  void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }\n\n  // insert/erase\n  pair<iterator,bool> insert(const value_type& __x) { \n    pair<typename _Rep_type::iterator, bool> __p = _M_t.insert_unique(__x); \n    return pair<iterator, bool>(__p.first, __p.second);\n  }\n  iterator insert(iterator __position, const value_type& __x) {\n    typedef typename _Rep_type::iterator _Rep_iterator;\n    return _M_t.insert_unique((_Rep_iterator&)__position, __x);\n  }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void insert(_InputIterator __first, _InputIterator __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n#else\n  void insert(const_iterator __first, const_iterator __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n  void insert(const value_type* __first, const value_type* __last) {\n    _M_t.insert_unique(__first, __last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator __position) { \n    typedef typename _Rep_type::iterator _Rep_iterator;\n    _M_t.erase((_Rep_iterator&)__position); \n  }\n  size_type erase(const key_type& __x) { \n    return _M_t.erase(__x); \n  }\n  void erase(iterator __first, iterator __last) { \n    typedef typename _Rep_type::iterator _Rep_iterator;\n    _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); \n  }\n  void clear() { _M_t.clear(); }\n\n  // set operations:\n\n  iterator find(const key_type& __x) const { return _M_t.find(__x); }\n  size_type count(const key_type& __x) const {\n    return _M_t.find(__x) == _M_t.end() ? 0 : 1;\n  }\n  iterator lower_bound(const key_type& __x) const {\n    return _M_t.lower_bound(__x);\n  }\n  iterator upper_bound(const key_type& __x) const {\n    return _M_t.upper_bound(__x); \n  }\n  pair<iterator,iterator> equal_range(const key_type& __x) const {\n    return _M_t.equal_range(__x);\n  }\n\n#ifdef __STL_TEMPLATE_FRIENDS\n  template <class _K1, class _C1, class _A1>\n  friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);\n  template <class _K1, class _C1, class _A1>\n  friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);\n#else /* __STL_TEMPLATE_FRIENDS */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const set&, const set&);\n  friend bool __STD_QUALIFIER\n  operator<  __STL_NULL_TMPL_ARGS (const set&, const set&);\n#endif /* __STL_TEMPLATE_FRIENDS */\n};\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator==(const set<_Key,_Compare,_Alloc>& __x, \n                       const set<_Key,_Compare,_Alloc>& __y) {\n  return __x._M_t == __y._M_t;\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<(const set<_Key,_Compare,_Alloc>& __x, \n                      const set<_Key,_Compare,_Alloc>& __y) {\n  return __x._M_t < __y._M_t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator!=(const set<_Key,_Compare,_Alloc>& __x, \n                       const set<_Key,_Compare,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator>(const set<_Key,_Compare,_Alloc>& __x, \n                      const set<_Key,_Compare,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator<=(const set<_Key,_Compare,_Alloc>& __x, \n                       const set<_Key,_Compare,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline bool operator>=(const set<_Key,_Compare,_Alloc>& __x, \n                       const set<_Key,_Compare,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _Key, class _Compare, class _Alloc>\ninline void swap(set<_Key,_Compare,_Alloc>& __x, \n                 set<_Key,_Compare,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_slist.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_SLIST_H\n#define __SGI_STL_INTERNAL_SLIST_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\nstruct _Slist_node_base\n{\n  _Slist_node_base* _M_next;\n};\n\ninline _Slist_node_base*\n__slist_make_link(_Slist_node_base* __prev_node,\n                  _Slist_node_base* __new_node)\n{\n  __new_node->_M_next = __prev_node->_M_next;\n  __prev_node->_M_next = __new_node;\n  return __new_node;\n}\n\ninline _Slist_node_base* \n__slist_previous(_Slist_node_base* __head,\n                 const _Slist_node_base* __node)\n{\n  while (__head && __head->_M_next != __node)\n    __head = __head->_M_next;\n  return __head;\n}\n\ninline const _Slist_node_base* \n__slist_previous(const _Slist_node_base* __head,\n                 const _Slist_node_base* __node)\n{\n  while (__head && __head->_M_next != __node)\n    __head = __head->_M_next;\n  return __head;\n}\n\ninline void __slist_splice_after(_Slist_node_base* __pos,\n                                 _Slist_node_base* __before_first,\n                                 _Slist_node_base* __before_last)\n{\n  if (__pos != __before_first && __pos != __before_last) {\n    _Slist_node_base* __first = __before_first->_M_next;\n    _Slist_node_base* __after = __pos->_M_next;\n    __before_first->_M_next = __before_last->_M_next;\n    __pos->_M_next = __first;\n    __before_last->_M_next = __after;\n  }\n}\n\ninline void\n__slist_splice_after(_Slist_node_base* __pos, _Slist_node_base* __head)\n{\n  _Slist_node_base* __before_last = __slist_previous(__head, 0);\n  if (__before_last != __head) {\n    _Slist_node_base* __after = __pos->_M_next;\n    __pos->_M_next = __head->_M_next;\n    __head->_M_next = 0;\n    __before_last->_M_next = __after;\n  }\n}\n\ninline _Slist_node_base* __slist_reverse(_Slist_node_base* __node)\n{\n  _Slist_node_base* __result = __node;\n  __node = __node->_M_next;\n  __result->_M_next = 0;\n  while(__node) {\n    _Slist_node_base* __next = __node->_M_next;\n    __node->_M_next = __result;\n    __result = __node;\n    __node = __next;\n  }\n  return __result;\n}\n\ninline size_t __slist_size(_Slist_node_base* __node)\n{\n  size_t __result = 0;\n  for ( ; __node != 0; __node = __node->_M_next)\n    ++__result;\n  return __result;\n}\n\ntemplate <class _Tp>\nstruct _Slist_node : public _Slist_node_base\n{\n  _Tp _M_data;\n};\n\nstruct _Slist_iterator_base\n{\n  typedef size_t               size_type;\n  typedef ptrdiff_t            difference_type;\n  typedef forward_iterator_tag iterator_category;\n\n  _Slist_node_base* _M_node;\n\n  _Slist_iterator_base(_Slist_node_base* __x) : _M_node(__x) {}\n  void _M_incr() { _M_node = _M_node->_M_next; }\n\n  bool operator==(const _Slist_iterator_base& __x) const {\n    return _M_node == __x._M_node;\n  }\n  bool operator!=(const _Slist_iterator_base& __x) const {\n    return _M_node != __x._M_node;\n  }\n};\n\ntemplate <class _Tp, class _Ref, class _Ptr>\nstruct _Slist_iterator : public _Slist_iterator_base\n{\n  typedef _Slist_iterator<_Tp, _Tp&, _Tp*>             iterator;\n  typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;\n  typedef _Slist_iterator<_Tp, _Ref, _Ptr>             _Self;\n\n  typedef _Tp              value_type;\n  typedef _Ptr             pointer;\n  typedef _Ref             reference;\n  typedef _Slist_node<_Tp> _Node;\n\n  _Slist_iterator(_Node* __x) : _Slist_iterator_base(__x) {}\n  _Slist_iterator() : _Slist_iterator_base(0) {}\n  _Slist_iterator(const iterator& __x) : _Slist_iterator_base(__x._M_node) {}\n\n  reference operator*() const { return ((_Node*) _M_node)->_M_data; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  _Self& operator++()\n  {\n    _M_incr();\n    return *this;\n  }\n  _Self operator++(int)\n  {\n    _Self __tmp = *this;\n    _M_incr();\n    return __tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ninline ptrdiff_t* distance_type(const _Slist_iterator_base&) {\n  return 0;\n}\n\ninline forward_iterator_tag iterator_category(const _Slist_iterator_base&) {\n  return forward_iterator_tag();\n}\n\ntemplate <class _Tp, class _Ref, class _Ptr> \ninline _Tp* value_type(const _Slist_iterator<_Tp, _Ref, _Ptr>&) {\n  return 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Base class that encapsulates details of allocators.  Three cases:\n// an ordinary standard-conforming allocator, a standard-conforming\n// allocator with no non-static data, and an SGI-style allocator.\n// This complexity is necessary only because we're worrying about backward\n// compatibility and because we want to avoid wasting storage on an \n// allocator instance if it isn't necessary.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base for general standard-conforming allocators.\ntemplate <class _Tp, class _Allocator, bool _IsStatic>\nclass _Slist_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _M_node_allocator; }\n\n  _Slist_alloc_base(const allocator_type& __a) : _M_node_allocator(__a) {}\n\nprotected:\n  _Slist_node<_Tp>* _M_get_node() \n    { return _M_node_allocator.allocate(1); }\n  void _M_put_node(_Slist_node<_Tp>* __p) \n    { _M_node_allocator.deallocate(__p, 1); }\n\nprotected:\n  typename _Alloc_traits<_Slist_node<_Tp>,_Allocator>::allocator_type\n           _M_node_allocator;\n  _Slist_node_base _M_head;\n};\n\n// Specialization for instanceless allocators.\ntemplate <class _Tp, class _Allocator>\nclass _Slist_alloc_base<_Tp,_Allocator, true> {\npublic:\n  typedef typename _Alloc_traits<_Tp,_Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Slist_alloc_base(const allocator_type&) {}\n\nprotected:\n  typedef typename _Alloc_traits<_Slist_node<_Tp>, _Allocator>::_Alloc_type\n          _Alloc_type;\n  _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }\n  void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); }\n\nprotected:\n  _Slist_node_base _M_head;\n};\n\n\ntemplate <class _Tp, class _Alloc>\nstruct _Slist_base\n  : public _Slist_alloc_base<_Tp, _Alloc,\n                             _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\n  typedef _Slist_alloc_base<_Tp, _Alloc,\n                            _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n\n  _Slist_base(const allocator_type& __a)\n    : _Base(__a) { this->_M_head._M_next = 0; }\n  ~_Slist_base() { _M_erase_after(&this->_M_head, 0); }\n\nprotected:\n\n  _Slist_node_base* _M_erase_after(_Slist_node_base* __pos)\n  {\n    _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next);\n    _Slist_node_base* __next_next = __next->_M_next;\n    __pos->_M_next = __next_next;\n    destroy(&__next->_M_data);\n    _M_put_node(__next);\n    return __next_next;\n  }\n  _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*);\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc> \nstruct _Slist_base {\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Slist_base(const allocator_type&) { _M_head._M_next = 0; }\n  ~_Slist_base() { _M_erase_after(&_M_head, 0); }\n\nprotected:\n  typedef simple_alloc<_Slist_node<_Tp>, _Alloc> _Alloc_type;\n  _Slist_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }\n  void _M_put_node(_Slist_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); }\n\n  _Slist_node_base* _M_erase_after(_Slist_node_base* __pos)\n  {\n    _Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next);\n    _Slist_node_base* __next_next = __next->_M_next;\n    __pos->_M_next = __next_next;\n    destroy(&__next->_M_data);\n    _M_put_node(__next);\n    return __next_next;\n  }\n  _Slist_node_base* _M_erase_after(_Slist_node_base*, _Slist_node_base*);\n\nprotected:\n  _Slist_node_base _M_head;\n};  \n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc> \n_Slist_node_base*\n_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first,\n                                        _Slist_node_base* __last_node) {\n  _Slist_node<_Tp>* __cur = (_Slist_node<_Tp>*) (__before_first->_M_next);\n  while (__cur != __last_node) {\n    _Slist_node<_Tp>* __tmp = __cur;\n    __cur = (_Slist_node<_Tp>*) __cur->_M_next;\n    destroy(&__tmp->_M_data);\n    _M_put_node(__tmp);\n  }\n  __before_first->_M_next = __last_node;\n  return __last_node;\n}\n\ntemplate <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass slist : private _Slist_base<_Tp,_Alloc>\n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n\nprivate:\n  typedef _Slist_base<_Tp,_Alloc> _Base;\npublic:\n  typedef _Tp                value_type;\n  typedef value_type*       pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type&       reference;\n  typedef const value_type& const_reference;\n  typedef size_t            size_type;\n  typedef ptrdiff_t         difference_type;\n\n  typedef _Slist_iterator<_Tp, _Tp&, _Tp*>             iterator;\n  typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;\n\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\nprivate:\n  typedef _Slist_node<_Tp>      _Node;\n  typedef _Slist_node_base      _Node_base;\n  typedef _Slist_iterator_base  _Iterator_base;\n\n  _Node* _M_create_node(const value_type& __x) {\n    _Node* __node = this->_M_get_node();\n    __STL_TRY {\n      construct(&__node->_M_data, __x);\n      __node->_M_next = 0;\n    }\n    __STL_UNWIND(this->_M_put_node(__node));\n    return __node;\n  }\n  \n  _Node* _M_create_node() {\n    _Node* __node = this->_M_get_node();\n    __STL_TRY {\n      construct(&__node->_M_data);\n      __node->_M_next = 0;\n    }\n    __STL_UNWIND(this->_M_put_node(__node));\n    return __node;\n  }\n\npublic:\n  explicit slist(const allocator_type& __a = allocator_type()) : _Base(__a) {}\n\n  slist(size_type __n, const value_type& __x,\n        const allocator_type& __a =  allocator_type()) : _Base(__a)\n    { _M_insert_after_fill(&this->_M_head, __n, __x); }\n\n  explicit slist(size_type __n) : _Base(allocator_type())\n    { _M_insert_after_fill(&this->_M_head, __n, value_type()); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  // We don't need any dispatching tricks here, because _M_insert_after_range\n  // already does them.\n  template <class _InputIterator>\n  slist(_InputIterator __first, _InputIterator __last,\n        const allocator_type& __a =  allocator_type()) : _Base(__a)\n    { _M_insert_after_range(&this->_M_head, __first, __last); }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  slist(const_iterator __first, const_iterator __last,\n        const allocator_type& __a =  allocator_type()) : _Base(__a)\n    { _M_insert_after_range(&this->_M_head, __first, __last); }\n  slist(const value_type* __first, const value_type* __last,\n        const allocator_type& __a =  allocator_type()) : _Base(__a)\n    { _M_insert_after_range(&this->_M_head, __first, __last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  slist(const slist& __x) : _Base(__x.get_allocator())\n    { _M_insert_after_range(&this->_M_head, __x.begin(), __x.end()); }\n\n  slist& operator= (const slist& __x);\n\n  ~slist() {}\n\npublic:\n  // assign(), a generalized assignment member function.  Two\n  // versions: one that takes a count, and one that takes a range.\n  // The range version is a member template, so we dispatch on whether\n  // or not the type is an integer.\n\n  void assign(size_type __n, const _Tp& __val)\n    { _M_fill_assign(__n, __val); }\n\n  void _M_fill_assign(size_type __n, const _Tp& __val);\n\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIterator>\n  void assign(_InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_assign_dispatch(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)\n    { _M_fill_assign((size_type) __n, (_Tp) __val); }\n\n  template <class _InputIterator>\n  void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,\n                          __false_type);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n\n  iterator begin() { return iterator((_Node*)this->_M_head._M_next); }\n  const_iterator begin() const \n    { return const_iterator((_Node*)this->_M_head._M_next);}\n\n  iterator end() { return iterator(0); }\n  const_iterator end() const { return const_iterator(0); }\n\n  // Experimental new feature: before_begin() returns a\n  // non-dereferenceable iterator that, when incremented, yields\n  // begin().  This iterator may be used as the argument to\n  // insert_after, erase_after, etc.  Note that even for an empty \n  // slist, before_begin() is not the same iterator as end().  It \n  // is always necessary to increment before_begin() at least once to\n  // obtain end().\n  iterator before_begin() { return iterator((_Node*) &this->_M_head); }\n  const_iterator before_begin() const\n    { return const_iterator((_Node*) &this->_M_head); }\n\n  size_type size() const { return __slist_size(this->_M_head._M_next); }\n  \n  size_type max_size() const { return size_type(-1); }\n\n  bool empty() const { return this->_M_head._M_next == 0; }\n\n  void swap(slist& __x)\n    { __STD::swap(this->_M_head._M_next, __x._M_head._M_next); }\n\npublic:\n\n  reference front() { return ((_Node*) this->_M_head._M_next)->_M_data; }\n  const_reference front() const \n    { return ((_Node*) this->_M_head._M_next)->_M_data; }\n  void push_front(const value_type& __x)   {\n    __slist_make_link(&this->_M_head, _M_create_node(__x));\n  }\n  void push_front() { __slist_make_link(&this->_M_head, _M_create_node()); }\n  void pop_front() {\n    _Node* __node = (_Node*) this->_M_head._M_next;\n    this->_M_head._M_next = __node->_M_next;\n    destroy(&__node->_M_data);\n    this->_M_put_node(__node);\n  }\n\n  iterator previous(const_iterator __pos) {\n    return iterator((_Node*) __slist_previous(&this->_M_head, __pos._M_node));\n  }\n  const_iterator previous(const_iterator __pos) const {\n    return const_iterator((_Node*) __slist_previous(&this->_M_head,\n                                                    __pos._M_node));\n  }\n\nprivate:\n  _Node* _M_insert_after(_Node_base* __pos, const value_type& __x) {\n    return (_Node*) (__slist_make_link(__pos, _M_create_node(__x)));\n  }\n\n  _Node* _M_insert_after(_Node_base* __pos) {\n    return (_Node*) (__slist_make_link(__pos, _M_create_node()));\n  }\n\n  void _M_insert_after_fill(_Node_base* __pos,\n                            size_type __n, const value_type& __x) {\n    for (size_type __i = 0; __i < __n; ++__i)\n      __pos = __slist_make_link(__pos, _M_create_node(__x));\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check whether it's an integral type.  If so, it's not an iterator.\n  template <class _InIter>\n  void _M_insert_after_range(_Node_base* __pos, \n                             _InIter __first, _InIter __last) {\n    typedef typename _Is_integer<_InIter>::_Integral _Integral;\n    _M_insert_after_range(__pos, __first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x,\n                             __true_type) {\n    _M_insert_after_fill(__pos, __n, __x);\n  }\n\n  template <class _InIter>\n  void _M_insert_after_range(_Node_base* __pos,\n                             _InIter __first, _InIter __last,\n                             __false_type) {\n    while (__first != __last) {\n      __pos = __slist_make_link(__pos, _M_create_node(*__first));\n      ++__first;\n    }\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void _M_insert_after_range(_Node_base* __pos,\n                             const_iterator __first, const_iterator __last) {\n    while (__first != __last) {\n      __pos = __slist_make_link(__pos, _M_create_node(*__first));\n      ++__first;\n    }\n  }\n  void _M_insert_after_range(_Node_base* __pos,\n                             const value_type* __first,\n                             const value_type* __last) {\n    while (__first != __last) {\n      __pos = __slist_make_link(__pos, _M_create_node(*__first));\n      ++__first;\n    }\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n\n  iterator insert_after(iterator __pos, const value_type& __x) {\n    return iterator(_M_insert_after(__pos._M_node, __x));\n  }\n\n  iterator insert_after(iterator __pos) {\n    return insert_after(__pos, value_type());\n  }\n\n  void insert_after(iterator __pos, size_type __n, const value_type& __x) {\n    _M_insert_after_fill(__pos._M_node, __n, __x);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // We don't need any dispatching tricks here, because _M_insert_after_range\n  // already does them.\n  template <class _InIter>\n  void insert_after(iterator __pos, _InIter __first, _InIter __last) {\n    _M_insert_after_range(__pos._M_node, __first, __last);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void insert_after(iterator __pos,\n                    const_iterator __first, const_iterator __last) {\n    _M_insert_after_range(__pos._M_node, __first, __last);\n  }\n  void insert_after(iterator __pos,\n                    const value_type* __first, const value_type* __last) {\n    _M_insert_after_range(__pos._M_node, __first, __last);\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator insert(iterator __pos, const value_type& __x) {\n    return iterator(_M_insert_after(__slist_previous(&this->_M_head,\n                                                     __pos._M_node),\n                    __x));\n  }\n\n  iterator insert(iterator __pos) {\n    return iterator(_M_insert_after(__slist_previous(&this->_M_head,\n                                                     __pos._M_node),\n                                    value_type()));\n  }\n\n  void insert(iterator __pos, size_type __n, const value_type& __x) {\n    _M_insert_after_fill(__slist_previous(&this->_M_head, __pos._M_node),\n                         __n, __x);\n  } \n    \n#ifdef __STL_MEMBER_TEMPLATES\n\n  // We don't need any dispatching tricks here, because _M_insert_after_range\n  // already does them.\n  template <class _InIter>\n  void insert(iterator __pos, _InIter __first, _InIter __last) {\n    _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), \n                          __first, __last);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void insert(iterator __pos, const_iterator __first, const_iterator __last) {\n    _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), \n                          __first, __last);\n  }\n  void insert(iterator __pos, const value_type* __first, \n                              const value_type* __last) {\n    _M_insert_after_range(__slist_previous(&this->_M_head, __pos._M_node), \n                          __first, __last);\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n\npublic:\n  iterator erase_after(iterator __pos) {\n    return iterator((_Node*) this->_M_erase_after(__pos._M_node));\n  }\n  iterator erase_after(iterator __before_first, iterator __last) {\n    return iterator((_Node*) this->_M_erase_after(__before_first._M_node, \n                                                  __last._M_node));\n  } \n\n  iterator erase(iterator __pos) {\n    return (_Node*) this->_M_erase_after(__slist_previous(&this->_M_head, \n                                                          __pos._M_node));\n  }\n  iterator erase(iterator __first, iterator __last) {\n    return (_Node*) this->_M_erase_after(\n      __slist_previous(&this->_M_head, __first._M_node), __last._M_node);\n  }\n\n  void resize(size_type new_size, const _Tp& __x);\n  void resize(size_type new_size) { resize(new_size, _Tp()); }\n  void clear() { this->_M_erase_after(&this->_M_head, 0); }\n\npublic:\n  // Moves the range [__before_first + 1, __before_last + 1) to *this,\n  //  inserting it immediately after __pos.  This is constant time.\n  void splice_after(iterator __pos, \n                    iterator __before_first, iterator __before_last)\n  {\n    if (__before_first != __before_last) \n      __slist_splice_after(__pos._M_node, __before_first._M_node, \n                           __before_last._M_node);\n  }\n\n  // Moves the element that follows __prev to *this, inserting it immediately\n  //  after __pos.  This is constant time.\n  void splice_after(iterator __pos, iterator __prev)\n  {\n    __slist_splice_after(__pos._M_node,\n                         __prev._M_node, __prev._M_node->_M_next);\n  }\n\n\n  // Removes all of the elements from the list __x to *this, inserting\n  // them immediately after __pos.  __x must not be *this.  Complexity:\n  // linear in __x.size().\n  void splice_after(iterator __pos, slist& __x)\n  {\n    __slist_splice_after(__pos._M_node, &__x._M_head);\n  }\n\n  // Linear in distance(begin(), __pos), and linear in __x.size().\n  void splice(iterator __pos, slist& __x) {\n    if (__x._M_head._M_next)\n      __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),\n                           &__x._M_head, __slist_previous(&__x._M_head, 0));\n  }\n\n  // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).\n  void splice(iterator __pos, slist& __x, iterator __i) {\n    __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),\n                         __slist_previous(&__x._M_head, __i._M_node),\n                         __i._M_node);\n  }\n\n  // Linear in distance(begin(), __pos), in distance(__x.begin(), __first),\n  // and in distance(__first, __last).\n  void splice(iterator __pos, slist& __x, iterator __first, iterator __last)\n  {\n    if (__first != __last)\n      __slist_splice_after(__slist_previous(&this->_M_head, __pos._M_node),\n                           __slist_previous(&__x._M_head, __first._M_node),\n                           __slist_previous(__first._M_node, __last._M_node));\n  }\n\npublic:\n  void reverse() { \n    if (this->_M_head._M_next)\n      this->_M_head._M_next = __slist_reverse(this->_M_head._M_next);\n  }\n\n  void remove(const _Tp& __val); \n  void unique(); \n  void merge(slist& __x);\n  void sort();     \n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Predicate> \n  void remove_if(_Predicate __pred);\n\n  template <class _BinaryPredicate> \n  void unique(_BinaryPredicate __pred); \n\n  template <class _StrictWeakOrdering> \n  void merge(slist&, _StrictWeakOrdering);\n\n  template <class _StrictWeakOrdering> \n  void sort(_StrictWeakOrdering __comp); \n#endif /* __STL_MEMBER_TEMPLATES */\n};\n\ntemplate <class _Tp, class _Alloc>\nslist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x)\n{\n  if (&__x != this) {\n    _Node_base* __p1 = &this->_M_head;\n    _Node* __n1 = (_Node*) this->_M_head._M_next;\n    const _Node* __n2 = (const _Node*) __x._M_head._M_next;\n    while (__n1 && __n2) {\n      __n1->_M_data = __n2->_M_data;\n      __p1 = __n1;\n      __n1 = (_Node*) __n1->_M_next;\n      __n2 = (const _Node*) __n2->_M_next;\n    }\n    if (__n2 == 0)\n      this->_M_erase_after(__p1, 0);\n    else\n      _M_insert_after_range(__p1, const_iterator((_Node*)__n2), \n                                  const_iterator(0));\n  }\n  return *this;\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {\n  _Node_base* __prev = &this->_M_head;\n  _Node* __node = (_Node*) this->_M_head._M_next;\n  for ( ; __node != 0 && __n > 0 ; --__n) {\n    __node->_M_data = __val;\n    __prev = __node;\n    __node = (_Node*) __node->_M_next;\n  }\n  if (__n > 0)\n    _M_insert_after_fill(__prev, __n, __val);\n  else\n    this->_M_erase_after(__prev, 0);\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _InputIter>\nvoid\nslist<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first, _InputIter __last,\n                                       __false_type)\n{\n  _Node_base* __prev = &this->_M_head;\n  _Node* __node = (_Node*) this->_M_head._M_next;\n  while (__node != 0 && __first != __last) {\n    __node->_M_data = *__first;\n    __prev = __node;\n    __node = (_Node*) __node->_M_next;\n    ++__first;\n  }\n  if (__first != __last)\n    _M_insert_after_range(__prev, __first, __last);\n  else\n    this->_M_erase_after(__prev, 0);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator==(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2)\n{\n  typedef typename slist<_Tp,_Alloc>::const_iterator const_iterator;\n  const_iterator __end1 = _SL1.end();\n  const_iterator __end2 = _SL2.end();\n\n  const_iterator __i1 = _SL1.begin();\n  const_iterator __i2 = _SL2.begin();\n  while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {\n    ++__i1;\n    ++__i2;\n  }\n  return __i1 == __end1 && __i2 == __end2;\n}\n\n\ntemplate <class _Tp, class _Alloc>\ninline bool\noperator<(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2)\n{\n  return lexicographical_compare(_SL1.begin(), _SL1.end(), \n                                 _SL2.begin(), _SL2.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator!=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {\n  return !(_SL1 == _SL2);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator>(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {\n  return _SL2 < _SL1;\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator<=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {\n  return !(_SL2 < _SL1);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator>=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {\n  return !(_SL1 < _SL2);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline void swap(slist<_Tp,_Alloc>& __x, slist<_Tp,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class _Tp, class _Alloc>\nvoid slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x)\n{\n  _Node_base* __cur = &this->_M_head;\n  while (__cur->_M_next != 0 && __len > 0) {\n    --__len;\n    __cur = __cur->_M_next;\n  }\n  if (__cur->_M_next) \n    this->_M_erase_after(__cur, 0);\n  else\n    _M_insert_after_fill(__cur, __len, __x);\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid slist<_Tp,_Alloc>::remove(const _Tp& __val)\n{\n  _Node_base* __cur = &this->_M_head;\n  while (__cur && __cur->_M_next) {\n    if (((_Node*) __cur->_M_next)->_M_data == __val)\n      this->_M_erase_after(__cur);\n    else\n      __cur = __cur->_M_next;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> \nvoid slist<_Tp,_Alloc>::unique()\n{\n  _Node_base* __cur = this->_M_head._M_next;\n  if (__cur) {\n    while (__cur->_M_next) {\n      if (((_Node*)__cur)->_M_data == \n          ((_Node*)(__cur->_M_next))->_M_data)\n        this->_M_erase_after(__cur);\n      else\n        __cur = __cur->_M_next;\n    }\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x)\n{\n  _Node_base* __n1 = &this->_M_head;\n  while (__n1->_M_next && __x._M_head._M_next) {\n    if (((_Node*) __x._M_head._M_next)->_M_data < \n        ((_Node*)       __n1->_M_next)->_M_data) \n      __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next);\n    __n1 = __n1->_M_next;\n  }\n  if (__x._M_head._M_next) {\n    __n1->_M_next = __x._M_head._M_next;\n    __x._M_head._M_next = 0;\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid slist<_Tp,_Alloc>::sort()\n{\n  if (this->_M_head._M_next && this->_M_head._M_next->_M_next) {\n    slist __carry;\n    slist __counter[64];\n    int __fill = 0;\n    while (!empty()) {\n      __slist_splice_after(&__carry._M_head,\n                           &this->_M_head, this->_M_head._M_next);\n      int __i = 0;\n      while (__i < __fill && !__counter[__i].empty()) {\n        __counter[__i].merge(__carry);\n        __carry.swap(__counter[__i]);\n        ++__i;\n      }\n      __carry.swap(__counter[__i]);\n      if (__i == __fill)\n        ++__fill;\n    }\n\n    for (int __i = 1; __i < __fill; ++__i)\n      __counter[__i].merge(__counter[__i-1]);\n    this->swap(__counter[__fill-1]);\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> \ntemplate <class _Predicate>\nvoid slist<_Tp,_Alloc>::remove_if(_Predicate __pred)\n{\n  _Node_base* __cur = &this->_M_head;\n  while (__cur->_M_next) {\n    if (__pred(((_Node*) __cur->_M_next)->_M_data))\n      this->_M_erase_after(__cur);\n    else\n      __cur = __cur->_M_next;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _BinaryPredicate> \nvoid slist<_Tp,_Alloc>::unique(_BinaryPredicate __pred)\n{\n  _Node* __cur = (_Node*) this->_M_head._M_next;\n  if (__cur) {\n    while (__cur->_M_next) {\n      if (__pred(((_Node*)__cur)->_M_data, \n                 ((_Node*)(__cur->_M_next))->_M_data))\n        this->_M_erase_after(__cur);\n      else\n        __cur = (_Node*) __cur->_M_next;\n    }\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _StrictWeakOrdering>\nvoid slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x,\n                              _StrictWeakOrdering __comp)\n{\n  _Node_base* __n1 = &this->_M_head;\n  while (__n1->_M_next && __x._M_head._M_next) {\n    if (__comp(((_Node*) __x._M_head._M_next)->_M_data,\n               ((_Node*)       __n1->_M_next)->_M_data))\n      __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next);\n    __n1 = __n1->_M_next;\n  }\n  if (__x._M_head._M_next) {\n    __n1->_M_next = __x._M_head._M_next;\n    __x._M_head._M_next = 0;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _StrictWeakOrdering> \nvoid slist<_Tp,_Alloc>::sort(_StrictWeakOrdering __comp)\n{\n  if (this->_M_head._M_next && this->_M_head._M_next->_M_next) {\n    slist __carry;\n    slist __counter[64];\n    int __fill = 0;\n    while (!empty()) {\n      __slist_splice_after(&__carry._M_head,\n                           &this->_M_head, this->_M_head._M_next);\n      int __i = 0;\n      while (__i < __fill && !__counter[__i].empty()) {\n        __counter[__i].merge(__carry, __comp);\n        __carry.swap(__counter[__i]);\n        ++__i;\n      }\n      __carry.swap(__counter[__i]);\n      if (__i == __fill)\n        ++__fill;\n    }\n\n    for (int __i = 1; __i < __fill; ++__i)\n      __counter[__i].merge(__counter[__i-1], __comp);\n    this->swap(__counter[__fill-1]);\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n// Specialization of insert_iterator so that insertions will be constant\n// time rather than linear time.\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp, class _Alloc>\nclass insert_iterator<slist<_Tp, _Alloc> > {\nprotected:\n  typedef slist<_Tp, _Alloc> _Container;\n  _Container* container;\n  typename _Container::iterator iter;\npublic:\n  typedef _Container          container_type;\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(_Container& __x, typename _Container::iterator __i) \n    : container(&__x) {\n    if (__i == __x.begin())\n      iter = __x.before_begin();\n    else\n      iter = __x.previous(__i);\n  }\n\n  insert_iterator<_Container>&\n  operator=(const typename _Container::value_type& __value) { \n    iter = container->insert_after(iter, __value);\n    return *this;\n  }\n  insert_iterator<_Container>& operator*() { return *this; }\n  insert_iterator<_Container>& operator++() { return *this; }\n  insert_iterator<_Container>& operator++(int) { return *this; }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_SLIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_stack.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_STACK_H\n#define __SGI_STL_INTERNAL_STACK_H\n\n#include <sequence_concepts.h>\n\n__STL_BEGIN_NAMESPACE\n\n// Forward declarations of operators == and <, needed for friend declaration.\n\ntemplate <class _Tp, \n          class _Sequence __STL_DEPENDENT_DEFAULT_TMPL(deque<_Tp>) >\nclass stack;\n\ntemplate <class _Tp, class _Seq>\nbool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);\n\ntemplate <class _Tp, class _Seq>\nbool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);\n\n\ntemplate <class _Tp, class _Sequence>\nclass stack {\n\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n  __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence);\n  typedef typename _Sequence::value_type _Sequence_value_type;\n  __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);\n\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _Tp1, class _Seq1>\n  friend bool operator== (const stack<_Tp1, _Seq1>&,\n                          const stack<_Tp1, _Seq1>&);\n  template <class _Tp1, class _Seq1>\n  friend bool operator< (const stack<_Tp1, _Seq1>&,\n                         const stack<_Tp1, _Seq1>&);\n#else /* __STL_MEMBER_TEMPLATES */\n  friend bool __STD_QUALIFIER\n  operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);\n  friend bool __STD_QUALIFIER\n  operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n  typedef typename _Sequence::value_type      value_type;\n  typedef typename _Sequence::size_type       size_type;\n  typedef          _Sequence                  container_type;\n\n  typedef typename _Sequence::reference       reference;\n  typedef typename _Sequence::const_reference const_reference;\nprotected:\n  _Sequence c;\npublic:\n  stack() : c() {}\n  explicit stack(const _Sequence& __s) : c(__s) {}\n\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  reference top() { return c.back(); }\n  const_reference top() const { return c.back(); }\n  void push(const value_type& __x) { c.push_back(__x); }\n  void pop() { c.pop_back(); }\n};\n\ntemplate <class _Tp, class _Seq>\nbool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return __x.c == __y.c;\n}\n\ntemplate <class _Tp, class _Seq>\nbool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return __x.c < __y.c;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Seq>\nbool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return !(__x == __y);\n}\n\ntemplate <class _Tp, class _Seq>\nbool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return __y < __x;\n}\n\ntemplate <class _Tp, class _Seq>\nbool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return !(__y < __x);\n}\n\ntemplate <class _Tp, class _Seq>\nbool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)\n{\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_STACK_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_string_fwd.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_STRING_FWD_H\n#define __SGI_STL_STRING_FWD_H\n\n#include <stddef.h>\n#include <stl_config.h>\n#include <stl_alloc.h>\n#include <char_traits.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _CharT, \n          class _Traits = char_traits<_CharT>, \n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) >\nclass basic_string;\n\ntypedef basic_string<char>    string;\ntypedef basic_string<wchar_t> wstring;\n\nstatic const char* __get_c_string(const string&);\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_STRING_FWD_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_tempbuf.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_TEMPBUF_H\n#define __SGI_STL_INTERNAL_TEMPBUF_H\n\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _Tp>\npair<_Tp*, ptrdiff_t> \n__get_temporary_buffer(ptrdiff_t __len, _Tp*)\n{\n  if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))\n    __len = INT_MAX / sizeof(_Tp);\n\n  while (__len > 0) {\n    _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp));\n    if (__tmp != 0)\n      return pair<_Tp*, ptrdiff_t>(__tmp, __len);\n    __len /= 2;\n  }\n\n  return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);\n}\n\n#ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n\ntemplate <class _Tp>\ninline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) {\n  return __get_temporary_buffer(__len, (_Tp*) 0);\n}\n\n#endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */\n\n// This overload is not required by the standard; it is an extension.\n// It is supported for backward compatibility with the HP STL, and\n// because not all compilers support the language feature (explicit\n// function template arguments) that is required for the standard\n// version of get_temporary_buffer.\ntemplate <class _Tp>\ninline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len, _Tp*) {\n  return __get_temporary_buffer(__len, (_Tp*) 0);\n}\n\ntemplate <class _Tp>\nvoid return_temporary_buffer(_Tp* __p) {\n  free(__p);\n}\n\ntemplate <class _ForwardIterator, class _Tp>\nclass _Temporary_buffer {\nprivate:\n  ptrdiff_t  _M_original_len;\n  ptrdiff_t  _M_len;\n  _Tp*       _M_buffer;\n\n  void _M_allocate_buffer() {\n    _M_original_len = _M_len;\n    _M_buffer = 0;\n\n    if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp)))\n      _M_len = INT_MAX / sizeof(_Tp);\n\n    while (_M_len > 0) {\n      _M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp));\n      if (_M_buffer)\n        break;\n      _M_len /= 2;\n    }\n  }\n\n  void _M_initialize_buffer(const _Tp&, __true_type) {}\n  void _M_initialize_buffer(const _Tp& val, __false_type) {\n    uninitialized_fill_n(_M_buffer, _M_len, val);\n  }\n\npublic:\n  ptrdiff_t size() const { return _M_len; }\n  ptrdiff_t requested_size() const { return _M_original_len; }\n  _Tp* begin() { return _M_buffer; }\n  _Tp* end() { return _M_buffer + _M_len; }\n\n  _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) {\n    // Workaround for a __type_traits bug in the pre-7.3 compiler.\n#   if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION < 730\n    typedef typename __type_traits<_Tp>::is_POD_type _Trivial;\n#   else\n    typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n            _Trivial;\n#   endif\n\n    __STL_TRY {\n      _M_len = 0;\n      distance(__first, __last, _M_len);\n      _M_allocate_buffer();\n      if (_M_len > 0)\n        _M_initialize_buffer(*__first, _Trivial());\n    }\n    __STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0);\n  }\n \n  ~_Temporary_buffer() {  \n    destroy(_M_buffer, _M_buffer + _M_len);\n    free(_M_buffer);\n  }\n\nprivate:\n  // Disable copy constructor and assignment operator.\n  _Temporary_buffer(const _Temporary_buffer&) {}\n  void operator=(const _Temporary_buffer&) {}\n};\n\n// Class temporary_buffer is not part of the standard.  It is an extension.\n\ntemplate <class _ForwardIterator, \n          class _Tp \n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n                    = typename iterator_traits<_ForwardIterator>::value_type\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n         >\nstruct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>\n{\n  temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)\n    : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {}\n  ~temporary_buffer() {}\n};\n    \n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_threads.h",
    "content": "/*\n * Copyright (c) 1997-1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n// WARNING: This is an internal header file, included by other C++\n// standard library headers.  You should not attempt to use this header\n// file directly.\n// Stl_config.h should be included before this file.\n\n#ifndef __SGI_STL_INTERNAL_THREADS_H\n#define __SGI_STL_INTERNAL_THREADS_H\n\n// Supported threading models are native SGI, pthreads, uithreads\n// (similar to pthreads, but based on an earlier draft of the Posix\n// threads standard), and Win32 threads.  Uithread support by Jochen\n// Schlick, 1999.\n\n#if defined(__STL_SGI_THREADS)\n#include <mutex.h>\n#include <time.h>\n#elif defined(__STL_PTHREADS)\n#include <pthread.h>\n#elif defined(__STL_UITHREADS)\n#include <thread.h>\n#include <synch.h>\n#elif defined(__STL_WIN32THREADS)\n#include <windows.h>\n#endif\n\n__STL_BEGIN_NAMESPACE\n\n\n// Class _Refcount_Base provides a type, _RC_t, a data member,\n// _M_ref_count, and member functions _M_incr and _M_decr, which perform\n// atomic preincrement/predecrement.  The constructor initializes \n// _M_ref_count.\n\n// Hack for SGI o32 compilers.\n#if defined(__STL_SGI_THREADS) && !defined(__add_and_fetch) && \\\n    (__mips < 3 || !(defined (_ABIN32) || defined(_ABI64)))\n#  define __add_and_fetch(__l,__v) add_then_test((unsigned long*)__l,__v)  \n#  define __test_and_set(__l,__v)  test_and_set(__l,__v)\n#endif /* o32 */\n\nstruct _Refcount_Base\n{\n  // The type _RC_t\n# ifdef __STL_WIN32THREADS\n  typedef long _RC_t;\n# else\n  typedef size_t _RC_t;\n#endif\n  \n  // The data member _M_ref_count\n   volatile _RC_t _M_ref_count;\n\n  // Constructor\n# ifdef __STL_PTHREADS\n  pthread_mutex_t _M_ref_count_lock;\n  _Refcount_Base(_RC_t __n) : _M_ref_count(__n)\n    { pthread_mutex_init(&_M_ref_count_lock, 0); }\n# elif defined(__STL_UITHREADS)\n  mutex_t         _M_ref_count_lock;\n  _Refcount_Base(_RC_t __n) : _M_ref_count(__n)\n    { mutex_init(&_M_ref_count_lock, USYNC_THREAD, 0); }\n# else\n  _Refcount_Base(_RC_t __n) : _M_ref_count(__n) {}\n# endif\n\n  // _M_incr and _M_decr\n# ifdef __STL_SGI_THREADS\n  void _M_incr() {  __add_and_fetch(&_M_ref_count, 1); }\n  _RC_t _M_decr() { return __add_and_fetch(&_M_ref_count, (size_t) -1); }\n# elif defined (__STL_WIN32THREADS)\n   void _M_incr() { InterlockedIncrement((_RC_t*)&_M_ref_count); }\n  _RC_t _M_decr() { return InterlockedDecrement((_RC_t*)&_M_ref_count); }\n# elif defined(__STL_PTHREADS)\n  void _M_incr() {\n    pthread_mutex_lock(&_M_ref_count_lock);\n    ++_M_ref_count;\n    pthread_mutex_unlock(&_M_ref_count_lock);\n  }\n  _RC_t _M_decr() {\n    pthread_mutex_lock(&_M_ref_count_lock);\n    volatile _RC_t __tmp = --_M_ref_count;\n    pthread_mutex_unlock(&_M_ref_count_lock);\n    return __tmp;\n  }\n# elif defined(__STL_UITHREADS)\n  void _M_incr() {\n    mutex_lock(&_M_ref_count_lock);\n    ++_M_ref_count;\n    mutex_unlock(&_M_ref_count_lock);\n  }\n  _RC_t _M_decr() {\n    mutex_lock(&_M_ref_count_lock);\n    /*volatile*/ _RC_t __tmp = --_M_ref_count;\n    mutex_unlock(&_M_ref_count_lock);\n    return __tmp;\n  }\n# else  /* No threads */\n  void _M_incr() { ++_M_ref_count; }\n  _RC_t _M_decr() { return --_M_ref_count; }\n# endif\n};\n\n// Atomic swap on unsigned long\n// This is guaranteed to behave as though it were atomic only if all\n// possibly concurrent updates use _Atomic_swap.\n// In some cases the operation is emulated with a lock.\n# ifdef __STL_SGI_THREADS\n    inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n#       if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))\n            return test_and_set(__p, __q);\n#       else\n            return __test_and_set(__p, (unsigned long)__q);\n#       endif\n    }\n# elif defined(__STL_WIN32THREADS)\n    inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n        return (unsigned long) InterlockedExchange((LPLONG)__p, (LONG)__q);\n    }\n# elif defined(__STL_PTHREADS)\n    // We use a template here only to get a unique initialized instance.\n    template<int __dummy>\n    struct _Swap_lock_struct {\n        static pthread_mutex_t _S_swap_lock;\n    };\n\n    template<int __dummy>\n    pthread_mutex_t\n    _Swap_lock_struct<__dummy>::_S_swap_lock = PTHREAD_MUTEX_INITIALIZER;\n\n    // This should be portable, but performance is expected\n    // to be quite awful.  This really needs platform specific\n    // code.\n    inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n        pthread_mutex_lock(&_Swap_lock_struct<0>::_S_swap_lock);\n        unsigned long __result = *__p;\n        *__p = __q;\n        pthread_mutex_unlock(&_Swap_lock_struct<0>::_S_swap_lock);\n        return __result;\n    }\n# elif defined(__STL_UITHREADS)\n    // We use a template here only to get a unique initialized instance.\n    template<int __dummy>\n    struct _Swap_lock_struct {\n        static mutex_t _S_swap_lock;\n    };\n\n    template<int __dummy>\n    mutex_t\n    _Swap_lock_struct<__dummy>::_S_swap_lock = DEFAULTMUTEX;\n\n    // This should be portable, but performance is expected\n    // to be quite awful.  This really needs platform specific\n    // code.\n    inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n        mutex_lock(&_Swap_lock_struct<0>::_S_swap_lock);\n        unsigned long __result = *__p;\n        *__p = __q;\n        mutex_unlock(&_Swap_lock_struct<0>::_S_swap_lock);\n        return __result;\n    }\n# elif defined (__STL_SOLARIS_THREADS)\n    // any better solutions ?\n    // We use a template here only to get a unique initialized instance.\n    template<int __dummy>\n    struct _Swap_lock_struct {\n        static mutex_t _S_swap_lock;\n    };\n\n# if ( __STL_STATIC_TEMPLATE_DATA > 0 )\n    template<int __dummy>\n    mutex_t\n    _Swap_lock_struct<__dummy>::_S_swap_lock = DEFAULTMUTEX;\n#  else\n    __DECLARE_INSTANCE(mutex_t, _Swap_lock_struct<__dummy>::_S_swap_lock, \n                       =DEFAULTMUTEX);\n# endif /* ( __STL_STATIC_TEMPLATE_DATA > 0 ) */\n\n    // This should be portable, but performance is expected\n    // to be quite awful.  This really needs platform specific\n    // code.\n    inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n        mutex_lock(&_Swap_lock_struct<0>::_S_swap_lock);\n        unsigned long __result = *__p;\n        *__p = __q;\n        mutex_unlock(&_Swap_lock_struct<0>::_S_swap_lock);\n        return __result;\n    }\n# else\n    static inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {\n        unsigned long __result = *__p;\n        *__p = __q;\n        return __result;\n    }\n# endif\n\n// Locking class.  Note that this class *does not have a constructor*.\n// It must be initialized either statically, with __STL_MUTEX_INITIALIZER,\n// or dynamically, by explicitly calling the _M_initialize member function.\n// (This is similar to the ways that a pthreads mutex can be initialized.)\n// There are explicit member functions for acquiring and releasing the lock.\n\n// There is no constructor because static initialization is essential for\n// some uses, and only a class aggregate (see section 8.5.1 of the C++\n// standard) can be initialized that way.  That means we must have no\n// constructors, no base classes, no virtual functions, and no private or\n// protected members.\n\n// Helper struct.  This is a workaround for various compilers that don't\n// handle static variables in inline functions properly.\ntemplate <int __inst>\nstruct _STL_mutex_spin {\n  enum { __low_max = 30, __high_max = 1000 };\n  // Low if we suspect uniprocessor, high for multiprocessor.\n\n  static unsigned __max;\n  static unsigned __last;\n};\n\ntemplate <int __inst>\nunsigned _STL_mutex_spin<__inst>::__max = _STL_mutex_spin<__inst>::__low_max;\n\ntemplate <int __inst>\nunsigned _STL_mutex_spin<__inst>::__last = 0;\n\nstruct _STL_mutex_lock\n{\n#if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS)\n  // It should be relatively easy to get this to work on any modern Unix.\n  volatile unsigned long _M_lock;\n  void _M_initialize() { _M_lock = 0; }\n  static void _S_nsec_sleep(int __log_nsec) {\n#     ifdef __STL_SGI_THREADS\n          struct timespec __ts;\n          /* Max sleep is 2**27nsec ~ 60msec      */\n          __ts.tv_sec = 0;\n          __ts.tv_nsec = 1 << __log_nsec;\n          nanosleep(&__ts, 0);\n#     elif defined(__STL_WIN32THREADS)\n          if (__log_nsec <= 20) {\n              Sleep(0);\n          } else {\n              Sleep(1 << (__log_nsec - 20));\n          }\n#     else\n#       error unimplemented\n#     endif\n  }\n  void _M_acquire_lock() {\n    volatile unsigned long* __lock = &this->_M_lock;\n\n    if (!_Atomic_swap((unsigned long*)__lock, 1)) {\n      return;\n    }\n    unsigned __my_spin_max = _STL_mutex_spin<0>::__max;\n    unsigned __my_last_spins = _STL_mutex_spin<0>::__last;\n    volatile unsigned __junk = 17;      // Value doesn't matter.\n    unsigned __i;\n    for (__i = 0; __i < __my_spin_max; __i++) {\n      if (__i < __my_last_spins/2 || *__lock) {\n        __junk *= __junk; __junk *= __junk;\n        __junk *= __junk; __junk *= __junk;\n        continue;\n      }\n      if (!_Atomic_swap((unsigned long*)__lock, 1)) {\n        // got it!\n        // Spinning worked.  Thus we're probably not being scheduled\n        // against the other process with which we were contending.\n        // Thus it makes sense to spin longer the next time.\n        _STL_mutex_spin<0>::__last = __i;\n        _STL_mutex_spin<0>::__max = _STL_mutex_spin<0>::__high_max;\n        return;\n      }\n    }\n    // We are probably being scheduled against the other process.  Sleep.\n    _STL_mutex_spin<0>::__max = _STL_mutex_spin<0>::__low_max;\n    for (__i = 0 ;; ++__i) {\n      int __log_nsec = __i + 6;\n\n      if (__log_nsec > 27) __log_nsec = 27;\n      if (!_Atomic_swap((unsigned long *)__lock, 1)) {\n        return;\n      }\n      _S_nsec_sleep(__log_nsec);\n    }\n  }\n  void _M_release_lock() {\n    volatile unsigned long* __lock = &_M_lock;\n#   if defined(__STL_SGI_THREADS) && defined(__GNUC__) && __mips >= 3\n        asm(\"sync\");\n        *__lock = 0;\n#   elif defined(__STL_SGI_THREADS) && __mips >= 3 \\\n         && (defined (_ABIN32) || defined(_ABI64))\n        __lock_release(__lock);\n#   else \n        *__lock = 0;\n        // This is not sufficient on many multiprocessors, since\n        // writes to protected variables and the lock may be reordered.\n#   endif\n  }\n\n// We no longer use win32 critical sections.\n// They appear to be slower in the contention-free case,\n// and they appear difficult to initialize without introducing a race.\n\n#elif defined(__STL_PTHREADS)\n  pthread_mutex_t _M_lock;\n  void _M_initialize()   { pthread_mutex_init(&_M_lock, NULL); }\n  void _M_acquire_lock() { pthread_mutex_lock(&_M_lock); }\n  void _M_release_lock() { pthread_mutex_unlock(&_M_lock); }\n#elif defined(__STL_UITHREADS)\n  mutex_t _M_lock;\n  void _M_initialize()   { mutex_init(&_M_lock, USYNC_THREAD, 0); }\n  void _M_acquire_lock() { mutex_lock(&_M_lock); }\n  void _M_release_lock() { mutex_unlock(&_M_lock); }\n#else /* No threads */\n  void _M_initialize()   {}\n  void _M_acquire_lock() {}\n  void _M_release_lock() {}\n#endif\n};\n\n#ifdef __STL_PTHREADS\n// Pthreads locks must be statically initialized to something other than\n// the default value of zero.\n#   define __STL_MUTEX_INITIALIZER = { PTHREAD_MUTEX_INITIALIZER }\n#elif defined(__STL_UITHREADS)\n// UIthreads locks must be statically initialized to something other than\n// the default value of zero.\n#   define __STL_MUTEX_INITIALIZER = { DEFAULTMUTEX }\n#elif defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS)\n#   define __STL_MUTEX_INITIALIZER = { 0 }\n#else\n#   define __STL_MUTEX_INITIALIZER\n#endif\n\n\n// A locking class that uses _STL_mutex_lock.  The constructor takes a\n// reference to an _STL_mutex_lock, and acquires a lock.  The\n// destructor releases the lock.  It's not clear that this is exactly\n// the right functionality.  It will probably change in the future.\n\nstruct _STL_auto_lock\n{\n  _STL_mutex_lock& _M_lock;\n  \n  _STL_auto_lock(_STL_mutex_lock& __lock) : _M_lock(__lock)\n    { _M_lock._M_acquire_lock(); }\n  ~_STL_auto_lock() { _M_lock._M_release_lock(); }\n\nprivate:\n  void operator=(const _STL_auto_lock&);\n  _STL_auto_lock(const _STL_auto_lock&);\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_THREADS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_tree.h",
    "content": "/*\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#define __SGI_STL_INTERNAL_TREE_H\n\n/*\n\nRed-black tree class, designed for use in implementing STL\nassociative containers (set, multiset, map, and multimap). The\ninsertion and deletion algorithms are based on those in Cormen,\nLeiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990),\nexcept that\n\n(1) the header cell is maintained with links not only to the root\nbut also to the leftmost node of the tree, to enable constant time\nbegin(), and to the rightmost node of the tree, to enable linear time\nperformance when used with the generic set algorithms (set_union,\netc.);\n\n(2) when a node being deleted has two children its successor node is\nrelinked into its place, rather than copied, so that the only\niterators invalidated are those referring to the deleted node.\n\n*/\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_function.h>\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1375\n#endif\n\ntypedef bool _Rb_tree_Color_type;\nconst _Rb_tree_Color_type _S_rb_tree_red = false;\nconst _Rb_tree_Color_type _S_rb_tree_black = true;\n\nstruct _Rb_tree_node_base\n{\n  typedef _Rb_tree_Color_type _Color_type;\n  typedef _Rb_tree_node_base* _Base_ptr;\n\n  _Color_type _M_color; \n  _Base_ptr _M_parent;\n  _Base_ptr _M_left;\n  _Base_ptr _M_right;\n\n  static _Base_ptr _S_minimum(_Base_ptr __x)\n  {\n    while (__x->_M_left != 0) __x = __x->_M_left;\n    return __x;\n  }\n\n  static _Base_ptr _S_maximum(_Base_ptr __x)\n  {\n    while (__x->_M_right != 0) __x = __x->_M_right;\n    return __x;\n  }\n};\n\ntemplate <class _Value>\nstruct _Rb_tree_node : public _Rb_tree_node_base\n{\n  typedef _Rb_tree_node<_Value>* _Link_type;\n  _Value _M_value_field;\n};\n\n\nstruct _Rb_tree_base_iterator\n{\n  typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef ptrdiff_t difference_type;\n  _Base_ptr _M_node;\n\n  void _M_increment()\n  {\n    if (_M_node->_M_right != 0) {\n      _M_node = _M_node->_M_right;\n      while (_M_node->_M_left != 0)\n        _M_node = _M_node->_M_left;\n    }\n    else {\n      _Base_ptr __y = _M_node->_M_parent;\n      while (_M_node == __y->_M_right) {\n        _M_node = __y;\n        __y = __y->_M_parent;\n      }\n      if (_M_node->_M_right != __y)\n        _M_node = __y;\n    }\n  }\n\n  void _M_decrement()\n  {\n    if (_M_node->_M_color == _S_rb_tree_red &&\n        _M_node->_M_parent->_M_parent == _M_node)\n      _M_node = _M_node->_M_right;\n    else if (_M_node->_M_left != 0) {\n      _Base_ptr __y = _M_node->_M_left;\n      while (__y->_M_right != 0)\n        __y = __y->_M_right;\n      _M_node = __y;\n    }\n    else {\n      _Base_ptr __y = _M_node->_M_parent;\n      while (_M_node == __y->_M_left) {\n        _M_node = __y;\n        __y = __y->_M_parent;\n      }\n      _M_node = __y;\n    }\n  }\n};\n\ntemplate <class _Value, class _Ref, class _Ptr>\nstruct _Rb_tree_iterator : public _Rb_tree_base_iterator\n{\n  typedef _Value value_type;\n  typedef _Ref reference;\n  typedef _Ptr pointer;\n  typedef _Rb_tree_iterator<_Value, _Value&, _Value*>             \n    iterator;\n  typedef _Rb_tree_iterator<_Value, const _Value&, const _Value*> \n    const_iterator;\n  typedef _Rb_tree_iterator<_Value, _Ref, _Ptr>                   \n    _Self;\n  typedef _Rb_tree_node<_Value>* _Link_type;\n\n  _Rb_tree_iterator() {}\n  _Rb_tree_iterator(_Link_type __x) { _M_node = __x; }\n  _Rb_tree_iterator(const iterator& __it) { _M_node = __it._M_node; }\n\n  reference operator*() const { return _Link_type(_M_node)->_M_value_field; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  _Self& operator++() { _M_increment(); return *this; }\n  _Self operator++(int) {\n    _Self __tmp = *this;\n    _M_increment();\n    return __tmp;\n  }\n    \n  _Self& operator--() { _M_decrement(); return *this; }\n  _Self operator--(int) {\n    _Self __tmp = *this;\n    _M_decrement();\n    return __tmp;\n  }\n};\n\ninline bool operator==(const _Rb_tree_base_iterator& __x,\n                       const _Rb_tree_base_iterator& __y) {\n  return __x._M_node == __y._M_node;\n}\n\ninline bool operator!=(const _Rb_tree_base_iterator& __x,\n                       const _Rb_tree_base_iterator& __y) {\n  return __x._M_node != __y._M_node;\n}\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ninline bidirectional_iterator_tag\niterator_category(const _Rb_tree_base_iterator&) {\n  return bidirectional_iterator_tag();\n}\n\ninline _Rb_tree_base_iterator::difference_type*\ndistance_type(const _Rb_tree_base_iterator&) {\n  return (_Rb_tree_base_iterator::difference_type*) 0;\n}\n\ntemplate <class _Value, class _Ref, class _Ptr>\ninline _Value* value_type(const _Rb_tree_iterator<_Value, _Ref, _Ptr>&) {\n  return (_Value*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ninline void \n_Rb_tree_rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)\n{\n  _Rb_tree_node_base* __y = __x->_M_right;\n  __x->_M_right = __y->_M_left;\n  if (__y->_M_left !=0)\n    __y->_M_left->_M_parent = __x;\n  __y->_M_parent = __x->_M_parent;\n\n  if (__x == __root)\n    __root = __y;\n  else if (__x == __x->_M_parent->_M_left)\n    __x->_M_parent->_M_left = __y;\n  else\n    __x->_M_parent->_M_right = __y;\n  __y->_M_left = __x;\n  __x->_M_parent = __y;\n}\n\ninline void \n_Rb_tree_rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)\n{\n  _Rb_tree_node_base* __y = __x->_M_left;\n  __x->_M_left = __y->_M_right;\n  if (__y->_M_right != 0)\n    __y->_M_right->_M_parent = __x;\n  __y->_M_parent = __x->_M_parent;\n\n  if (__x == __root)\n    __root = __y;\n  else if (__x == __x->_M_parent->_M_right)\n    __x->_M_parent->_M_right = __y;\n  else\n    __x->_M_parent->_M_left = __y;\n  __y->_M_right = __x;\n  __x->_M_parent = __y;\n}\n\ninline void \n_Rb_tree_rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)\n{\n  __x->_M_color = _S_rb_tree_red;\n  while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) {\n    if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) {\n      _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right;\n      if (__y && __y->_M_color == _S_rb_tree_red) {\n        __x->_M_parent->_M_color = _S_rb_tree_black;\n        __y->_M_color = _S_rb_tree_black;\n        __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;\n        __x = __x->_M_parent->_M_parent;\n      }\n      else {\n        if (__x == __x->_M_parent->_M_right) {\n          __x = __x->_M_parent;\n          _Rb_tree_rotate_left(__x, __root);\n        }\n        __x->_M_parent->_M_color = _S_rb_tree_black;\n        __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;\n        _Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root);\n      }\n    }\n    else {\n      _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left;\n      if (__y && __y->_M_color == _S_rb_tree_red) {\n        __x->_M_parent->_M_color = _S_rb_tree_black;\n        __y->_M_color = _S_rb_tree_black;\n        __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;\n        __x = __x->_M_parent->_M_parent;\n      }\n      else {\n        if (__x == __x->_M_parent->_M_left) {\n          __x = __x->_M_parent;\n          _Rb_tree_rotate_right(__x, __root);\n        }\n        __x->_M_parent->_M_color = _S_rb_tree_black;\n        __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;\n        _Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root);\n      }\n    }\n  }\n  __root->_M_color = _S_rb_tree_black;\n}\n\ninline _Rb_tree_node_base*\n_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* __z,\n                             _Rb_tree_node_base*& __root,\n                             _Rb_tree_node_base*& __leftmost,\n                             _Rb_tree_node_base*& __rightmost)\n{\n  _Rb_tree_node_base* __y = __z;\n  _Rb_tree_node_base* __x = 0;\n  _Rb_tree_node_base* __x_parent = 0;\n  if (__y->_M_left == 0)     // __z has at most one non-null child. y == z.\n    __x = __y->_M_right;     // __x might be null.\n  else\n    if (__y->_M_right == 0)  // __z has exactly one non-null child. y == z.\n      __x = __y->_M_left;    // __x is not null.\n    else {                   // __z has two non-null children.  Set __y to\n      __y = __y->_M_right;   //   __z's successor.  __x might be null.\n      while (__y->_M_left != 0)\n        __y = __y->_M_left;\n      __x = __y->_M_right;\n    }\n  if (__y != __z) {          // relink y in place of z.  y is z's successor\n    __z->_M_left->_M_parent = __y; \n    __y->_M_left = __z->_M_left;\n    if (__y != __z->_M_right) {\n      __x_parent = __y->_M_parent;\n      if (__x) __x->_M_parent = __y->_M_parent;\n      __y->_M_parent->_M_left = __x;      // __y must be a child of _M_left\n      __y->_M_right = __z->_M_right;\n      __z->_M_right->_M_parent = __y;\n    }\n    else\n      __x_parent = __y;  \n    if (__root == __z)\n      __root = __y;\n    else if (__z->_M_parent->_M_left == __z)\n      __z->_M_parent->_M_left = __y;\n    else \n      __z->_M_parent->_M_right = __y;\n    __y->_M_parent = __z->_M_parent;\n    __STD::swap(__y->_M_color, __z->_M_color);\n    __y = __z;\n    // __y now points to node to be actually deleted\n  }\n  else {                        // __y == __z\n    __x_parent = __y->_M_parent;\n    if (__x) __x->_M_parent = __y->_M_parent;   \n    if (__root == __z)\n      __root = __x;\n    else \n      if (__z->_M_parent->_M_left == __z)\n        __z->_M_parent->_M_left = __x;\n      else\n        __z->_M_parent->_M_right = __x;\n    if (__leftmost == __z) \n      if (__z->_M_right == 0)        // __z->_M_left must be null also\n        __leftmost = __z->_M_parent;\n    // makes __leftmost == _M_header if __z == __root\n      else\n        __leftmost = _Rb_tree_node_base::_S_minimum(__x);\n    if (__rightmost == __z)  \n      if (__z->_M_left == 0)         // __z->_M_right must be null also\n        __rightmost = __z->_M_parent;  \n    // makes __rightmost == _M_header if __z == __root\n      else                      // __x == __z->_M_left\n        __rightmost = _Rb_tree_node_base::_S_maximum(__x);\n  }\n  if (__y->_M_color != _S_rb_tree_red) { \n    while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black))\n      if (__x == __x_parent->_M_left) {\n        _Rb_tree_node_base* __w = __x_parent->_M_right;\n        if (__w->_M_color == _S_rb_tree_red) {\n          __w->_M_color = _S_rb_tree_black;\n          __x_parent->_M_color = _S_rb_tree_red;\n          _Rb_tree_rotate_left(__x_parent, __root);\n          __w = __x_parent->_M_right;\n        }\n        if ((__w->_M_left == 0 || \n             __w->_M_left->_M_color == _S_rb_tree_black) &&\n            (__w->_M_right == 0 || \n             __w->_M_right->_M_color == _S_rb_tree_black)) {\n          __w->_M_color = _S_rb_tree_red;\n          __x = __x_parent;\n          __x_parent = __x_parent->_M_parent;\n        } else {\n          if (__w->_M_right == 0 || \n              __w->_M_right->_M_color == _S_rb_tree_black) {\n            if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black;\n            __w->_M_color = _S_rb_tree_red;\n            _Rb_tree_rotate_right(__w, __root);\n            __w = __x_parent->_M_right;\n          }\n          __w->_M_color = __x_parent->_M_color;\n          __x_parent->_M_color = _S_rb_tree_black;\n          if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black;\n          _Rb_tree_rotate_left(__x_parent, __root);\n          break;\n        }\n      } else {                  // same as above, with _M_right <-> _M_left.\n        _Rb_tree_node_base* __w = __x_parent->_M_left;\n        if (__w->_M_color == _S_rb_tree_red) {\n          __w->_M_color = _S_rb_tree_black;\n          __x_parent->_M_color = _S_rb_tree_red;\n          _Rb_tree_rotate_right(__x_parent, __root);\n          __w = __x_parent->_M_left;\n        }\n        if ((__w->_M_right == 0 || \n             __w->_M_right->_M_color == _S_rb_tree_black) &&\n            (__w->_M_left == 0 || \n             __w->_M_left->_M_color == _S_rb_tree_black)) {\n          __w->_M_color = _S_rb_tree_red;\n          __x = __x_parent;\n          __x_parent = __x_parent->_M_parent;\n        } else {\n          if (__w->_M_left == 0 || \n              __w->_M_left->_M_color == _S_rb_tree_black) {\n            if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black;\n            __w->_M_color = _S_rb_tree_red;\n            _Rb_tree_rotate_left(__w, __root);\n            __w = __x_parent->_M_left;\n          }\n          __w->_M_color = __x_parent->_M_color;\n          __x_parent->_M_color = _S_rb_tree_black;\n          if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black;\n          _Rb_tree_rotate_right(__x_parent, __root);\n          break;\n        }\n      }\n    if (__x) __x->_M_color = _S_rb_tree_black;\n  }\n  return __y;\n}\n\n// Base class to encapsulate the differences between old SGI-style\n// allocators and standard-conforming allocators.  In order to avoid\n// having an empty base class, we arbitrarily move one of rb_tree's\n// data members into the base class.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// _Base for general standard-conforming allocators.\ntemplate <class _Tp, class _Alloc, bool _S_instanceless>\nclass _Rb_tree_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _M_node_allocator; }\n\n  _Rb_tree_alloc_base(const allocator_type& __a)\n    : _M_node_allocator(__a), _M_header(0) {}\n\nprotected:\n  typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::allocator_type\n           _M_node_allocator;\n  _Rb_tree_node<_Tp>* _M_header;\n\n  _Rb_tree_node<_Tp>* _M_get_node() \n    { return _M_node_allocator.allocate(1); }\n  void _M_put_node(_Rb_tree_node<_Tp>* __p) \n    { _M_node_allocator.deallocate(__p, 1); }\n};\n\n// Specialization for instanceless allocators.\ntemplate <class _Tp, class _Alloc>\nclass _Rb_tree_alloc_base<_Tp, _Alloc, true> {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Rb_tree_alloc_base(const allocator_type&) : _M_header(0) {}\n\nprotected:\n  _Rb_tree_node<_Tp>* _M_header;\n\n  typedef typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::_Alloc_type\n          _Alloc_type;\n\n  _Rb_tree_node<_Tp>* _M_get_node()\n    { return _Alloc_type::allocate(1); }\n  void _M_put_node(_Rb_tree_node<_Tp>* __p)\n    { _Alloc_type::deallocate(__p, 1); }\n};\n\ntemplate <class _Tp, class _Alloc>\nstruct _Rb_tree_base\n  : public _Rb_tree_alloc_base<_Tp, _Alloc,\n                               _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\n  typedef _Rb_tree_alloc_base<_Tp, _Alloc,\n                              _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n\n  _Rb_tree_base(const allocator_type& __a) \n    : _Base(__a) { _M_header = _M_get_node(); }\n  ~_Rb_tree_base() { _M_put_node(_M_header); }\n\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc>\nstruct _Rb_tree_base\n{\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Rb_tree_base(const allocator_type&) \n    : _M_header(0) { _M_header = _M_get_node(); }\n  ~_Rb_tree_base() { _M_put_node(_M_header); }\n\nprotected:\n  _Rb_tree_node<_Tp>* _M_header;\n\n  typedef simple_alloc<_Rb_tree_node<_Tp>, _Alloc> _Alloc_type;\n\n  _Rb_tree_node<_Tp>* _M_get_node()\n    { return _Alloc_type::allocate(1); }\n  void _M_put_node(_Rb_tree_node<_Tp>* __p)\n    { _Alloc_type::deallocate(__p, 1); }\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Key, class _Value, class _KeyOfValue, class _Compare,\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >\nclass _Rb_tree : protected _Rb_tree_base<_Value, _Alloc> {\n  typedef _Rb_tree_base<_Value, _Alloc> _Base;\nprotected:\n  typedef _Rb_tree_node_base* _Base_ptr;\n  typedef _Rb_tree_node<_Value> _Rb_tree_node;\n  typedef _Rb_tree_Color_type _Color_type;\npublic:\n  typedef _Key key_type;\n  typedef _Value value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef _Rb_tree_node* _Link_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\nprotected:\n#ifdef __STL_USE_NAMESPACES\n  using _Base::_M_get_node;\n  using _Base::_M_put_node;\n  using _Base::_M_header;\n#endif /* __STL_USE_NAMESPACES */\n\nprotected:\n\n  _Link_type _M_create_node(const value_type& __x)\n  {\n    _Link_type __tmp = _M_get_node();\n    __STL_TRY {\n      construct(&__tmp->_M_value_field, __x);\n    }\n    __STL_UNWIND(_M_put_node(__tmp));\n    return __tmp;\n  }\n\n  _Link_type _M_clone_node(_Link_type __x)\n  {\n    _Link_type __tmp = _M_create_node(__x->_M_value_field);\n    __tmp->_M_color = __x->_M_color;\n    __tmp->_M_left = 0;\n    __tmp->_M_right = 0;\n    return __tmp;\n  }\n\n  void destroy_node(_Link_type __p)\n  {\n    destroy(&__p->_M_value_field);\n    _M_put_node(__p);\n  }\n\nprotected:\n  size_type _M_node_count; // keeps track of size of tree\n  _Compare _M_key_compare;\n\n  _Link_type& _M_root() const \n    { return (_Link_type&) _M_header->_M_parent; }\n  _Link_type& _M_leftmost() const \n    { return (_Link_type&) _M_header->_M_left; }\n  _Link_type& _M_rightmost() const \n    { return (_Link_type&) _M_header->_M_right; }\n\n  static _Link_type& _S_left(_Link_type __x)\n    { return (_Link_type&)(__x->_M_left); }\n  static _Link_type& _S_right(_Link_type __x)\n    { return (_Link_type&)(__x->_M_right); }\n  static _Link_type& _S_parent(_Link_type __x)\n    { return (_Link_type&)(__x->_M_parent); }\n  static reference _S_value(_Link_type __x)\n    { return __x->_M_value_field; }\n  static const _Key& _S_key(_Link_type __x)\n    { return _KeyOfValue()(_S_value(__x)); }\n  static _Color_type& _S_color(_Link_type __x)\n    { return (_Color_type&)(__x->_M_color); }\n\n  static _Link_type& _S_left(_Base_ptr __x)\n    { return (_Link_type&)(__x->_M_left); }\n  static _Link_type& _S_right(_Base_ptr __x)\n    { return (_Link_type&)(__x->_M_right); }\n  static _Link_type& _S_parent(_Base_ptr __x)\n    { return (_Link_type&)(__x->_M_parent); }\n  static reference _S_value(_Base_ptr __x)\n    { return ((_Link_type)__x)->_M_value_field; }\n  static const _Key& _S_key(_Base_ptr __x)\n    { return _KeyOfValue()(_S_value(_Link_type(__x)));} \n  static _Color_type& _S_color(_Base_ptr __x)\n    { return (_Color_type&)(_Link_type(__x)->_M_color); }\n\n  static _Link_type _S_minimum(_Link_type __x) \n    { return (_Link_type)  _Rb_tree_node_base::_S_minimum(__x); }\n\n  static _Link_type _S_maximum(_Link_type __x)\n    { return (_Link_type) _Rb_tree_node_base::_S_maximum(__x); }\n\npublic:\n  typedef _Rb_tree_iterator<value_type, reference, pointer> iterator;\n  typedef _Rb_tree_iterator<value_type, const_reference, const_pointer> \n          const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_bidirectional_iterator<iterator, value_type, reference,\n                                         difference_type>\n          reverse_iterator; \n  typedef reverse_bidirectional_iterator<const_iterator, value_type,\n                                         const_reference, difference_type>\n          const_reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \n\nprivate:\n  iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v);\n  _Link_type _M_copy(_Link_type __x, _Link_type __p);\n  void _M_erase(_Link_type __x);\n\npublic:\n                                // allocation/deallocation\n  _Rb_tree()\n    : _Base(allocator_type()), _M_node_count(0), _M_key_compare()\n    { _M_empty_initialize(); }\n\n  _Rb_tree(const _Compare& __comp)\n    : _Base(allocator_type()), _M_node_count(0), _M_key_compare(__comp) \n    { _M_empty_initialize(); }\n\n  _Rb_tree(const _Compare& __comp, const allocator_type& __a)\n    : _Base(__a), _M_node_count(0), _M_key_compare(__comp) \n    { _M_empty_initialize(); }\n\n  _Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) \n    : _Base(__x.get_allocator()),\n      _M_node_count(0), _M_key_compare(__x._M_key_compare)\n  { \n    if (__x._M_root() == 0)\n      _M_empty_initialize();\n    else {\n      _S_color(_M_header) = _S_rb_tree_red;\n      _M_root() = _M_copy(__x._M_root(), _M_header);\n      _M_leftmost() = _S_minimum(_M_root());\n      _M_rightmost() = _S_maximum(_M_root());\n    }\n    _M_node_count = __x._M_node_count;\n  }\n  ~_Rb_tree() { clear(); }\n  _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& \n  operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x);\n\nprivate:\n  void _M_empty_initialize() {\n    _S_color(_M_header) = _S_rb_tree_red; // used to distinguish header from \n                                          // __root, in iterator.operator++\n    _M_root() = 0;\n    _M_leftmost() = _M_header;\n    _M_rightmost() = _M_header;\n  }\n\npublic:    \n                                // accessors:\n  _Compare key_comp() const { return _M_key_compare; }\n  iterator begin() { return _M_leftmost(); }\n  const_iterator begin() const { return _M_leftmost(); }\n  iterator end() { return _M_header; }\n  const_iterator end() const { return _M_header; }\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin());\n  } \n  bool empty() const { return _M_node_count == 0; }\n  size_type size() const { return _M_node_count; }\n  size_type max_size() const { return size_type(-1); }\n\n  void swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __t) {\n    __STD::swap(_M_header, __t._M_header);\n    __STD::swap(_M_node_count, __t._M_node_count);\n    __STD::swap(_M_key_compare, __t._M_key_compare);\n  }\n    \npublic:\n                                // insert/erase\n  pair<iterator,bool> insert_unique(const value_type& __x);\n  iterator insert_equal(const value_type& __x);\n\n  iterator insert_unique(iterator __position, const value_type& __x);\n  iterator insert_equal(iterator __position, const value_type& __x);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class _InputIterator>\n  void insert_unique(_InputIterator __first, _InputIterator __last);\n  template <class _InputIterator>\n  void insert_equal(_InputIterator __first, _InputIterator __last);\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert_unique(const_iterator __first, const_iterator __last);\n  void insert_unique(const value_type* __first, const value_type* __last);\n  void insert_equal(const_iterator __first, const_iterator __last);\n  void insert_equal(const value_type* __first, const value_type* __last);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void erase(iterator __position);\n  size_type erase(const key_type& __x);\n  void erase(iterator __first, iterator __last);\n  void erase(const key_type* __first, const key_type* __last);\n  void clear() {\n    if (_M_node_count != 0) {\n      _M_erase(_M_root());\n      _M_leftmost() = _M_header;\n      _M_root() = 0;\n      _M_rightmost() = _M_header;\n      _M_node_count = 0;\n    }\n  }      \n\npublic:\n                                // set operations:\n  iterator find(const key_type& __x);\n  const_iterator find(const key_type& __x) const;\n  size_type count(const key_type& __x) const;\n  iterator lower_bound(const key_type& __x);\n  const_iterator lower_bound(const key_type& __x) const;\n  iterator upper_bound(const key_type& __x);\n  const_iterator upper_bound(const key_type& __x) const;\n  pair<iterator,iterator> equal_range(const key_type& __x);\n  pair<const_iterator, const_iterator> equal_range(const key_type& __x) const;\n\npublic:\n                                // Debugging.\n  bool __rb_verify() const;\n};\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator==(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)\n{\n  return __x.size() == __y.size() &&\n         equal(__x.begin(), __x.end(), __y.begin());\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator<(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n          const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)\n{\n  return lexicographical_compare(__x.begin(), __x.end(), \n                                 __y.begin(), __y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator!=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator>(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n          const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator<=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline bool \noperator>=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline void \nswap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, \n     _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)\n{\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x)\n{\n  if (this != &__x) {\n                                // Note that _Key may be a constant type.\n    clear();\n    _M_node_count = 0;\n    _M_key_compare = __x._M_key_compare;        \n    if (__x._M_root() == 0) {\n      _M_root() = 0;\n      _M_leftmost() = _M_header;\n      _M_rightmost() = _M_header;\n    }\n    else {\n      _M_root() = _M_copy(__x._M_root(), _M_header);\n      _M_leftmost() = _S_minimum(_M_root());\n      _M_rightmost() = _S_maximum(_M_root());\n      _M_node_count = __x._M_node_count;\n    }\n  }\n  return *this;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator\n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::_M_insert(_Base_ptr __x_, _Base_ptr __y_, const _Value& __v)\n{\n  _Link_type __x = (_Link_type) __x_;\n  _Link_type __y = (_Link_type) __y_;\n  _Link_type __z;\n\n  if (__y == _M_header || __x != 0 || \n      _M_key_compare(_KeyOfValue()(__v), _S_key(__y))) {\n    __z = _M_create_node(__v);\n    _S_left(__y) = __z;               // also makes _M_leftmost() = __z \n                                      //    when __y == _M_header\n    if (__y == _M_header) {\n      _M_root() = __z;\n      _M_rightmost() = __z;\n    }\n    else if (__y == _M_leftmost())\n      _M_leftmost() = __z;   // maintain _M_leftmost() pointing to min node\n  }\n  else {\n    __z = _M_create_node(__v);\n    _S_right(__y) = __z;\n    if (__y == _M_rightmost())\n      _M_rightmost() = __z;  // maintain _M_rightmost() pointing to max node\n  }\n  _S_parent(__z) = __y;\n  _S_left(__z) = 0;\n  _S_right(__z) = 0;\n  _Rb_tree_rebalance(__z, _M_header->_M_parent);\n  ++_M_node_count;\n  return iterator(__z);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator\n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::insert_equal(const _Value& __v)\n{\n  _Link_type __y = _M_header;\n  _Link_type __x = _M_root();\n  while (__x != 0) {\n    __y = __x;\n    __x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ? \n            _S_left(__x) : _S_right(__x);\n  }\n  return _M_insert(__x, __y, __v);\n}\n\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\npair<typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator, \n     bool>\n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::insert_unique(const _Value& __v)\n{\n  _Link_type __y = _M_header;\n  _Link_type __x = _M_root();\n  bool __comp = true;\n  while (__x != 0) {\n    __y = __x;\n    __comp = _M_key_compare(_KeyOfValue()(__v), _S_key(__x));\n    __x = __comp ? _S_left(__x) : _S_right(__x);\n  }\n  iterator __j = iterator(__y);   \n  if (__comp)\n    if (__j == begin())     \n      return pair<iterator,bool>(_M_insert(__x, __y, __v), true);\n    else\n      --__j;\n  if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))\n    return pair<iterator,bool>(_M_insert(__x, __y, __v), true);\n  return pair<iterator,bool>(__j, false);\n}\n\n\ntemplate <class _Key, class _Val, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator \n_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>\n  ::insert_unique(iterator __position, const _Val& __v)\n{\n  if (__position._M_node == _M_header->_M_left) { // begin()\n    if (size() > 0 && \n        _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))\n      return _M_insert(__position._M_node, __position._M_node, __v);\n    // first argument just needs to be non-null \n    else\n      return insert_unique(__v).first;\n  } else if (__position._M_node == _M_header) { // end()\n    if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v)))\n      return _M_insert(0, _M_rightmost(), __v);\n    else\n      return insert_unique(__v).first;\n  } else {\n    iterator __before = __position;\n    --__before;\n    if (_M_key_compare(_S_key(__before._M_node), _KeyOfValue()(__v)) \n        && _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) {\n      if (_S_right(__before._M_node) == 0)\n        return _M_insert(0, __before._M_node, __v); \n      else\n        return _M_insert(__position._M_node, __position._M_node, __v);\n    // first argument just needs to be non-null \n    } else\n      return insert_unique(__v).first;\n  }\n}\n\ntemplate <class _Key, class _Val, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator \n_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>\n  ::insert_equal(iterator __position, const _Val& __v)\n{\n  if (__position._M_node == _M_header->_M_left) { // begin()\n    if (size() > 0 && \n        !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v)))\n      return _M_insert(__position._M_node, __position._M_node, __v);\n    // first argument just needs to be non-null \n    else\n      return insert_equal(__v);\n  } else if (__position._M_node == _M_header) {// end()\n    if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost())))\n      return _M_insert(0, _M_rightmost(), __v);\n    else\n      return insert_equal(__v);\n  } else {\n    iterator __before = __position;\n    --__before;\n    if (!_M_key_compare(_KeyOfValue()(__v), _S_key(__before._M_node))\n        && !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) {\n      if (_S_right(__before._M_node) == 0)\n        return _M_insert(0, __before._M_node, __v); \n      else\n        return _M_insert(__position._M_node, __position._M_node, __v);\n    // first argument just needs to be non-null \n    } else\n      return insert_equal(__v);\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>\n  template<class _II>\nvoid _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_equal(_II __first, _II __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert_equal(*__first);\n}\n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc> \n  template<class _II>\nvoid _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_unique(_II __first, _II __last) {\n  for ( ; __first != __last; ++__first)\n    insert_unique(*__first);\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>\nvoid\n_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_equal(const _Val* __first, const _Val* __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert_equal(*__first);\n}\n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>\nvoid\n_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_equal(const_iterator __first, const_iterator __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert_equal(*__first);\n}\n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>\nvoid \n_Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_unique(const _Val* __first, const _Val* __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert_unique(*__first);\n}\n\ntemplate <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>\nvoid _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>\n  ::insert_unique(const_iterator __first, const_iterator __last)\n{\n  for ( ; __first != __last; ++__first)\n    insert_unique(*__first);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n         \ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::erase(iterator __position)\n{\n  _Link_type __y = \n    (_Link_type) _Rb_tree_rebalance_for_erase(__position._M_node,\n                                              _M_header->_M_parent,\n                                              _M_header->_M_left,\n                                              _M_header->_M_right);\n  destroy_node(__y);\n  --_M_node_count;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::erase(const _Key& __x)\n{\n  pair<iterator,iterator> __p = equal_range(__x);\n  size_type __n = 0;\n  distance(__p.first, __p.second, __n);\n  erase(__p.first, __p.second);\n  return __n;\n}\n\ntemplate <class _Key, class _Val, class _KoV, class _Compare, class _Alloc>\ntypename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type \n_Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>\n  ::_M_copy(_Link_type __x, _Link_type __p)\n{\n                        // structural copy.  __x and __p must be non-null.\n  _Link_type __top = _M_clone_node(__x);\n  __top->_M_parent = __p;\n \n  __STL_TRY {\n    if (__x->_M_right)\n      __top->_M_right = _M_copy(_S_right(__x), __top);\n    __p = __top;\n    __x = _S_left(__x);\n\n    while (__x != 0) {\n      _Link_type __y = _M_clone_node(__x);\n      __p->_M_left = __y;\n      __y->_M_parent = __p;\n      if (__x->_M_right)\n        __y->_M_right = _M_copy(_S_right(__x), __y);\n      __p = __y;\n      __x = _S_left(__x);\n    }\n  }\n  __STL_UNWIND(_M_erase(__top));\n\n  return __top;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\nvoid _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::_M_erase(_Link_type __x)\n{\n                                // erase without rebalancing\n  while (__x != 0) {\n    _M_erase(_S_right(__x));\n    _Link_type __y = _S_left(__x);\n    destroy_node(__x);\n    __x = __y;\n  }\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\nvoid _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::erase(iterator __first, iterator __last)\n{\n  if (__first == begin() && __last == end())\n    clear();\n  else\n    while (__first != __last) erase(__first++);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\nvoid _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::erase(const _Key* __first, const _Key* __last) \n{\n  while (__first != __last) erase(*__first++);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k)\n{\n  _Link_type __y = _M_header;      // Last node which is not less than __k. \n  _Link_type __x = _M_root();      // Current node. \n\n  while (__x != 0) \n    if (!_M_key_compare(_S_key(__x), __k))\n      __y = __x, __x = _S_left(__x);\n    else\n      __x = _S_right(__x);\n\n  iterator __j = iterator(__y);   \n  return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ? \n     end() : __j;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) const\n{\n  _Link_type __y = _M_header; /* Last node which is not less than __k. */\n  _Link_type __x = _M_root(); /* Current node. */\n\n  while (__x != 0) {\n    if (!_M_key_compare(_S_key(__x), __k))\n      __y = __x, __x = _S_left(__x);\n    else\n      __x = _S_right(__x);\n  }\n  const_iterator __j = const_iterator(__y);   \n  return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ?\n    end() : __j;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::count(const _Key& __k) const\n{\n  pair<const_iterator, const_iterator> __p = equal_range(__k);\n  size_type __n = 0;\n  distance(__p.first, __p.second, __n);\n  return __n;\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::lower_bound(const _Key& __k)\n{\n  _Link_type __y = _M_header; /* Last node which is not less than __k. */\n  _Link_type __x = _M_root(); /* Current node. */\n\n  while (__x != 0) \n    if (!_M_key_compare(_S_key(__x), __k))\n      __y = __x, __x = _S_left(__x);\n    else\n      __x = _S_right(__x);\n\n  return iterator(__y);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::lower_bound(const _Key& __k) const\n{\n  _Link_type __y = _M_header; /* Last node which is not less than __k. */\n  _Link_type __x = _M_root(); /* Current node. */\n\n  while (__x != 0) \n    if (!_M_key_compare(_S_key(__x), __k))\n      __y = __x, __x = _S_left(__x);\n    else\n      __x = _S_right(__x);\n\n  return const_iterator(__y);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::upper_bound(const _Key& __k)\n{\n  _Link_type __y = _M_header; /* Last node which is greater than __k. */\n  _Link_type __x = _M_root(); /* Current node. */\n\n   while (__x != 0) \n     if (_M_key_compare(__k, _S_key(__x)))\n       __y = __x, __x = _S_left(__x);\n     else\n       __x = _S_right(__x);\n\n   return iterator(__y);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ntypename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator \n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::upper_bound(const _Key& __k) const\n{\n  _Link_type __y = _M_header; /* Last node which is greater than __k. */\n  _Link_type __x = _M_root(); /* Current node. */\n\n   while (__x != 0) \n     if (_M_key_compare(__k, _S_key(__x)))\n       __y = __x, __x = _S_left(__x);\n     else\n       __x = _S_right(__x);\n\n   return const_iterator(__y);\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\ninline \npair<typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator,\n     typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator>\n_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>\n  ::equal_range(const _Key& __k)\n{\n  return pair<iterator, iterator>(lower_bound(__k), upper_bound(__k));\n}\n\ntemplate <class _Key, class _Value, class _KoV, class _Compare, class _Alloc>\ninline \npair<typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator,\n     typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator>\n_Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>\n  ::equal_range(const _Key& __k) const\n{\n  return pair<const_iterator,const_iterator>(lower_bound(__k),\n                                             upper_bound(__k));\n}\n\ninline int \n__black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root)\n{\n  if (__node == 0)\n    return 0;\n  else {\n    int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0;\n    if (__node == __root)\n      return __bc;\n    else\n      return __bc + __black_count(__node->_M_parent, __root);\n  }\n}\n\ntemplate <class _Key, class _Value, class _KeyOfValue, \n          class _Compare, class _Alloc>\nbool _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const\n{\n  if (_M_node_count == 0 || begin() == end())\n    return _M_node_count == 0 && begin() == end() &&\n      _M_header->_M_left == _M_header && _M_header->_M_right == _M_header;\n  \n  int __len = __black_count(_M_leftmost(), _M_root());\n  for (const_iterator __it = begin(); __it != end(); ++__it) {\n    _Link_type __x = (_Link_type) __it._M_node;\n    _Link_type __L = _S_left(__x);\n    _Link_type __R = _S_right(__x);\n\n    if (__x->_M_color == _S_rb_tree_red)\n      if ((__L && __L->_M_color == _S_rb_tree_red) ||\n          (__R && __R->_M_color == _S_rb_tree_red))\n        return false;\n\n    if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))\n      return false;\n    if (__R && _M_key_compare(_S_key(__R), _S_key(__x)))\n      return false;\n\n    if (!__L && !__R && __black_count(__x, _M_root()) != __len)\n      return false;\n  }\n\n  if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))\n    return false;\n  if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))\n    return false;\n\n  return true;\n}\n\n// Class rb_tree is not part of the C++ standard.  It is provided for\n// compatibility with the HP STL.\n\ntemplate <class _Key, class _Value, class _KeyOfValue, class _Compare,\n          class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >\nstruct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>\n{\n  typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;\n  typedef typename _Base::allocator_type allocator_type;\n\n  rb_tree(const _Compare& __comp = _Compare(),\n          const allocator_type& __a = allocator_type())\n    : _Base(__comp, __a) {}\n  \n  ~rb_tree() {}\n};\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_TREE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_uninitialized.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H\n#define __SGI_STL_INTERNAL_UNINITIALIZED_H\n\n__STL_BEGIN_NAMESPACE\n\n// uninitialized_copy\n\n// Valid if copy construction is equivalent to assignment, and if the\n//  destructor is trivial.\ntemplate <class _InputIter, class _ForwardIter>\ninline _ForwardIter \n__uninitialized_copy_aux(_InputIter __first, _InputIter __last,\n                         _ForwardIter __result,\n                         __true_type)\n{\n  return copy(__first, __last, __result);\n}\n\ntemplate <class _InputIter, class _ForwardIter>\n_ForwardIter \n__uninitialized_copy_aux(_InputIter __first, _InputIter __last,\n                         _ForwardIter __result,\n                         __false_type)\n{\n  _ForwardIter __cur = __result;\n  __STL_TRY {\n    for ( ; __first != __last; ++__first, ++__cur)\n      _Construct(&*__cur, *__first);\n    return __cur;\n  }\n  __STL_UNWIND(_Destroy(__result, __cur));\n}\n\n\ntemplate <class _InputIter, class _ForwardIter, class _Tp>\ninline _ForwardIter\n__uninitialized_copy(_InputIter __first, _InputIter __last,\n                     _ForwardIter __result, _Tp*)\n{\n  typedef typename __type_traits<_Tp>::is_POD_type _Is_POD;\n  return __uninitialized_copy_aux(__first, __last, __result, _Is_POD());\n}\n\ntemplate <class _InputIter, class _ForwardIter>\ninline _ForwardIter\n  uninitialized_copy(_InputIter __first, _InputIter __last,\n                     _ForwardIter __result)\n{\n  return __uninitialized_copy(__first, __last, __result,\n                              __VALUE_TYPE(__result));\n}\n\ninline char* uninitialized_copy(const char* __first, const char* __last,\n                                char* __result) {\n  memmove(__result, __first, __last - __first);\n  return __result + (__last - __first);\n}\n\ninline wchar_t* \nuninitialized_copy(const wchar_t* __first, const wchar_t* __last,\n                   wchar_t* __result)\n{\n  memmove(__result, __first, sizeof(wchar_t) * (__last - __first));\n  return __result + (__last - __first);\n}\n\n// uninitialized_copy_n (not part of the C++ standard)\n\ntemplate <class _InputIter, class _Size, class _ForwardIter>\npair<_InputIter, _ForwardIter>\n__uninitialized_copy_n(_InputIter __first, _Size __count,\n                       _ForwardIter __result,\n                       input_iterator_tag)\n{\n  _ForwardIter __cur = __result;\n  __STL_TRY {\n    for ( ; __count > 0 ; --__count, ++__first, ++__cur) \n      _Construct(&*__cur, *__first);\n    return pair<_InputIter, _ForwardIter>(__first, __cur);\n  }\n  __STL_UNWIND(_Destroy(__result, __cur));\n}\n\ntemplate <class _RandomAccessIter, class _Size, class _ForwardIter>\ninline pair<_RandomAccessIter, _ForwardIter>\n__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,\n                       _ForwardIter __result,\n                       random_access_iterator_tag) {\n  _RandomAccessIter __last = __first + __count;\n  return pair<_RandomAccessIter, _ForwardIter>(\n                 __last,\n                 uninitialized_copy(__first, __last, __result));\n}\n\ntemplate <class _InputIter, class _Size, class _ForwardIter>\ninline pair<_InputIter, _ForwardIter>\n__uninitialized_copy_n(_InputIter __first, _Size __count,\n                     _ForwardIter __result) {\n  return __uninitialized_copy_n(__first, __count, __result,\n                                __ITERATOR_CATEGORY(__first));\n}\n\ntemplate <class _InputIter, class _Size, class _ForwardIter>\ninline pair<_InputIter, _ForwardIter>\nuninitialized_copy_n(_InputIter __first, _Size __count,\n                     _ForwardIter __result) {\n  return __uninitialized_copy_n(__first, __count, __result,\n                                __ITERATOR_CATEGORY(__first));\n}\n\n// Valid if copy construction is equivalent to assignment, and if the\n// destructor is trivial.\ntemplate <class _ForwardIter, class _Tp>\ninline void\n__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, \n                         const _Tp& __x, __true_type)\n{\n  fill(__first, __last, __x);\n}\n\ntemplate <class _ForwardIter, class _Tp>\nvoid\n__uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, \n                         const _Tp& __x, __false_type)\n{\n  _ForwardIter __cur = __first;\n  __STL_TRY {\n    for ( ; __cur != __last; ++__cur)\n      _Construct(&*__cur, __x);\n  }\n  __STL_UNWIND(_Destroy(__first, __cur));\n}\n\ntemplate <class _ForwardIter, class _Tp, class _Tp1>\ninline void __uninitialized_fill(_ForwardIter __first, \n                                 _ForwardIter __last, const _Tp& __x, _Tp1*)\n{\n  typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;\n  __uninitialized_fill_aux(__first, __last, __x, _Is_POD());\n                   \n}\n\ntemplate <class _ForwardIter, class _Tp>\ninline void uninitialized_fill(_ForwardIter __first,\n                               _ForwardIter __last, \n                               const _Tp& __x)\n{\n  __uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first));\n}\n\n// Valid if copy construction is equivalent to assignment, and if the\n//  destructor is trivial.\ntemplate <class _ForwardIter, class _Size, class _Tp>\ninline _ForwardIter\n__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,\n                           const _Tp& __x, __true_type)\n{\n  return fill_n(__first, __n, __x);\n}\n\ntemplate <class _ForwardIter, class _Size, class _Tp>\n_ForwardIter\n__uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,\n                           const _Tp& __x, __false_type)\n{\n  _ForwardIter __cur = __first;\n  __STL_TRY {\n    for ( ; __n > 0; --__n, ++__cur)\n      _Construct(&*__cur, __x);\n    return __cur;\n  }\n  __STL_UNWIND(_Destroy(__first, __cur));\n}\n\ntemplate <class _ForwardIter, class _Size, class _Tp, class _Tp1>\ninline _ForwardIter \n__uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*)\n{\n  typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;\n  return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());\n}\n\ntemplate <class _ForwardIter, class _Size, class _Tp>\ninline _ForwardIter \nuninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)\n{\n  return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first));\n}\n\n// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, \n// __uninitialized_fill_copy.\n\n// __uninitialized_copy_copy\n// Copies [first1, last1) into [result, result + (last1 - first1)), and\n//  copies [first2, last2) into\n//  [result, result + (last1 - first1) + (last2 - first2)).\n\ntemplate <class _InputIter1, class _InputIter2, class _ForwardIter>\ninline _ForwardIter\n__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,\n                          _InputIter2 __first2, _InputIter2 __last2,\n                          _ForwardIter __result)\n{\n  _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);\n  __STL_TRY {\n    return uninitialized_copy(__first2, __last2, __mid);\n  }\n  __STL_UNWIND(_Destroy(__result, __mid));\n}\n\n// __uninitialized_fill_copy\n// Fills [result, mid) with x, and copies [first, last) into\n//  [mid, mid + (last - first)).\ntemplate <class _ForwardIter, class _Tp, class _InputIter>\ninline _ForwardIter \n__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,\n                          const _Tp& __x,\n                          _InputIter __first, _InputIter __last)\n{\n  uninitialized_fill(__result, __mid, __x);\n  __STL_TRY {\n    return uninitialized_copy(__first, __last, __mid);\n  }\n  __STL_UNWIND(_Destroy(__result, __mid));\n}\n\n// __uninitialized_copy_fill\n// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and\n//  fills [first2 + (last1 - first1), last2) with x.\ntemplate <class _InputIter, class _ForwardIter, class _Tp>\ninline void\n__uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,\n                          _ForwardIter __first2, _ForwardIter __last2,\n                          const _Tp& __x)\n{\n  _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);\n  __STL_TRY {\n    uninitialized_fill(__mid2, __last2, __x);\n  }\n  __STL_UNWIND(_Destroy(__first2, __mid2));\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/stl_vector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_VECTOR_H\n#define __SGI_STL_INTERNAL_VECTOR_H\n\n#include <concept_checks.h>\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// The vector base class serves two purposes.  First, its constructor\n// and destructor allocate (but don't initialize) storage.  This makes\n// exception safety easier.  Second, the base class encapsulates all of\n// the differences between SGI-style allocators and standard-conforming\n// allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// Base class for ordinary allocators.\ntemplate <class _Tp, class _Allocator, bool _IsStatic>\nclass _Vector_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return _M_data_allocator; }\n\n  _Vector_alloc_base(const allocator_type& __a)\n    : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) \n  {}\n  \nprotected:\n  allocator_type _M_data_allocator;\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n\n  _Tp* _M_allocate(size_t __n)\n    { return _M_data_allocator.allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n)\n    { if (__p) _M_data_allocator.deallocate(__p, __n); }\n};\n\n// Specialization for allocators that have the property that we don't\n// actually have to store an allocator object.  \ntemplate <class _Tp, class _Allocator>\nclass _Vector_alloc_base<_Tp, _Allocator, true> {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type\n          allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Vector_alloc_base(const allocator_type&)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0) \n  {}\n  \nprotected:\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n\n  typedef typename _Alloc_traits<_Tp, _Allocator>::_Alloc_type _Alloc_type;\n  _Tp* _M_allocate(size_t __n)\n    { return _Alloc_type::allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n)\n    { _Alloc_type::deallocate(__p, __n);}\n};\n\ntemplate <class _Tp, class _Alloc>\nstruct _Vector_base\n  : public _Vector_alloc_base<_Tp, _Alloc,\n                              _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\n  typedef _Vector_alloc_base<_Tp, _Alloc, \n                             _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n\n  _Vector_base(const allocator_type& __a) : _Base(__a) {}\n  _Vector_base(size_t __n, const allocator_type& __a) : _Base(__a) {\n    _M_start = _M_allocate(__n);\n    _M_finish = _M_start;\n    _M_end_of_storage = _M_start + __n;\n  }\n\n  ~_Vector_base() { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }\n};    \n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc> \nclass _Vector_base {\npublic:\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _Vector_base(const _Alloc&)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0) {}\n  _Vector_base(size_t __n, const _Alloc&)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0) \n  {\n    _M_start = _M_allocate(__n);\n    _M_finish = _M_start;\n    _M_end_of_storage = _M_start + __n;\n  }\n\n  ~_Vector_base() { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }\n\nprotected:\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n\n  typedef simple_alloc<_Tp, _Alloc> _M_data_allocator;\n  _Tp* _M_allocate(size_t __n)\n    { return _M_data_allocator::allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n) \n    { _M_data_allocator::deallocate(__p, __n); }\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >\nclass vector : protected _Vector_base<_Tp, _Alloc> \n{\n  // requirements:\n\n  __STL_CLASS_REQUIRES(_Tp, _Assignable);\n\nprivate:\n  typedef _Vector_base<_Tp, _Alloc> _Base;\npublic:\n  typedef _Tp value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type* iterator;\n  typedef const value_type* const_iterator;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type>  const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:\n#ifdef __STL_HAS_NAMESPACES\n  using _Base::_M_allocate;\n  using _Base::_M_deallocate;\n  using _Base::_M_start;\n  using _Base::_M_finish;\n  using _Base::_M_end_of_storage;\n#endif /* __STL_HAS_NAMESPACES */\n\nprotected:\n  void _M_insert_aux(iterator __position, const _Tp& __x);\n  void _M_insert_aux(iterator __position);\n\npublic:\n  iterator begin() { return _M_start; }\n  const_iterator begin() const { return _M_start; }\n  iterator end() { return _M_finish; }\n  const_iterator end() const { return _M_finish; }\n\n  reverse_iterator rbegin()\n    { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const\n    { return const_reverse_iterator(end()); }\n  reverse_iterator rend()\n    { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const\n    { return const_reverse_iterator(begin()); }\n\n  size_type size() const\n    { return size_type(end() - begin()); }\n  size_type max_size() const\n    { return size_type(-1) / sizeof(_Tp); }\n  size_type capacity() const\n    { return size_type(_M_end_of_storage - begin()); }\n  bool empty() const\n    { return begin() == end(); }\n\n  reference operator[](size_type __n) { return *(begin() + __n); }\n  const_reference operator[](size_type __n) const { return *(begin() + __n); }\n\n#ifdef __STL_THROW_RANGE_ERRORS\n  void _M_range_check(size_type __n) const {\n    if (__n >= this->size())\n      __stl_throw_range_error(\"vector\");\n  }\n\n  reference at(size_type __n)\n    { _M_range_check(__n); return (*this)[__n]; }\n  const_reference at(size_type __n) const\n    { _M_range_check(__n); return (*this)[__n]; }\n#endif /* __STL_THROW_RANGE_ERRORS */\n\n  explicit vector(const allocator_type& __a = allocator_type())\n    : _Base(__a) {}\n\n  vector(size_type __n, const _Tp& __value,\n         const allocator_type& __a = allocator_type()) \n    : _Base(__n, __a)\n    { _M_finish = uninitialized_fill_n(_M_start, __n, __value); }\n\n  explicit vector(size_type __n)\n    : _Base(__n, allocator_type())\n    { _M_finish = uninitialized_fill_n(_M_start, __n, _Tp()); }\n\n  vector(const vector<_Tp, _Alloc>& __x) \n    : _Base(__x.size(), __x.get_allocator())\n    { _M_finish = uninitialized_copy(__x.begin(), __x.end(), _M_start); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  // Check whether it's an integral type.  If so, it's not an iterator.\n  template <class _InputIterator>\n  vector(_InputIterator __first, _InputIterator __last,\n         const allocator_type& __a = allocator_type()) : _Base(__a) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_initialize_aux(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_initialize_aux(_Integer __n, _Integer __value, __true_type) {\n    _M_start = _M_allocate(__n);\n    _M_end_of_storage = _M_start + __n; \n    _M_finish = uninitialized_fill_n(_M_start, __n, __value);\n  }\n\n  template <class _InputIterator>\n  void _M_initialize_aux(_InputIterator __first, _InputIterator __last,\n                         __false_type) {\n    _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first));\n  }\n\n#else\n  vector(const _Tp* __first, const _Tp* __last,\n         const allocator_type& __a = allocator_type())\n    : _Base(__last - __first, __a) \n    { _M_finish = uninitialized_copy(__first, __last, _M_start); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  ~vector() { destroy(_M_start, _M_finish); }\n\n  vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x);\n  void reserve(size_type __n) {\n    if (capacity() < __n) {\n      const size_type __old_size = size();\n      iterator __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish);\n      destroy(_M_start, _M_finish);\n      _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n      _M_start = __tmp;\n      _M_finish = __tmp + __old_size;\n      _M_end_of_storage = _M_start + __n;\n    }\n  }\n\n  // assign(), a generalized assignment member function.  Two\n  // versions: one that takes a count, and one that takes a range.\n  // The range version is a member template, so we dispatch on whether\n  // or not the type is an integer.\n\n  void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }\n  void _M_fill_assign(size_type __n, const _Tp& __val);\n\n#ifdef __STL_MEMBER_TEMPLATES\n  \n  template <class _InputIterator>\n  void assign(_InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_assign_dispatch(__first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)\n    { _M_fill_assign((size_type) __n, (_Tp) __val); }\n\n  template <class _InputIter>\n  void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)\n    { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); }\n\n  template <class _InputIterator>\n  void _M_assign_aux(_InputIterator __first, _InputIterator __last,\n                     input_iterator_tag);\n\n  template <class _ForwardIterator>\n  void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,\n                     forward_iterator_tag); \n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(end() - 1); }\n  const_reference back() const { return *(end() - 1); }\n\n  void push_back(const _Tp& __x) {\n    if (_M_finish != _M_end_of_storage) {\n      construct(_M_finish, __x);\n      ++_M_finish;\n    }\n    else\n      _M_insert_aux(end(), __x);\n  }\n  void push_back() {\n    if (_M_finish != _M_end_of_storage) {\n      construct(_M_finish);\n      ++_M_finish;\n    }\n    else\n      _M_insert_aux(end());\n  }\n  void swap(vector<_Tp, _Alloc>& __x) {\n    __STD::swap(_M_start, __x._M_start);\n    __STD::swap(_M_finish, __x._M_finish);\n    __STD::swap(_M_end_of_storage, __x._M_end_of_storage);\n  }\n\n  iterator insert(iterator __position, const _Tp& __x) {\n    size_type __n = __position - begin();\n    if (_M_finish != _M_end_of_storage && __position == end()) {\n      construct(_M_finish, __x);\n      ++_M_finish;\n    }\n    else\n      _M_insert_aux(__position, __x);\n    return begin() + __n;\n  }\n  iterator insert(iterator __position) {\n    size_type __n = __position - begin();\n    if (_M_finish != _M_end_of_storage && __position == end()) {\n      construct(_M_finish);\n      ++_M_finish;\n    }\n    else\n      _M_insert_aux(__position);\n    return begin() + __n;\n  }\n#ifdef __STL_MEMBER_TEMPLATES\n  // Check whether it's an integral type.  If so, it's not an iterator.\n  template <class _InputIterator>\n  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_insert_dispatch(__pos, __first, __last, _Integral());\n  }\n\n  template <class _Integer>\n  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,\n                          __true_type)\n    { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); }\n\n  template <class _InputIterator>\n  void _M_insert_dispatch(iterator __pos,\n                          _InputIterator __first, _InputIterator __last,\n                          __false_type) {\n    _M_range_insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator __position,\n              const_iterator __first, const_iterator __last);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void insert (iterator __pos, size_type __n, const _Tp& __x)\n    { _M_fill_insert(__pos, __n, __x); }\n\n  void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);\n\n  void pop_back() {\n    --_M_finish;\n    destroy(_M_finish);\n  }\n  iterator erase(iterator __position) {\n    if (__position + 1 != end())\n      copy(__position + 1, _M_finish, __position);\n    --_M_finish;\n    destroy(_M_finish);\n    return __position;\n  }\n  iterator erase(iterator __first, iterator __last) {\n    iterator __i = copy(__last, _M_finish, __first);\n    destroy(__i, _M_finish);\n    _M_finish = _M_finish - (__last - __first);\n    return __first;\n  }\n\n  void resize(size_type __new_size, const _Tp& __x) {\n    if (__new_size < size()) \n      erase(begin() + __new_size, end());\n    else\n      insert(end(), __new_size - size(), __x);\n  }\n  void resize(size_type __new_size) { resize(__new_size, _Tp()); }\n  void clear() { erase(begin(), end()); }\n\nprotected:\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _ForwardIterator>\n  iterator _M_allocate_and_copy(size_type __n, _ForwardIterator __first, \n                                               _ForwardIterator __last)\n{\n    iterator __result = _M_allocate(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, __result);\n      return __result;\n    }\n    __STL_UNWIND(_M_deallocate(__result, __n));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  iterator _M_allocate_and_copy(size_type __n, const_iterator __first, \n                                               const_iterator __last)\n  {\n    iterator __result = _M_allocate(__n);\n    __STL_TRY {\n      uninitialized_copy(__first, __last, __result);\n      return __result;\n    }\n    __STL_UNWIND(_M_deallocate(__result, __n));\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  void _M_range_initialize(_InputIterator __first,  \n                           _InputIterator __last, input_iterator_tag)\n  {\n    for ( ; __first != __last; ++__first)\n      push_back(*__first);\n  }\n\n  // This function is only called by the constructor. \n  template <class _ForwardIterator>\n  void _M_range_initialize(_ForwardIterator __first,\n                           _ForwardIterator __last, forward_iterator_tag)\n  {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    _M_start = _M_allocate(__n);\n    _M_end_of_storage = _M_start + __n;\n    _M_finish = uninitialized_copy(__first, __last, _M_start);\n  }\n\n  template <class _InputIterator>\n  void _M_range_insert(iterator __pos,\n                       _InputIterator __first, _InputIterator __last,\n                       input_iterator_tag);\n\n  template <class _ForwardIterator>\n  void _M_range_insert(iterator __pos,\n                       _ForwardIterator __first, _ForwardIterator __last,\n                       forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n};\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)\n{\n  return __x.size() == __y.size() &&\n         equal(__x.begin(), __x.end(), __y.begin());\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool \noperator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)\n{\n  return lexicographical_compare(__x.begin(), __x.end(), \n                                 __y.begin(), __y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp, class _Alloc>\ninline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)\n{\n  __x.swap(__y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool\noperator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool\noperator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool\noperator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _Tp, class _Alloc>\ninline bool\noperator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) {\n  return !(__x < __y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Tp, class _Alloc>\nvector<_Tp,_Alloc>& \nvector<_Tp,_Alloc>::operator=(const vector<_Tp, _Alloc>& __x)\n{\n  if (&__x != this) {\n    const size_type __xlen = __x.size();\n    if (__xlen > capacity()) {\n      iterator __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());\n      destroy(_M_start, _M_finish);\n      _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n      _M_start = __tmp;\n      _M_end_of_storage = _M_start + __xlen;\n    }\n    else if (size() >= __xlen) {\n      iterator __i = copy(__x.begin(), __x.end(), begin());\n      destroy(__i, _M_finish);\n    }\n    else {\n      copy(__x.begin(), __x.begin() + size(), _M_start);\n      uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish);\n    }\n    _M_finish = _M_start + __xlen;\n  }\n  return *this;\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid vector<_Tp, _Alloc>::_M_fill_assign(size_t __n, const value_type& __val) \n{\n  if (__n > capacity()) {\n    vector<_Tp, _Alloc> __tmp(__n, __val, get_allocator());\n    __tmp.swap(*this);\n  }\n  else if (__n > size()) {\n    fill(begin(), end(), __val);\n    _M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val);\n  }\n  else\n    erase(fill_n(begin(), __n, __val), end());\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _InputIter>\nvoid vector<_Tp, _Alloc>::_M_assign_aux(_InputIter __first, _InputIter __last,\n                                        input_iterator_tag) {\n  iterator __cur = begin();\n  for ( ; __first != __last && __cur != end(); ++__cur, ++__first)\n    *__cur = *__first;\n  if (__first == __last)\n    erase(__cur, end());\n  else\n    insert(end(), __first, __last);\n}\n\ntemplate <class _Tp, class _Alloc> template <class _ForwardIter>\nvoid\nvector<_Tp, _Alloc>::_M_assign_aux(_ForwardIter __first, _ForwardIter __last,\n                                   forward_iterator_tag) {\n  size_type __len = 0;\n  distance(__first, __last, __len);\n\n  if (__len > capacity()) {\n    iterator __tmp = _M_allocate_and_copy(__len, __first, __last);\n    destroy(_M_start, _M_finish);\n    _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n    _M_start = __tmp;\n    _M_end_of_storage = _M_finish = _M_start + __len;\n  }\n  else if (size() >= __len) {\n    iterator __new_finish = copy(__first, __last, _M_start);\n    destroy(__new_finish, _M_finish);\n    _M_finish = __new_finish;\n  }\n  else {\n    _ForwardIter __mid = __first;\n    advance(__mid, size());\n    copy(__first, __mid, _M_start);\n    _M_finish = uninitialized_copy(__mid, __last, _M_finish);\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid \nvector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)\n{\n  if (_M_finish != _M_end_of_storage) {\n    construct(_M_finish, *(_M_finish - 1));\n    ++_M_finish;\n    _Tp __x_copy = __x;\n    copy_backward(__position, _M_finish - 2, _M_finish - 1);\n    *__position = __x_copy;\n  }\n  else {\n    const size_type __old_size = size();\n    const size_type __len = __old_size != 0 ? 2 * __old_size : 1;\n    iterator __new_start = _M_allocate(__len);\n    iterator __new_finish = __new_start;\n    __STL_TRY {\n      __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n      construct(__new_finish, __x);\n      ++__new_finish;\n      __new_finish = uninitialized_copy(__position, _M_finish, __new_finish);\n    }\n    __STL_UNWIND((destroy(__new_start,__new_finish), \n                  _M_deallocate(__new_start,__len)));\n    destroy(begin(), end());\n    _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n    _M_start = __new_start;\n    _M_finish = __new_finish;\n    _M_end_of_storage = __new_start + __len;\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid \nvector<_Tp, _Alloc>::_M_insert_aux(iterator __position)\n{\n  if (_M_finish != _M_end_of_storage) {\n    construct(_M_finish, *(_M_finish - 1));\n    ++_M_finish;\n    copy_backward(__position, _M_finish - 2, _M_finish - 1);\n    *__position = _Tp();\n  }\n  else {\n    const size_type __old_size = size();\n    const size_type __len = __old_size != 0 ? 2 * __old_size : 1;\n    iterator __new_start = _M_allocate(__len);\n    iterator __new_finish = __new_start;\n    __STL_TRY {\n      __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n      construct(__new_finish);\n      ++__new_finish;\n      __new_finish = uninitialized_copy(__position, _M_finish, __new_finish);\n    }\n    __STL_UNWIND((destroy(__new_start,__new_finish), \n                  _M_deallocate(__new_start,__len)));\n    destroy(begin(), end());\n    _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n    _M_start = __new_start;\n    _M_finish = __new_finish;\n    _M_end_of_storage = __new_start + __len;\n  }\n}\n\ntemplate <class _Tp, class _Alloc>\nvoid vector<_Tp, _Alloc>::_M_fill_insert(iterator __position, size_type __n, \n                                         const _Tp& __x)\n{\n  if (__n != 0) {\n    if (size_type(_M_end_of_storage - _M_finish) >= __n) {\n      _Tp __x_copy = __x;\n      const size_type __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after > __n) {\n        uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);\n        _M_finish += __n;\n        copy_backward(__position, __old_finish - __n, __old_finish);\n        fill(__position, __position + __n, __x_copy);\n      }\n      else {\n        uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy);\n        _M_finish += __n - __elems_after;\n        uninitialized_copy(__position, __old_finish, _M_finish);\n        _M_finish += __elems_after;\n        fill(__position, __old_finish, __x_copy);\n      }\n    }\n    else {\n      const size_type __old_size = size();        \n      const size_type __len = __old_size + max(__old_size, __n);\n      iterator __new_start = _M_allocate(__len);\n      iterator __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_fill_n(__new_finish, __n, __x);\n        __new_finish\n          = uninitialized_copy(__position, _M_finish, __new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish), \n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish);\n      _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len;\n    }\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Alloc> template <class _InputIterator>\nvoid \nvector<_Tp, _Alloc>::_M_range_insert(iterator __pos, \n                                     _InputIterator __first, \n                                     _InputIterator __last,\n                                     input_iterator_tag)\n{\n  for ( ; __first != __last; ++__first) {\n    __pos = insert(__pos, *__first);\n    ++__pos;\n  }\n}\n\ntemplate <class _Tp, class _Alloc> template <class _ForwardIterator>\nvoid \nvector<_Tp, _Alloc>::_M_range_insert(iterator __position,\n                                     _ForwardIterator __first,\n                                     _ForwardIterator __last,\n                                     forward_iterator_tag)\n{\n  if (__first != __last) {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    if (size_type(_M_end_of_storage - _M_finish) >= __n) {\n      const size_type __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after > __n) {\n        uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);\n        _M_finish += __n;\n        copy_backward(__position, __old_finish - __n, __old_finish);\n        copy(__first, __last, __position);\n      }\n      else {\n        _ForwardIterator __mid = __first;\n        advance(__mid, __elems_after);\n        uninitialized_copy(__mid, __last, _M_finish);\n        _M_finish += __n - __elems_after;\n        uninitialized_copy(__position, __old_finish, _M_finish);\n        _M_finish += __elems_after;\n        copy(__first, __mid, __position);\n      }\n    }\n    else {\n      const size_type __old_size = size();\n      const size_type __len = __old_size + max(__old_size, __n);\n      iterator __new_start = _M_allocate(__len);\n      iterator __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        __new_finish\n          = uninitialized_copy(__position, _M_finish, __new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish), \n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish);\n      _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len;\n    }\n  }\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Alloc>\nvoid \nvector<_Tp, _Alloc>::insert(iterator __position, \n                            const_iterator __first, \n                            const_iterator __last)\n{\n  if (__first != __last) {\n    size_type __n = 0;\n    distance(__first, __last, __n);\n    if (size_type(_M_end_of_storage - _M_finish) >= __n) {\n      const size_type __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after > __n) {\n        uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);\n        _M_finish += __n;\n        copy_backward(__position, __old_finish - __n, __old_finish);\n        copy(__first, __last, __position);\n      }\n      else {\n        uninitialized_copy(__first + __elems_after, __last, _M_finish);\n        _M_finish += __n - __elems_after;\n        uninitialized_copy(__position, __old_finish, _M_finish);\n        _M_finish += __elems_after;\n        copy(__first, __first + __elems_after, __position);\n      }\n    }\n    else {\n      const size_type __old_size = size();\n      const size_type __len = __old_size + max(__old_size, __n);\n      iterator __new_start = _M_allocate(__len);\n      iterator __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        __new_finish\n          = uninitialized_copy(__position, _M_finish, __new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish);\n      _M_deallocate(_M_start, _M_end_of_storage - _M_start);\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len;\n    }\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_VECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/string",
    "content": "/*\n * Copyright (c) 1997-1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_STRING\n#define __SGI_STL_STRING\n\n#include <stl_config.h>\n#include <stl_string_fwd.h>\n#include <ctype.h>        \n#include <functional>\n#include <stl_ctraits_fns.h>\n#include <stdexcept>      \n#include <stl_iterator_base.h>\n#include <memory>\n#include <algorithm>\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n#include <iosfwd>\n#else /* __STL_USE_NEW_IOSTREAMS */\n#include <char_traits.h>\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n// Standard C++ string class.  This class has performance\n// characteristics very much like vector<>, meaning, for example, that\n// it does not perform reference-count or copy-on-write, and that\n// concatenation of two strings is an O(N) operation. \n\n// There are three reasons why basic_string is not identical to\n// vector.  First, basic_string always stores a null character at the\n// end; this makes it possible for c_str to be a fast operation.\n// Second, the C++ standard requires basic_string to copy elements\n// using char_traits<>::assign, char_traits<>::copy, and\n// char_traits<>::move.  This means that all of vector<>'s low-level\n// operations must be rewritten.  Third, basic_string<> has a lot of\n// extra functions in its interface that are convenient but, strictly\n// speaking, redundant.\n\n// Additionally, the C++ standard imposes a major restriction: according\n// to the standard, the character type _CharT must be a POD type.  This\n// implementation weakens that restriction, and allows _CharT to be a\n// a user-defined non-POD type.  However, _CharT must still have a\n// default constructor.\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#pragma set woff 1375\n#endif\n\n// A helper class to use a char_traits as a function object.\n\ntemplate <class _Traits>\nstruct _Not_within_traits\n  : public unary_function<typename _Traits::char_type, bool>\n{\n  typedef const typename _Traits::char_type* _Pointer;\n  const _Pointer _M_first;\n  const _Pointer _M_last;\n\n  _Not_within_traits(_Pointer __f, _Pointer __l) \n    : _M_first(__f), _M_last(__l) {}\n\n  bool operator()(const typename _Traits::char_type& __x) const {\n    return find_if(_M_first, _M_last, \n                   bind1st(_Eq_traits<_Traits>(), __x)) == _M_last;\n  }\n};\n\n// ------------------------------------------------------------\n// Class _String_base.  \n\n// _String_base is a helper class that makes it it easier to write an\n// exception-safe version of basic_string.  The constructor allocates,\n// but does not initialize, a block of memory.  The destructor\n// deallocates, but does not destroy elements within, a block of\n// memory.  The destructor assumes that _M_start either is null, or else\n// points to a block of memory that was allocated using _String_base's \n// allocator and whose size is _M_end_of_storage - _M_start.\n\n// Additionally, _String_base encapsulates the difference between\n// old SGI-style allocators and standard-conforming allocators.\n\n#ifdef __STL_USE_STD_ALLOCATORS\n\n// General base class.\ntemplate <class _Tp, class _Alloc, bool _S_instanceless>\nclass _String_alloc_base {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _M_data_allocator; }\n\n  _String_alloc_base(const allocator_type& __a)\n    : _M_data_allocator(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)\n    {}\n\nprotected:\n  _Tp* _M_allocate(size_t __n)\n    { return _M_data_allocator.allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n) {\n    if (__p)\n      _M_data_allocator.deallocate(__p, __n); \n  }\n\nprotected:\n  allocator_type _M_data_allocator;\n\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n};\n\n// Specialization for instanceless allocators.\ntemplate <class _Tp, class _Alloc>\nclass _String_alloc_base<_Tp,_Alloc,true> {\npublic:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\n  _String_alloc_base(const allocator_type&)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0) {}\n\nprotected:\n  typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Alloc_type;\n  _Tp* _M_allocate(size_t __n)\n    { return _Alloc_type::allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n)\n    { _Alloc_type::deallocate(__p, __n); }\n\nprotected:\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n};\n\ntemplate <class _Tp, class _Alloc>\nclass _String_base \n  : public _String_alloc_base<_Tp, _Alloc,\n                              _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n{\nprotected:\n  typedef _String_alloc_base<_Tp, _Alloc,\n                             _Alloc_traits<_Tp, _Alloc>::_S_instanceless>\n          _Base;\n  typedef typename _Base::allocator_type allocator_type;\n\n  void _M_allocate_block(size_t __n) { \n    if (__n <= max_size()) {\n      _M_start  = _M_allocate(__n);\n      _M_finish = _M_start;\n      _M_end_of_storage = _M_start + __n;\n    }\n    else\n      _M_throw_length_error();\n  }\n\n  void _M_deallocate_block() \n    { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }\n  \n  size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; }\n\n  _String_base(const allocator_type& __a) : _Base(__a) { }\n  \n  _String_base(const allocator_type& __a, size_t __n) : _Base(__a)\n    { _M_allocate_block(__n); }\n\n  ~_String_base() { _M_deallocate_block(); }\n\n  void _M_throw_length_error() const;\n  void _M_throw_out_of_range() const;\n};\n\n#else /* __STL_USE_STD_ALLOCATORS */\n\ntemplate <class _Tp, class _Alloc> class _String_base {\npublic:\n  typedef _Alloc allocator_type;\n  allocator_type get_allocator() const { return allocator_type(); }\n\nprotected:\n  typedef simple_alloc<_Tp, _Alloc> _Alloc_type;\n\n  _Tp* _M_start;\n  _Tp* _M_finish;\n  _Tp* _M_end_of_storage;\n                                // Precondition: 0 < __n <= max_size().\n\n  _Tp* _M_allocate(size_t __n) { return _Alloc_type::allocate(__n); }\n  void _M_deallocate(_Tp* __p, size_t __n) {\n    if (__p)\n      _Alloc_type::deallocate(__p, __n); \n  }\n\n  void _M_allocate_block(size_t __n) { \n    if (__n <= max_size()) {\n      _M_start  = _M_allocate(__n);\n      _M_finish = _M_start;\n      _M_end_of_storage = _M_start + __n;\n    }\n    else\n      _M_throw_length_error();\n  }\n\n  void _M_deallocate_block() \n    { _M_deallocate(_M_start, _M_end_of_storage - _M_start); }\n  \n  size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; }\n\n  _String_base(const allocator_type&)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0) { }\n  \n  _String_base(const allocator_type&, size_t __n)\n    : _M_start(0), _M_finish(0), _M_end_of_storage(0)\n    { _M_allocate_block(__n); }\n\n  ~_String_base() { _M_deallocate_block(); }\n\n  void _M_throw_length_error() const;\n  void _M_throw_out_of_range() const;\n};\n\n#endif /* __STL_USE_STD_ALLOCATORS */\n\n// Helper functions for exception handling.\ntemplate <class _Tp, class _Alloc> \nvoid _String_base<_Tp,_Alloc>::_M_throw_length_error() const {\n  __STL_THROW(length_error(\"basic_string\"));\n}\n\ntemplate <class _Tp, class _Alloc> \nvoid _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const {\n  __STL_THROW(out_of_range(\"basic_string\"));\n}\n\n\n// ------------------------------------------------------------\n// Class basic_string.  \n\n// Class invariants:\n// (1) [start, finish) is a valid range.\n// (2) Each iterator in [start, finish) points to a valid object\n//     of type value_type.\n// (3) *finish is a valid object of type value_type; in particular,\n//     it is value_type().\n// (4) [finish + 1, end_of_storage) is a valid range.\n// (5) Each iterator in [finish + 1, end_of_storage) points to \n//     unininitialized memory.\n\n// Note one important consequence: a string of length n must manage\n// a block of memory whose size is at least n + 1.  \n\n\ntemplate <class _CharT, class _Traits, class _Alloc> \nclass basic_string : private _String_base<_CharT,_Alloc> {\npublic:\n  typedef _CharT value_type;\n  typedef _Traits traits_type;\n\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef const value_type*                const_iterator;\n  typedef value_type*                      iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator>       reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type>  \n          const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator; \n#endif /* __STL_PARTIAL_SPECIALIZATION */\n\n  static const size_type npos;\n\n  typedef _String_base<_CharT,_Alloc> _Base;\n\npublic:                         // Constructor, destructor, assignment.\n  typedef typename _Base::allocator_type allocator_type;\n  allocator_type get_allocator() const { return _Base::get_allocator(); }\n\n  explicit basic_string(const allocator_type& __a = allocator_type())\n    : _Base(__a, 8) { _M_terminate_string(); }\n\n  struct _Reserve_t {};\n  basic_string(_Reserve_t, size_t __n,\n               const allocator_type& __a = allocator_type())\n    : _Base(__a, __n + 1) { _M_terminate_string(); }\n\n  basic_string(const basic_string& __s) : _Base(__s.get_allocator()) \n    { _M_range_initialize(__s.begin(), __s.end()); }\n\n  basic_string(const basic_string& __s, size_type __pos, size_type __n = npos,\n               const allocator_type& __a = allocator_type()) \n    : _Base(__a) {\n    if (__pos > __s.size())\n      _M_throw_out_of_range();\n    else\n      _M_range_initialize(__s.begin() + __pos,\n                          __s.begin() + __pos + min(__n, __s.size() - __pos));\n  }\n\n  basic_string(const _CharT* __s, size_type __n,\n               const allocator_type& __a = allocator_type()) \n    : _Base(__a) \n    { _M_range_initialize(__s, __s + __n); }\n\n  basic_string(const _CharT* __s,\n               const allocator_type& __a = allocator_type())\n    : _Base(__a) \n    { _M_range_initialize(__s, __s + _Traits::length(__s)); }\n\n  basic_string(size_type __n, _CharT __c,\n               const allocator_type& __a = allocator_type())\n    : _Base(__a, __n + 1)\n  {\n    _M_finish = uninitialized_fill_n(_M_start, __n, __c);\n    _M_terminate_string();\n  }\n\n  // Check to see if _InputIterator is an integer type.  If so, then\n  // it can't be an iterator.\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIterator>\n  basic_string(_InputIterator __f, _InputIterator __l,\n               const allocator_type& __a = allocator_type())\n    : _Base(__a)\n  {\n    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;\n    _M_initialize_dispatch(__f, __l, _Integral());\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  basic_string(const _CharT* __f, const _CharT* __l,\n               const allocator_type& __a = allocator_type())\n    : _Base(__a)\n  {\n    _M_range_initialize(__f, __l);\n  }\n#endif\n\n  ~basic_string() { destroy(_M_start, _M_finish + 1); }\n    \n  basic_string& operator=(const basic_string& __s) {\n    if (&__s != this) \n      assign(__s.begin(), __s.end());\n    return *this;\n  }\n\n  basic_string& operator=(const _CharT* __s) \n    { return assign(__s, __s + _Traits::length(__s)); }\n\n  basic_string& operator=(_CharT __c)\n    { return assign(static_cast<size_type>(1), __c); }\n\nprotected:                      // Protected members inherited from base.\n#ifdef __STL_HAS_NAMESPACES\n  using _Base::_M_allocate;\n  using _Base::_M_deallocate;\n  using _Base::_M_allocate_block;\n  using _Base::_M_deallocate_block;\n  using _Base::_M_throw_length_error;\n  using _Base::_M_throw_out_of_range;\n\n  using _Base::_M_start;\n  using _Base::_M_finish;\n  using _Base::_M_end_of_storage;\n#endif /* __STL_HAS_NAMESPACES */\n\nprivate:                        // Helper functions used by constructors\n                                // and elsewhere.\n  void _M_construct_null(_CharT* __p) {\n    construct(__p);\n#   ifdef __STL_DEFAULT_CONSTRUCTOR_BUG\n    __STL_TRY {\n      *__p = (_CharT) 0;\n    }\n    __STL_UNWIND(destroy(__p));\n#   endif\n  }\n\n  static _CharT _M_null() {\n#   ifndef __STL_DEFAULT_CONSTRUCTOR_BUG\n    return _CharT();\n#   else\n    return (_CharT) 0;\n#   endif\n  }\n\nprivate:                        \n  // Helper functions used by constructors.  It is a severe error for\n  // any of them to be called anywhere except from within constructors.\n\n  void _M_terminate_string() {\n    __STL_TRY {\n      _M_construct_null(_M_finish);\n    }\n    __STL_UNWIND(destroy(_M_start, _M_finish));\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n    \n  template <class _InputIter>\n  void _M_range_initialize(_InputIter __f, _InputIter __l,\n                           input_iterator_tag) {\n    _M_allocate_block(8);\n    _M_construct_null(_M_finish);\n    __STL_TRY {\n      append(__f, __l);\n    }\n    __STL_UNWIND(destroy(_M_start, _M_finish + 1));\n  }\n\n  template <class _ForwardIter>\n  void _M_range_initialize(_ForwardIter __f, _ForwardIter __l, \n                           forward_iterator_tag) {\n    difference_type __n = 0;\n    distance(__f, __l, __n);\n    _M_allocate_block(__n + 1);\n    _M_finish = uninitialized_copy(__f, __l, _M_start);\n    _M_terminate_string();\n  }\n\n  template <class _InputIter>\n  void _M_range_initialize(_InputIter __f, _InputIter __l) {\n    typedef typename iterator_traits<_InputIter>::iterator_category _Category;\n    _M_range_initialize(__f, __l, _Category());\n  }\n\n  template <class _Integer>\n  void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {\n    _M_allocate_block(__n + 1);\n    _M_finish = uninitialized_fill_n(_M_start, __n, __x);\n    _M_terminate_string();\n  }\n\n  template <class _InputIter>\n  void _M_initialize_dispatch(_InputIter __f, _InputIter __l, __false_type) {\n     _M_range_initialize(__f, __l);\n  }\n    \n#else /* __STL_MEMBER_TEMPLATES */\n\n  void _M_range_initialize(const _CharT* __f, const _CharT* __l) {\n    ptrdiff_t __n = __l - __f;\n    _M_allocate_block(__n + 1);\n    _M_finish = uninitialized_copy(__f, __l, _M_start);\n    _M_terminate_string();\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:                         // Iterators.\n  iterator begin()             { return _M_start; }\n  iterator end()               { return _M_finish; }\n  const_iterator begin() const { return _M_start; }\n  const_iterator end()   const { return _M_finish; }  \n\n  reverse_iterator rbegin()             \n    { return reverse_iterator(_M_finish); }\n  reverse_iterator rend()               \n    { return reverse_iterator(_M_start); }\n  const_reverse_iterator rbegin() const \n    { return const_reverse_iterator(_M_finish); }\n  const_reverse_iterator rend()   const \n    { return const_reverse_iterator(_M_start); }\n\npublic:                         // Size, capacity, etc.\n  size_type size() const { return _M_finish - _M_start; }\n  size_type length() const { return size(); }\n\n  size_t max_size() const { return _Base::max_size(); }\n\n\n  void resize(size_type __n, _CharT __c) {\n    if (__n <= size())\n      erase(begin() + __n, end());\n    else\n      append(__n - size(), __c);\n  }\n\n  void resize(size_type __n) { resize(__n, _M_null()); }\n\n  void reserve(size_type = 0);\n\n  size_type capacity() const { return (_M_end_of_storage - _M_start) - 1; }\n\n  void clear() {\n    if (!empty()) {\n      _Traits::assign(*_M_start, _M_null());\n      destroy(_M_start+1, _M_finish+1);\n      _M_finish = _M_start;\n    }\n  } \n\n  bool empty() const { return _M_start == _M_finish; }    \n\npublic:                         // Element access.\n\n  const_reference operator[](size_type __n) const\n    { return *(_M_start + __n); }\n  reference operator[](size_type __n)\n    { return *(_M_start + __n); }\n\n  const_reference at(size_type __n) const {\n    if (__n >= size())\n      _M_throw_out_of_range();\n    return *(_M_start + __n);\n  }\n\n  reference at(size_type __n) {\n    if (__n >= size())\n      _M_throw_out_of_range();\n    return *(_M_start + __n);\n  }\n\npublic:                         // Append, operator+=, push_back.\n\n  basic_string& operator+=(const basic_string& __s) { return append(__s); }\n  basic_string& operator+=(const _CharT* __s) { return append(__s); }\n  basic_string& operator+=(_CharT __c) { push_back(__c); return *this; }\n\n  basic_string& append(const basic_string& __s) \n    { return append(__s.begin(), __s.end()); }\n\n  basic_string& append(const basic_string& __s,\n                       size_type __pos, size_type __n)\n  {\n    if (__pos > __s.size())\n      _M_throw_out_of_range();\n    return append(__s.begin() + __pos,\n                  __s.begin() + __pos + min(__n, __s.size() - __pos));\n  }\n\n  basic_string& append(const _CharT* __s, size_type __n) \n    { return append(__s, __s+__n); }\n\n  basic_string& append(const _CharT* __s) \n    { return append(__s, __s + _Traits::length(__s)); }\n\n  basic_string& append(size_type __n, _CharT __c);\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check to see if _InputIterator is an integer type.  If so, then\n  // it can't be an iterator.\n  template <class _InputIter>\n  basic_string& append(_InputIter __first, _InputIter __last) {\n    typedef typename _Is_integer<_InputIter>::_Integral _Integral;\n    return _M_append_dispatch(__first, __last, _Integral());\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  basic_string& append(const _CharT* __first, const _CharT* __last);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void push_back(_CharT __c) {\n    if (_M_finish + 1 == _M_end_of_storage)\n      reserve(size() + max(size(), static_cast<size_type>(1)));\n    _M_construct_null(_M_finish + 1);\n    _Traits::assign(*_M_finish, __c);\n    ++_M_finish;\n  }\n\n  void pop_back() {\n    _Traits::assign(*(_M_finish - 1), _M_null());\n    destroy(_M_finish);\n    --_M_finish;\n  }\n\nprivate:                        // Helper functions for append.\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIter>\n  basic_string& append(_InputIter __f, _InputIter __l, input_iterator_tag);\n\n  template <class _ForwardIter>\n  basic_string& append(_ForwardIter __f, _ForwardIter __l, \n                       forward_iterator_tag);\n\n  template <class _Integer>\n  basic_string& _M_append_dispatch(_Integer __n, _Integer __x, __true_type) {\n    return append((size_type) __n, (_CharT) __x);\n  }\n\n  template <class _InputIter>\n  basic_string& _M_append_dispatch(_InputIter __f, _InputIter __l,\n                                   __false_type) {\n    typedef typename iterator_traits<_InputIter>::iterator_category _Category;\n    return append(__f, __l, _Category());\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:                         // Assign\n  \n  basic_string& assign(const basic_string& __s) \n    { return assign(__s.begin(), __s.end()); }\n\n  basic_string& assign(const basic_string& __s, \n                       size_type __pos, size_type __n) {\n    if (__pos > __s.size())\n      _M_throw_out_of_range();\n    return assign(__s.begin() + __pos, \n                  __s.begin() + __pos + min(__n, __s.size() - __pos));\n  }\n\n  basic_string& assign(const _CharT* __s, size_type __n)\n    { return assign(__s, __s + __n); }\n\n  basic_string& assign(const _CharT* __s)\n    { return assign(__s, __s + _Traits::length(__s)); }\n\n  basic_string& assign(size_type __n, _CharT __c);\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check to see if _InputIterator is an integer type.  If so, then\n  // it can't be an iterator.\n  template <class _InputIter>\n  basic_string& assign(_InputIter __first, _InputIter __last) {\n    typedef typename _Is_integer<_InputIter>::_Integral _Integral;\n    return _M_assign_dispatch(__first, __last, _Integral());\n  }\n\n#endif  /* __STL_MEMBER_TEMPLATES */\n\n  basic_string& assign(const _CharT* __f, const _CharT* __l);\n\nprivate:                        // Helper functions for assign.\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _Integer>\n  basic_string& _M_assign_dispatch(_Integer __n, _Integer __x, __true_type) {\n    return assign((size_type) __n, (_CharT) __x);\n  }\n\n  template <class _InputIter>\n  basic_string& _M_assign_dispatch(_InputIter __f, _InputIter __l,\n                                   __false_type);\n\n#endif  /* __STL_MEMBER_TEMPLATES */\n\npublic:                         // Insert\n\n  basic_string& insert(size_type __pos, const basic_string& __s) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    if (size() > max_size() - __s.size())\n      _M_throw_length_error();\n    insert(_M_start + __pos, __s.begin(), __s.end());\n    return *this;\n  }\n\n  basic_string& insert(size_type __pos, const basic_string& __s,\n                       size_type __beg, size_type __n) {\n    if (__pos > size() || __beg > __s.size())\n      _M_throw_out_of_range();\n    size_type __len = min(__n, __s.size() - __beg);\n    if (size() > max_size() - __len)\n      _M_throw_length_error();\n    insert(_M_start + __pos,\n           __s.begin() + __beg, __s.begin() + __beg + __len);\n    return *this;\n  }\n\n  basic_string& insert(size_type __pos, const _CharT* __s, size_type __n) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    if (size() > max_size() - __n)\n      _M_throw_length_error();\n    insert(_M_start + __pos, __s, __s + __n);\n    return *this;\n  }\n\n  basic_string& insert(size_type __pos, const _CharT* __s) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    size_type __len = _Traits::length(__s);\n    if (size() > max_size() - __len)\n      _M_throw_length_error();\n    insert(_M_start + __pos, __s, __s + __len);\n    return *this;\n  }\n    \n  basic_string& insert(size_type __pos, size_type __n, _CharT __c) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    if (size() > max_size() - __n)\n      _M_throw_length_error();\n    insert(_M_start + __pos, __n, __c);\n    return *this;\n  }\n\n  iterator insert(iterator __p, _CharT __c) {\n    if (__p == _M_finish) {\n      push_back(__c);\n      return _M_finish - 1;\n    }\n    else\n      return _M_insert_aux(__p, __c);\n  }\n\n  void insert(iterator __p, size_t __n, _CharT __c);\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  // Check to see if _InputIterator is an integer type.  If so, then\n  // it can't be an iterator.\n  template <class _InputIter>\n  void insert(iterator __p, _InputIter __first, _InputIter __last) {\n    typedef typename _Is_integer<_InputIter>::_Integral _Integral;\n    _M_insert_dispatch(__p, __first, __last, _Integral());\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void insert(iterator __p, const _CharT* __first, const _CharT* __last);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprivate:                        // Helper functions for insert.\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _InputIter>\n  void insert(iterator __p, _InputIter, _InputIter, input_iterator_tag);\n\n  template <class _ForwardIter>\n  void insert(iterator __p, _ForwardIter, _ForwardIter, forward_iterator_tag);\n\n\n  template <class _Integer>\n  void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,\n                          __true_type) {\n    insert(__p, (size_type) __n, (_CharT) __x);\n  }\n\n  template <class _InputIter>\n  void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,\n                          __false_type) {\n    typedef typename iterator_traits<_InputIter>::iterator_category _Category;\n    insert(__p, __first, __last, _Category());\n  }\n\n  template <class _InputIterator>\n  void \n  _M_copy(_InputIterator __first, _InputIterator __last, iterator __result) {\n    for ( ; __first != __last; ++__first, ++__result)\n      _Traits::assign(*__result, *__first);\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator _M_insert_aux(iterator, _CharT);\n\n  void \n  _M_copy(const _CharT* __first, const _CharT* __last, _CharT* __result) {\n    _Traits::copy(__result, __first, __last - __first);\n  }\n\npublic:                         // Erase.\n\n  basic_string& erase(size_type __pos = 0, size_type __n = npos) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    erase(_M_start + __pos, _M_start + __pos + min(__n, size() - __pos));\n    return *this;\n  }  \n\n  iterator erase(iterator __position) {\n                                // The move includes the terminating null.\n    _Traits::move(__position, __position + 1, _M_finish - __position);\n    destroy(_M_finish);\n    --_M_finish;\n    return __position;\n  }\n\n  iterator erase(iterator __first, iterator __last) {\n    if (__first != __last) {\n                                // The move includes the terminating null.\n      _Traits::move(__first, __last, (_M_finish - __last) + 1);\n      const iterator __new_finish = _M_finish - (__last - __first);\n      destroy(__new_finish + 1, _M_finish + 1);\n      _M_finish = __new_finish;\n    }\n    return __first;\n  }\n\npublic:                         // Replace.  (Conceptually equivalent\n                                // to erase followed by insert.)\n  basic_string& replace(size_type __pos, size_type __n, \n                        const basic_string& __s) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    const size_type __len = min(__n, size() - __pos);\n    if (size() - __len >= max_size() - __s.size())\n      _M_throw_length_error();\n    return replace(_M_start + __pos, _M_start + __pos + __len, \n                   __s.begin(), __s.end());\n  }\n\n  basic_string& replace(size_type __pos1, size_type __n1,\n                        const basic_string& __s,\n                        size_type __pos2, size_type __n2) {\n    if (__pos1 > size() || __pos2 > __s.size())\n      _M_throw_out_of_range();\n    const size_type __len1 = min(__n1, size() - __pos1);\n    const size_type __len2 = min(__n2, __s.size() - __pos2);\n    if (size() - __len1 >= max_size() - __len2)\n      _M_throw_length_error();\n    return replace(_M_start + __pos1, _M_start + __pos1 + __len1,\n                   __s._M_start + __pos2, __s._M_start + __pos2 + __len2);\n  }\n\n  basic_string& replace(size_type __pos, size_type __n1,\n                        const _CharT* __s, size_type __n2) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    const size_type __len = min(__n1, size() - __pos);\n    if (__n2 > max_size() || size() - __len >= max_size() - __n2)\n      _M_throw_length_error();\n    return replace(_M_start + __pos, _M_start + __pos + __len,\n                   __s, __s + __n2);\n  }\n\n  basic_string& replace(size_type __pos, size_type __n1,\n                        const _CharT* __s) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    const size_type __len = min(__n1, size() - __pos);\n    const size_type __n2 = _Traits::length(__s);\n    if (__n2 > max_size() || size() - __len >= max_size() - __n2)\n      _M_throw_length_error();\n    return replace(_M_start + __pos, _M_start + __pos + __len,\n                   __s, __s + _Traits::length(__s));\n  }\n\n  basic_string& replace(size_type __pos, size_type __n1,\n                        size_type __n2, _CharT __c) {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    const size_type __len = min(__n1, size() - __pos);\n    if (__n2 > max_size() || size() - __len >= max_size() - __n2)\n      _M_throw_length_error();\n    return replace(_M_start + __pos, _M_start + __pos + __len, __n2, __c);\n  }\n\n  basic_string& replace(iterator __first, iterator __last, \n                        const basic_string& __s) \n    { return replace(__first, __last, __s.begin(), __s.end()); }\n\n  basic_string& replace(iterator __first, iterator __last,\n                        const _CharT* __s, size_type __n) \n    { return replace(__first, __last, __s, __s + __n); }\n\n  basic_string& replace(iterator __first, iterator __last,\n                        const _CharT* __s) {\n    return replace(__first, __last, __s, __s + _Traits::length(__s));\n  }\n\n  basic_string& replace(iterator __first, iterator __last, \n                        size_type __n, _CharT __c);\n\n  // Check to see if _InputIterator is an integer type.  If so, then\n  // it can't be an iterator.\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class _InputIter>\n  basic_string& replace(iterator __first, iterator __last,\n                        _InputIter __f, _InputIter __l) {\n    typedef typename _Is_integer<_InputIter>::_Integral _Integral;\n    return _M_replace_dispatch(__first, __last, __f, __l,  _Integral());\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  basic_string& replace(iterator __first, iterator __last,\n                        const _CharT* __f, const _CharT* __l);\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprivate:                        // Helper functions for replace.\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class _Integer>\n  basic_string& _M_replace_dispatch(iterator __first, iterator __last,\n                                    _Integer __n, _Integer __x,\n                                    __true_type) {\n    return replace(__first, __last, (size_type) __n, (_CharT) __x);\n  }\n\n  template <class _InputIter>\n  basic_string& _M_replace_dispatch(iterator __first, iterator __last,\n                                    _InputIter __f, _InputIter __l,\n                                    __false_type) {\n    typedef typename iterator_traits<_InputIter>::iterator_category _Category;\n    return replace(__first, __last, __f, __l, _Category());\n  }\n\n  template <class _InputIter>\n  basic_string& replace(iterator __first, iterator __last,\n                        _InputIter __f, _InputIter __l, input_iterator_tag);\n\n  template <class _ForwardIter>\n  basic_string& replace(iterator __first, iterator __last,\n                        _ForwardIter __f, _ForwardIter __l, \n                        forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:                         // Other modifier member functions.\n\n  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    const size_type __len = min(__n, size() - __pos);\n    _Traits::copy(__s, _M_start + __pos, __len);\n    return __len;\n  }\n\n  void swap(basic_string& __s) {\n    __STD::swap(_M_start, __s._M_start);\n    __STD::swap(_M_finish, __s._M_finish);\n    __STD::swap(_M_end_of_storage, __s._M_end_of_storage);\n  }\n\npublic:                         // Conversion to C string.\n\n  const _CharT* c_str() const { return _M_start; }\n  const _CharT* data()  const { return _M_start; }\n\npublic:                         // find.\n\n  size_type find(const basic_string& __s, size_type __pos = 0) const \n    { return find(__s.begin(), __pos, __s.size()); }\n\n  size_type find(const _CharT* __s, size_type __pos = 0) const \n    { return find(__s, __pos, _Traits::length(__s)); }\n\n  size_type find(const _CharT* __s, size_type __pos, size_type __n) const;\n  size_type find(_CharT __c, size_type __pos = 0) const;\n\npublic:                         // rfind.\n\n  size_type rfind(const basic_string& __s, size_type __pos = npos) const \n    { return rfind(__s.begin(), __pos, __s.size()); }\n\n  size_type rfind(const _CharT* __s, size_type __pos = npos) const \n    { return rfind(__s, __pos, _Traits::length(__s)); }\n\n  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const;\n  size_type rfind(_CharT __c, size_type __pos = npos) const;\n\npublic:                         // find_first_of\n  \n  size_type find_first_of(const basic_string& __s, size_type __pos = 0) const \n    { return find_first_of(__s.begin(), __pos, __s.size()); }\n\n  size_type find_first_of(const _CharT* __s, size_type __pos = 0) const \n    { return find_first_of(__s, __pos, _Traits::length(__s)); }\n\n  size_type find_first_of(const _CharT* __s, size_type __pos, \n                          size_type __n) const;\n\n  size_type find_first_of(_CharT __c, size_type __pos = 0) const \n    { return find(__c, __pos); }\n\npublic:                         // find_last_of\n\n  size_type find_last_of(const basic_string& __s,\n                         size_type __pos = npos) const\n    { return find_last_of(__s.begin(), __pos, __s.size()); }\n\n  size_type find_last_of(const _CharT* __s, size_type __pos = npos) const \n    { return find_last_of(__s, __pos, _Traits::length(__s)); }\n\n  size_type find_last_of(const _CharT* __s, size_type __pos, \n                         size_type __n) const;\n\n  size_type find_last_of(_CharT __c, size_type __pos = npos) const {\n    return rfind(__c, __pos);\n  }\n\npublic:                         // find_first_not_of\n\n  size_type find_first_not_of(const basic_string& __s, \n                              size_type __pos = 0) const \n    { return find_first_not_of(__s.begin(), __pos, __s.size()); }\n\n  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const \n    { return find_first_not_of(__s, __pos, _Traits::length(__s)); }\n\n  size_type find_first_not_of(const _CharT* __s, size_type __pos,\n                              size_type __n) const;\n\n  size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;\n\npublic:                         // find_last_not_of\n\n  size_type find_last_not_of(const basic_string& __s, \n                             size_type __pos = npos) const\n    { return find_last_not_of(__s.begin(), __pos, __s.size()); }\n\n  size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const\n    { return find_last_not_of(__s, __pos, _Traits::length(__s)); }\n\n  size_type find_last_not_of(const _CharT* __s, size_type __pos,\n                             size_type __n) const;\n\n  size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;\n\npublic:                         // Substring.\n\n  basic_string substr(size_type __pos = 0, size_type __n = npos) const {\n    if (__pos > size())\n      _M_throw_out_of_range();\n    return basic_string(_M_start + __pos, \n                        _M_start + __pos + min(__n, size() - __pos));\n  }\n\npublic:                         // Compare\n\n  int compare(const basic_string& __s) const \n    { return _M_compare(_M_start, _M_finish, __s._M_start, __s._M_finish); }\n\n  int compare(size_type __pos1, size_type __n1,\n              const basic_string& __s) const {\n    if (__pos1 > size())\n      _M_throw_out_of_range();\n    return _M_compare(_M_start + __pos1, \n                      _M_start + __pos1 + min(__n1, size() - __pos1),\n                      __s._M_start, __s._M_finish);\n  }\n    \n  int compare(size_type __pos1, size_type __n1,\n              const basic_string& __s,\n              size_type __pos2, size_type __n2) const {\n    if (__pos1 > size() || __pos2 > __s.size())\n      _M_throw_out_of_range();\n    return _M_compare(_M_start + __pos1, \n                      _M_start + __pos1 + min(__n1, size() - __pos1),\n                      __s._M_start + __pos2, \n                      __s._M_start + __pos2 + min(__n2, size() - __pos2));\n  }\n\n  int compare(const _CharT* __s) const {\n    return _M_compare(_M_start, _M_finish, __s, __s + _Traits::length(__s));\n  }\n\n  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const {\n    if (__pos1 > size())\n      _M_throw_out_of_range();\n    return _M_compare(_M_start + __pos1, \n                      _M_start + __pos1 + min(__n1, size() - __pos1),\n                      __s, __s + _Traits::length(__s));\n  }\n\n  int compare(size_type __pos1, size_type __n1, const _CharT* __s,\n              size_type __n2) const {\n    if (__pos1 > size())\n      _M_throw_out_of_range();\n    return _M_compare(_M_start + __pos1, \n                      _M_start + __pos1 + min(__n1, size() - __pos1),\n                      __s, __s + __n2);\n  }\n\npublic:                        // Helper function for compare.\n  static int _M_compare(const _CharT* __f1, const _CharT* __l1,\n                        const _CharT* __f2, const _CharT* __l2) {\n    const ptrdiff_t __n1 = __l1 - __f1;\n    const ptrdiff_t __n2 = __l2 - __f2;\n    const int cmp = _Traits::compare(__f1, __f2, min(__n1, __n2));\n    return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0));\n  }\n};\n\n\n\n// ------------------------------------------------------------\n// Non-inline declarations.\n\ntemplate <class _CharT, class _Traits, class _Alloc> \nconst basic_string<_CharT,_Traits,_Alloc>::size_type \nbasic_string<_CharT,_Traits,_Alloc>::npos \n  = (basic_string<_CharT,_Traits,_Alloc>::size_type) -1;\n\n// Change the string's capacity so that it is large enough to hold\n//  at least __res_arg elements, plus the terminating null.  Note that,\n//  if __res_arg < capacity(), this member function may actually decrease\n//  the string's capacity.\ntemplate <class _CharT, class _Traits, class _Alloc> \nvoid basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) {\n  if (__res_arg > max_size())\n    _M_throw_length_error();\n\n  size_type __n = max(__res_arg, size()) + 1;\n  pointer __new_start = _M_allocate(__n);\n  pointer __new_finish = __new_start;\n\n  __STL_TRY {\n    __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start);\n    _M_construct_null(__new_finish);\n  }\n  __STL_UNWIND((destroy(__new_start, __new_finish), \n                _M_deallocate(__new_start, __n)));\n\n  destroy(_M_start, _M_finish + 1);\n  _M_deallocate_block();\n  _M_start = __new_start;\n  _M_finish = __new_finish;\n  _M_end_of_storage = __new_start + __n;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc> \nbasic_string<_CharT,_Traits,_Alloc>& \nbasic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) {\n  if (__n > max_size() || size() > max_size() - __n)\n    _M_throw_length_error();\n  if (size() + __n > capacity())\n    reserve(size() + max(size(), __n));\n  if (__n > 0) {\n    uninitialized_fill_n(_M_finish + 1, __n - 1, __c);\n    __STL_TRY {\n      _M_construct_null(_M_finish + __n);\n    }\n    __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n));\n    _Traits::assign(*_M_finish, __c);\n    _M_finish += __n;\n  }\n  return *this;\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Traits, class _Alloc> \ntemplate <class _InputIterator>\nbasic_string<_Tp, _Traits, _Alloc>& \nbasic_string<_Tp, _Traits, _Alloc>::append(_InputIterator __first, \n                                          _InputIterator __last,\n                                          input_iterator_tag) {\n  for ( ; __first != __last ; ++__first)\n    push_back(*__first);\n  return *this;\n}\n\ntemplate <class _Tp, class _Traits, class _Alloc> \ntemplate <class _ForwardIter>\nbasic_string<_Tp, _Traits, _Alloc>& \nbasic_string<_Tp, _Traits, _Alloc>::append(_ForwardIter __first, \n                                           _ForwardIter __last,\n                                           forward_iterator_tag) {\n  if (__first != __last) {\n    const size_type __old_size = size();\n    difference_type __n = 0;\n    distance(__first, __last, __n);\n    if (static_cast<size_type>(__n) > max_size() ||\n        __old_size > max_size() - static_cast<size_type>(__n))\n      _M_throw_length_error();\n    if (__old_size + static_cast<size_type>(__n) > capacity()) {\n      const size_type __len = __old_size +\n                            max(__old_size, static_cast<size_type>(__n)) + 1;\n      pointer __new_start = _M_allocate(__len);\n      pointer __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        _M_construct_null(__new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish + 1);\n      _M_deallocate_block();\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len; \n    }\n    else {\n      _ForwardIter __f1 = __first;\n      ++__f1;\n      uninitialized_copy(__f1, __last, _M_finish + 1);\n      __STL_TRY {\n        _M_construct_null(_M_finish + __n);\n      }\n      __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n));\n      _Traits::assign(*_M_finish, *__first);\n      _M_finish += __n;\n    }\n  }\n  return *this;  \n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _Tp, class _Traits, class _Alloc> \nbasic_string<_Tp, _Traits, _Alloc>& \nbasic_string<_Tp, _Traits, _Alloc>::append(const _Tp* __first,\n                                           const _Tp* __last)\n{\n  if (__first != __last) {\n    const size_type __old_size = size();\n    ptrdiff_t __n = __last - __first;\n    if (__n > max_size() || __old_size > max_size() - __n)\n      _M_throw_length_error();\n    if (__old_size + __n > capacity()) {\n      const size_type __len = __old_size + max(__old_size, (size_t) __n) + 1;\n      pointer __new_start = _M_allocate(__len);\n      pointer __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, _M_finish, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        _M_construct_null(__new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish + 1);\n      _M_deallocate_block();\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len; \n    }\n    else {\n      const _Tp* __f1 = __first;\n      ++__f1;\n      uninitialized_copy(__f1, __last, _M_finish + 1);\n      __STL_TRY {\n        _M_construct_null(_M_finish + __n);\n      }\n      __STL_UNWIND(destroy(_M_finish + 1, _M_finish + __n));\n      _Traits::assign(*_M_finish, *__first);\n      _M_finish += __n;\n    }\n  }\n  return *this;  \n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc> \nbasic_string<_CharT,_Traits,_Alloc>& \nbasic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) {\n  if (__n <= size()) {\n    _Traits::assign(_M_start, __n, __c);\n    erase(_M_start + __n, _M_finish);\n  }\n  else {\n    _Traits::assign(_M_start, size(), __c);\n    append(__n - size(), __c);\n  }\n  return *this;\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _CharT, class _Traits, class _Alloc> \ntemplate <class _InputIter>\nbasic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc>\n  ::_M_assign_dispatch(_InputIter __f, _InputIter __l, __false_type)\n{\n  pointer __cur = _M_start;\n  while (__f != __l && __cur != _M_finish) {\n    _Traits::assign(*__cur, *__f);\n    ++__f;\n    ++__cur;\n  }\n  if (__f == __l)\n    erase(__cur, _M_finish);\n  else\n    append(__f, __l);\n  return *this;\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc> \nbasic_string<_CharT,_Traits,_Alloc>& \nbasic_string<_CharT,_Traits,_Alloc>::assign(const _CharT* __f, \n                                            const _CharT* __l)\n{\n  const ptrdiff_t __n = __l - __f;\n  if (static_cast<size_type>(__n) <= size()) {\n    _Traits::copy(_M_start, __f, __n);\n    erase(_M_start + __n, _M_finish);\n  }\n  else {\n    _Traits::copy(_M_start, __f, size());\n    append(__f + size(), __l);\n  }\n  return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::iterator \nbasic_string<_CharT,_Traits,_Alloc>\n  ::_M_insert_aux(basic_string<_CharT,_Traits,_Alloc>::iterator __p,\n                  _CharT __c)\n{\n  iterator __new_pos = __p;\n  if (_M_finish + 1 < _M_end_of_storage) {\n    _M_construct_null(_M_finish + 1);\n    _Traits::move(__p + 1, __p, _M_finish - __p);\n    _Traits::assign(*__p, __c);\n    ++_M_finish;\n  }\n  else {\n    const size_type __old_len = size();\n    const size_type __len = __old_len +\n                            max(__old_len, static_cast<size_type>(1)) + 1;\n    iterator __new_start = _M_allocate(__len);\n    iterator __new_finish = __new_start;\n    __STL_TRY {\n      __new_pos = uninitialized_copy(_M_start, __p, __new_start);\n      construct(__new_pos, __c);\n      __new_finish = __new_pos + 1;\n      __new_finish = uninitialized_copy(__p, _M_finish, __new_finish);\n      _M_construct_null(__new_finish);\n    }\n    __STL_UNWIND((destroy(__new_start,__new_finish), \n                  _M_deallocate(__new_start,__len)));\n    destroy(_M_start, _M_finish + 1);\n    _M_deallocate_block();\n    _M_start = __new_start;\n    _M_finish = __new_finish;\n    _M_end_of_storage = __new_start + __len;\n  }\n  return __new_pos;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nvoid basic_string<_CharT,_Traits,_Alloc>\n  ::insert(basic_string<_CharT,_Traits,_Alloc>::iterator __position,\n           size_t __n, _CharT __c)\n{\n  if (__n != 0) {\n    if (size_type(_M_end_of_storage - _M_finish) >= __n + 1) {\n      const size_type __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after >= __n) {\n        uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1,\n                           _M_finish + 1);\n        _M_finish += __n;\n        _Traits::move(__position + __n,\n                      __position, (__elems_after - __n) + 1);\n        _Traits::assign(__position, __n, __c);\n      }\n      else {\n        uninitialized_fill_n(_M_finish + 1, __n - __elems_after - 1, __c);\n        _M_finish += __n - __elems_after;\n        __STL_TRY {\n          uninitialized_copy(__position, __old_finish + 1, _M_finish);\n          _M_finish += __elems_after;\n        }\n        __STL_UNWIND((destroy(__old_finish + 1, _M_finish), \n                      _M_finish = __old_finish));\n        _Traits::assign(__position, __elems_after + 1, __c);\n      }\n    }\n    else {\n      const size_type __old_size = size();        \n      const size_type __len = __old_size + max(__old_size, __n) + 1;\n      iterator __new_start = _M_allocate(__len);\n      iterator __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_fill_n(__new_finish, __n, __c);\n        __new_finish = uninitialized_copy(__position, _M_finish,\n                                          __new_finish);\n        _M_construct_null(__new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish + 1);\n      _M_deallocate_block();\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len;    \n    }\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _Tp, class _Traits, class _Alloc>\ntemplate <class _InputIter>\nvoid basic_string<_Tp, _Traits, _Alloc>::insert(iterator __p,\n                                                _InputIter __first, \n                                                _InputIter __last,\n                                                input_iterator_tag)\n{\n  for ( ; __first != __last; ++__first) {\n    __p = insert(__p, *__first);\n    ++__p;\n  }\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ntemplate <class _ForwardIter>\nvoid \nbasic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,\n                                            _ForwardIter __first, \n                                            _ForwardIter __last,\n                                            forward_iterator_tag)\n{\n  if (__first != __last) {\n    difference_type __n = 0;\n    distance(__first, __last, __n);\n    if (_M_end_of_storage - _M_finish >= __n + 1) {\n      const difference_type __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after >= __n) {\n        uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1,\n                           _M_finish + 1);\n        _M_finish += __n;\n        _Traits::move(__position + __n,\n                      __position, (__elems_after - __n) + 1);\n        _M_copy(__first, __last, __position);\n      }\n      else {\n        _ForwardIter __mid = __first;\n        advance(__mid, __elems_after + 1);\n        uninitialized_copy(__mid, __last, _M_finish + 1);\n        _M_finish += __n - __elems_after;\n        __STL_TRY {\n          uninitialized_copy(__position, __old_finish + 1, _M_finish);\n          _M_finish += __elems_after;\n        }\n        __STL_UNWIND((destroy(__old_finish + 1, _M_finish), \n                      _M_finish = __old_finish));\n        _M_copy(__first, __mid, __position);\n      }\n    }\n    else {\n      const size_type __old_size = size();        \n      const size_type __len\n        = __old_size + max(__old_size, static_cast<size_type>(__n)) + 1;\n      pointer __new_start = _M_allocate(__len);\n      pointer __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        __new_finish\n          = uninitialized_copy(__position, _M_finish, __new_finish);\n        _M_construct_null(__new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish + 1);\n      _M_deallocate_block();\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len; \n    }\n  }\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nvoid \nbasic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,\n                                            const _CharT* __first, \n                                            const _CharT* __last)\n{\n  if (__first != __last) {\n    const ptrdiff_t __n = __last - __first;\n    if (_M_end_of_storage - _M_finish >= __n + 1) {\n      const ptrdiff_t __elems_after = _M_finish - __position;\n      iterator __old_finish = _M_finish;\n      if (__elems_after >= __n) {\n        uninitialized_copy((_M_finish - __n) + 1, _M_finish + 1,\n                           _M_finish + 1);\n        _M_finish += __n;\n        _Traits::move(__position + __n,\n                      __position, (__elems_after - __n) + 1);\n        _M_copy(__first, __last, __position);\n      }\n      else {\n        const _CharT* __mid = __first;\n        advance(__mid, __elems_after + 1);\n        uninitialized_copy(__mid, __last, _M_finish + 1);\n        _M_finish += __n - __elems_after;\n        __STL_TRY {\n          uninitialized_copy(__position, __old_finish + 1, _M_finish);\n          _M_finish += __elems_after;\n        }\n        __STL_UNWIND((destroy(__old_finish + 1, _M_finish), \n                      _M_finish = __old_finish));\n        _M_copy(__first, __mid, __position);\n      }\n    }\n    else {\n      const size_type __old_size = size();        \n      const size_type __len\n        = __old_size + max(__old_size, static_cast<size_type>(__n)) + 1;\n      pointer __new_start = _M_allocate(__len);\n      pointer __new_finish = __new_start;\n      __STL_TRY {\n        __new_finish = uninitialized_copy(_M_start, __position, __new_start);\n        __new_finish = uninitialized_copy(__first, __last, __new_finish);\n        __new_finish\n          = uninitialized_copy(__position, _M_finish, __new_finish);\n        _M_construct_null(__new_finish);\n      }\n      __STL_UNWIND((destroy(__new_start,__new_finish),\n                    _M_deallocate(__new_start,__len)));\n      destroy(_M_start, _M_finish + 1);\n      _M_deallocate_block();\n      _M_start = __new_start;\n      _M_finish = __new_finish;\n      _M_end_of_storage = __new_start + __len; \n    }\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>&\nbasic_string<_CharT,_Traits,_Alloc>\n  ::replace(iterator __first, iterator __last, size_type __n, _CharT __c)\n{\n  const size_type __len = static_cast<size_type>(__last - __first);\n  if (__len >= __n) {\n    _Traits::assign(__first, __n, __c);\n    erase(__first + __n, __last);\n  }\n  else {\n    _Traits::assign(__first, __len, __c);\n    insert(__last, __n - __len, __c);\n  }\n  return *this;\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ntemplate <class _InputIter>\nbasic_string<_CharT,_Traits,_Alloc>&\nbasic_string<_CharT,_Traits,_Alloc>\n  ::replace(iterator __first, iterator __last, _InputIter __f, _InputIter __l,\n            input_iterator_tag) \n{\n  for ( ; __first != __last && __f != __l; ++__first, ++__f)\n    _Traits::assign(*__first, *__f);\n\n  if (__f == __l)\n    erase(__first, __last);\n  else\n    insert(__last, __f, __l);\n  return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ntemplate <class _ForwardIter>\nbasic_string<_CharT,_Traits,_Alloc>&\nbasic_string<_CharT,_Traits,_Alloc>\n  ::replace(iterator __first, iterator __last,\n            _ForwardIter __f, _ForwardIter __l,\n            forward_iterator_tag) \n{\n  difference_type __n = 0;\n  distance(__f, __l, __n);\n  const difference_type __len = __last - __first;\n  if (__len >= __n) {\n    _M_copy(__f, __l, __first);\n    erase(__first + __n, __last);\n  }\n  else {\n    _ForwardIter __m = __f;\n    advance(__m, __len);\n    _M_copy(__f, __m, __first);\n    insert(__last, __m, __l);\n  }\n  return *this;\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>&\nbasic_string<_CharT,_Traits,_Alloc>\n  ::replace(iterator __first, iterator __last,\n            const _CharT* __f, const _CharT* __l)\n{\n  const ptrdiff_t         __n = __l - __f;\n  const difference_type __len = __last - __first;\n  if (__len >= __n) {\n    _M_copy(__f, __l, __first);\n    erase(__first + __n, __last);\n  }\n  else {\n    const _CharT* __m = __f + __len;\n    _M_copy(__f, __m, __first);\n    insert(__last, __m, __l);\n  }\n  return *this;\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find(const _CharT* __s, size_type __pos, size_type __n) const \n{\n  if (__pos + __n > size())\n    return npos;\n  else {\n    const const_iterator __result =\n      search(_M_start + __pos, _M_finish, \n             __s, __s + __n, _Eq_traits<_Traits>());\n    return __result != _M_finish ? __result - begin() : npos;\n  }\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find(_CharT __c, size_type __pos) const \n{\n  if (__pos >= size())\n    return npos;\n  else {\n    const const_iterator __result =\n      find_if(_M_start + __pos, _M_finish,\n              bind2nd(_Eq_traits<_Traits>(), __c));\n    return __result != _M_finish ? __result - begin() : npos;\n  }\n}    \n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::rfind(const _CharT* __s, size_type __pos, size_type __n) const \n{\n  const size_t __len = size();\n\n  if (__n > __len)\n    return npos;\n  else if (__n == 0)\n    return min(__len, __pos);\n  else {\n    const const_iterator __last = begin() + min(__len - __n, __pos) + __n;\n    const const_iterator __result = find_end(begin(), __last,\n                                           __s, __s + __n,\n                                           _Eq_traits<_Traits>());\n    return __result != __last ? __result - begin() : npos;\n  }\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::rfind(_CharT __c, size_type __pos) const \n{\n  const size_type __len = size();\n\n  if (__len < 1)\n    return npos;\n  else {\n    const const_iterator __last = begin() + min(__len - 1, __pos) + 1;\n    const_reverse_iterator __rresult =\n      find_if(const_reverse_iterator(__last), rend(),\n              bind2nd(_Eq_traits<_Traits>(), __c));\n    return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;\n  }\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find_first_of(const _CharT* __s, size_type __pos, size_type __n) const\n{\n  if (__pos >= size())\n    return npos;\n  else {\n    const_iterator __result = __STD::find_first_of(begin() + __pos, end(),\n                                                   __s, __s + __n,\n                                                   _Eq_traits<_Traits>());\n    return __result != _M_finish ? __result - begin() : npos;\n  }\n}\n\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find_last_of(const _CharT* __s, size_type __pos, size_type __n) const\n{\n  const size_type __len = size();\n\n  if (__len < 1)\n    return npos;\n  else {\n    const const_iterator __last = _M_start + min(__len - 1, __pos) + 1;\n    const const_reverse_iterator __rresult =\n      __STD::find_first_of(const_reverse_iterator(__last), rend(),\n                           __s, __s + __n,\n                           _Eq_traits<_Traits>());\n    return __rresult != rend() ? (__rresult.base() - 1) - _M_start : npos;\n  }\n}\n\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const\n{\n  if (__pos > size())\n    return npos;\n  else {\n    const_iterator __result = find_if(_M_start + __pos, _M_finish,\n                                _Not_within_traits<_Traits>(__s, __s + __n));\n    return __result != _M_finish ? __result - _M_start : npos;\n  }\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find_first_not_of(_CharT __c, size_type __pos) const\n{\n  if (__pos > size())\n    return npos;\n  else {\n    const_iterator __result\n      = find_if(begin() + __pos, end(),\n                not1(bind2nd(_Eq_traits<_Traits>(), __c)));\n    return __result != _M_finish ? __result - begin() : npos;\n  }\n}    \n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_string<_CharT,_Traits,_Alloc>::size_type\nbasic_string<_CharT,_Traits,_Alloc>\n  ::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const \n{\n\n  const size_type __len = size();\n\n  if (__len < 1)\n    return npos;\n  else {\n    const const_iterator __last = begin() + min(__len - 1, __pos) + 1;\n    const const_reverse_iterator __rresult =\n      find_if(const_reverse_iterator(__last), rend(),\n              _Not_within_traits<_Traits>(__s, __s + __n));\n    return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;\n  }\n}\n\ntemplate <class _Tp, class _Traits, class _Alloc>\nbasic_string<_Tp, _Traits, _Alloc>::size_type\nbasic_string<_Tp, _Traits, _Alloc>\n  ::find_last_not_of(_Tp __c, size_type __pos) const \n{\n  const size_type __len = size();\n\n  if (__len < 1)\n    return npos;\n  else {\n    const const_iterator __last = begin() + min(__len - 1, __pos) + 1;\n    const_reverse_iterator __rresult =\n      find_if(const_reverse_iterator(__last), rend(),\n              not1(bind2nd(_Eq_traits<_Traits>(), __c)));\n    return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;\n  }\n}\n\n// ------------------------------------------------------------\n// Non-member functions.\n\n// Operator+\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline basic_string<_CharT,_Traits,_Alloc>\noperator+(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const basic_string<_CharT,_Traits,_Alloc>& __y)\n{\n  typedef basic_string<_CharT,_Traits,_Alloc> _Str;\n  typedef typename _Str::_Reserve_t _Reserve_t;\n  _Reserve_t __reserve;\n  _Str __result(__reserve, __x.size() + __y.size(), __x.get_allocator());\n  __result.append(__x);\n  __result.append(__y);\n  return __result;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline basic_string<_CharT,_Traits,_Alloc>\noperator+(const _CharT* __s,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  typedef basic_string<_CharT,_Traits,_Alloc> _Str;\n  typedef typename _Str::_Reserve_t _Reserve_t;\n  _Reserve_t __reserve;\n  const size_t __n = _Traits::length(__s);\n  _Str __result(__reserve, __n + __y.size());\n  __result.append(__s, __s + __n);\n  __result.append(__y);\n  return __result;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline basic_string<_CharT,_Traits,_Alloc>\noperator+(_CharT __c,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  typedef basic_string<_CharT,_Traits,_Alloc> _Str;\n  typedef typename _Str::_Reserve_t _Reserve_t;\n  _Reserve_t __reserve;\n  _Str __result(__reserve, 1 + __y.size());\n  __result.push_back(__c);\n  __result.append(__y);\n  return __result;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline basic_string<_CharT,_Traits,_Alloc>\noperator+(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const _CharT* __s) {\n  typedef basic_string<_CharT,_Traits,_Alloc> _Str;\n  typedef typename _Str::_Reserve_t _Reserve_t;\n  _Reserve_t __reserve;\n  const size_t __n = _Traits::length(__s);\n  _Str __result(__reserve, __x.size() + __n, __x.get_allocator());\n  __result.append(__x);\n  __result.append(__s, __s + __n);\n  return __result;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline basic_string<_CharT,_Traits,_Alloc>\noperator+(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const _CharT __c) {\n  typedef basic_string<_CharT,_Traits,_Alloc> _Str;\n  typedef typename _Str::_Reserve_t _Reserve_t;\n  _Reserve_t __reserve;\n  _Str __result(__reserve, __x.size() + 1, __x.get_allocator());\n  __result.append(__x);\n  __result.push_back(__c);\n  return __result;\n}\n\n// Operator== and operator!=\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator==(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return __x.size() == __y.size() &&\n         _Traits::compare(__x.data(), __y.data(), __x.size()) == 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator==(const _CharT* __s,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  size_t __n = _Traits::length(__s);\n  return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator==(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const _CharT* __s) {\n  size_t __n = _Traits::length(__s);\n  return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__x == __y);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator!=(const _CharT* __s,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__s == __y);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const _CharT* __s) {\n  return !(__x == __s);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Operator< (and also >, <=, and >=).\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return basic_string<_CharT,_Traits,_Alloc>\n    ::_M_compare(__x.begin(), __x.end(), __y.begin(), __y.end()) < 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<(const _CharT* __s,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  size_t __n = _Traits::length(__s);\n  return basic_string<_CharT,_Traits,_Alloc>\n    ::_M_compare(__s, __s + __n, __y.begin(), __y.end()) < 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const _CharT* __s) {\n  size_t __n = _Traits::length(__s);\n  return basic_string<_CharT,_Traits,_Alloc>\n    ::_M_compare(__x.begin(), __x.end(), __s, __s + __n) < 0;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return __y < __x;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>(const _CharT* __s,\n          const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return __y < __s;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>(const basic_string<_CharT,_Traits,_Alloc>& __x,\n          const _CharT* __s) {\n  return __s < __x;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__y < __x);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<=(const _CharT* __s,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__y < __s);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const _CharT* __s) {\n  return !(__s < __x);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__x < __y);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>=(const _CharT* __s,\n           const basic_string<_CharT,_Traits,_Alloc>& __y) {\n  return !(__s < __y);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline bool\noperator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,\n           const _CharT* __s) {\n  return !(__x < __s);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Swap.\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _CharT, class _Traits, class _Alloc>\ninline void swap(basic_string<_CharT,_Traits,_Alloc>& __x,\n                 basic_string<_CharT,_Traits,_Alloc>& __y) {\n  __x.swap(__y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// I/O.  \n\n#ifndef __STL_USE_NEW_IOSTREAMS \n__STL_END_NAMESPACE\n#include <iostream.h>\n__STL_BEGIN_NAMESPACE\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\n#ifdef __STL_USE_NEW_IOSTREAMS\n\ntemplate <class _CharT, class _Traits>\ninline bool\n__sgi_string_fill(basic_ostream<_CharT, _Traits>& __os,\n                  basic_streambuf<_CharT, _Traits>* __buf,\n                  size_t __n)\n{\n  _CharT __f = __os.fill();\n  size_t __i;\n  bool __ok = true;\n\n  for (__i = 0; __i < __n; __i++)\n    __ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof());\n  return __ok;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_ostream<_CharT, _Traits>&\noperator<<(basic_ostream<_CharT, _Traits>& __os, \n           const basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  typename basic_ostream<_CharT, _Traits>::sentry __sentry(__os);\n  bool __ok = false;\n\n  if (__sentry) {\n    __ok = true;\n    size_t __n = __s.size();\n    size_t __pad_len = 0;\n    const bool __left = (__os.flags() & ios::left) != 0;\n    const size_t __w = __os.width(0);\n    basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf();\n\n    if (__w != 0 && __n < __w)\n      __pad_len = __w - __n;\n    \n    if (!__left)\n      __ok = __sgi_string_fill(__os, __buf, __pad_len);    \n\n    __ok = __ok && \n           __buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n);\n\n    if (__left)\n      __ok = __ok && __sgi_string_fill(__os, __buf, __pad_len);\n  }\n\n  if (!__ok)\n    __os.setstate(ios_base::failbit);\n\n  return __os;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nbasic_istream<_CharT, _Traits>& \noperator>>(basic_istream<_CharT, _Traits>& __is,\n           basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);\n\n  if (__sentry) {\n    basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();\n    const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__is.getloc());\n\n    __s.clear();\n    size_t __n = __is.width(0);\n    if (__n == 0)\n      __n = static_cast<size_t>(-1);\n    else\n      __s.reserve(__n);\n    \n\n    while (__n-- > 0) {\n      typename _Traits::int_type __c1 = __buf->sbumpc();\n      if (_Traits::eq_int_type(__c1, _Traits::eof())) {\n        __is.setstate(ios_base::eofbit);\n        break;\n      }\n      else {\n        _CharT __c = _Traits::to_char_type(__c1);\n\n        if (__ctype.is(ctype<_CharT>::space, __c)) {\n          if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof()))\n            __is.setstate(ios_base::failbit);\n          break;\n        }\n        else\n          __s.push_back(__c);\n      }\n    }\n    \n    // If we have read no characters, then set failbit.\n    if (__s.size() == 0)\n      __is.setstate(ios_base::failbit);\n  }\n  else\n    __is.setstate(ios_base::failbit);\n\n  return __is;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>    \nbasic_istream<_CharT, _Traits>& \ngetline(istream& __is,\n        basic_string<_CharT,_Traits,_Alloc>& __s,\n        _CharT __delim)\n{\n  size_t __nread = 0;\n  typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true);\n  if (__sentry) {\n    basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();\n    __s.clear();\n\n    int __c1;\n    while (__nread < __s.max_size()) {\n      int __c1 = __buf->sbumpc();\n      if (_Traits::eq_int_type(__c1, _Traits::eof())) {\n        __is.setstate(ios_base::eofbit);\n        break;\n      }\n      else {\n        ++__nread;\n        _CharT __c = _Traits::to_char_type(__c1);\n        if (!_Traits::eq(__c, __delim)) \n          __s.push_back(__c);\n        else\n          break;              // Character is extracted but not appended.\n      }\n    }\n  }\n  if (__nread == 0 || __nread >= __s.max_size())\n    __is.setstate(ios_base::failbit);\n\n  return __is;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>    \ninline basic_istream<_CharT, _Traits>& \ngetline(basic_istream<_CharT, _Traits>& __is,\n        basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  return getline(__is, __s, '\\n');\n}\n\n#else /* __STL_USE_NEW_IOSTREAMS */\n\ninline void __sgi_string_fill(ostream& __os, streambuf* __buf, size_t __n)\n{\n  char __f = __os.fill();\n  size_t __i;\n\n  for (__i = 0; __i < __n; __i++) __buf->sputc(__f);\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nostream& operator<<(ostream& __os, \n                    const basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  streambuf* __buf = __os.rdbuf();\n  if (__buf) {\n    size_t __n = __s.size();\n    size_t __pad_len = 0;\n    const bool __left = (__os.flags() & ios::left) != 0;\n    const size_t __w = __os.width();\n\n    if (__w > 0) {\n      __n = min(__w, __n);\n      __pad_len = __w - __n;\n    }\n    \n    if (!__left)\n      __sgi_string_fill(__os, __buf, __pad_len);\n  \n    const size_t __nwritten = __buf->sputn(__s.data(), __n);\n\n    if (__left)\n      __sgi_string_fill(__os, __buf, __pad_len);\n\n    if (__nwritten != __n)\n      __os.clear(__os.rdstate() | ios::failbit);\n\n    __os.width(0);\n  }\n  else\n    __os.clear(__os.rdstate() | ios::badbit);\n\n  return __os;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nistream& operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  if (!__is)\n    return __is;\n\n  streambuf* __buf = __is.rdbuf();\n  if (__buf) {\n\n#ifdef __USLC__\n/* Jochen Schlick '1999  - operator >> modified. Work-around to get the \n *                         output buffer flushed (necessary when using \n *                         \"cout\" (without endl or flushing) followed by\n *                         \"cin >>\" ...)\n */\n    if (__is.flags() & ios::skipws) {\n      _CharT __c;\n      do \n         __is.get(__c);\n      while (__is && isspace(__c));\n      if (__is)\n         __is.putback(__c);\n    }\n#else\n    if (__is.flags() & ios::skipws) {\n      int __c;\n      do {\n        __c = __buf->sbumpc();\n      }\n      while (__c != EOF && isspace((unsigned char)__c));\n\n      if (__c == EOF) {\n        __is.clear(__is.rdstate() | ios::eofbit | ios::failbit);\n      }\n      else {\n        if (__buf->sputbackc(__c) == EOF)\n          __is.clear(__is.rdstate() | ios::failbit);\n      }\n    }\n#endif\n\n    // If we arrive at end of file (or fail for some other reason) while\n    // still discarding whitespace, then we don't try to read the string.\n    if (__is) {\n      __s.clear();\n\n      size_t __n = __is.width();\n      if (__n == 0)\n        __n = static_cast<size_t>(-1);\n      else\n        __s.reserve(__n);\n\n      while (__n-- > 0) {\n        int __c1 = __buf->sbumpc();\n        if (__c1 == EOF) {\n          __is.clear(__is.rdstate() | ios::eofbit);\n          break;\n        }\n        else {\n          _CharT __c = _Traits::to_char_type(__c1);\n\n          if (isspace((unsigned char) __c)) {\n            if (__buf->sputbackc(__c) == EOF)\n              __is.clear(__is.rdstate() | ios::failbit);\n            break;\n          }\n          else\n            __s.push_back(__c);\n        }\n      }\n    \n      // If we have read no characters, then set failbit.\n      if (__s.size() == 0)\n        __is.clear(__is.rdstate() | ios::failbit);\n    }\n\n    __is.width(0);\n  }\n  else                          // We have no streambuf.\n    __is.clear(__is.rdstate() | ios::badbit);\n\n  return __is;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>    \nistream& getline(istream& __is,\n                 basic_string<_CharT,_Traits,_Alloc>& __s,\n                 _CharT __delim)\n{\n  streambuf* __buf = __is.rdbuf();\n  if (__buf) {\n    size_t __nread = 0;\n    if (__is) {\n      __s.clear();\n\n      while (__nread < __s.max_size()) {\n        int __c1 = __buf->sbumpc();\n        if (__c1 == EOF) {\n          __is.clear(__is.rdstate() | ios::eofbit);\n          break;\n        }\n        else {\n          ++__nread;\n          _CharT __c = _Traits::to_char_type(__c1);\n          if (!_Traits::eq(__c, __delim)) \n            __s.push_back(__c);\n          else\n            break;              // Character is extracted but not appended.\n        }\n      }\n    }\n\n    if (__nread == 0 || __nread >= __s.max_size())\n      __is.clear(__is.rdstate() | ios::failbit);\n  }\n  else\n    __is.clear(__is.rdstate() | ios::badbit);\n\n  return __is;\n}\n\ntemplate <class _CharT, class _Traits, class _Alloc>    \ninline istream& \ngetline(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s)\n{\n  return getline(__is, __s, '\\n');\n}\n\n#endif /* __STL_USE_NEW_IOSTREAMS */\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nvoid _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,\n                    _CharT* __buf,\n                    size_t __n)\n{\n  if (__n > 0) {\n    __n = min(__n - 1, __s.size());\n    copy(__s.begin(), __s.begin() + __n, __buf);\n    _Traits::assign(__buf[__n],\n                    basic_string<_CharT,_Traits,_Alloc>::_M_null());\n  }\n}\n\ninline const char* __get_c_string(const string& __s) { return __s.c_str(); }\n\n// ------------------------------------------------------------\n// Typedefs\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#pragma reset woff 1375\n#endif\n\n__STL_END_NAMESPACE\n\n#include <stl_hash_fun.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nsize_t __stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) {\n  unsigned long __h = 0;\n  for (basic_string<_CharT,_Traits,_Alloc>::const_iterator __i = __s.begin();\n       __i != __s.end();\n       ++__i)\n    __h = 5*__h + *__i;\n  return size_t(__h);\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _CharT, class _Traits, class _Alloc>\nstruct hash<basic_string<_CharT,_Traits,_Alloc> > {\n  size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const\n    { return __stl_string_hash(__s); }\n};\n\n#else\n\n__STL_TEMPLATE_NULL struct hash<string> {\n  size_t operator()(const string& __s) const\n    { return __stl_string_hash(__s); }\n};\n\n__STL_TEMPLATE_NULL struct hash<wstring> {\n  size_t operator()(const wstring& __s) const\n    { return __stl_string_hash(__s); }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_STRING */\n\n\n// Local Variables:\n// mode:C++\n// End:\n\n"
  },
  {
    "path": "stl-3.3-source/tempbuf.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_TEMPBUF_H\n#define __SGI_STL_TEMPBUF_H\n\n#ifndef __SGI_STL_PAIR_H\n#include <pair.h>\n#endif\n#include <limits.h>      /* XXX should use <climits> */\n#include <stddef.h>      /* XXX should use <cstddef> */\n#include <stdlib.h>      /* XXX should use <cstdlib> */\n#ifndef __TYPE_TRAITS_H\n#include <type_traits.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#include <stl_construct.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H\n#include <stl_uninitialized.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_TEMPBUF_H\n#include <stl_tempbuf.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::get_temporary_buffer;\nusing __STD::return_temporary_buffer;\nusing __STD::temporary_buffer;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_TEMPBUF_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/tree.h",
    "content": "/*\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n */\n\n#ifndef __SGI_STL_TREE_H\n#define __SGI_STL_TREE_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_TREE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/type_traits.h",
    "content": "/*\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __TYPE_TRAITS_H\n#define __TYPE_TRAITS_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n\n/*\nThis header file provides a framework for allowing compile time dispatch\nbased on type attributes. This is useful when writing template code.\nFor example, when making a copy of an array of an unknown type, it helps\nto know if the type has a trivial copy constructor or not, to help decide\nif a memcpy can be used.\n\nThe class template __type_traits provides a series of typedefs each of\nwhich is either __true_type or __false_type. The argument to\n__type_traits can be any type. The typedefs within this template will\nattain their correct values by one of these means:\n    1. The general instantiation contain conservative values which work\n       for all types.\n    2. Specializations may be declared to make distinctions between types.\n    3. Some compilers (such as the Silicon Graphics N32 and N64 compilers)\n       will automatically provide the appropriate specializations for all\n       types.\n\nEXAMPLE:\n\n//Copy an array of elements which have non-trivial copy constructors\ntemplate <class T> void copy(T* source, T* destination, int n, __false_type);\n//Copy an array of elements which have trivial copy constructors. Use memcpy.\ntemplate <class T> void copy(T* source, T* destination, int n, __true_type);\n\n//Copy an array of any type by using the most efficient copy mechanism\ntemplate <class T> inline void copy(T* source,T* destination,int n) {\n   copy(source, destination, n,\n        typename __type_traits<T>::has_trivial_copy_constructor());\n}\n*/\n\n\nstruct __true_type {\n};\n\nstruct __false_type {\n};\n\ntemplate <class _Tp>\nstruct __type_traits { \n   typedef __true_type     this_dummy_member_must_be_first;\n                   /* Do not remove this member. It informs a compiler which\n                      automatically specializes __type_traits that this\n                      __type_traits template is special. It just makes sure that\n                      things work if an implementation is using a template\n                      called __type_traits for something unrelated. */\n\n   /* The following restrictions should be observed for the sake of\n      compilers which automatically produce type specific specializations \n      of this class:\n          - You may reorder the members below if you wish\n          - You may remove any of the members below if you wish\n          - You must not rename members without making the corresponding\n            name change in the compiler\n          - Members you add will be treated like regular members unless\n            you add the appropriate support in the compiler. */\n \n\n   typedef __false_type    has_trivial_default_constructor;\n   typedef __false_type    has_trivial_copy_constructor;\n   typedef __false_type    has_trivial_assignment_operator;\n   typedef __false_type    has_trivial_destructor;\n   typedef __false_type    is_POD_type;\n};\n\n\n\n// Provide some specializations.  This is harmless for compilers that\n//  have built-in __types_traits support, and essential for compilers\n//  that don't.\n\n#ifndef __STL_NO_BOOL\n\n__STL_TEMPLATE_NULL struct __type_traits<bool> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#endif /* __STL_NO_BOOL */\n\n__STL_TEMPLATE_NULL struct __type_traits<char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<signed char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#ifdef __STL_HAS_WCHAR_T\n\n__STL_TEMPLATE_NULL struct __type_traits<wchar_t> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#endif /* __STL_HAS_WCHAR_T */\n\n__STL_TEMPLATE_NULL struct __type_traits<short> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned short> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<int> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned int> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#ifdef __STL_LONG_LONG\n\n__STL_TEMPLATE_NULL struct __type_traits<long long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned long long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#endif /* __STL_LONG_LONG */\n\n__STL_TEMPLATE_NULL struct __type_traits<float> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<double> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<long double> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class _Tp>\nstruct __type_traits<_Tp*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n__STL_TEMPLATE_NULL struct __type_traits<char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<signed char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<const char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<const signed char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<const unsigned char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n\n// The following could be written in terms of numeric_limits.  \n// We're doing it separately to reduce the number of dependencies.\n\ntemplate <class _Tp> struct _Is_integer {\n  typedef __false_type _Integral;\n};\n\n#ifndef __STL_NO_BOOL\n\n__STL_TEMPLATE_NULL struct _Is_integer<bool> {\n  typedef __true_type _Integral;\n};\n\n#endif /* __STL_NO_BOOL */\n\n__STL_TEMPLATE_NULL struct _Is_integer<char> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<signed char> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<unsigned char> {\n  typedef __true_type _Integral;\n};\n\n#ifdef __STL_HAS_WCHAR_T\n\n__STL_TEMPLATE_NULL struct _Is_integer<wchar_t> {\n  typedef __true_type _Integral;\n};\n\n#endif /* __STL_HAS_WCHAR_T */\n\n__STL_TEMPLATE_NULL struct _Is_integer<short> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<unsigned short> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<int> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<unsigned int> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<long> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<unsigned long> {\n  typedef __true_type _Integral;\n};\n\n#ifdef __STL_LONG_LONG\n\n__STL_TEMPLATE_NULL struct _Is_integer<long long> {\n  typedef __true_type _Integral;\n};\n\n__STL_TEMPLATE_NULL struct _Is_integer<unsigned long long> {\n  typedef __true_type _Integral;\n};\n\n#endif /* __STL_LONG_LONG */\n\n#endif /* __TYPE_TRAITS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/utility",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_UTILITY\n#define __SGI_STL_UTILITY\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stl_pair.h>\n\n#endif /* __SGI_STL_UTILITY */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/valarray",
    "content": "/*\n * Copyright (c) 1999\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */ \n\n#ifndef __SGI_STL_VALARRAY\n#define __SGI_STL_VALARRAY\n\n#include <type_traits.h>\n#include <math.h>\n#include <algorithm>\n#include <numeric>\n#include <limits>\n#include <new>\n\n\n__STL_BEGIN_NAMESPACE\n\nclass slice;\nclass gslice;\n\ntemplate <class _Tp> class valarray;\ntemplate <class _Tp> class slice_array;\ntemplate <class _Tp> class gslice_array;\ntemplate <class _Tp> class mask_array;\ntemplate <class _Tp> class indirect_array;\n\n//----------------------------------------------------------------------\n// class valarray\n\n// Base class to handle memory allocation and deallocation.  We can't just\n// use vector<>, because vector<bool> would be unsuitable as an internal \n// representation for valarray<bool>.\n\ntemplate <class _Tp> \nstruct _Valarray_base\n{\n  _Tp*   _M_first;\n  size_t _M_size;\n\n  _Valarray_base() : _M_first(0), _M_size(0) {}\n  _Valarray_base(size_t __n) : _M_first(0), _M_size(0) { _M_allocate(__n); }\n  ~_Valarray_base() { _M_deallocate(); }\n\n  void _M_allocate(size_t __n) {\n    if (__n != 0) {\n      _M_first = static_cast<_Tp*>(malloc(__n * sizeof(_Tp)));\n      _M_size  = __n;\n#   if !defined(__STL_NO_BAD_ALLOC) && defined(__STL_USE_EXCEPTIONS)\n      if (_M_first == 0) {\n        _M_size = 0;\n        throw std::bad_alloc();\n      }\n#   endif\n    }\n    else {\n      _M_first = 0;\n      _M_size = 0;\n    }\n  }\n\n  void _M_deallocate() {\n    free(_M_first);\n    _M_first = 0;\n    _M_size = 0;\n  }\n};\n\ntemplate <class _Tp> \nclass valarray : private _Valarray_base<_Tp>\n{\n  friend class gslice;\n\npublic:\n  typedef _Tp value_type;\n\n  // Basic constructors\n  valarray() : _Valarray_base<_Tp>() {}\n  valarray(size_t __n) : _Valarray_base<_Tp>(__n)\n    { uninitialized_fill_n(this->_M_first, this->_M_size, value_type()); }\n  valarray(const value_type& __x, size_t __n) : _Valarray_base<_Tp>(__n)\n    { uninitialized_fill_n(this->_M_first, this->_M_size, __x); }\n  valarray(const value_type* __p, size_t __n) : _Valarray_base<_Tp>(__n)\n    { uninitialized_copy(__p, __p + __n, this->_M_first); } \n  valarray(const valarray& __x) : _Valarray_base<_Tp>(__x._M_size) {\n    uninitialized_copy(__x._M_first, __x._M_first + __x._M_size,\n                       this->_M_first);\n  }\n\n  // Constructors from auxiliary array types\n  valarray(const slice_array<_Tp>&);\n  valarray(const gslice_array<_Tp>&);\n  valarray(const mask_array<_Tp>&);\n  valarray(const indirect_array<_Tp>&);\n\n  // Destructor\n  ~valarray() { destroy(this->_M_first, this->_M_first + this->_M_size); }\n\n  // Extension: constructor that doesn't initialize valarray elements to a\n  // specific value.  This is faster for types such as int and double.\nprivate:\n  void _M_initialize(__true_type) {}\n  void _M_initialize(__false_type)\n    { uninitialized_fill_n(this->_M_first, this->_M_size, value_type()); }\n\npublic:\n  struct _NoInit {};\n  valarray(size_t __n, _NoInit) : _Valarray_base<_Tp>(__n) {\n    typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n            _Is_Trivial;\n    _M_initialize(_Is_Trivial());\n  }\n\npublic:                         // Assignment\n  // Basic assignment.  Note that 'x = y' is undefined if x.size() != y.size()\n  valarray& operator=(const valarray& __x) {\n    if (this != &__x)\n      copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first);\n    return *this;\n  }\n\n  // Scalar assignment\n  valarray& operator=(const value_type& __x) {\n    fill_n(this->_M_first, this->_M_size, __x);\n    return *this;\n  }\n\n  // Assignment of auxiliary array types\n  valarray& operator=(const slice_array<_Tp>&);\n  valarray& operator=(const gslice_array<_Tp>&);\n  valarray& operator=(const mask_array<_Tp>&);\n  valarray& operator=(const indirect_array<_Tp>&);\n\npublic:                         // Element access\n  value_type  operator[](size_t __n) const { return this->_M_first[__n]; }\n  value_type& operator[](size_t __n)       { return this->_M_first[__n]; }\n  size_t size() const { return this->_M_size; }\n\npublic:                         // Subsetting operations with auxiliary type\n  valarray            operator[](slice) const;\n  slice_array<_Tp>    operator[](slice);\n  valarray            operator[](gslice) const;\n  gslice_array<_Tp>   operator[](gslice);  \n  valarray            operator[](const valarray<bool>&) const;\n  mask_array<_Tp>     operator[](const valarray<bool>&);\n  valarray            operator[](const valarray<size_t>&) const;\n  indirect_array<_Tp> operator[](const valarray<size_t>&);\n  \npublic:                         // Unary operators.\n  valarray operator+() const { return *this; }\n\n  valarray operator-() const {\n    valarray __tmp(this->size(), _NoInit());\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      __tmp[__i] = -(*this)[__i];\n    return __tmp;\n  }\n  \n  valarray operator~() const {\n    valarray __tmp(this->size(), _NoInit());\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      __tmp[__i] = ~(*this)[__i];\n    return __tmp;\n  }\n\n  valarray<bool> operator!() const {\n    valarray<bool> __tmp(this->size(), valarray<bool>::_NoInit());\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      __tmp[__i] = !(*this)[__i];\n    return __tmp;\n  }\n\npublic:                         // Scalar computed assignment.\n  valarray& operator*= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] *= __x;\n    return *this;\n  }\n    \n  valarray& operator/= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] /= __x;\n    return *this;\n  }\n\n  valarray& operator%= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] %= __x;\n    return *this;\n  }\n\n  valarray& operator+= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] += __x;\n    return *this;\n  }\n\n  valarray& operator-= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] -= __x;\n    return *this;\n  }\n\n  valarray& operator^= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] ^= __x;\n    return *this;\n  }\n\n  valarray& operator&= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] &= __x;\n    return *this;\n  }\n\n  valarray& operator|= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] |= __x;\n    return *this;\n  }\n\n  valarray& operator<<= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] <<= __x;\n    return *this;\n  }\n\n  valarray& operator>>= (const value_type& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] >>= __x;\n    return *this;\n  }\n\npublic:                         // Array computed assignment.\n  valarray& operator*= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] *= __x[__i];\n    return *this;\n  }\n    \n  valarray& operator/= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] /= __x[__i];\n    return *this;\n  }\n\n  valarray& operator%= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] %= __x[__i];\n    return *this;\n  }\n\n  valarray& operator+= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] += __x[__i];\n    return *this;\n  }\n\n  valarray& operator-= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] -= __x[__i];\n    return *this;\n  }\n\n  valarray& operator^= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] ^= __x[__i];\n    return *this;\n  }\n\n  valarray& operator&= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] &= __x[__i];\n    return *this;\n  }\n\n  valarray& operator|= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] |= __x[__i];\n    return *this;\n  }\n\n  valarray& operator<<= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] <<= __x[__i];\n    return *this;\n  }\n\n  valarray& operator>>= (const valarray& __x) {\n    for (size_t __i = 0; __i < this->size(); ++__i)\n      (*this)[__i] >>= __x[__i];\n    return *this;\n  }\n\npublic:                         // Other member functions.\n\n  // The result is undefined for zero-length arrays\n  value_type sum() const {\n    return accumulate(this->_M_first + 1, this->_M_first + this->_M_size,\n                      (*this)[0]);\n  }\n\n  // The result is undefined for zero-length arrays\n  value_type min() const {\n    return *min_element(this->_M_first + 0, this->_M_first + this->_M_size);\n  }\n\n  value_type max() const {\n    return *max_element(this->_M_first + 0, this->_M_first + this->_M_size);\n  }\n\n  valarray shift(int __n) const;\n  valarray cshift(int __n) const;\n\n  valarray apply(value_type __f(value_type)) const {\n    valarray __tmp(this->size());\n    transform(this->_M_first, this->_M_first + this->_M_size, __tmp._M_first,\n              __f);\n    return __tmp;\n  }\n  valarray apply(value_type __f(const value_type&)) const {\n    valarray __tmp(this->size());\n    transform(this->_M_first, this->_M_first + this->_M_size, __tmp._M_first,\n              __f);\n    return __tmp;\n  }\n  \n  void resize(size_t __n, value_type __x = value_type()) {\n    destroy(this->_M_first, this->_M_first + this->_M_size);\n    this->_Valarray_base<_Tp>::_M_deallocate();\n    this->_Valarray_base<_Tp>::_M_allocate(__n);\n    uninitialized_fill_n(this->_M_first, this->_M_size, __x);\n  }\n};\n\n//----------------------------------------------------------------------\n// valarray non-member functions.\n\n// Binary arithmetic operations between two arrays.  Behavior is\n// undefined if the two arrays do not have the same length.\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator*(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] * __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator/(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] / __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator%(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] % __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator+(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] + __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator-(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] - __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator^(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] ^ __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator&(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] & __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator|(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] | __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator<<(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] << __y[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator>>(const valarray<_Tp>& __x,\n                               const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] >> __y[__i];\n  return __tmp;\n}\n\n// Binary arithmetic operations between an array and a scalar.\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator*(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  * __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator*(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c * __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator/(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  / __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator/(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c / __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator%(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  % __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator%(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c % __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator+(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  + __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator+(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c + __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator-(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  - __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator-(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c - __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator^(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  ^ __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator^(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c ^ __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator&(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  & __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator&(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c & __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator|(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  | __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator|(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c | __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator<<(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  << __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator<<(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c << __x[__i];\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator>>(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  >> __c;\n  return __tmp;\n}\n\ntemplate <class _Tp> \ninline valarray<_Tp> operator>>(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c >> __x[__i];\n  return __tmp;\n}\n\n// Binary logical operations between two arrays.  Behavior is undefined\n// if the two arrays have different lengths.  Note that operator== does\n// not do what you might at first expect.\n\ntemplate <class _Tp> \ninline valarray<bool> operator==(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] == __y[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp> \ninline valarray<bool> operator<(const valarray<_Tp>& __x,\n                                const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] < __y[__i];\n  return __tmp;  \n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class _Tp> \ninline valarray<bool> operator!=(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] != __y[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp> \ninline valarray<bool> operator>(const valarray<_Tp>& __x,\n                                const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] > __y[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp> \ninline valarray<bool> operator<=(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] <= __y[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp> \ninline valarray<bool> operator>=(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] >= __y[__i];\n  return __tmp;  \n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class _Tp> \ninline valarray<bool> operator&&(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] && __y[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp> \ninline valarray<bool> operator||(const valarray<_Tp>& __x,\n                                 const valarray<_Tp>& __y)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] || __y[__i];\n  return __tmp;  \n}\n\n// Logical operations between an array and a scalar.\n\ntemplate <class _Tp>\ninline valarray<bool> operator==(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] == __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator==(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c == __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator!=(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] != __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator!=(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c != __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator<(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] < __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator<(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c < __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator>(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] > __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator>(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c > __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator<=(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i]  <= __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator<=(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c <= __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator>=(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] >= __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator>=(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c >= __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator&&(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] && __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator&&(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c && __x[__i];\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator||(const valarray<_Tp>& __x, const _Tp& __c)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __x[__i] || __c;\n  return __tmp;  \n}\n\ntemplate <class _Tp>\ninline valarray<bool> operator||(const _Tp& __c, const valarray<_Tp>& __x)\n{\n  valarray<bool> __tmp(__x.size(), valarray<bool>::_NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = __c || __x[__i];\n  return __tmp;  \n}\n\n// valarray \"transcendentals\" (the list includes abs and sqrt, which,\n// of course, are not transcendental).\n\ntemplate <class _Tp>\ninline valarray<_Tp> abs(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = abs(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> acos(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = acos(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> asin(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = asin(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> atan(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = atan(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> atan2(const valarray<_Tp>& __x,\n                           const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = atan2(__x[__i], __y[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> atan2(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = atan2(__x[__i], __c);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> atan2(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = atan2(__c, __x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> cos(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = cos(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> cosh(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = cosh(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> exp(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = exp(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> log(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = log(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> log10(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = log10(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> pow(const valarray<_Tp>& __x,\n                           const valarray<_Tp>& __y) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = pow(__x[__i], __y[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> pow(const valarray<_Tp>& __x, const _Tp& __c) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = pow(__x[__i], __c);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> pow(const _Tp& __c, const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = pow(__c, __x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> sin(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = sin(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> sinh(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = sinh(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> sqrt(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = sqrt(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> tan(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = tan(__x[__i]);\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline valarray<_Tp> tanh(const valarray<_Tp>& __x) {\n  typedef typename valarray<_Tp>::_NoInit _NoInit;\n  valarray<_Tp> __tmp(__x.size(), _NoInit());\n  for (size_t __i = 0; __i < __x.size(); ++__i)\n    __tmp[__i] = tanh(__x[__i]);\n  return __tmp;\n}\n\n//----------------------------------------------------------------------\n// slice and slice_array\n\nclass slice {\npublic:\n  slice() : _M_start(0), _M_length(0), _M_stride(0) {}\n  slice(size_t __start, size_t __length, size_t __stride)\n    : _M_start(__start), _M_length(__length), _M_stride(__stride)\n    {}\n\n  size_t start()  const { return _M_start; }\n  size_t size()   const { return _M_length; }\n  size_t stride() const { return _M_stride; }\n\n   \nprivate:\n  size_t _M_start;\n  size_t _M_length;\n  size_t _M_stride;\n};\n\ntemplate <class _Tp>\nclass slice_array {\n  friend class valarray<_Tp>;\npublic:\n  typedef _Tp value_type;\n\n  void operator=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] = __x[__i];\n  }\n\n  void operator*=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] *= __x[__i];\n  }\n\n  void operator/=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] /= __x[__i];\n  }\n\n  void operator%=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] %= __x[__i];\n  }\n\n  void operator+=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] += __x[__i];\n  }\n\n  void operator-=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] -= __x[__i];\n  }\n\n  void operator^=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] ^= __x[__i];\n  }\n\n  void operator&=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] &= __x[__i];\n  }\n\n  void operator|=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] |= __x[__i];\n  }\n\n  void operator<<=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] <<= __x[__i];\n  }\n\n  void operator>>=(const valarray<value_type>& __x) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] >>= __x[__i];\n  }\n\n  void operator=(const value_type& __c) const {\n    size_t __index = _M_slice.start();\n    for (size_t __i = 0;\n         __i < _M_slice.size();\n         ++__i, __index += _M_slice.stride())\n      _M_array[__index] = __c;\n  }\n\n  ~slice_array() {}\n\nprivate:\n  slice_array(const slice& __slice, valarray<_Tp>& __array)\n    : _M_slice(__slice), _M_array(__array)\n    {}\n\n  slice          _M_slice;\n  valarray<_Tp>& _M_array;\n\nprivate:                        // Disable assignment and default constructor\n  slice_array();\n};\n\n// valarray member functions dealing with slice and slice_array\n\ntemplate <class _Tp>\ninline valarray<_Tp>::valarray(const slice_array<_Tp>& __x)\n  : _Valarray_base<_Tp>(__x._M_slice.size())\n{\n  typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n          _Is_Trivial;\n  _M_initialize(_Is_Trivial());  \n  *this = __x;\n}\n\n// Behavior is undefined if __x and *this have different sizes\ntemplate <class _Tp>\nvalarray<_Tp>& valarray<_Tp>::operator=(const slice_array<_Tp>& __x)\n{\n  size_t __index = __x._M_slice.start();\n  for (size_t __i = 0;\n       __i < __x._M_slice.size();\n       ++__i, __index += __x._M_slice.stride())\n    (*this)[__i] = __x._M_array[__index];\n  return *this;\n}\n\ntemplate <class _Tp>\nvalarray<_Tp> valarray<_Tp>::operator[](slice __slice) const {\n  valarray<_Tp> __tmp(__slice.size(), _NoInit());\n  size_t __index = __slice.start();\n  for (size_t __i = 0;\n       __i < __slice.size();\n       ++__i, __index += __slice.stride())\n    __tmp[__i] = (*this)[__index];\n  return __tmp;\n}\n\ntemplate <class _Tp>\ninline slice_array<_Tp> valarray<_Tp>::operator[](slice __slice) {\n  return slice_array<_Tp>(__slice, *this);\n}\n\n//----------------------------------------------------------------------\n// gslice and gslice_array\n\nstruct _Gslice_Iter;\n\nclass gslice {\n  friend struct _Gslice_Iter;\npublic:\n  gslice() : _M_start(0), _M_lengths(0), _M_strides(0) {}\n  gslice(size_t __start,\n         const valarray<size_t>& __lengths, const valarray<size_t>& __strides)\n    : _M_start(__start), _M_lengths(__lengths), _M_strides(__strides)\n    {}\n\n  size_t start()            const { return _M_start; }\n  valarray<size_t> size()   const { return _M_lengths; }\n  valarray<size_t> stride() const { return _M_strides; }\n\n  // Extension: check for an empty gslice.\n  bool _M_empty() const { return _M_lengths.size() == 0; }\n\n  // Extension: number of indices this gslice represents.  (For a degenerate\n  // gslice, they're not necessarily all distinct.)\n  size_t _M_size() const {\n    return !this->_M_empty()\n      ? accumulate(_M_lengths._M_first + 1,\n                   _M_lengths._M_first + _M_lengths._M_size,\n                   _M_lengths[0],\n                   multiplies<size_t>())\n      : 0;\n  }\n\nprivate:\n  size_t _M_start;\n  valarray<size_t> _M_lengths;\n  valarray<size_t> _M_strides;\n};\n\n// This is not an STL iterator.  It is constructed from a gslice, and it\n// steps through the gslice indices in sequence.  See 23.3.6 of the C++\n// standard, paragraphs 2-3, for an explanation of the sequence.  At\n// each step we get two things: the ordinal (i.e. number of steps taken),\n// and the one-dimensional index.\n\nstruct _Gslice_Iter {\n  _Gslice_Iter(const gslice& __gslice)\n    : _M_step(0), _M_1d_idx(__gslice.start()),\n      _M_indices(size_t(0), __gslice._M_lengths.size()),\n      _M_gslice(__gslice)\n    {}\n    \n  bool _M_done() const { return _M_indices[0] == _M_gslice._M_lengths[0]; }\n\n  bool _M_incr() {\n    size_t __dim = _M_indices.size() - 1;\n    ++_M_step;\n    while (true) {\n      _M_1d_idx += _M_gslice._M_strides[__dim];\n      if (++_M_indices[__dim] != _M_gslice._M_lengths[__dim])\n        return true;\n      else if (__dim != 0) {\n        _M_1d_idx -=\n          _M_gslice._M_strides[__dim] * _M_gslice._M_lengths[__dim];\n        _M_indices[__dim] = 0;\n        --__dim;\n      }\n      else\n        return false;\n    }\n  }\n\n  size_t _M_step;\n  size_t _M_1d_idx;\n\n  valarray<size_t> _M_indices;\n  const gslice& _M_gslice;\n};\n\ntemplate <class _Tp>\nclass gslice_array {\n  friend class valarray<_Tp>;\npublic:\n  typedef _Tp value_type;\n\n  void operator= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] = __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator*= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] *= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator/= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] /= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator%= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] %= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator+= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] += __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator-= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] -= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator^= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] ^= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator&= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] &= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator|= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] |= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator<<= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] <<= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator>>= (const valarray<value_type>& __x) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] >>= __x[__i._M_step]; while(__i._M_incr());\n    }\n  }\n\n  void operator= (const value_type& __c) const {\n    if (!_M_gslice._M_empty()) {\n      _Gslice_Iter __i(_M_gslice);\n      do _M_array[__i._M_1d_idx] = __c; while(__i._M_incr());\n    }\n  }\n\n  ~gslice_array() {}\n\nprivate:                        \n  gslice_array(gslice __gslice, valarray<_Tp>& __array)\n    : _M_gslice(__gslice), _M_array(__array)\n    {}\n\n  gslice                _M_gslice;\n  valarray<value_type>& _M_array;\n\nprivate:                        // Disable assignment\n  void operator=(const gslice_array&);\n};\n\n// valarray member functions dealing with gslice and gslice_array.  Note\n// that it is illegal (behavior is undefined) to construct a gslice_array\n// from a degenerate gslice.\n\ntemplate <class _Tp>\ninline valarray<_Tp>::valarray(const gslice_array<_Tp>& __x)\n  : _Valarray_base<_Tp>(__x._M_gslice._M_size())\n{\n  typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n          _Is_Trivial;\n  _M_initialize(_Is_Trivial());  \n  *this = __x;\n}\n\n// Behavior is undefined if __x and *this have different sizes, or if\n// __x was constructed from a degenerate gslice.\ntemplate <class _Tp>\nvalarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __x)\n{\n  if (this->size() != 0) {\n    _Gslice_Iter __i(__x._M_gslice);\n    do\n      (*this)[__i._M_step] = __x._M_array[__i._M_1d_idx];\n    while(__i._M_incr());\n  }\n  return *this;\n}\n\ntemplate <class _Tp>\ninline gslice_array<_Tp> valarray<_Tp>::operator[](gslice __slice) {\n  return gslice_array<_Tp>(__slice, *this);\n}\n\ntemplate <class _Tp>\nvalarray<_Tp> valarray<_Tp>::operator[](gslice __slice) const\n{\n  valarray __tmp(__slice._M_size(), _NoInit());\n  if (__tmp.size() != 0) {\n    _Gslice_Iter __i(__slice);\n    do __tmp[__i._M_step] = (*this)[__i._M_1d_idx]; while(__i._M_incr());\n  }\n  return __tmp;\n}\n\n//----------------------------------------------------------------------\n// mask_array\n\ntemplate <class _Tp>\nclass mask_array {\n  friend class valarray<_Tp>;\npublic:\n  typedef _Tp value_type;\n\n  void operator=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] = __x[__idx++];\n  }\n\n  void operator*=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] *= __x[__idx++];\n  }\n\n  void operator/=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] /= __x[__idx++];\n  }\n\n  void operator%=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] %= __x[__idx++];\n  }\n\n  void operator+=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] += __x[__idx++];\n  }\n\n  void operator-=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] -= __x[__idx++];\n  }\n  \n  void operator^=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] ^= __x[__idx++];\n  }\n\n  void operator&=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] &= __x[__idx++];\n  }\n\n  void operator|=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] |= __x[__idx++];\n  }\n\n  void operator<<=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] <<= __x[__idx++];\n  }\n\n  void operator>>=(const valarray<value_type>& __x) const {\n    size_t __idx = 0;\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] >>= __x[__idx++];\n  }\n\n  void operator=(const value_type& __c) const {\n    for (size_t __i = 0; __i < _M_array.size(); ++__i)\n      if (_M_mask[__i]) _M_array[__i] = __c;\n  }\n\n  ~mask_array() {}\n\n  // Extension: number of true values in the mask\n  size_t _M_num_true() const {\n    size_t __result = 0;\n    for (size_t __i = 0; __i < _M_mask.size(); ++__i)\n      if (_M_mask[__i]) ++__result;\n    return __result;\n  }\n\nprivate:\n  mask_array(const valarray<bool>& __mask, valarray<_Tp>& __array)\n    : _M_mask(__mask), _M_array(__array)\n    {}\n\n  valarray<bool> _M_mask;\n  valarray<_Tp>& _M_array;\n\nprivate:                        // Disable assignment\n  void operator=(const mask_array&);\n};\n\n// valarray member functions dealing with mask_array\n\ntemplate <class _Tp>\ninline valarray<_Tp>::valarray(const mask_array<_Tp>& __x)\n  : _Valarray_base<_Tp>(__x._M_num_true())\n{\n  typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n          _Is_Trivial;\n  _M_initialize(_Is_Trivial());  \n  *this = __x;\n}\n\n// Behavior is undefined if __x._M_num_true() != this->size()\ntemplate <class _Tp>\ninline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __x) {\n  size_t __idx = 0;\n  for (size_t __i = 0; __i < __x._M_array.size(); ++__i)\n    if (__x._M_mask[__i]) (*this)[__idx++] = __x._M_array[__i];\n  return *this;\n}\n\ntemplate <class _Tp>\ninline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __mask)\n{\n  return mask_array<_Tp>(__mask, *this);\n}\n\ntemplate <class _Tp>\nvalarray<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __mask) const\n{\n  size_t __size = 0;\n  {\n    for (size_t __i = 0; __i < __mask.size(); ++__i)\n      if (__mask[__i]) ++__size;\n  }\n\n  valarray __tmp(__size, _NoInit());\n  size_t __idx = 0;\n  {\n    for (size_t __i = 0; __i < __mask.size(); ++__i)\n      if (__mask[__i]) __tmp[__idx++] = (*this)[__i];\n  }\n\n  return __tmp;\n}\n\n//----------------------------------------------------------------------\n// indirect_array\n\ntemplate <class _Tp>\nclass indirect_array {\n  friend class valarray<_Tp>;\npublic:\n  typedef _Tp value_type;\n\n  void operator=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] = __x[__i];\n  }\n\n  void operator*=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] *= __x[__i];\n  }\n\n  void operator/=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] /= __x[__i];\n  }\n\n  void operator%=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] %= __x[__i];\n  }\n\n  void operator+=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] += __x[__i];\n  }\n\n  void operator-=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] -= __x[__i];\n  }\n\n  void operator^=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] ^= __x[__i];\n  }\n\n  void operator&=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] &= __x[__i];\n  }\n\n  void operator|=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] |= __x[__i];\n  }\n\n  void operator<<=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] <<= __x[__i];\n  }\n\n  void operator>>=(const valarray<value_type>& __x) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] >>= __x[__i];\n  }\n\n  void operator=(const value_type& __c) const {\n    for (size_t __i = 0; __i < _M_addr.size(); ++__i)\n      _M_array[_M_addr[__i]] = __c;\n  }\n\n  ~indirect_array() {}\n\nprivate:\n  indirect_array(const valarray<size_t>& __addr, valarray<_Tp>& __array)\n    : _M_addr(__addr), _M_array(__array)\n    {}\n\n  valarray<size_t> _M_addr;\n  valarray<_Tp>&   _M_array;\n\nprivate:                        // Disable assignment\n  void operator=(const indirect_array&);\n};\n\n// valarray member functions dealing with indirect_array\n\ntemplate <class _Tp>\ninline valarray<_Tp>::valarray(const indirect_array<_Tp>& __x)\n  : _Valarray_base<_Tp>(__x._M_addr.size())\n{\n  typedef typename __type_traits<_Tp>::has_trivial_default_constructor\n          _Is_Trivial;\n  _M_initialize(_Is_Trivial());  \n  *this = __x;\n}\n\ntemplate <class _Tp>\nvalarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<_Tp>& __x) {\n  for (size_t __i = 0; __i < __x._M_addr.size(); ++__i)\n    (*this)[__i] = __x._M_array[__x._M_addr[__i]];\n  return *this;\n}\n\ntemplate <class _Tp>\ninline indirect_array<_Tp>\nvalarray<_Tp>::operator[](const valarray<size_t>& __addr)\n{\n  return indirect_array<_Tp>(__addr, *this);\n}\n\ntemplate <class _Tp>\nvalarray<_Tp>\nvalarray<_Tp>::operator[](const valarray<size_t>& __addr) const\n{\n  valarray<_Tp> __tmp(__addr.size(), _NoInit());\n  for (size_t __i = 0; __i < __addr.size(); ++__i)\n    __tmp[__i] = (*this)[__addr[__i]];\n  return __tmp;\n}\n\n//----------------------------------------------------------------------\n// Other valarray noninline member functions\n\n// Shift and cshift\n\ntemplate <class _Tp>\nvalarray<_Tp> valarray<_Tp>::shift(int __n) const\n{\n  valarray<_Tp> __tmp(this->size());\n\n  if (__n >= 0) {\n    if (__n < this->size())\n      copy(this->_M_first + __n, this->_M_first + this->size(),\n           __tmp._M_first);\n  }\n  else {\n    if (-__n < this->size())\n      copy(this->_M_first, this->_M_first + this->size() + __n,\n           __tmp._M_first - __n);\n  }\n  return __tmp;\n}\n\ntemplate <class _Tp>\nvalarray<_Tp> valarray<_Tp>::cshift(int __m) const\n{\n  valarray<_Tp> __tmp(this->size());\n\n  // Reduce __m to an equivalent number in the range [0, size()).  We\n  // have to be careful with negative numbers, since the sign of a % b\n  // is unspecified when a < 0.\n  long __n = __m;\n  if (this->size() < numeric_limits<long>::max())\n    __n %= long(this->size());\n  if (__n < 0)\n    __n += this->size();\n\n  copy(this->_M_first,       this->_M_first + __n,\n       __tmp._M_first + (this->size() - __n));\n  copy(this->_M_first + __n, this->_M_first + this->size(),\n       __tmp._M_first);\n\n  return __tmp;\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_VALARRAY */\n\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/vector",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_VECTOR\n#define __SGI_STL_VECTOR\n\n#include <stl_range_errors.h>\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_vector.h>\n#include <stl_bvector.h>\n\n#endif /* __SGI_STL_VECTOR */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-3.3-source/vector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_VECTOR_H\n#define __SGI_STL_VECTOR_H\n\n#include <stl_range_errors.h>\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_vector.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::vector;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_VECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config-inclass-init.cpp",
    "content": "//̬ʼ\r\n#include <iostream>\r\nusing namespace std;\r\n\r\ntemplate <typename T>\r\nclass testClass\r\n{\r\n\r\npublic:\r\n\r\n    static const int _datai = 5;\r\n    static const long _datal = 3L;\r\n    static const char _datac = 'c';\r\n};\r\n\r\nint main()\r\n{\r\n    cout<<testClass<int>::_datai<<endl;\r\n    cout<<testClass<long>::_datal<<endl;\r\n    cout<<testClass<char>::_datac<<endl;\r\n\r\n    return 0;\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config-operator-overloading.cpp",
    "content": "//Լȡֵ\r\n#include <iostream>\r\nusing namespace std;\r\n\r\nclass INT\r\n{\r\n    friend ostream& operator<<(ostream& os, const INT& i);\r\n\r\npublic:\r\n    INT(int i) : m_i(i) { };\r\n\r\n    //  prefix : increment and then fetch\r\n    //  ++INT\r\n    INT& operator++()\r\n    {\r\n        ++(this->m_i);\r\n        return *this;\r\n    }\r\n\r\n    //  postfix : fetch and then increment\r\n    //  INT++\r\n    const INT operator++(int)\r\n    {\r\n        INT temp = *this;\r\n        ++(*this);\r\n        return temp;\r\n    }\r\n\r\n    //  prefix  :   decrement and then fetch\r\n    //  --INT\r\n    INT& operator--()\r\n    {\r\n        --(this->m_i);\r\n        return *this;\r\n    }\r\n\r\n    //  prefix  :   fetch and then decrement\r\n    const INT operator--(int)\r\n    {\r\n        INT temp = *this;\r\n        --(*this);\r\n        return temp;\r\n    }\r\n\r\n    int& operator*() const\r\n    {\r\n        return (int&)m_i;\r\n    }\r\n\r\nprivate:\r\n    int m_i;\r\n};\r\n\r\nostream& operator<<(ostream& os, const INT& i)\r\n{\r\n    os <<'[' <<i.m_i <<']';\r\n    return os;\r\n}\r\n\r\nint main()\r\n{\r\n    INT I(5);\r\n    cout <<I++ <<endl;\r\n    cout <<++I <<endl;\r\n    cout <<I-- <<endl;\r\n    cout <<--I <<endl;\r\n    cout <<*I <<endl;\r\n\r\n  return 1;\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config-template-exp-special.cpp",
    "content": "//class template explicit specializatin  \r\n#include <iostream>  \r\nusing namespace std;  \r\n  \r\ntemplate <class Key>  \r\nstruct hash  \r\n{  \r\n  void operator()()  \r\n  {  \r\n    cout<<\"hash<T>\"<<endl;  \r\n  }  \r\n};  \r\n  \r\ntemplate<>  \r\nstruct hash<char>  \r\n{  \r\n  void operator()()  \r\n  {  \r\n    cout<<\"hash<char>\"<<endl;  \r\n  }  \r\n};  \r\n  \r\ntemplate<>  \r\nstruct hash<unsigned char>  \r\n{  \r\n  void operator()()  \r\n  {  \r\n    cout<<\"hash<unsinged char>\"<<endl;  \r\n  }  \r\n};  \r\n  \r\nint main()  \r\n{  \r\n  hash<long> t1;  \r\n  hash<char> t2;  \r\n  hash<unsigned char> t3;  \r\n  \r\n  t1();  \r\n  t2();  \r\n  t3();  \r\n  \r\n  return 1;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1config-temporary-object.cpp",
    "content": "//ʱĲ\r\n#include <vector>\r\n#include <iostream>\r\n#include <algorithm>\r\nusing namespace std;\r\n\r\ntemplate <typename T>\r\nclass print\r\n{\r\npublic:\r\n  void operator()(const T& elem)\r\n  {\r\n    cout<<elem<<' ';\r\n  }\r\n};\r\n\r\nint main()\r\n{\r\n    int ia[6] = {0,1,2,3,4,5};\r\n    vector<int> iv(ia, ia+6);\r\n\r\n    for_each(iv.begin(), iv.end(), print<int>());\r\n\r\n    cout<<endl;\r\n\r\n  return 1;\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config.cpp",
    "content": "#include <iostream>\r\n#include <stdio.h>\r\nusing namespace std;\r\n\r\n\r\nvoid    test(void)\r\n{\r\n#ifdef _PTHREADS\r\n    cout<<\"define __STL_PTHREADS\"<<endl;\r\n#endif\r\n\r\n# if defined(__sgi) && !defined(__GNUC__)\r\n    cout<<\"__sgi begin\"<<endl;\r\n# if !defined(_BOOL)\r\n        cout<<\"__STL_NEED_BOOL\"<<endl;\r\n# endif\r\n# if !defined(_TYPENAME_IS_KEYWORD)\r\n         cout<<\"__STL_NEED_TYPENAME\"<<endl;\r\n# endif\r\n# ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES\r\n        cout<<\"__STL_CLASS_PARTIAL_SPECIALIZATION\"<<endl;\r\n# endif\r\n# ifdef _MEMBER_TEMPLATES\r\n        cout<<\"__STL_MEMBER_TEMPLATES\"<<endl;\r\n# endif\r\n# if !defined(_EXPLICIT_IS_KEYWORD)\r\n        cout<<\"__STL_NEED_EXPLICIT\"<<endl;\r\n# endif\r\n# ifdef __EXCEPTIONS\r\n        cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n# endif\r\n# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)\r\n        cout<<\"__STL_USE_NAMESPACES\"<<endl;\r\n# endif\r\n# if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)\r\n        cout<<\"__STL_SGI_THREADS\"<<endl;\r\n# endif\r\n    cout<<\"__sgi end\"<<endl<<endl;\r\n# endif\r\n\r\n# ifdef __GNUC__\r\n    cout<<\"__GNUC__ begin\"<<endl;\r\n//# include <_G_config.h>\r\n# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)\r\n        cout<<\"__STL_STATIC_TEMPLATE_MEMBER_BUG\"<<endl;\r\n        cout<<\"__STL_NEED_TYPENAME\"<<endl;\r\n        cout<<\"__STL_NEED_EXPLICIT\"<<endl;\r\n# else\r\n        cout<<\"__STL_CLASS_PARTIAL_SPECIALIZATION\"<<endl;\r\n        cout<<\"__STL_FUNCTION_TMPL_PARTIAL_ORDER\"<<endl;\r\n        cout<<\"__STL_EXPLICIT_FUNCTION_TMPL_ARGS\"<<endl;\r\n        cout<<\"__STL_MEMBER_TEMPLATES\"<<endl;\r\n# endif\r\n    /* glibc pre 2.0 is very buggy. We have to disable thread for it.\r\n       It should be upgraded to glibc 2.0 or later. */\r\n# if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)\r\n        cout<<\"__STL_PTHREADS\"<<endl;\r\n# endif\r\n# ifdef __EXCEPTIONS\r\n        cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n# endif\r\n    cout<<\"__GNUC__ end\"<<endl<<endl;\r\n# endif\r\n\r\n# if defined(__SUNPRO_CC)\r\n    cout<<\"__SUNPRO_CC begin\"<<endl;\r\n    cout<<\"__STL_NEED_BOOL\"<<endl;\r\n    cout<<\"__STL_NEED_TYPENAME\"<<endl;\r\n    cout<<\"__STL_NEED_EXPLICIT\"<<endl;\r\n    cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n    cout<<\"__SUNPRO_CC end\"<<endl<<endl;\r\n# endif\r\n\r\n# if defined(__COMO__)\r\n    cout<<\"__COMO__ begin\"<<endl;\r\n    cout<<\"__STL_MEMBER_TEMPLATES\"<<endl;\r\n    cout<<\"__STL_CLASS_PARTIAL_SPECIALIZATION\"<<endl;\r\n    cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n    cout<<\"__STL_USE_NAMESPACES\"<<endl;\r\n    cout<<\"__COMO__ end\"<<endl<<endl;\r\n# endif\r\n\r\n# if defined(_MSC_VER)\r\ncout<<\"_MSC_VER begin\"<<endl;\r\n# if _MSC_VER > 1000\r\n        cout<<\"include \"<<endl;\r\n# else\r\n        cout<<\"__STL_NEED_BOOL\"<<endl;\r\n# endif\r\n        cout<<\"__STL_NO_DRAND48\"<<endl;\r\n        cout<<\"__STL_NEED_TYPENAME\"<<endl;\r\n# if _MSC_VER < 1100\r\n        cout<<\"__STL_NEED_EXPLICIT\"<<endl;\r\n# endif\r\n        cout<<\"__STL_NON_TYPE_TMPL_PARAM_BUG\"<<endl;\r\n        cout<<\"__SGI_STL_NO_ARROW_OPERATOR\"<<endl;\r\n# ifdef _CPPUNWIND\r\n        cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n# endif\r\n# ifdef _MT\r\n        cout<<\"__STL_WIN32THREADS\"<<endl;\r\n# endif\r\n    cout<<\"_MSC_VER end\"<<endl<<endl;\r\n# endif\r\n\r\n# if defined(__BORLANDC__)\r\n    cout<<\"__BORLANDC__ begin\"<<endl;\r\n    cout<<\"__STL_NO_DRAND48\"<<endl;\r\n    cout<<\"__STL_NEED_TYPENAME\"<<endl;\r\n    cout<<\"__STL_LIMITED_DEFAULT_TEMPLATES\"<<endl;\r\n    cout<<\"__SGI_STL_NO_ARROW_OPERATOR\"<<endl;\r\n    cout<<\"__STL_NON_TYPE_TMPL_PARAM_BUG\"<<endl;\r\n# ifdef _CPPUNWIND\r\n        cout<<\"__STL_USE_EXCEPTIONS\"<<endl;\r\n# endif\r\n# ifdef __MT__\r\n        cout<<\"__STL_WIN32THREADS\"<<endl;\r\n# endif\r\n    cout<<\"__BORLANDC__ end\"<<endl<<endl;\r\n# endif\r\n\r\n\r\n# if defined(__STL_NEED_BOOL)\r\n    cout<<\"__STL_NEED_BOOL begin\"<<endl;\r\n    cout<<\"typedef int bool;\"<<endl;\r\n    cout<<\"define true 1\"<<endl;\r\n    cout<<\"define false 0\"<<endl;\r\n    cout<<\"__STL_NEED_BOOL end\"<<endl<<endl;\r\n# endif\r\n\r\n# ifdef __STL_NEED_TYPENAME\r\n    cout<<\"define typename\"<<endl;\r\n# endif\r\n\r\n# ifdef __STL_NEED_EXPLICIT\r\n    cout<<\"define explicit\"<<endl;\r\n# endif\r\n\r\n# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS\r\n    cout<<\"__STL_NULL_TMPL_ARGS <>\"<<endl;\r\n# else\r\n    cout<<\"__STL_NULL_TMPL_ARGS\"<<endl;\r\n# endif\r\n\r\n# ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\r\n    cout<<\"__STL_TEMPLATE_NULL template<>\"<<endl;\r\n# else\r\n    cout<<\"__STL_TEMPLATE_NULL\"<<endl;\r\n# endif\r\n\r\n// __STL_NO_NAMESPACES is a hook so that users can disable namespaces\r\n// without having to edit library headers.\r\n# if defined(__STL_USE_NAMESPACES) && !defined(__STL_NO_NAMESPACES)\r\n    cout<<\"__STL_USE_NAMESPACES begin\"<<endl;\r\n    cout<<\"__STD std\"<<endl;\r\n    cout<<\"__STL_BEGIN_NAMESPACE namespace std {\"<<endl;\r\n    cout<<\"__STL_END_NAMESPACE }\"<<endl;\r\n    cout<<\"__STL_USE_NAMESPACE_FOR_RELOPS\"<<endl;\r\n    cout<<\"__STL_BEGIN_RELOPS_NAMESPACE namespace std {\"<<endl;\r\n    cout<<\"__STL_END_RELOPS_NAMESPACE }\"<<endl;\r\n    cout<<\"__STD_RELOPS std\"<<endl;\r\n    cout<<\"__STL_USE_NAMESPACES end\"<<endl<<endl;\r\n# else\r\n    cout<<\"! __STL_USE_NAMESPACES begin\"<<endl;\r\n    cout<<\"__STD \"<<endl;\r\n    cout<<\"__STL_BEGIN_NAMESPACE \"<<endl;\r\n    cout<<\"__STL_END_NAMESPACE \"<<endl;\r\n    cout<<\"__STL_USE_NAMESPACE_FOR_RELOPS\"<<endl;\r\n    cout<<\"__STL_BEGIN_RELOPS_NAMESPACE \"<<endl;\r\n    cout<<\"__STL_END_RELOPS_NAMESPACE \"<<endl;\r\n    cout<<\"__STD_RELOPS \"<<endl;\r\n    cout<<\"! __STL_USE_NAMESPACES end\"<<endl<<endl;\r\n# endif\r\n\r\n# ifdef __STL_USE_EXCEPTIONS\r\n    cout<<\"__STL_USE_EXCEPTIONS begin\"<<endl;\r\n    cout<<\"__STL_TRY try\"<<endl;\r\n    cout<<\"__STL_CATCH_ALL catch(...)\"<<endl;\r\n    cout<<\"__STL_RETHROW throw\"<<endl;\r\n    cout<<\"__STL_NOTHROW throw()\"<<endl;\r\n    cout<<\"__STL_UNWIND(action) catch(...) { action; throw; }\"<<endl;\r\n    cout<<\"__STL_USE_EXCEPTIONS end\"<<endl<<endl;\r\n# else\r\n    cout<<\"! __STL_USE_EXCEPTIONS begin\"<<endl;\r\n    cout<<\"__STL_TRY \"<<endl;\r\n    cout<<\"__STL_CATCH_ALL if (false)\"<<endl;\r\n    cout<<\"__STL_RETHROW \"<<endl;\r\n    cout<<\"__STL_NOTHROW \"<<endl;\r\n    cout<<\"__STL_UNWIND(action) \"<<endl;\r\n    cout<<\"! __STL_USE_EXCEPTIONS end\"<<endl<<endl;\r\n# endif\r\n\r\n#ifdef __STL_ASSERTIONS\r\n# include <stdio.h>\r\n    cout<<\"__stl_assert(expr) \\\r\n    if (!(expr)) { fprintf(stderr, \\\"%s:%d STL assertion failure: %s\\n\\\", \\\r\n             __FILE__, __LINE__, # expr); abort(); }\"<<endl;\r\n#else\r\n    cout<<\"__stl_assert(expr)\"<<endl;\r\n#endif\r\n\r\n\r\n}\r\n\r\n\r\n\r\nint main(void)\r\n{\r\n    test();\r\n\r\n    return 0;\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config10.cpp",
    "content": "//template ɷǰһtemplate趨Ĭֵ  \r\n#include <iostream>  \r\n#include <cstddef>  \r\n  \r\nusing namespace std;  \r\n  \r\nclass alloc  \r\n{  \r\n};  \r\n  \r\ntemplate <class T, class Alloc = alloc, size_t BufSiz = 0>  \r\nclass deque  \r\n{  \r\npublic:  \r\n  deque()  \r\n  {  \r\n    cout<<\"deque\"<<endl;  \r\n  }  \r\n};  \r\n  \r\ntemplate <class T, class Sequence = deque<T> >  \r\nclass stack  \r\n{  \r\npublic:  \r\n  stack()  \r\n  {  \r\n    cout<<\"stack\"<<endl;  \r\n  }  \r\n  \r\nprivate:  \r\n  Sequence c;  \r\n};  \r\n  \r\nint main()  \r\n{  \r\n  stack<int> x;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1config11.cpp",
    "content": "//class template ɷӵnon-type template  \r\n#include <iostream>  \r\n#include <cstddef>  \r\nusing namespace std;  \r\n  \r\nclass alloc  \r\n{  \r\n};  \r\n  \r\ninline size_t __deque_buf_size(size_t n, size_t sz)  \r\n{  \r\n  return n != 0 ? n : (sz < 512 ? size_t(512/sz) : size_t(1));  \r\n}  \r\n  \r\ntemplate <class T, class Ref, class Ptr, size_t BufSiz>  \r\nstruct __deque_iterator  \r\n{  \r\n  typedef __deque_iterator<T, T&, T*, BufSiz> iterator;  \r\n  typedef __deque_iterator<T, const T&, const T*, BufSiz> const_iterator;  \r\n  static size_t buffer_size()  \r\n  {  \r\n    return __deque_buf_size(BufSiz, sizeof(T));  \r\n  }  \r\n};  \r\n  \r\ntemplate <class T, class Alloc = alloc, size_t BufSiz = 0>  \r\nclass deque  \r\n{  \r\npublic:  \r\n  typedef __deque_iterator<T, T&, T*, BufSiz> iterator;  \r\n};  \r\n  \r\nint main()  \r\n{  \r\n  cout<<deque<int>::iterator::buffer_size()<<endl;  \r\n  cout<<deque<int,alloc,64>::iterator::buffer_size()<<endl;  \r\n  return 1;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1config2.cpp",
    "content": "\r\n#include <iostream>\r\n#include <vector>\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n# if defined(__sgi)\r\n cout << \"__sig\" << endl;\r\n# endif\r\n\r\n# if defined(__GNUC__)\r\n cout << \"_GNUC_\" << endl;\r\n //cout << _GNUC_ << ' ' << _GNUC_MINOR_ << endl;\r\n# endif\r\n\r\n# ifdef __STL_NO_DRAND48\r\n cout << \"__STL_NO_DRAND48 defined\" << endl;\r\n# else\r\n cout << \"__STL_NO_DRAND48 undefined\"  << endl;\r\n# endif\r\n\r\n# ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\r\n cout << \"__STL_STATIC_TEMPLATE_MEMBER_BUG defined\" << endl;\r\n# else\r\n cout << \"__STL_STATIC_TEMPLATE_MEMBER_BUG undefined\"  << endl;\r\n# endif\r\n\r\n# ifdef __STL_WIN32THREADS\r\n cout << \"__STL_WIN32THREADS defined\" << endl;\r\n# else\r\n cout << \"__STL_WIN32THREADSk undefined\"  << endl;\r\n# endif\r\n\r\n# ifdef __STL_ASSERTIONS\r\n cout << \"__STL_ASSERTIONS defined\" << endl;\r\n# else\r\n cout << \"__STL_ASSERTIONS undefined\"  << endl;\r\n# endif\r\n\r\n# ifdef __STL_NEED_BOOL\r\n cout << \"__STL_NEED_BOOL defined\" << endl;\r\n# else\r\n cout << \"__STL_NEED_BOOL undefined\"  << endl;\r\n# endif\r\n\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1config3.cpp",
    "content": "//class templateӵstatic data members.  \r\n#include <iostream>  \r\nusing namespace std;  \r\n  \r\ntemplate <typename T>  \r\nclass testclass  \r\n{  \r\npublic:  \r\n  static int _data;  \r\n};  \r\n  \r\ntemplate<> int testclass<int>::_data = 1;  \r\ntemplate<> int testclass<char>::_data = 2;  \r\n  \r\nint main()  \r\n{  \r\n  cout<<testclass<int>::_data<<endl;  \r\n  cout<<testclass<char>::_data<<endl;  \r\n  \r\n  testclass<int> obji1, obji2;  \r\n  testclass<char> objc1, objc2;  \r\n  \r\n  cout<<obji1._data<<endl;  \r\n  cout<<obji2._data<<endl;  \r\n  cout<<objc1._data<<endl;  \r\n  cout<<objc2._data<<endl;  \r\n  \r\n  obji1._data = 3;  \r\n  objc2._data = 4;  \r\n    \r\n  cout<<obji1._data<<endl;  \r\n  cout<<obji2._data<<endl;  \r\n  cout<<objc1._data<<endl;  \r\n  cout<<objc2._data<<endl;  \r\n  \r\n  return 1;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1config5.cpp",
    "content": "//class template ָconst֧  \r\n#include <iostream>  \r\nusing namespace std;  \r\n  \r\ntemplate <class I, class O>  \r\nstruct testClass  \r\n{  \r\n  testClass()  \r\n  {  \r\n    cout<<\"I, O\"<<endl;  \r\n  }  \r\n};  \r\n  \r\ntemplate <class T>  \r\nstruct testClass<T*, T*>  \r\n{  \r\n  testClass()  \r\n  {  \r\n    cout<<\"T*,T*\"<<endl;  \r\n  }  \r\n};  \r\n  \r\ntemplate <class T>  \r\nstruct testClass<const T*, T*>  \r\n{  \r\n  testClass()  \r\n  {  \r\n    cout<<\"const T*, T*\"<<endl;  \r\n  }  \r\n};  \r\n  \r\nint main()  \r\n{  \r\n  testClass<int, char> obj1;  \r\n  testClass<int*, int*> obj2;  \r\n  testClass<const int*, int*> obj3;  \r\n  return 1;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1config8.cpp",
    "content": "//class template ֮ڿɷtemplate (members)  \r\n#include <iostream>  \r\nusing namespace std;  \r\n  \r\nclass alloc  \r\n{  \r\n};  \r\n  \r\ntemplate <class T, class Alloc = alloc>  \r\nclass vector  \r\n{  \r\npublic:  \r\n  typedef T value_type;  \r\n  typedef value_type* iterator;  \r\n  \r\n  template <class I>  \r\n  void insert(iterator position, I first, I last)  \r\n  {  \r\n    cout<<\"insert()\"<<endl;  \r\n  }  \r\n};  \r\n  \r\nint main()  \r\n{  \r\n  int ia[5] = {0,1,2,3,4};  \r\n    \r\n  cout<<*ia<<endl;  \r\n  cout<<*(ia+4)<<endl;  \r\n    \r\n  vector<int> x;  \r\n  vector<int>::iterator ite = NULL;  \r\n  x.insert(ite, ia, ia+4);  \r\n  return 1;  \r\n}  "
  },
  {
    "path": "stl-gatieme/1-stl_config/1functor.cpp",
    "content": "//STL采用仿函数排序\r\n#include <iostream>\r\nusing namespace std;\r\n\r\n\r\n//  由于将operator()重载了, 因此plus成了一个仿函数\r\ntemplate <class T>\r\nstruct myplus\r\n{\r\n    T operator()(const T& x, const T& y) const\r\n    {\r\n        return x + y;\r\n    }\r\n};\r\n\r\n//  由于将operator()重载了, 因此minus成了一个仿函数\r\n\r\ntemplate <class T>\r\nstruct myminus\r\n{\r\n    T operator()(const T& x, const T& y) const\r\n    {\r\n        return x - y;\r\n    }\r\n};\r\n\r\nint main()\r\n{\r\n    //  创建仿函数对象\r\n    myplus<int> plusobj;\r\n    myminus<int> minusobj;\r\n\r\n    cout<<plusobj(3,5)<<endl;\r\n    cout<<minusobj(3,5)<<endl;\r\n\r\n    cout<<myplus<int>()(43,50)<<endl;\r\n    cout<<myminus<int>()(43,50)<<endl;\r\n\r\n    return 1;\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/1qsort.cpp",
    "content": "#include <cstdlib>\r\n#include <iostream>\r\n\r\n\r\nusing namespace std;\r\n\r\n\r\nint fcmp(const void *elem1, const void *elem2);\r\n\r\n\r\nint main( )\r\n{\r\n    int ia[] = {32, 92, 67, 58, 10, 4, 25, 52, 59, 54};\r\n\r\n    for(int i = 0; i < 10; i++)\r\n    {\r\n        cout <<ia[i] <<\" \";\r\n    }\r\n    cout <<endl;\r\n\r\n    qsort(ia, sizeof(ia)/sizeof(ia[0]), sizeof(ia[0]), fcmp);\r\n\r\n\r\n    for(int i = 0; i < 10; i++)\r\n    {\r\n        cout <<ia[i] <<\" \";\r\n    }\r\n    cout <<endl;\r\n\r\n}\r\n\r\nint fcmp(const void *elem1, const void *elem2)\r\n{\r\n    const int *i1 = (const int *)elem1;\r\n    const int *i2 = (const int *)elem2;\r\n\r\n    return (*i1 - *i2);\r\n}\r\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/Makefile",
    "content": "ROOT=..\nPLATFORM=$(shell $(ROOT)/systype.sh)\ninclude $(ROOT)/Make.defines.$(PLATFORM)\n\ntarget=1config 1config2 1config3 1config5 1config8  1config10 1config11 \t\\\n\t   1config-inclass-init  1config-template-exp-special  1functor \t\t\t\t\t\t\\\n\t   1config-operator-overloading  1config-temporary-object   1qsort \n\nall:$(target)\n\t\n\n\n1config:1config.o\n\t$(CXX) $^ -o $@ \n\t@echo \"CXX编译器配置支持...\"\n\n1config2:1config2.o\n\t$(CXX) $^ -o $@ \n\t\n1config5:1config5.o\n\t$(CXX) $^ -o $@ \n\n1config8:1config8.o\n\t$(CXX) $^ -o $@ \n\n1config10:1config10.o\n\t$(CXX) $^ -o $@ \n\n1config11:1config11.o\n\t$(CXX) $^ -o $@ \n\n\n1config-inclass-init:1config-inclass-init.o\n\t$(CXX) $^ -o $@ \n\t\n1config-template-exp-special : 1config-template-exp-special.o  \n\t$(CXX) $^ -o $@ \n\n1functor : 1functor.o\n\t$(CXX) $^ -o $@ \n\n1config-operator-overloading : 1config-operator-overloading.o\n\t$(CXX) $^ -o $@ \n\n1config-temporary-object : 1config-temporary-object.o\n\t$(CXX) $^ -o $@ \n\n1qsort : 1qsort.o \n\t$(CXX) $^ -o $@ \n\n\n%.o:%.cpp\n\t$(CXX) -c $^ -o $@ \n      \nclean :\n\trm $(target)\n"
  },
  {
    "path": "stl-gatieme/1-stl_config/stl_config.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __STL_CONFIG_H\n# define __STL_CONFIG_H\n\n// Flags:\n// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin\n//   type.\n// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type.\n// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48 \n//   function.\n// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle\n//   static members of template classes.\n// * __STL_STATIC_CONST_INIT_BUG: defined if the compiler can't handle a\n//   constant-initializer in the declaration of a static const data member\n//   of integer type.  (See section 9.4.2, paragraph 4, of the C++ standard.)\n// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports\n//   partial specialization of template classes.\n// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler \n//   supports partial specialization syntax for full specialization of\n//   class templates.  (Even if it doesn't actually support partial \n//   specialization itself.)\n// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports\n//   partial ordering of function templates.  (a.k.a partial specialization\n//   of function templates.)\n// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template\n//   member functions of classes.\n// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports \n//   nested classes that are member templates of other classes.\n// * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized\n//   friend declarations.\n// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler \n//   supports calling a function template by providing its template\n//   arguments explicitly.\n// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable\n//   to handle default template parameters that depend on previous template\n//   parameters.\n// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with\n//   function template argument deduction for non-type template parameters.\n// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable\n//   to support the -> operator for iterators.\n// * __STL_DEFAULT_CONSTRUCTOR_BUG: defined if T() does not work properly\n//   when T is a builtin type.\n// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation\n//   mode) supports exceptions.\n// * __STL_USE_NAMESPACES: defined if the compiler has the necessary\n//   support for namespaces.\n// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a\n//   standard-conforming header <exception>.\n// * __STL_NO_BAD_ALLOC: defined if the compiler does not have a <new>\n//   header, or if <new> does not contain a bad_alloc class.  If a bad_alloc\n//   class exists, it is assumed to be in namespace std.\n// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX\n//   system in multithreaded mode, using native SGI threads instead of \n//   pthreads.\n// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32\n//   compiler in multithreaded mode.\n// * __STL_PTHREADS: defined if we should use portable pthreads\n//   synchronization.\n// * __STL_UITHREADS: defined if we should use UI / solaris / UnixWare threads\n//   synchronization.  UIthreads are similar to pthreads, but are based \n//   on an earlier version of the Posix threads standard.\n// * __STL_LONG_LONG if the compiler has long long and unsigned long long\n//   types.  (They're not in the C++ standard, but they are expected to be \n//   included in the forthcoming C9X standard.)\n// * __STL_THREADS is defined if thread safety is needed.\n// * __STL_VOLATILE is defined to be \"volatile\" if threads are being\n//   used, and the empty string otherwise.\n// * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error\n//   checking to make sure that user-defined template arguments satisfy\n//   all of the appropriate requirements.  This may result in more\n//   comprehensible error messages.  It incurs no runtime overhead.  This \n//   feature requires member templates and partial specialization.\n// * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle \"using\"\n//   clauses inside of class definitions.\n// * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend\n//   declaractions where the friend is a template class.\n// * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not\n//   support the use of a function pointer type as the argument\n//   for a template.\n// * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template\n//   keyword in a few new places (14.2.4).  This flag is set for\n//   compilers that support (and require) this usage.\n\n\n// User-settable macros that control compilation:\n// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older\n//   SGI-style allocators, instead of standard-conforming allocators,\n//   even if the compiler supports all of the language features needed\n//   for standard-conforming allocators.\n// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace\n//   std, even if the compiler supports namespaces.\n// * __STL_NO_RELOPS_NAMESPACE: if defined, don't put the relational\n//   operator templates (>, <=. >=, !=) in namespace std::rel_ops, even\n//   if the compiler supports namespaces and partial ordering of\n//   function templates.\n// * __STL_ASSERTIONS: if defined, then enable runtime checking through the\n//   __stl_assert macro.\n// * _PTHREADS: if defined, use Posix threads for multithreading support.\n// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading \n//   support\n// * _NOTHREADS: if defined, don't use any multithreading support.  \n// * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that\n//   we get from __STL_USE_CONCEPT_CHECKS.\n// * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new,\n//   standard-conforming iostreams (e.g. the <iosfwd> header).  If not\n//   defined, the STL will use old cfront-style iostreams (e.g. the\n//   <iostream.h> header).\n\n// Other macros defined by this file:\n\n// * bool, true, and false, if __STL_NO_BOOL is defined.\n// * typename, as a null macro if it's not already a keyword.\n// * explicit, as a null macro if it's not already a keyword.\n// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)\n// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.)\n// * __stl_assert, either as a test or as a null macro, depending on\n//   whether or not __STL_ASSERTIONS is defined.\n\n\n\n//  ļܱ:  \n//  (1)  ûжbool, true, false  \n//  (2)  ֧drand48()__STL_NO_DRAND48  \n//       ע: drand48˫ȵα, Ϊ48bit, drand48  \n//  (3)  ֧static members of template classes(ģྲ̬Ա),  \n//       __STL_STATIC_TEMPLATE_MEMBER_BUG  \n//  (4)  ֧'typename'ؼ, 'typename'Ϊ(null macro)  \n//  (5)  ֧partial specialization of class templates(ģƫػ),  \n//       __STL_CLASS_PARTIAL_SPECIALIZATION  \n//       ο: http://msdn.microsoft.com/en-us/library/9w7t3kf1(v=VS.71).aspx  \n//  (6)  ֧partial ordering of function templates(ģ庯ػȼ),  \n//       __STL_FUNCTION_TMPL_PARTIAL_ORDER  \n//       ο: http://msdn.microsoft.com/zh-cn/library/zaycz069.aspx  \n//  (7)  ֧calling a function template by providing its template  \n//       arguments explicitly(ʽָģ庯ģ)  \n//       __STL_EXPLICIT_FUNCTION_TMPL_ARGS  \n//  (8)  ֧template members of classes(ģԱ),  \n//       __STL_MEMBER_TEMPLATES  \n//  (9)  ֧'explicit'ؼ, 'explicit'Ϊ(null macro)  \n//  (10) ܸǰһģ趨Ĭģ,  \n//       __STL_LIMITED_DEFAULT_TEMPLATES  \n//  (11) ģ庯non-typeģƶ,  \n//       __STL_NON_TYPE_TMPL_PARAM_BUG  \n//  (12) ֵ֧ʹ'->',  \n//       __SGI_STL_NO_ARROW_OPERATOR  \n//  (13) (ڵǰģʽ)֧쳣,  \n//       __STL_USE_EXCEPTIONS  \n//  (14) ǽSTLŽռ,  \n//       __STL_USE_NAMESPACES  \n//  (15) STLSGIıϱ, ûûѡpthreadsno threads,  \n//       Ĭʹ__STL_SGI_THREADS  \n//       ע: POSIX thread Ϊpthread, Posix߳һPOSIX׼߳.  \n//  (16) STLWin32ƽ̨ıʹö߳ģʽ,  \n//       __STL_WIN32THREADS  \n//  (17) ʵĶռصĺ(__STD, __STL_BEGIN_NAMESPACE, )  \n//  (18) ʵĶ쳣صĺ(__STL_TRY, __STL_UNWIND, )  \n//  (19) Ƿ__STL_ASSERTIONS, __stl_assertΪԻ߿(null macro)  \n\n# if defined(_PTHREADS) && !defined(_NOTHREADS)\n#     define __STL_PTHREADS\n# endif\n\n# if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)\n#     define __STL_UITHREADS\n# endif\n\n\n//  ṩSTLҪһЩ,__STL_NEED_XXX  \n//  ʹ SGI STL, ǲʹGNU C++\n# if defined(__sgi) && !defined(__GNUC__)\n#   include <standards.h>\n#   if !defined(_BOOL)\n#     define __STL_NO_BOOL\n#   endif\n#   if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32\n#     define __STL_STATIC_CONST_INIT_BUG\n#   endif\n#   if defined(_WCHAR_T_IS_KEYWORD)\n#     define __STL_HAS_WCHAR_T \n#   endif\n#   if !defined(_TYPENAME_IS_KEYWORD)\n#     define __STL_NEED_TYPENAME\n#   endif\n#   ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   endif\n#   if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#   endif\n#   ifdef _MEMBER_TEMPLATES\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_TEMPLATE_FRIENDS\n#     define __STL_MEMBER_TEMPLATE_CLASSES\n#   endif\n#   if defined(_MEMBER_TEMPLATE_KEYWORD)\n#     define __STL_MEMBER_TEMPLATE_KEYWORD\n#   endif\n#   if defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#   endif\n#   if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32\n#     define __STL_MEMBER_TEMPLATE_KEYWORD\n#   endif\n#   if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32)\n#     define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   endif\n#   if !defined(_EXPLICIT_IS_KEYWORD)\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)\n#     define __STL_HAS_NAMESPACES\n#   endif \n#   if (_COMPILER_VERSION < 721) || \\\n    !defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES)\n#     define __STL_NO_EXCEPTION_HEADER\n#   endif\n#   if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \\\n      !defined(_NAMESPACES)\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)\n#     define __STL_SGI_THREADS\n#   endif\n#   if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI\n#     define __STL_LONG_LONG\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_USE_NEW_IOSTREAMS\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __STL_CAN_THROW_RANGE_ERRORS\n#   endif\n#   if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)\n#     define __SGI_STL_USE_AUTO_PTR_CONVERSIONS\n#   endif\n# endif\n\n\n/*\n * Jochen Schlick '1999  - added new #defines (__STL)_UITHREADS (for \n *                         providing SCO / Solaris / UI thread support)\n *                       - added the necessary defines for the SCO UDK 7 \n *                         compiler (and its template friend behavior)\n *                       - all UDK7 specific STL changes are based on the \n *                         macro __USLC__ being defined\n */\n// SCO UDK 7 compiler (UnixWare 7x, OSR 5, UnixWare 2x)\n# if defined(__USLC__)\n#     define __STL_HAS_WCHAR_T \n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_MEMBER_TEMPLATE_CLASSES\n#     define __STL_USE_EXCEPTIONS\n#     define __STL_HAS_NAMESPACES\n#     define __STL_USE_NAMESPACES\n#     define __STL_LONG_LONG\n#     if defined(_REENTRANT)\n#           define _UITHREADS     /* if      UnixWare < 7.0.1 */\n#           define __STL_UITHREADS\n//   use the following defines instead of the UI threads defines when\n//   you want to use POSIX threads\n//#         define _PTHREADS      /* only if UnixWare >=7.0.1 */\n//#         define __STL_PTHREADS\n#     endif\n# endif\n\n\n\n# ifdef __GNUC__\n#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 7\n#     define __STL_STATIC_TEMPLATE_MEMBER_BUG\n#   endif\n#   if __GNUC__ < 2 \n#     define __STL_NEED_TYPENAME\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 8\n#     define __STL_NO_EXCEPTION_HEADER\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if __GNUC__ == 2 && __GNUC_MINOR__ >= 8\n\t  //    GNUC 2.8+ ĳ\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_CAN_THROW_RANGE_ERRORS\n\n      //    g++ 2.8.1 supports member template functions, but not member\n      //    template nested classes.\n#     if __GNUC_MINOR__ >= 9\n#       define __STL_MEMBER_TEMPLATE_CLASSES\n#       define __STL_TEMPLATE_FRIENDS\n#       define __SGI_STL_USE_AUTO_PTR_CONVERSIONS\n#       define __STL_HAS_NAMESPACES\n//#       define __STL_USE_NEW_IOSTREAMS\n#     endif\n#   endif\n#   define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _REENTRANT\n#     define __STL_PTHREADS\n#   endif\n    /* glibc pre 2.0 is very buggy. We have to disable thread for it. \n       It should be upgraded to glibc 2.0 or later. */  \n#   if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)\n#     define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE\n#   endif\n# endif\n\n// Sun C++ compiler  \n# if defined(__SUNPRO_CC) \n#   define __STL_NO_BOOL\n#   define __STL_NEED_TYPENAME\n#   define __STL_NEED_EXPLICIT\n#   define __STL_USE_EXCEPTIONS\n#   ifdef _REENTRANT\n#     define __STL_PTHREADS\n#   endif\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#   define __STL_NO_EXCEPTION_HEADER\n#   define __STL_NO_BAD_ALLOC\n# endif\n\n# if defined(__COMO__)\n#   define __STL_MEMBER_TEMPLATES\n#   define __STL_MEMBER_TEMPLATE_CLASSES\n#   define __STL_TEMPLATE_FRIENDS\n#   define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_USE_EXCEPTIONS\n#   define __STL_HAS_NAMESPACES\n# endif\n\n// Intel compiler, which uses the EDG front end.\n# if defined(__ICL)\n#   define __STL_LONG_LONG \n#   define __STL_MEMBER_TEMPLATES\n#   define __STL_MEMBER_TEMPLATE_CLASSES\n#   define __STL_TEMPLATE_FRIENDS\n#   define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#   define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_NO_DRAND48\n#   define __STL_HAS_NAMESPACES\n#   define __STL_USE_EXCEPTIONS\n#   define __STL_MEMBER_TEMPLATE_KEYWORD\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n// Mingw32, egcs compiler using the Microsoft C runtime\n# if defined(__MINGW32__)\n#   define __STL_NO_DRAND48\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n// Cygwin32, egcs compiler on MS Windows\n# if defined(__CYGWIN__)\n#   define __STL_NO_DRAND48\n# endif\n\n\n\n// Microsoft compiler.\n// _MSC_VER ΢İ汾  \n# if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__)\n#   define __STL_NO_DRAND48\n#   define __STL_STATIC_CONST_INIT_BUG\n#   define __STL_NEED_TYPENAME\n#   define __STL_NO_USING_CLAUSE_IN_CLASS\n#   define __STL_NO_FRIEND_TEMPLATE_CLASS\n#   if _MSC_VER < 1100  /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */\n#     define __STL_NEED_EXPLICIT\n#     define __STL_NO_BOOL\n#     define __STL_NO_BAD_ALLOC\n#   endif\n#   if _MSC_VER > 1000\n#     include <yvals.h>\n#     define __STL_DONT_USE_BOOL_TYPEDEF\n#   endif\n#   define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n#   if _MSC_VER >= 1200\n#     define __STL_PARTIAL_SPECIALIZATION_SYNTAX\n#     define __STL_HAS_NAMESPACES\n#     define __STL_CAN_THROW_RANGE_ERRORS\n#     define NOMINMAX\n#     undef min\n#     undef max\n// disable warning 'initializers put in unrecognized initialization area'\n#     pragma warning ( disable : 4075 )\n// disable warning 'empty controlled statement found'\n#     pragma warning ( disable : 4390 )\n// disable warning 'debug symbol greater than 255 chars'\n#     pragma warning ( disable : 4786 )\n#   endif\n#   if _MSC_VER < 1100\n#     define __STL_NO_EXCEPTION_HEADER\n#     define __STL_NO_BAD_ALLOC\n#   endif\n    // Because of a Microsoft front end bug, we must not provide a\n    // namespace qualifier when declaring a friend function.\n#   define __STD_QUALIFIER\n# endif\n\n# if defined(__BORLANDC__)\n#     define __STL_NO_BAD_ALLOC\n#     define __STL_NO_DRAND48\n#     define __STL_DEFAULT_CONSTRUCTOR_BUG\n#   if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#     define __STL_MEMBER_TEMPLATES\n#     define __STL_TEMPLATE_FRIENDS\n#   else\n#     define __STL_NEED_TYPENAME\n#     define __STL_LIMITED_DEFAULT_TEMPLATES\n#     define __SGI_STL_NO_ARROW_OPERATOR\n#     define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   endif\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef __MT__\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF)\n    typedef int bool;\n#   define true 1\n#   define false 0\n# endif\n\n# ifdef __STL_NEED_TYPENAME\n#   define typename\n# endif\n\n# ifdef __STL_LIMITED_DEFAULT_TEMPLATES\n#   define __STL_DEPENDENT_DEFAULT_TMPL(_Tp)\n# else\n#   define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp\n# endif\n\n# ifdef __STL_MEMBER_TEMPLATE_KEYWORD\n#   define __STL_TEMPLATE template\n# else\n#   define __STL_TEMPLATE\n# endif\n\n# ifdef __STL_NEED_EXPLICIT\n#   define explicit\n# endif\n\n# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#   define __STL_NULL_TMPL_ARGS <>\n# else\n#   define __STL_NULL_TMPL_ARGS\n# endif\n\n# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \\\n     || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX)\n#   define __STL_TEMPLATE_NULL template<>\n# else\n#   define __STL_TEMPLATE_NULL\n# endif\n\n// Use standard-conforming allocators if we have the necessary language\n// features.  __STL_USE_SGI_ALLOCATORS is a hook so that users can \n// disable new-style allocators, and continue to use the same kind of\n// allocators as before, without having to edit library headers.\n# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \\\n     defined(__STL_MEMBER_TEMPLATES) && \\\n     defined(__STL_MEMBER_TEMPLATE_CLASSES) && \\\n    !defined(__STL_NO_BOOL) && \\\n    !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \\\n    !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \\\n    !defined(__STL_USE_SGI_ALLOCATORS) \n#   define __STL_USE_STD_ALLOCATORS\n# endif\n\n# ifndef __STL_DEFAULT_ALLOCATOR\n#   ifdef __STL_USE_STD_ALLOCATORS\n#     define __STL_DEFAULT_ALLOCATOR(T) allocator< T >\n#   else\n#     define __STL_DEFAULT_ALLOCATOR(T) alloc\n#   endif\n# endif\n\n// __STL_NO_NAMESPACES is a hook so that users can disable namespaces\n// without having to edit library headers.  __STL_NO_RELOPS_NAMESPACE is\n// a hook so that users can disable the std::rel_ops namespace, keeping \n// the relational operator template in namespace std, without having to \n// edit library headers.\n# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES)\n#   define __STL_USE_NAMESPACES\n#   define __STD std\n#   define __STL_BEGIN_NAMESPACE namespace std {\n#   define __STL_END_NAMESPACE }\n#   if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \\\n       !defined(__STL_NO_RELOPS_NAMESPACE)\n#     define __STL_USE_NAMESPACE_FOR_RELOPS\n#     define __STL_BEGIN_RELOPS_NAMESPACE namespace std { namespace rel_ops {\n#     define __STL_END_RELOPS_NAMESPACE } }\n#     define __STD_RELOPS std::rel_ops\n#   else /* Use std::rel_ops namespace */\n#     define __STL_USE_NAMESPACE_FOR_RELOPS\n#     define __STL_BEGIN_RELOPS_NAMESPACE namespace std {\n#     define __STL_END_RELOPS_NAMESPACE }\n#     define __STD_RELOPS std\n#   endif /* Use std::rel_ops namespace */\n# else\n#   define __STD \n#   define __STL_BEGIN_NAMESPACE \n#   define __STL_END_NAMESPACE \n#   undef  __STL_USE_NAMESPACE_FOR_RELOPS\n#   define __STL_BEGIN_RELOPS_NAMESPACE \n#   define __STL_END_RELOPS_NAMESPACE \n#   define __STD_RELOPS \n#   undef  __STL_USE_NAMESPACES\n# endif\n\n// Some versions of the EDG front end sometimes require an explicit\n// namespace spec where they shouldn't.  This macro facilitates that.\n// If the bug becomes irrelevant, then all uses of __STD_QUALIFIER\n// should be removed.  The 7.3 beta SGI compiler has this bug, but the\n// MR version is not expected to have it.\n\n# if defined(__STL_USE_NAMESPACES) && !defined(__STD_QUALIFIER)\n#   define __STD_QUALIFIER std::\n# else\n#   define __STD_QUALIFIER\n# endif\n\n# ifdef __STL_USE_EXCEPTIONS\n#   define __STL_TRY try\n#   define __STL_CATCH_ALL catch(...)\n#   define __STL_THROW(x) throw x\n#   define __STL_RETHROW throw\n#   define __STL_NOTHROW throw()\n#   define __STL_UNWIND(action) catch(...) { action; throw; }\n# else\n#   define __STL_TRY \n#   define __STL_CATCH_ALL if (false)\n#   define __STL_THROW(x) \n#   define __STL_RETHROW \n#   define __STL_NOTHROW \n#   define __STL_UNWIND(action) \n# endif\n\n#ifdef __STL_ASSERTIONS\n# include <stdio.h>\n# define __stl_assert(expr) \\\n    if (!(expr)) { fprintf(stderr, \"%s:%d STL assertion failure: %s\\n\", \\\n\t\t\t  __FILE__, __LINE__, # expr); abort(); }\n#else\n# define __stl_assert(expr)\n#endif\n\n#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \\\n    || defined(__STL_PTHREADS)  || defined(__STL_UITHREADS)\n#   define __STL_THREADS\n#   define __STL_VOLATILE volatile\n#else\n#   define __STL_VOLATILE\n#endif\n\n#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \\\n    && defined(__STL_MEMBER_TEMPLATES) \\\n    && !defined(_STL_NO_CONCEPT_CHECKS)\n#  define __STL_USE_CONCEPT_CHECKS\n#endif\n\n\n#endif /* __STL_CONFIG_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "stl-gatieme/2-defalloc/2jjalloc.h",
    "content": "   //file: 2jjalloc.h\n\n#ifndef _JJALLOC_\n\n#define _JJALLOC_\n\n#include <new> \t\t\t//  for placement new \n#include <cstddef>    \t//  for ptrdiff_t,size_t\n#include <cstdlib.h>\t//  for exit()\n#include <climits>\t\t//\tfor UINT_MAX\n#include <iostream>\t\t//  for cerr\n\nnamespace JJ\n\n{\n\ntemplate <class T>\ninline T* _allocate(ptrdiff_t  size,T*)\n{\n    set_new_handle(0);\t//newʧʱиúĲ\n\n    T* tmp = (T*)(::operator new((size_t)(size*sizeof(T))));\n\n\tif (tmp == 0)\n\t{\n        exit(1);\n    }\n\n    return tmp;\n\n}\n\n   \n\ntemplate <class T>\ninline void _deallocate(T* buffer)\n{\n    ::operator delete(buffer);\n}\n\n\n\ntemplate <class T1,class T2>\ninline void _construct(T1* p, const T2& value)\n{\n    new(p) T1(value);\n}\n\ntemplate <class T>\ninline void _destroy(T* ptr)\n{\n    ptr->!T();\n}\n\n\n\ntemplate <class T>\nclass allocator\n\n{\n\n  public:\n\n        typedef T             value_type;\n\n        typedef T*             pointer;\n\n        typedef const T*  const_pointer;\n\n        typedef T&          reference;\n\n        typedef const T& const_reference;\n\n        typedef size_t        size_type;\n\n        typedef ptrdiff_t    difference_type;\n\n\n\n        template <class U> struct rebind\n\n           {typedef allocator<U> other;}\n\n       \n\n        pointer allocate(size_type n, const void* hint=0)\n\n    {\n\n        return _allocate((difference_type)n,(pointer)0);\n\n    }\n\n    void deallocate(pointer p,size_type n) {_deallocate(p);}\n\n    void construct(pointer p,const t& value)\n\n    {\n\n        _construct(p,value);\n\n    }\n\nvoid destroy(pointer p) {_destroy(p);}\n\npointer address(reference x) {return (pointer)&x;}\n\n   const_pointer const_address(const_reference x) {return (const_pointer)&x;}\n\nsize_type max_size() const\n\n    {return size_type(UINT_MAX/sizeof(T));}\n\n}\n\n}"
  },
  {
    "path": "stl-gatieme/2-defalloc/Makefile",
    "content": "ROOT=../../..\nPLATFORM=$(shell $(ROOT)/systype.sh)\ninclude $(ROOT)/Make.defines.$(PLATFORM)\n\ntarget=constructor copyconstructor-onrvo  copyconstructor-rvo\n\n\n\nall:$(target)\n\nconstructor :   constructor\n\t$(CXX) $^ -o $@ \n\t#echo \"单参数构造函数...\"\n\ncopyconstructor-nonrvo: copyconstructor.o\n\t$(CXX) $^ -o $@ \n\techo \"拷贝构造函数的调用时机-非优化版...\"\n\ncopyconstructor-rvo: copyconstructor.o\n\t$(CXX) $^ -o $@ \n\techo \"拷贝构造函数的调用时机-RVO优化版...\"\n\n      \ncopyconstructexplicit : copyconstructexplicit.o\n\t$(CXX) -c $^ -o $@  \n       \techo \"explicit限制下的拷贝构造函数...\"\n\nclean :\n\trm $(target)\n"
  },
  {
    "path": "stl-gatieme/2-defalloc/README.md",
    "content": "[ ռSTLԴ](http://blog.csdn.net/chinajane163/article/details/50148073)"
  },
  {
    "path": "stl-gatieme/2-defalloc/defalloc.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n// Inclusion of this file is DEPRECATED.  This is the original HP\n// default allocator.  It is provided only for backward compatibility.\n// This file WILL BE REMOVED in a future release.\n//\n// DO NOT USE THIS FILE unless you have an old container implementation\n// that requires an allocator with the HP-style interface.  \n//\n// Standard-conforming allocators have a very different interface.  The\n// standard default allocator is declared in the header <memory>.\n\n\n#ifndef DEFALLOC_H\n#define DEFALLOC_H\n\n\n\n// ļṩԭʼHPĬallocator, Ϊ  \n//  \n// Ҫʹļ,ʹһҪHP-style allocatorľ  \n// SGI STLʹһͬallocatorӿ  \n// SGI-styleallocatorԶͽв, ʹvoid *ָ  \n\n\n\n#include <new.h>\n#include <stddef.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <iostream.h>\n#include <algobase.h>\n\n\n// ڴʧ, ֱ˳\ntemplate <class T>\ninline T* allocate(ptrdiff_t size, T*) {\n    set_new_handler(0);\n    T* tmp = (T*)(::operator new((size_t)(size * sizeof(T))));\n    if (tmp == 0) {\n\tcerr << \"out of memory\" << endl; \n\texit(1);\n    }\n    return tmp;\n}\n\n\ntemplate <class T>\ninline void deallocate(T* buffer) {\n    ::operator delete(buffer);\n}\n\ntemplate <class T>\nclass allocator {\npublic:\n    typedef T value_type;\n    typedef T* pointer;\n    typedef const T* const_pointer;\n    typedef T& reference;\n    typedef const T& const_reference;\n    typedef size_t size_type;\n    typedef ptrdiff_t difference_type;\n    pointer allocate(size_type n) { \n\treturn ::allocate((difference_type)n, (pointer)0);\n    }\n    void deallocate(pointer p) { ::deallocate(p); }\n    pointer address(reference x) { return (pointer)&x; }\n    const_pointer const_address(const_reference x) { \n\treturn (const_pointer)&x; \n    }\n    size_type init_page_size() { \n\treturn max(size_type(1), size_type(4096/sizeof(T))); \n    }\n    size_type max_size() const { \n\treturn max(size_type(1), size_type(UINT_MAX/sizeof(T))); \n    }\n};\n\nclass allocator<void> {\npublic:\n    typedef void* pointer;\n};\n\n\n\n#endif\n"
  },
  {
    "path": "stl-gatieme/2-defalloc/simple_jjallocator.h",
    "content": "#ifndef SIMPLE_JJALLOC_H  \n#define SIMPLE_JJALLOC_H  \n#include<new>         //for placement new   \n#include<cstddef> //for ptrdiff_t,size_t  \n#include<cstdlib> //for exit()  \n#include<climits> //for UINT_MAX十进制的最大值   \n#include<iostream>    //for cerr  \n  \nnamespace JJ  \n{  \n    /*****************ptrdiff_t与size_t类型*****size_type与difference_type类型********************  \n    ****ptrdiff_t:signed类型，通常用于两指针减法操作的结果，它可以是负数。（因为指针相减有正有负）  \n    ****size_t:unsigned类型，用于指明数组长度，它是非负整数。 \n    ****size_type:unsigned类型，容器中元素长度或下表，vector<int>::size_type i=0; \n    ****difference_type:signed类型，表示迭代器差距，vector<int>::difference_type=iter1-iter2 \n    ****前两者位于标准类库std内，后两者为stl对象所有  \n    *********************************************************************************************/  \n    template<class T>  \n    inline T* _allocate(ptrdiff_t size, T*)  \n    {     \n        std::cout<<\"I'm _allocate in simple_jjalloc!\"<<std::endl;  \n        /**************************new_handler与set_new_handler***********************************  \n        ****new_handler:内存分配失败后，调用的处理函数。 \n        ****set_new_handler:参数是被指定的new_handler函数指针，返回参数也是new_handler是被替换掉的new_handler  \n        *****************************************************************************************/    \n        std::set_new_handler(0);  \n        /****************::*********************************************************************** \n        ****\"::\":全局作用。比如::luo这就是个全局变量，而luo这是个局部变量  \n        ****\"::\":类作用。比如Node::function() \n        ****\"::\":名字空间。比如std::size_t  \n        *****************************************************************************************/    \n        T *tmp=(T*)(::operator new((size_t)(size*sizeof(T))));  \n        if(tmp == 0)//没有前面的std::set_new_handler(0);把内存分配失败后的异常调用函数给替换掉，就执行不到这儿   \n        {  \n            std::cout<<\"failed!\"<<std::endl;  \n            std::cerr<<\"out of memory\"<<std::endl;  \n            exit(1);  \n        }  \n        return tmp;   \n    }  \n      \n    template<class T>  \n    inline void _deallocate(T* buffer)  \n    {  \n        ::operator delete(buffer);  \n    }  \n    /************************************new的三种形态******************************************* \n    ****new operator:就是平常用的new，通常做三件事，1.用operator new分配内存给对象，2.调用构造函数初始化那块内存，3.将地址转给对象指针  \n                     如果仅仅是在堆上建立对象，那么应该使用new operator，它会提供周全的服务   \n    ****operator new:在默认情况下首先会调用分配内存的代码，尝试从堆上得到一段空间，成功就返回，失败就调用new_hander，重复前面过程，直到抛出异常  \n                     如果仅仅是分配内存，那么应该调用operator new，但初始化不在它的职责之内。若对默认的内存分配过程不满意，那就重载它  \n    ****placement new:用来实现定位构造，可以通过它来选择合适的构造函数。  \n                     如果想在一块已获得的内存里建立一个对象，那就改用placement new  \n    ********************************************************************************************/  \n    template<class T1,class T2>  \n    inline void _construct(T1* p,const T2& val)  \n    {  \n        new(p) T1(val);//p为那块内存地址，T1()为指定构造函数；此句为p->T1::T1(val);   \n        std::cout<<\"I'm _construct!\"<<std::endl;  \n    }  \n      \n    template<class T>  \n    inline void _destroy(T* ptr)  \n    {  \n        std::cout<<\"I'm _destroy!\"<<std::endl;  \n        ptr->~T();  \n    }  \n      \n    template<class T>  \n    class mallocator  \n    {  \n        public:  \n            typedef T value_type;//为什么要重新定义，原因在章三  \n            typedef T* pointer;  \n            typedef const T* const_pointer;  \n            typedef T& reference;  \n            typedef const T& const_reference;  \n            typedef size_t size_type;  \n            typedef ptrdiff_t difference_type;  \n          \n          \n            template<class U>  \n            struct rebind//干吗用？见下   \n            {  \n                typedef mallocator<U> mother;  \n            };   \n              \n            pointer allocate(size_type n,const void* hint=0)  \n            {  \n                return _allocate((difference_type)n,(pointer)0);  \n            }  \n              \n            void deallocate(pointer p,size_type n)  \n            {  \n                _deallocate(p);  \n            }  \n              \n            void construct(pointer p,const_reference val)  \n            {  \n                _construct(p,val);  \n            }  \n              \n            void destroy(pointer p)  \n            {  \n                _destroy(p);  \n            }  \n              \n            pointer address(reference x)  \n            {  \n                return (pointer)&x;  \n            }  \n              \n            const pointer const_address(const_reference x)  \n            {  \n                return (const pointer)&x;  \n            }  \n              \n            size_type max_size()const  \n            {  \n                return size_type(UINT_MAX/sizeof(value_type));  \n            }  \n    };  \n}  \n#endif "
  },
  {
    "path": "stl-gatieme/2-defalloc/stl_alloc.h",
    "content": "// Filename:    stl_alloc.h  \n  \n\n  \n// ر˵: SGI STLallocatorҵı뻷²ʹڴ  \n//          ڴزڴͷŲ, ͷʱΪ˳stack unwinding  \n//          ɲϵͳ֤ڴĻ  \n  \n/* \n * Copyright (c) 1996-1997 \n * Silicon Graphics Computer Systems, Inc. \n * \n * Permission to use, copy, modify, distribute and sell this software \n * and its documentation for any purpose is hereby granted without fee, \n * provided that the above copyright notice appear in all copies and \n * that both that copyright notice and this permission notice appear \n * in supporting documentation.  Silicon Graphics makes no \n * representations about the suitability of this software for any \n * purpose.  It is provided \"as is\" without express or implied warranty. \n */  \n  \n/* NOTE: This is an internal header file, included by other STL headers. \n *   You should not attempt to use it directly. \n */  \n  \n#ifndef __SGI_STL_INTERNAL_ALLOC_H  \n#define __SGI_STL_INTERNAL_ALLOC_H  \n  \n#ifdef __SUNPRO_CC  \n#  define __PRIVATE public  \n// SUNprivateƹ, ҪȨ  \n#else  \n#  define __PRIVATE private  \n#endif  \n  \n// Ϊ˱֤, ڲ֧ģྲ̬Ա, ʹmalloc()ڴ  \n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG  \n#  define __USE_MALLOC  \n#endif  \n  \n// ʵһЩ׼node allocator  \n// ǲͬC++׼STLԭʼSTL׼  \n// Щallocatorûзװָͬ  \n// ʵǼٶֻһָ  \n// allocation primitivesڷ䲻ԭʼSTL allocatorĶĶ  \n  \n#if 0  \n#   include <new>  \n#   define __THROW_BAD_ALLOC throw bad_alloc  \n#elif !defined(__THROW_BAD_ALLOC)  \n#   include <iostream.h>  \n#   define __THROW_BAD_ALLOC cerr << \"out of memory\" << endl; exit(1)  \n#endif  \n  \n#ifndef __ALLOC  \n#   define __ALLOC alloc  \n#endif  \n#ifdef __STL_WIN32THREADS  \n#   include <windows.h>  \n#endif  \n  \n#include <stddef.h>  \n#include <stdlib.h>  \n#include <string.h>  \n#include <assert.h>  \n#ifndef __RESTRICT  \n#  define __RESTRICT  \n#endif  \n  \n// ֧߳  \n// __STL_PTHREADS       // GCC  \n// _NOTHREADS           // ֶ֧߳  \n// __STL_SGI_THREADS    // SGIר  \n// __STL_WIN32THREADS   // MSVC  \n#if !defined(__STL_PTHREADS) && !defined(_NOTHREADS) \\  \n && !defined(__STL_SGI_THREADS) && !defined(__STL_WIN32THREADS)  \n#   define _NOTHREADS  \n#endif  \n  \n# ifdef __STL_PTHREADS  \n    // POSIX Threads  \n    // This is dubious, since this is likely to be a high contention  \n    // lock.   Performance may not be adequate.  \n#   include <pthread.h>  \n#   define __NODE_ALLOCATOR_LOCK \\  \n        if (threads) pthread_mutex_lock(&__node_allocator_lock)  \n#   define __NODE_ALLOCATOR_UNLOCK \\  \n        if (threads) pthread_mutex_unlock(&__node_allocator_lock)  \n#   define __NODE_ALLOCATOR_THREADS true  \n#   define __VOLATILE volatile  // Needed at -O3 on SGI  \n# endif  \n# ifdef __STL_WIN32THREADS  \n    // The lock needs to be initialized by constructing an allocator  \n    // objects of the right type.  We do that here explicitly for alloc.  \n#   define __NODE_ALLOCATOR_LOCK \\  \n        EnterCriticalSection(&__node_allocator_lock)  \n#   define __NODE_ALLOCATOR_UNLOCK \\  \n        LeaveCriticalSection(&__node_allocator_lock)  \n#   define __NODE_ALLOCATOR_THREADS true  \n#   define __VOLATILE volatile  // may not be needed  \n# endif /* WIN32THREADS */  \n# ifdef __STL_SGI_THREADS  \n    // This should work without threads, with sproc threads, or with  \n    // pthreads.  It is suboptimal in all cases.  \n    // It is unlikely to even compile on nonSGI machines.  \n  \n    extern \"C\" {  \n      extern int __us_rsthread_malloc;  \n    }  \n    // The above is copied from malloc.h.  Including <malloc.h>  \n    // would be cleaner but fails with certain levels of standard  \n    // conformance.  \n#   define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \\  \n                { __lock(&__node_allocator_lock); }  \n#   define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \\  \n                { __unlock(&__node_allocator_lock); }  \n#   define __NODE_ALLOCATOR_THREADS true  \n#   define __VOLATILE volatile  // Needed at -O3 on SGI  \n# endif  \n# ifdef _NOTHREADS  \n//  Thread-unsafe  \n#   define __NODE_ALLOCATOR_LOCK  \n#   define __NODE_ALLOCATOR_UNLOCK  \n#   define __NODE_ALLOCATOR_THREADS false  \n#   define __VOLATILE  \n# endif  \n  \n__STL_BEGIN_NAMESPACE  \n  \n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)  \n#pragma set woff 1174  \n#endif  \n  \n// Malloc-based allocator.  Typically slower than default alloc below.  \n// Typically thread-safe and more storage efficient.  \n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG  \n# ifdef __DECLARE_GLOBALS_HERE  \n    void (* __malloc_alloc_oom_handler)() = 0;  \n    // g++ 2.7.2 does not handle static template data members.  \n# else  \n    extern void (* __malloc_alloc_oom_handler)();  \n# endif  \n#endif  \n  \n// һ  \ntemplate <int inst>  \nclass __malloc_alloc_template  \n{  \nprivate:  \n    // __malloc_alloc_oom_handlerѭڴ,  \n    // ֱɹ  \n    static void *oom_malloc(size_t);  \n    static void *oom_realloc(void *, size_t);  \n  \n    // ֧ģྲ̬Ա, ʹô, C++set_new_handler()  \n    // ĬֵΪ0, , ڴʧʱֱ__THROW_BAD_ALLOC  \n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG  \n    static void (* __malloc_alloc_oom_handler)();  \n#endif  \n  \npublic:  \n    // ָСڴ(size_t n) ʧ, ѭ׶  \n    // ѭǰҪ֤ȷ__malloc_alloc_oom_handler  \n    static void * allocate(size_t n)  \n    {  \n        void *result = malloc(n);  \n        if (0 == result) result = oom_malloc(n);  \n        return result;  \n    }  \n  \n    // size_tΪ˼operator delele  \n    static void deallocate(void *p, size_t /* n */)  \n    { free(p); }  \n  \n    // ·ڴС, ڶΪ˼operator new  \n    static void * reallocate(void *p, size_t /* old_sz */, size_t new_sz)  \n    {  \n        void * result = realloc(p, new_sz);  \n        if (0 == result) result = oom_realloc(p, new_sz);  \n        return result;  \n    }  \n  \n    // ô, ԭĺָ  \n    // C++׼涨Ľӿ  \n    static void (* set_malloc_handler(void (*f)()))()  \n    {  \n        void (* old)() = __malloc_alloc_oom_handler;  \n        __malloc_alloc_oom_handler = f;  \n        return(old);  \n    }  \n};  \n  \n// malloc_alloc out-of-memory handling  \n  \n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG  \ntemplate <int inst>  \nvoid (* __malloc_alloc_template<inst>::__malloc_alloc_oom_handler)() = 0;  \n#endif  \n  \n// __malloc_alloc_oom_handler, ִд, Ȼѭֱɹ  \n// δ__malloc_alloc_oom_handler, __THROW_BAD_ALLOC  \ntemplate <int inst>  \nvoid * __malloc_alloc_template<inst>::oom_malloc(size_t n)  \n{  \n    void (* my_malloc_handler)();  \n    void *result;  \n  \n    for (;;) {  \n        my_malloc_handler = __malloc_alloc_oom_handler;  \n        if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; }  \n        (*my_malloc_handler)();  \n        result = malloc(n);  \n        if (result) return(result);  \n    }  \n}  \n  \ntemplate <int inst>  \nvoid * __malloc_alloc_template<inst>::oom_realloc(void *p, size_t n)  \n{  \n    void (* my_malloc_handler)();  \n    void *result;  \n  \n    for (;;) {  \n        my_malloc_handler = __malloc_alloc_oom_handler;  \n        if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; }  \n        (*my_malloc_handler)();  \n        result = realloc(p, n);  \n        if (result) return(result);  \n    }  \n}  \n  \n// 汾STLûʹnon-typeģ  \ntypedef __malloc_alloc_template<0> malloc_alloc;  \n  \n// еĽӿʵSTL׼еallocatorĽӿ  \n// ʵеSGI STLʹڴ  \n// : stl_vector.h  \n// template <class T, class Alloc = alloc>  \n// class vector  \n// {  \n//      ...  \n// protected:  \n//      typedef simple_alloc<value_type, Alloc> data_allocator;  \n//      ...  \n//};  \ntemplate<class T, class Alloc>  \nclass simple_alloc  \n{  \npublic:  \n    static T *allocate(size_t n)  \n                { return 0 == n? 0 : (T*) Alloc::allocate(n * sizeof (T)); }  \n    static T *allocate(void)  \n                { return (T*) Alloc::allocate(sizeof (T)); }  \n    static void deallocate(T *p, size_t n)  \n                { if (0 != n) Alloc::deallocate(p, n * sizeof (T)); }  \n    static void deallocate(T *p)  \n                { Alloc::deallocate(p, sizeof (T)); }  \n};  \n  \n// Allocator adaptor to check size arguments for debugging.  \n// Reports errors using assert.  Checking can be disabled with  \n// NDEBUG, but it's far better to just use the underlying allocator  \n// instead when no checking is desired.  \n// There is some evidence that this can confuse Purify.  \ntemplate <class Alloc>  \nclass debug_alloc  \n{  \nprivate:  \n    enum {extra = 8};       // Size of space used to store size.  Note  \n                            // that this must be large enough to preserve  \n                            // alignment.  \n  \npublic:  \n  \n    // extra ֤Ϊ0ڴռ, Ҫ֤ڴ  \n    // ѷڴǰónĴС, ںУ  \n    // ڴþǱǰextraСݲ޸  \n    static void * allocate(size_t n)  \n    {  \n        char *result = (char *)Alloc::allocate(n + extra);  \n        *(size_t *)result = n;  \n        return result + extra;  \n    }  \n  \n    // *(size_t *)real_p != n϶ǰԽ  \n    static void deallocate(void *p, size_t n)  \n    {  \n        char * real_p = (char *)p - extra;  \n        assert(*(size_t *)real_p == n);  \n        Alloc::deallocate(real_p, n + extra);  \n    }  \n  \n    static void * reallocate(void *p, size_t old_sz, size_t new_sz)  \n    {  \n        char * real_p = (char *)p - extra;  \n        assert(*(size_t *)real_p == old_sz);  \n        char * result = (char *)  \n                      Alloc::reallocate(real_p, old_sz + extra, new_sz + extra);  \n        *(size_t *)result = new_sz;  \n        return result + extra;  \n    }  \n};  \n  \n# ifdef __USE_MALLOC  \n  \ntypedef malloc_alloc alloc;  \ntypedef malloc_alloc single_client_alloc;  \n  \n# else  \n  \n// Ĭϵnode allocator  \n// кʵı, ٶԭʼSTL class-specific allocatorsµȼ  \n// ǾвڴƬŵ  \n// Default_alloc_templateʵʵ, δܻʧ  \n// ͻֻڵʹalloc  \n//  \n// Ҫʵ:  \n// 1. ͻһsize > __MAX_BYTEĶ, ֱʹmalloc()  \n// 2. , ǽĴСڴROUND_UP(requested_size)  \n// TODO:   \n// 2. In all other cases, we allocate an object of size exactly  \n//    ROUND_UP(requested_size).  Thus the client has enough size  \n//    information that we can return the object to the proper free list  \n//    without permanently losing part of the object.  \n//  \n  \n// һģָǷжһ߳ʹñallocator  \n// һdefault_allocʵз, һdeallocateʵͷŶ, ǰȫ  \n// ЧתȨһ  \n// ܵ¶õӰ  \n// ڶģڴdefault_allocʵ  \n// ͬʹòͬallocatorʵnodeӵвͬ, ˴˷ͨ  \n  \n// Sun C++ compilerҪⶨЩö  \n#ifdef __SUNPRO_CC  \n// breaks if we make these template class members:  \n  enum {__ALIGN = 8};  \n  enum {__MAX_BYTES = 128};  \n  enum {__NFREELISTS = __MAX_BYTES/__ALIGN};  \n#endif  \n  \ntemplate <bool threads, int inst>  \nclass __default_alloc_template  \n{  \nprivate:  \n  // Really we should use static const int x = N  \n  // instead of enum { x = N }, but few compilers accept the former.  \n# ifndef __SUNPRO_CC  \n    enum {__ALIGN = 8};  \n    enum {__MAX_BYTES = 128};  \n    enum {__NFREELISTS = __MAX_BYTES/__ALIGN};  \n# endif  \n    //   \n    // һ, __ALIGN - 1ָʵڴ  \n    // __ALIGN = 8ʱ, ֻҪ7Ϳʵʱʾ8(0~7)  \n    // ô~(__ALIGN - 1)ǽ  \n    // ǽ(bytes) + __ALIGN-1)Ƚнλ, Ȼض  \n    // ͱ֤  \n    // byte = 100, __ALIGN = 8  \n    // ~(__ALIGN - 1) = (1 000)B  \n    // ((bytes) + __ALIGN-1) = (1 101 011)B  \n    // (((bytes) + __ALIGN-1) & ~(__ALIGN - 1)) = (1 101 000 )B = (104)D  \n    // 104 / 8 = 13, ʵ  \n    // byteպڴ, byteС  \n    // ǵáHacker's Delightصļ  \n    // ʽĵȼ  \n    // ((((bytes) + _ALIGN - 1) * _ALIGN) / _ALIGN)  \n    // SGI STLʹõķЧʷǳ  \n    static size_t ROUND_UP(size_t bytes)  \n    {  \n        return (((bytes) + __ALIGN-1) & ~(__ALIGN - 1));  \n    }  \n__PRIVATE:  \n    // ڴ  \n    // Ϊ˾ܼڴʹ, ʹһunion  \n    // ʹõһԱ, ָһͬunion obj  \n    // ʹõڶԱ, ָʵʵڴ  \n    // ʵֻʹһָĴСռ, ȴͬʱָڴ  \n    // Էǳǿ, ֵѧϰ  \n    union obj  \n    {  \n        union obj * free_list_link;  \n        char client_data[1];    /* The client sees this.        */  \n    };  \nprivate:  \n# ifdef __SUNPRO_CC  \n    static obj * __VOLATILE free_list[];  \n        // Specifying a size results in duplicate def for 4.1  \n# else  \n    // free_listΪ16  \n    // ӦڴֱΪ8, 16, 32 ... 128  \n    static obj * __VOLATILE free_list[__NFREELISTS];  \n# endif  \n    // ݴĿռС, free_listѡʵĴС  \n    static  size_t FREELIST_INDEX(size_t bytes)  \n    {  \n        return (((bytes) + __ALIGN-1)/__ALIGN - 1);  \n    }  \n  \n  // Returns an object of size n, and optionally adds to size n free list.  \n  static void *refill(size_t n);  \n  // Allocates a chunk for nobjs of size \"size\".  nobjs may be reduced  \n  // if it is inconvenient to allocate the requested number.  \n  static char *chunk_alloc(size_t size, int &nobjs);  \n  \n  // ڴ  \n  static char *start_free;      // ڴʼ  \n  static char *end_free;        // ڴؽ  \n  static size_t heap_size;      // ѾڶϷĿռС  \n  \n// ߳ʹõṩҪ֧  \n# ifdef __STL_SGI_THREADS  \n    static volatile unsigned long __node_allocator_lock;  \n    static void __lock(volatile unsigned long *);  \n    static inline void __unlock(volatile unsigned long *);  \n# endif  \n  \n# ifdef __STL_PTHREADS  \n    static pthread_mutex_t __node_allocator_lock;  \n# endif  \n  \n# ifdef __STL_WIN32THREADS  \n    static CRITICAL_SECTION __node_allocator_lock;  \n    static bool __node_allocator_lock_initialized;  \n  \n  public:  \n    __default_alloc_template() {  \n    // This assumes the first constructor is called before threads  \n    // are started.  \n        if (!__node_allocator_lock_initialized) {  \n            InitializeCriticalSection(&__node_allocator_lock);  \n            __node_allocator_lock_initialized = true;  \n        }  \n    }  \n  private:  \n# endif  \n  \n    // ڶ̻߳  \n    class lock  \n    {  \n    public:  \n        lock() { __NODE_ALLOCATOR_LOCK; }  \n        ~lock() { __NODE_ALLOCATOR_UNLOCK; }  \n    };  \n    friend class lock;  \n  \npublic:  \n  /* n must be > 0      */  \n  static void * allocate(size_t n)  \n  {  \n    obj * __VOLATILE * my_free_list;  \n    obj * __RESTRICT result;  \n  \n    // __MAX_BYTES, ʹһ  \n    if (n > (size_t) __MAX_BYTES) {  \n        return(malloc_alloc::allocate(n));  \n    }  \n    my_free_list = free_list + FREELIST_INDEX(n);  \n    // Acquire the lock here with a constructor call.  \n    // This ensures that it is released in exit or during stack  \n    // unwinding.  \n#       ifndef _NOTHREADS  \n        /*REFERENCED*/  \n        lock lock_instance;  \n#       endif  \n    result = *my_free_list;  \n    // ǵһʹ, Ҫڴ  \n    // , жڴ,   \n    if (result == 0) {  \n        void *r = refill(ROUND_UP(n));  \n        return r;  \n    }  \n    *my_free_list = result -> free_list_link;  \n    return (result);  \n  };  \n  \n  /* p may not be 0 */  \n  static void deallocate(void *p, size_t n)  \n  {  \n    obj *q = (obj *)p;  \n    obj * __VOLATILE * my_free_list;  \n  \n    // ڴ__MAX_BYTESĶ, Ϊõһ, ͬʹһͷ  \n    if (n > (size_t) __MAX_BYTES) {  \n        malloc_alloc::deallocate(p, n);  \n        return;  \n    }  \n    my_free_list = free_list + FREELIST_INDEX(n);  \n    // acquire lock  \n#       ifndef _NOTHREADS  \n        /*REFERENCED*/  \n        lock lock_instance;  \n#       endif /* _NOTHREADS */  \n    q -> free_list_link = *my_free_list;  \n    *my_free_list = q;  \n    // lock is released here  \n  }  \n  \n  static void * reallocate(void *p, size_t old_sz, size_t new_sz);  \n} ;  \n  \ntypedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;  \ntypedef __default_alloc_template<false, 0> single_client_alloc;  \n  \n// ÿηһڴ, ֹηСڴڴƬ  \n// зʱ, ݾ廷Ƿ  \n// ǼٶҪڴڴҪ  \ntemplate <bool threads, int inst>  \nchar*  \n__default_alloc_template<threads, inst>::chunk_alloc(size_t size, int& nobjs)  \n{  \n    char * result;  \n    size_t total_bytes = size * nobjs;  \n    size_t bytes_left = end_free - start_free;  // ڴʣ  \n  \n    // ڴʣڴ>=Ҫڴ, start_freeָڴ,  \n    // ڴʼ  \n    if (bytes_left >= total_bytes) {  \n        result = start_free;  \n        start_free += total_bytes;  \n        return(result);  \n    }  \n    // ڴʣ, ٷһڵʱ,  \n    // ܷĽڵ, start_freeָڴ  \n    // ڴʼ  \n    else if (bytes_left >= size) {  \n        nobjs = bytes_left/size;  \n        total_bytes = size * nobjs;  \n        result = start_free;  \n        start_free += total_bytes;  \n        return(result);  \n    }  \n    // ڴʣڴһڵҲ  \n    else {  \n        size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4);  \n        // ʣڴָfree_list[FREELIST_INDEX(bytes_left)]  \n        if (bytes_left > 0) {  \n            obj * __VOLATILE * my_free_list =  \n                        free_list + FREELIST_INDEX(bytes_left);  \n  \n            ((obj *)start_free) -> free_list_link = *my_free_list;  \n            *my_free_list = (obj *)start_free;  \n        }  \n        start_free = (char *)malloc(bytes_to_get);  \n        // ʧ, ԭѾڴ, Ƿдڵڵǰڴ  \n        if (0 == start_free) {  \n            int i;  \n            obj * __VOLATILE * my_free_list, *p;  \n            // Try to make do with what we have.  That can't  \n            // hurt.  We do not try smaller requests, since that tends  \n            // to result in disaster on multi-process machines.  \n            for (i = size; i <= __MAX_BYTES; i += __ALIGN) {  \n                my_free_list = free_list + FREELIST_INDEX(i);  \n                p = *my_free_list;  \n                // ҵһ, ڴ  \n                if (0 != p) {  \n                    *my_free_list = p -> free_list_link;  \n                    start_free = (char *)p;  \n                    end_free = start_free + i;  \n                    // ڴظ, ·Ҫڴ  \n                    return(chunk_alloc(size, nobjs));  \n                    // Any leftover piece will eventually make it to the  \n                    // right free list.  \n                }  \n            }  \n  \n            // ٴʧ, ֱӵһ, ڴ쳣ṩ  \n            // ҿ, ڴʧܽѾûʲô,  \n            // ֱlog, Ȼó  \n        end_free = 0;   // In case of exception.  \n            start_free = (char *)malloc_alloc::allocate(bytes_to_get);  \n        }  \n        heap_size += bytes_to_get;  \n        end_free = start_free + bytes_to_get;  \n        // ڴظ, ·Ҫڴ  \n        return(chunk_alloc(size, nobjs));  \n    }  \n}  \n  \n  \n// һСΪnĶ, Ҽ뵽free_list[FREELIST_INDEX(n)]  \n// зʱ, ݾ廷Ƿ  \n// ǼٶҪڴڴҪ  \ntemplate <bool threads, int inst>  \nvoid* __default_alloc_template<threads, inst>::refill(size_t n)  \n{  \n    int nobjs = 20;  \n    char * chunk = chunk_alloc(n, nobjs);  \n    obj * __VOLATILE * my_free_list;  \n    obj * result;  \n    obj * current_obj, * next_obj;  \n    int i;  \n  \n    // ڴؽֻһĿռ, ֱӷؼ  \n    if (1 == nobjs) return(chunk);  \n  \n    // ڴܷĿռ  \n    my_free_list = free_list + FREELIST_INDEX(n);  \n  \n    // chunkĿռнfree_list  \n      result = (obj *)chunk;  \n      *my_free_list = next_obj = (obj *)(chunk + n);  \n      for (i = 1; ; i++) {  \n        current_obj = next_obj;  \n        next_obj = (obj *)((char *)next_obj + n);  \n        if (nobjs - 1 == i) {  \n            current_obj -> free_list_link = 0;  \n            break;  \n        } else {  \n            current_obj -> free_list_link = next_obj;  \n        }  \n      }  \n    return(result);  \n}  \n  \ntemplate <bool threads, int inst>  \nvoid*  \n__default_alloc_template<threads, inst>::reallocate(void *p,  \n                                                    size_t old_sz,  \n                                                    size_t new_sz)  \n{  \n    void * result;  \n    size_t copy_sz;  \n  \n    // old_sizenew_size__MAX_BYTES, ֱӵrealloc()  \n    // Ϊⲿڴ治Ǿڴط  \n    if (old_sz > (size_t) __MAX_BYTES && new_sz > (size_t) __MAX_BYTES) {  \n        return(realloc(p, new_sz));  \n    }  \n    // ROUND_UP(old_sz) == ROUND_UP(new_sz), ڴСû仯, ·  \n    if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p);  \n    // ·䲢  \n    result = allocate(new_sz);  \n    copy_sz = new_sz > old_sz? old_sz : new_sz;  \n    memcpy(result, p, copy_sz);  \n    deallocate(p, old_sz);  \n    return(result);  \n}  \n  \n#ifdef __STL_PTHREADS  \n    template <bool threads, int inst>  \n    pthread_mutex_t  \n    __default_alloc_template<threads, inst>::__node_allocator_lock  \n        = PTHREAD_MUTEX_INITIALIZER;  \n#endif  \n  \n#ifdef __STL_WIN32THREADS  \n    template <bool threads, int inst> CRITICAL_SECTION  \n    __default_alloc_template<threads, inst>::__node_allocator_lock;  \n  \n    template <bool threads, int inst> bool  \n    __default_alloc_template<threads, inst>::__node_allocator_lock_initialized  \n    = false;  \n#endif  \n  \n#ifdef __STL_SGI_THREADS  \n__STL_END_NAMESPACE  \n#include <mutex.h>  \n#include <time.h>  \n__STL_BEGIN_NAMESPACE  \n// Somewhat generic lock implementations.  We need only test-and-set  \n// and some way to sleep.  These should work with both SGI pthreads  \n// and sproc threads.  They may be useful on other systems.  \ntemplate <bool threads, int inst>  \nvolatile unsigned long  \n__default_alloc_template<threads, inst>::__node_allocator_lock = 0;  \n  \n#if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) || defined(__GNUC__)  \n#   define __test_and_set(l,v) test_and_set(l,v)  \n#endif  \n  \ntemplate <bool threads, int inst>  \nvoid  \n__default_alloc_template<threads, inst>::__lock(volatile unsigned long *lock)  \n{  \n    const unsigned low_spin_max = 30;  // spin cycles if we suspect uniprocessor  \n    const unsigned high_spin_max = 1000; // spin cycles for multiprocessor  \n    static unsigned spin_max = low_spin_max;  \n    unsigned my_spin_max;  \n    static unsigned last_spins = 0;  \n    unsigned my_last_spins;  \n    static struct timespec ts = {0, 1000};  \n    unsigned junk;  \n#   define __ALLOC_PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk  \n    int i;  \n  \n    if (!__test_and_set((unsigned long *)lock, 1)) {  \n        return;  \n    }  \n    my_spin_max = spin_max;  \n    my_last_spins = last_spins;  \n    for (i = 0; i < my_spin_max; i++) {  \n        if (i < my_last_spins/2 || *lock) {  \n            __ALLOC_PAUSE;  \n            continue;  \n        }  \n        if (!__test_and_set((unsigned long *)lock, 1)) {  \n            // got it!  \n            // Spinning worked.  Thus we're probably not being scheduled  \n            // against the other process with which we were contending.  \n            // Thus it makes sense to spin longer the next time.  \n            last_spins = i;  \n            spin_max = high_spin_max;  \n            return;  \n        }  \n    }  \n    // We are probably being scheduled against the other process.  Sleep.  \n    spin_max = low_spin_max;  \n    for (;;) {  \n        if (!__test_and_set((unsigned long *)lock, 1)) {  \n            return;  \n        }  \n        nanosleep(&ts, 0);  \n    }  \n}  \n  \ntemplate <bool threads, int inst>  \ninline void  \n__default_alloc_template<threads, inst>::__unlock(volatile unsigned long *lock)  \n{  \n#   if defined(__GNUC__) && __mips >= 3  \n        asm(\"sync\");  \n        *lock = 0;  \n#   elif __mips >= 3 && (defined (_ABIN32) || defined(_ABI64))  \n        __lock_release(lock);  \n#   else  \n        *lock = 0;  \n        // This is not sufficient on many multiprocessors, since  \n        // writes to protected variables and the lock may be reordered.  \n#   endif  \n}  \n#endif  \n  \n// ڴʼλ  \ntemplate <bool threads, int inst>  \nchar *__default_alloc_template<threads, inst>::start_free = 0;  \n// ڴؽλ  \ntemplate <bool threads, int inst>  \nchar *__default_alloc_template<threads, inst>::end_free = 0;  \n  \ntemplate <bool threads, int inst>  \nsize_t __default_alloc_template<threads, inst>::heap_size = 0;  \n// ڴ  \ntemplate <bool threads, int inst>  \n__default_alloc_template<threads, inst>::obj * __VOLATILE  \n__default_alloc_template<threads, inst> ::free_list[  \n# ifdef __SUNPRO_CC  \n    __NFREELISTS  \n# else  \n    __default_alloc_template<threads, inst>::__NFREELISTS  \n# endif  \n] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };  \n// The 16 zeros are necessary to make version 4.1 of the SunPro  \n// compiler happy.  Otherwise it appears to allocate too little  \n// space for the array.  \n  \n# ifdef __STL_WIN32THREADS  \n  // Create one to get critical section initialized.  \n  // We do this onece per file, but only the first constructor  \n  // does anything.  \n  static alloc __node_allocator_dummy_instance;  \n# endif  \n  \n#endif /* ! __USE_MALLOC */  \n  \n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)  \n#pragma reset woff 1174  \n#endif  \n  \n__STL_END_NAMESPACE  \n  \n#undef __PRIVATE  \n  \n#endif /* __SGI_STL_INTERNAL_ALLOC_H */  \n  \n// Local Variables:  \n// mode:C++  \n// End:  "
  },
  {
    "path": "stl-gatieme/2-defalloc/test.cpp",
    "content": "#include \"simple_jjalloc.h\"  \n\n#include<vector>  \n#include<iostream>  \n\nusing namespace std;  \n\n\t\nint main()  \n{  \n    {  \n        int ia[5]={0,1,2,3,4};  \n        unsigned int i;  \n      \n        vector<int,JJ::mallocator<int> > iv(ia,ia+5);//使用了JJ::mallocator的alloc来分配内存   \n        for(int i=0;i<iv.size();i++)  \n        {  \n            cout<<iv[i]<<\"\\t\";  \n        }  \n        cout<<endl;  \n        //为什么没有用JJ::mallocator的destroy来回收内存，而自动用了vector的析构函数来回收 ？？？？明明指定了空间配置器是JJ::mallocator了啊  \n    }  \n      \n    return 0;  \n}   "
  },
  {
    "path": "stl-gatieme/3-iterator/3autoptr.cpp",
    "content": "#include <iostream>\n#include <string>\n\n\n#include <typeinfo>\nusing namespace std;\n\n#if defined(__SGI_STL_USE_AutoPtr_CONVERSIONS) && \\\n    defined(__STL_MEMBER_TEMPLATES)\n\ntemplate<class U>\nstruct AutoPtrRef\n{\n  U* m_pointee;\n\n  AutoPtrRef(U* p)\n  :m_pointee(p)\n  {\n\n  }\n\n};\n\n#endif /* auto ptr conversions && member templates */\n\ntemplate<class T>\nclass AutoPtr\n{\npublic :\n    /// constructor\n    explicit AutoPtr(T *p = NULL)\n    :m_pointee(p)\n    {\n        /// NOP\n    }\n\n    /// copy constructor\n    template<class U>\n    AutoPtr(AutoPtr<U> &rhs)    //  Ҫͷrhsָָ ˲Ϊconst\n    :m_pointee(rhs.release())\n    {\n        /// NOP\n    }\n\n    ///\n    ~AutoPtr()\n    {\n        delete this->m_pointee;\n    }\n\n    ///\n    ///   ȡget, releaseͷ, reset\n    ///\n\n    ///  ȡָָ\n    T* get( ) const\n    {\n        return m_pointee;\n    }\n\n    ///  ͷָָ\n    T* release( )\n    {\n        T *temp = this->m_pointee;  //  ԭַָ\n        this->m_pointee = NULL;     //  ָָ\n\n        ///     ڴͷ\n        return temp;\n    }\n\n    /// ָָ\n    void reset(T *p)\n    {\n        if(m_pointee != p)\n        {\n            delete m_pointee;       //  ͷԭĿռ\n            this->m_pointee = p;    //  ޸ָ\n        }\n    }\n\n    ///\n    ///  ز\n    ///\n\n    /// *ptrȡַ\n    T& operator*( ) const\n    {\n        if(m_pointee == NULL)\n        {\n            std::cout <<\"pointee is NULL...\" <<std::endl;\n        }\n        return *m_pointee;\n//        try\n//        {\n//            typeid(*m_pointee).name();\n//\n//            return *m_pointee;\n//        }\n//        catch(std::bad_typeid)\n//        {\n//           std::cout <<__LINE__ <<std::endl;\n//           cout << \"Object is NULL\" << endl;\n//        }\n    }\n\n    ///  ָָ->\n    T*  operator->( ) const\n    {\n        return m_pointee;\n    }\n\n    template<class U>\n    AutoPtr& operator=(AutoPtr<U> &ptr)\n    {\n        ///  auto_pstrռԵĹؼ\n        if(this->m_pointee != ptr.m_pointee)\n        {\n            //  Ҫ޸ֵָ\n            delete this->m_pointee;\n\n            this->m_pointee = ptr.m_pointee;\n            ptr.release( );                             //  ͷֵָָ\n\n        }\n        return *this;\n    }\n\n    ///\n    ///  ӵýӿ\n    ///\n#if defined(__SGI_STL_USE_AutoPtr_CONVERSIONS) && \\\n    defined(__STL_MEMBER_TEMPLATES)\n    /// 캯\n    AutoPtr(AutoPtrRef<T> ref)\n    : m_pointee(ref.m_pointee)\n    {\n\n    }\n\n    //  \n    AutoPtr& operator=(AutoPtrRef<T> ref)\n    {\n        if (ref.m_pointee != this->get()) {\n        delete m_pointee;\n      m_pointee = ref.m_pointee;\n    }\n    return *this;\n  }\n\n    template <class U>\n    operator AutoPtrRef<U>( )\n    {\n        return AutoPtrRef<U>(this->release());\n    }\n\n    template <class U>\n    operator AutoPtr<U>( )\n    {\n        return AutoPtr<U>(this->release());\n    }\n\n#endif /* auto ptr conversions && member templates */\n\nprivate :\n    T   *m_pointee;\n};\n\n\nint main(void)\n{\n\n    AutoPtr<string> pstr1(new string(\"jeancheng\"));\n\n    AutoPtr<string> pstr2(new string(\"gatieme\"));\n\n\n    std::cout <<*pstr1 <<std::endl;\n    std::cout <<*pstr2 <<std::endl;\n\n    pstr1 = pstr2;\n\n    std::cout <<*pstr1 <<std::endl;\n    std::cout <<*pstr2 <<std::endl;           //  segment fault  -=> becase\n\n\n    return 0;\n\n\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3find.cpp",
    "content": "#include <iostream>\n#include <vector>\n#include <deque>\n#include <list>\n#include <algorithm>\n\n\nusing namespace std;\n\nint main()\n{\n    const int arraySize = 7;\n    int ia[arraySize] = {0, 1, 2, 3, 4, 5, 6};\n\n    vector<int> ivect(ia, ia + arraySize);\n    list<int> ilist(ia, ia + arraySize);\n    deque<int> ideque(ia, ia + arraySize);\n\n    vector<int>::iterator it1 = find(ivect.begin(), ivect.end(), 4);\n    if(it1 == ivect.end())\n    {\n       cout <<\"4 not found...\" <<endl;\n    }\n    else\n    {\n        cout <<\"find 4 @ \" <<*it1 <<endl;\n    }\n\n\n    list<int>::iterator it2 = find(ilist.begin(), ilist.end(), 4);\n    if(it2 == ilist.end())\n    {\n       cout <<\"4 not found...\" <<endl;\n    }\n    else\n    {\n        cout <<\"find 4 @ \" <<*it1 <<endl;\n    }\n\n    deque<int>::iterator it3 = find(ideque.begin(), ideque.end(), 4);\n    if(it3 == ideque.end())\n    {\n       cout <<\"4 not found...\" <<endl;\n    }\n    else\n    {\n        cout <<\"find 4 @ \" <<*it1 <<endl;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3function_template1.cpp",
    "content": "///c++11 1ģƵ\n///http://blog.csdn.net/coolmeme/article/details/43986163\n///http://blog.csdn.net/shinehoo/article/details/5722362\n#include <iostream>\n\ntemplate <class Iter, class T>\nvoid func_impl(Iter iter, T t)\n\n{\n    T tmp;              //  , Tǵָ֮, Ϊint\n\n    /// ...  ԭfuncӦȫ\n}\n\n\n\n\ntemplate<class Iter>\ninline func(Iter iter)\n{\n    func_impl(iter, *iter);\n}\n\n\nint main( )\n{\n    int i;\n    func(&i);\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3function_template2.cpp",
    "content": "///c++11 1ģƵ\n///http://blog.csdn.net/coolmeme/article/details/43986163\n///http://blog.csdn.net/shinehoo/article/details/5722362\n///  STLԴ PDF-119/534\n\n#include <iostream>\ntemplate <class T>\nstruct MyIter\n{\n    MyIter(T *p = NULL)\n    :m_ptr(p)\n    {\n        /// NOP...\n    }\n\n    T& operator*( ) const\n    {\n        return *m_ptr;\n    }\n\n\n\n    typedef T value_type;       //  Ƕͱ{nested type}\n    T   *m_ptr;\n};\n\n\ntemplate <class Iter>\ntypename Iter::value_type          ///  һfuncķֵ\nfunc(Iter iter)\n{\n    ///\n    return *iter;\n}\n\n\nint main(void)\n{\n    MyIter<int> ite(new int(8));\n    std::cout <<func(ite) <<std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3function_template3.cpp",
    "content": "///c++11 1ģƵ\n///http://blog.csdn.net/coolmeme/article/details/43986163\n///http://blog.csdn.net/shinehoo/article/details/5722362\n///  STLԴ PDF-119/534\n\n#include <iostream>\n#include <typeinfo>\n\n\n#include <iostream>\ntemplate <class T>\nstruct MyIter\n{\n    MyIter(T *p = NULL)\n    :m_ptr(p)\n    {\n        /// NOP...\n    }\n\n    T& operator*( ) const\n    {\n        return *m_ptr;\n    }\n\n\n\n    typedef T value_type;       //  Ƕͱ{nested type}\n    T   *m_ptr;\n};\n\n\n///// C\n//template <typename T>\n//class C             //  汾TΪ\n//{\n//    // NOP...\n//};\n//\n//\n///// ػCԭָΪ\n//template <typename T>\n//class C<T*>             //  汾\"TΪԭָ\"\n//{\n//    //  TΪԭָTΪκͱһһ\n//    // NOP...\n//};\n\n\n//  iterator_traits\ntemplate <typename Iter>\nstruct iterator_traits\n{\n    typedef typename Iter::value_type value_type;\n};\n\n// ػiterator_traits<T*>, ȡһT\ntemplate<class T>\nstruct iterator_traits<T *>\n{\n    typedef T value_type;\n};\n\n// ػiterator_traits<const T*>, ȡһT\ntemplate<class T>\nstruct iterator_traits<const T *>\n{\n    typedef T value_type;\n};\n\n\ntemplate <class Iter>\n//typename Iter::value_type          ///  һfuncķֵ\ntypename iterator_traits<Iter>::value_type\nfunc(Iter iter)\n{\n    ///\n    return *iter;\n}\n\n\n\nint main(void)\n{\n\n    MyIter<int> ite(new int(8));\n    std::cout <<func(ite) <<std::endl;\n\n\n    std::cout <<typeid(iterator_traits< MyIter<int> >::value_type).name();\n    std::cout <<typeid(iterator_traits<int *>::value_type).name();\n    std::cout <<typeid(iterator_traits<const int *>::value_type).name();\n\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3mylist.h",
    "content": "#ifndef __MYLIST_H__\n#define __MYLIST_H__\n\n#include <iostream>\n#include <ostream>\n#include <vector>\n#include <deque>\n#include <list>\n#include <algorithm>\n\ntemplate <typename T>\nclass ListItem\n{\npublic :\n    T value( ) const\n    {\n        return this->m_value;\n    }\n\n    ListItem *next( ) const\n    {\n        return this->m_next;\n    }\nprotected:\n    T           m_value;\n    ListItem    *m_next;\n};\n\n\nusing namespace std;\n\ntemplate <typename T>\nclass List\n{\npublic :\n    void insert_front(T value)\n    {\n    }\n\n    void insert_end(T value)\n    {\n    }\n\n    void display(std::ostream &os = std::cout) const;\n\nprotected :\n\n    ListItem<T> *m_end;\n    ListItem<T> *m_front;\n    long        m_size;\n};\n\n\n\n#endif  // __MYLIST_H__\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3mylist_iter.h",
    "content": "#ifndef  __MYLIST_ITER_H__\n#define  __MYLIST_ITER_H__\n\n#include <iostream>\n#include <vector>\n#include <deque>\n#include <list>\n#include <algorithm>\n\n#include \"3mylist.h\"\n\n\ntemplate <typename Item>    // itemǵ˫бڵ\nclass ListIter\n{\npublic :\n    ///\n    /// 캯\n    ///\n    ListIter(Item *p = NULL)\n    :m_ptr(p)\n    {\n        /// NOP...\n    }\n\n    /// ʵcopy ctor, ΪṩȱʡΪ㹻\n    /// ʵoperator= ΪṩȱʡΪ㹻\n\n    ///\n    ///  ָ\n    ///\n\n    Item& operator*( ) const\n    {\n        return *m_ptr;\n    }\n\n    Item* operator->( ) const\n    {\n        return m_ptr;\n    }\n\n    ///\n    ///  operator++ѭ׼,\n    ///\n\n    //(1) pre-increment operator...\n    //  it meens ++i == iter.operator++( )\n    Item& operator++( )\n    {\n        m_ptr = m_ptr->m_next;\n\n        return (*this);\n    }\n\n    //(2) post-increment operator...\n    //  it meens i++ == iter.operator++(int)\n    Item& operator++(int)\n    {\n        Item temp = *this;\n        ++*this;                //  ǰ++\n\n        return temp;\n    }\n\n    bool operator==(const Item &i) const\n    {\n        return m_ptr == i.m_ptr;\n    }\n\n    bool operator!=(const Item &i) const\n    {\n        return m_ptr != i.m_ptr;\n    }\n\nprotected :\n    Item *m_ptr;                //  ֮ϵ\n};\n\n\n\n#endif  // #define  __MYLIST_ITER_H__\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3mylist_iter_stl.h",
    "content": "#ifndef  __MYLIST_ITER_H__\n#define  __MYLIST_ITER_H__\n\n#include <iostream>\n#include <vector>                                                                           _\n#include <deque>\n#include <list>\n#include <algorithm>\n\n#include \"3mylist.h\"\n\n\ntemplate <typename Item>    // itemǵ˫бڵ\nclass ListIter  \n: public std::iterator<std::forward_iterator_tag, Item>\n{\n\t\n};\n\n\n\n#endif  // #define  __MYLIST_ITER_H__\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3mylist_iter_test.cpp",
    "content": "/*************************************************************************\n    > File Name: 3mylist-iter-test.cpp\n    > Author: gatieme\n    > Created Time: 2016年03月21日 星期一 15时13分39秒\n ************************************************************************/\n\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\n#include \"3mylist.h\"\n#include \"3mylist_iter.h\"\n\n\nint main( )\n{\n    List<int>   mylist;\n\n    for(int i = 0; i < 5; i++)\n    {\n        mylist.insert_front(i);\n        mylist.insert_end(i + 2);\n    }\n\n    mylist.display( );\n\n    ListIter< ListItem<int> > begin(mylist.front);\n\n    ListIter< Listitem<int> > end;                    // default 0, null\n    ListIter< Listitem<int> > iter;                   // default 0, null\n\n    iter = find(begin, end, 3);\n    if(iter == end)\n    {\n        cout <<\"not found\" <<endl;\n    }\n    else\n    {\n        cout <<\"found.\" <<iter->m_value() <<endl;\n    }\n\n    iter = find(begin, end, 7);\n    if(iter == end)\n    {\n        cout <<\"not found\" <<endl;\n    }\n    else\n    {\n        cout <<\"found.\" <<iter->m_value() <<endl;\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3tag_test.cpp",
    "content": "#include <iostream>\nusing namespace std;\n\nstruct B                ///  B  ɱΪInputIterator\n{\n\n};\n\nstruct D1 : public B   ///  D1 ɱΪForwardIteraor\n{\n\n};\n\nstruct D2 : public D1    //  D2 ɱΪBidirectionalIterator\n{\n\n};\n\n\ntemplate <class I>\nfunc(I &p, B)\n{\n    std::cout <<\"B version...\" <<endl;\n}\n\ntemplate <class I>\nfunc(I &p, D2)\n{\n    std::cout <<\"D2 version...\" <<endl;\n\n}\n\n\n\nint main(void)\n{\n    int *p;\n    func(p, B());        //  BȫǺ, \"B version...\"\n    func(p, D1());       //  δȫǺ, ̳йϵ, \"B version...\"\n    func(p, D2());       //  D2ȫǺ, \"D2 version...\"\n\n\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3templatespecial_class.cpp",
    "content": "#include <iostream>\n#include <cstring>\n#include <cmath>\n// general version\ntemplate<class T>\nclass Compare\n{\npublic:\n    static bool IsEqual(const T& lh, const T& rh)\n    {\n        std::cout <<\"in the general class...\" <<std::endl;\n        return lh == rh;\n    }\n};\n\n\n\n// specialize for float ȫػ\ntemplate<>\nclass Compare<float>\n{\npublic:\n    static bool IsEqual(const float& lh, const float& rh)\n    {\n        std::cout <<\"in the float special class...\" <<std::endl;\n\n        return std::abs(lh - rh) < 10e-3;\n    }\n};\n\n// specialize for double ȫػ\ntemplate<>\nclass Compare<double>\n{\npublic:\n    static bool IsEqual(const double& lh, const double& rh)\n    {\n        std::cout <<\"in the double special class...\" <<std::endl;\n\n        return std::abs(lh - rh) < 10e-6;\n    }\n};\n\n\n\n\n\nint main(void)\n{\n    Compare<int> comp1;\n    std::cout <<comp1.IsEqual(3, 4) <<std::endl;\n    std::cout <<comp1.IsEqual(3, 3) <<std::endl;\n\n    Compare<float> comp2;\n    std::cout <<comp2.IsEqual(3.14, 4.14) <<std::endl;\n    std::cout <<comp2.IsEqual(3, 3) <<std::endl;\n\n    Compare<double> comp3;\n    std::cout <<comp3.IsEqual(3.14159, 4.14159) <<std::endl;\n    std::cout <<comp3.IsEqual(3.14159, 3.14159) <<std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3templatespecial_func.cpp",
    "content": "#include <iostream>\n#include <cstring>\n\n///  ģػ\n\ntemplate <class T>\nint compare(const T left, const T right)\n{\n    std::cout <<\"in template<class T>...\" <<std::endl;\n    return (left - right);\n}\n\n\n//  һػĺģ\ntemplate < >\nint compare<const char*>(const char* left, const char* right)\n{\n    std::cout <<\"in special template< >...\" <<std::endl;\n\n    return strcmp(left, right);\n}\n//  ػĺģ, ػģ汾ͬ, ˱ᱨ\n// error: redefinition of 'int compare(T, T) [with T = const char*]'|\n//template < >\n//int compare(const char* left, const char* right)\n//{\n//    std::cout <<\"in special template< >...\" <<std::endl;\n//\n//    return strcmp(left, right);\n//}\n\n\n//  ʵǺ\nint compare(char* left, char* right)\n{\n    std::cout <<\"in overload function...\" <<std::endl;\n\n    return strcmp(left, right);\n}\n\nint main( )\n{\n    compare(1, 4);\n\n    const char *left = \"gatieme\";\n    const char *right = \"jeancheng\";\n    compare(left, right);\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/3test_typeid.cpp",
    "content": "/*************************************************************************\n    > File Name: 3typeif.cpp\n    > Author: gatieme\n    > Created Time: 2016年03月21日 星期一 16时31分59秒\n ************************************************************************/\n\n#include <iostream>\n#include <typeinfo>\nusing namespace std;\n\n\n\nclass A\n{\n};\n\nint main( )\n{\n    int ia = 10;\n    cout <<\"typeid(int) = \" <<typeid(ia).name() <<endl;\n    if(typeid(ia) == typeid(int))\n    {\n        cout <<\"int\" <<endl;\n    }\n\n    cout <<\"typeid(char) = \" <<typeid(float).name( ) <<endl;\n\n    cout <<\"typeid(float) = \" <<typeid(float).name() <<endl;\n\n    cout <<\"typeid(double) = \" <<typeid(double).name() <<endl;\n\n    cout <<\"typeid(A) = \" <<typeid(A).name() <<endl;\n\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/Makefile",
    "content": "ROOT=..\nPLATFORM=$(shell $(ROOT)/systype.sh)\ninclude $(ROOT)/Make.defines.$(PLATFORM)\n\ntarget=3autoptr 3find test_auto_ptr 3test_typeid #3mylist_iter_test\n\n\n\nall:$(target)\n\t\ntest_auto_ptr : test_auto_ptr.o\n\t$(CXX) $^ -o $@ \n\t@echo \"complie 测试stl的智能指针auto_ptr...\"\n\n\n3autoptr : 3autoptr.o\n\t$(CXX) $^ -o $@ \n\t@echo \"complie 自己实现的智能指针AutoPtr...\"\n\n3find : 3find.o\n\t$(CXX) $^ -o $@ \n\t@echo \"complie 通过迭代器进行查找...\"\n\n3mylist_iter_test:3mylist_iter_test.o\n\t$(CXX) $^ -o $@ \n\t@echo \"complie 自己实现的迭代器...\"\n\n3test_typeid:3test_typeid.o\n\t$(CXX) $^ -o $@ \n\t@echo \"complie 测试typeid关键字...\"\n\n\n\n\n%.o:%.cpp\n\t$(CXX) -c $^ -o $@ -I./\n      \nclean :\n\trm $(target)\n\trm *.o\n"
  },
  {
    "path": "stl-gatieme/3-iterator/test_auto_ptr.cpp",
    "content": "#include <memory>\n#include <iostream>\nusing namespace std;\n\nclass A\n{\npublic:\n    A( )\n    {\n        id = ++count;\n        cout <<\"create A\" <<id  <<std::endl;\n    }\n\n    ~A()\n    {\n        cout <<\"destroy A\" <<id <<std::endl;\n    }\n\nprivate:\n    static int count;\n    int id;\n};\n\nint A::count = 0;\n\n/*  øúᶪʧȨ */\nvoid sink(auto_ptr<A> a)\n{\n    cout << \"Enter sink()\\n\";\n}\n\n/*  øúᴴ󣬲ȡȨ  */\nauto_ptr<A> create()\n{\n    cout << \"Enter create()\\n\";\n    auto_ptr<A> a(new A());\n    return a;\n}\n\nint main(int argc, char *argv[])\n{\n    //auto_ptr<string> pstr(new string(\"abcd\"));\n    //auto_ptr<string> pstr = new string(\"abcd\");\n    auto_ptr<A> a1 = create();\n    cout << \"Exit create()\\n\";\n\n\n    auto_ptr<A> a2 = a1;            /* ֵתȨʱa1Ч*/\n\n    auto_ptr<A> a3(new A());\n\n\n    sink(a2);                       /* λᶪʧȨᷢa2ͷsinkн*/\n\n    cout << \"Exit sink()\\n\";\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/test_bad_typeid.cpp",
    "content": "// expre_bad_typeid.cpp\n\n#include <typeinfo>\n#include <iostream>\n\nusing namespace std;\n\nclass A\n{\npublic:\n  // object for class needs vtable\n  virtual ~A( );\n};\n\nint main()\n{\n    A* a = NULL;\n\n    try\n    {\n        cout << typeid(*a).name() << endl; // Error condition\n    }\n    catch (bad_typeid)\n    {\n        cout << \"Object is NULL\" << endl;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/3-iterator/typeinfo.h",
    "content": "// cp /usr/include/c++/4.4.4/typeinfo  ./typeinfo.h\n// RTTI support for -*- C++ -*-\n// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,\n// 2003, 2004, 2005, 2006, 2007, 2009\n// Free Software Foundation\n//\n// This file is part of GCC.\n//\n// GCC is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 3, or (at your option)\n// any later version.\n//\n// GCC is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// Under Section 7 of GPL version 3, you are granted additional\n// permissions described in the GCC Runtime Library Exception, version\n// 3.1, as published by the Free Software Foundation.\n\n// You should have received a copy of the GNU General Public License and\n// a copy of the GCC Runtime Library Exception along with this program;\n// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n// <http://www.gnu.org/licenses/>.\n\n/** @file typeinfo\n *  This is a Standard C++ Library header.\n */\n\n#ifndef _TYPEINFO\n#define _TYPEINFO\n\n#include <exception>\n\n#pragma GCC visibility push(default)\n\nextern \"C++\" {\n\nnamespace __cxxabiv1\n{\n  class __class_type_info;\n} // namespace __cxxabiv1\n\n// Determine whether typeinfo names for the same type are merged (in which\n// case comparison can just compare pointers) or not (in which case strings\n// must be compared), and whether comparison is to be implemented inline or\n// not.  We used to do inline pointer comparison by default if weak symbols\n// are available, but even with weak symbols sometimes names are not merged\n// when objects are loaded with RTLD_LOCAL, so now we always use strcmp by\n// default.  For ABI compatibility, we do the strcmp inline if weak symbols\n// are available, and out-of-line if not.  Out-of-line pointer comparison\n// is used where the object files are to be portable to multiple systems,\n// some of which may not be able to use pointer comparison, but the\n// particular system for which libstdc++ is being built can use pointer\n// comparison; in particular for most ARM EABI systems, where the ABI\n// specifies out-of-line comparison.  The compiler's target configuration\n// can override the defaults by defining __GXX_TYPEINFO_EQUALITY_INLINE to\n// 1 or 0 to indicate whether or not comparison is inline, and\n// __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to indicate whether or not pointer\n// comparison can be used.\n\n#ifndef __GXX_MERGED_TYPEINFO_NAMES\n// By default, typeinfo names are not merged.\n#define __GXX_MERGED_TYPEINFO_NAMES 0\n#endif\n\n// By default follow the old inline rules to avoid ABI changes.\n#ifndef __GXX_TYPEINFO_EQUALITY_INLINE\n  #if !__GXX_WEAK__\n    #define __GXX_TYPEINFO_EQUALITY_INLINE 0\n  #else\n    #define __GXX_TYPEINFO_EQUALITY_INLINE 1\n  #endif\n#endif\n\nnamespace std\n{\n  /**\n   *  @brief  Part of RTTI.\n   *\n   *  The @c type_info class describes type information generated by\n   *  an implementation.\n  */\n  class type_info\n  {\n  public:\n    /** Destructor first. Being the first non-inline virtual function, this\n     *  controls in which translation unit the vtable is emitted. The\n     *  compiler makes use of that information to know where to emit\n     *  the runtime-mandated type_info structures in the new-abi.  */\n    virtual ~type_info();\n\n    /** Returns an @e implementation-defined byte string; this is not\n     *  portable between compilers!  */\n    const char* name() const\n    { return __name[0] == '*' ? __name + 1 : __name; }\n\n#if !__GXX_TYPEINFO_EQUALITY_INLINE\n    // In old abi, or when weak symbols are not supported, there can\n    // be multiple instances of a type_info object for one\n    // type. Uniqueness must use the _name value, not object address.\n    bool before(const type_info& __arg) const;\n    bool operator==(const type_info& __arg) const;\n#else\n  #if !__GXX_MERGED_TYPEINFO_NAMES\n    /** Returns true if @c *this precedes @c __arg in the implementation's\n     *  collation order.  */\n    // Even with the new abi, on systems that support dlopen\n    // we can run into cases where type_info names aren't merged,\n    // so we still need to do string comparison.\n    bool before(const type_info& __arg) const\n    { return (__name[0] == '*' && __arg.__name[0] == '*')\n\t? __name < __arg.__name\n\t: __builtin_strcmp (__name, __arg.__name) < 0; }\n\n    bool operator==(const type_info& __arg) const\n    {\n      return ((__name == __arg.__name)\n\t      || (__name[0] != '*' &&\n\t\t  __builtin_strcmp (__name, __arg.__name) == 0));\n    }\n  #else\n    // On some targets we can rely on type_info's NTBS being unique,\n    // and therefore address comparisons are sufficient.\n    bool before(const type_info& __arg) const\n    { return __name < __arg.__name; }\n\n    bool operator==(const type_info& __arg) const\n    { return __name == __arg.__name; }\n  #endif\n#endif\n    bool operator!=(const type_info& __arg) const\n    { return !operator==(__arg); }\n\n    // Return true if this is a pointer type of some kind\n    virtual bool __is_pointer_p() const;\n\n    // Return true if this is a function type\n    virtual bool __is_function_p() const;\n\n    // Try and catch a thrown type. Store an adjusted pointer to the\n    // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then\n    // THR_OBJ points to the thrown object. If THR_TYPE is a pointer\n    // type, then THR_OBJ is the pointer itself. OUTER indicates the\n    // number of outer pointers, and whether they were const\n    // qualified.\n    virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,\n\t\t\t    unsigned __outer) const;\n\n    // Internally used during catch matching\n    virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,\n\t\t\t     void **__obj_ptr) const;\n\n  protected:\n    const char *__name;\n\n    explicit type_info(const char *__n): __name(__n) { }\n\n  private:\n    /// Assigning type_info is not supported.\n    type_info& operator=(const type_info&);\n    type_info(const type_info&);\n  };\n\n  /**\n   *  @brief  Thrown during incorrect typecasting.\n   *  @ingroup exceptions\n   *\n   *  If you attempt an invalid @c dynamic_cast expression, an instance of\n   *  this class (or something derived from this class) is thrown.  */\n  class bad_cast : public exception\n  {\n  public:\n    bad_cast() throw() { }\n\n    // This declaration is not useless:\n    // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118\n    virtual ~bad_cast() throw();\n\n    // See comment in eh_exception.cc.\n    virtual const char* what() const throw();\n  };\n\n  /**\n   *  @brief Thrown when a NULL pointer in a @c typeid expression is used.\n   *  @ingroup exceptions\n   */\n  class bad_typeid : public exception\n  {\n  public:\n    bad_typeid () throw() { }\n\n    // This declaration is not useless:\n    // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118\n    virtual ~bad_typeid() throw();\n\n    // See comment in eh_exception.cc.\n    virtual const char* what() const throw();\n  };\n} // namespace std\n\n#pragma GCC visibility pop\n\n} // extern \"C++\"\n#endif\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4deque_test.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n#include <deque>\n#include <iomanip>\n#include <cstdlib>\n\n\nusing namespace std;\nvoid Print(int a)\n{\n    cout <<std::setw(4) <<a;\n\n}\n\nint main( )\n{\n    deque<int, alloc, 32> ideq(20, 9);              //  allocֻG++\n    cout <<\"size = \" <<ideq.size( );\n    /// ڹһdeque, 20intԪ, ֵΪ9\n    /// СΪ32byte\n\n    ///  ΪÿԪ趨ֵ\n    for(int i = 0; i < ideq.size( ); i++)\n    {\n        ideq[i] = i;\n    }\n    cout <<endl;\n\n\n\n    return 0;\n}\n\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4heap_test.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n#include <vector>\n#include <iomanip>\n\n\nusing namespace std;\nvoid Print(int a)\n{\n    cout <<std::setw(4) <<a;\n\n}\n\nint main( )\n{\n    /// test heap (ײvector)\n    int ia[9] = {0, 1, 2, 3, 4, 8, 9, 3, 5};\n    vector<int> ivec(ia, ia + 9);\n\n    make_heap(ivec.begin( ), ivec.end( ));\n    for(vector<int>::iterator iter = ivec.begin( );\n        iter != ivec.end( );\n        iter++)\n    {\n        cout <<setw(4)<<*iter;\n    }\n    cout <<endl;\n\n    ivec.push_back(7);\n    push_heap(ivec.begin( ), ivec.end());\n    cout <<ivec.back( ) <<endl;\n    ivec.pop_back( );\n    for(vector<int>::iterator iter = ivec.begin( );\n        iter != ivec.end( );\n        iter++)\n    {\n        cout <<setw(4)<<*iter;\n    }\n    cout <<endl;\n\n    pop_head(ivec.begin( ), ivec.end( )));\n    cout <<ivec.back( ) <<endl;\n    ivec.pop_back( );\n\n    sort_head(ivec.begin(), ivect.end( ));\n    for(vector<int>::iterator iter = ivec.begin( );\n        iter != ivec.end( );\n        iter++)\n    {\n        cout <<setw(4)<<*iter;\n    }\n    cout <<endl;\n\n    return 0;\n}\n\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4queue_test.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n\n#include <iomanip>\n#include <cstdlib>\n\n#include <queue>\n#include <list>\n\nusing namespace std;\n\n\nint main( )\n{\n    queue< int, list<int> > iqueue;\n\n    iqueue.push(1);\n    iqueue.push(3);\n    iqueue.push(5);\n    iqueue.push(7);\n\n    cout <<\"size = \" <<iqueue.size( ) <<\", \";\n    cout <<\"top = \"<<iqueue.front( ) <<endl;\n\n    iqueue.pop( );\n    cout <<\"size = \" <<iqueue.size( ) <<\", \";\n    cout <<\"top = \"<<iqueue.front( ) <<endl;\n\n    iqueue.pop( );\n    cout <<\"size = \" <<iqueue.size( ) <<\", \";\n    cout <<\"top = \"<<iqueue.front( ) <<endl;\n\n    iqueue.pop( );\n    cout <<\"size = \" <<iqueue.size( ) <<\", \";\n    cout <<\"top = \"<<iqueue.front( ) <<endl;\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4stack_test.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n\n#include <iomanip>\n#include <cstdlib>\n\n#include <stack>\n#include <list>\n\nusing namespace std;\n\n\nint main( )\n{\n    stack< int, list<int> > istack;\n\n    istack.push(1);\n    istack.push(3);\n    istack.push(5);\n    istack.push(7);\n\n    cout <<\"size = \" <<istack.size( ) <<\", \";\n    cout <<\"top = \"<<istack.top( ) <<endl;\n\n    istack.pop( );\n    cout <<\"size = \" <<istack.size( ) <<\", \";\n    cout <<\"top = \"<<istack.top( ) <<endl;\n\n    istack.pop( );\n    cout <<\"size = \" <<istack.size( ) <<\", \";\n    cout <<\"top = \"<<istack.top( ) <<endl;\n\n    istack.pop( );\n    cout <<\"size = \" <<istack.size( ) <<\", \";\n    cout <<\"top = \"<<istack.top( ) <<endl;\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4vector_reset.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n#include <vector>\n#include <iomanip>\n\n\nusing std::cout;\nusing std::endl;\nusing std::vector;\nint main( )\n{\n\n    vector<int> iv(3, 9);\n    std::cout <<\"size = \" <<iv.size() <<\", \";                //  3\n    cout <<\"capacity = \" <<iv.capacity() <<endl;             //  3\n\n    vector<int>::iterator itdegin1 = iv.begin();\n    vector<int>::iterator itend1 = iv.end();\n    cout <<\"begin = \" <<*itdegin1 <<\", \";\n    cout <<\"end   = \" <<*(itend1 - 1) <<endl;\n\n    /// ѹһ֮, òԭ2\n    iv.push_back(1);\n    cout <<\"size = \" <<iv.size() <<\", \";                //  4\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  6\n    /// ERROR...  ú, ԭĵʧЧ\n    cout <<\"begin = \" <<*itdegin1 <<\", \";\n    cout <<\"end   = \" <<*(itend1 - 1) <<endl;\n\n    return 0;\n}\n"
  },
  {
    "path": "stl-gatieme/4-sequence-containers/4vector_test.cpp",
    "content": "#include <iostream>\n#include <algorithm>\n#include <vector>\n#include <iomanip>\n\n\nusing namespace std;\nvoid Print(int a)\n{\n    cout <<std::setw(4) <<a;\n\n}\n\nint main( )\n{\n    int i;\n    vector<int> iv(2, 9);\n\n    cout <<\"size = \" <<iv.size() <<endl;                //  2\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  2\n\n    iv.push_back(1);\n    cout <<\"size = \" <<iv.size() <<endl;                //  3\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  4\n\n    iv.push_back(2);\n    cout <<\"size = \" <<iv.size() <<endl;                //  4\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  4\n\n\n    iv.push_back(3);\n    cout <<\"size = \" <<iv.size() <<endl;                //  5\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n\n    iv.push_back(4);\n    cout <<\"size = \" <<iv.size() <<endl;                //  6\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n\n    for(i = 0; i < iv.size( ); i++)\n    {\n        cout <<std::setw(4) <<iv[i];\n    }\n    cout <<endl;\n\n    iv.push_back(5);\n    cout <<\"size = \" <<iv.size() <<endl;                //  7\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n    for(vector<int>::iterator iter = iv.begin();\n        iter != iv.end();\n        iter++)\n    {\n        cout <<std::setw(4) <<*iter;\n    }\n    cout <<endl;\n\n    iv.pop_back( );\n    iv.pop_back( );\n    cout <<\"size = \" <<iv.size() <<endl;                //  5\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n    iv.pop_back( );\n    cout <<\"size = \" <<iv.size() <<endl;                //  4\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n    vector<int>::iterator ivite = find(iv.begin(), iv.end( ), 1);\n    if(ivite != iv.end( ))\n    {\n        iv.erase(ivite);\n    }\n    cout <<endl;\n\n    cout <<\"size = \" <<iv.size() <<endl;                //  3\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n    for_each(iv.begin(), iv.end(), Print);\n    cout <<endl;\n\n    vector<int>::iterator ite = find(iv.begin(), iv.end( ), 2);\n    if(ite != iv.end( ))\n    {\n        iv.insert(ite, 3, 7);\n    }\n    cout <<\"size = \" <<iv.size() <<endl;                //  3\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n    for_each(iv.begin(), iv.end(), Print);\n    cout <<endl;\n\n    iv.clear( );\n    cout <<\"size = \" <<iv.size() <<endl;                //  3\n    cout <<\"capacity = \" <<iv.capacity() <<endl;        //  8\n\n\n    return 0;\n}\n\n"
  },
  {
    "path": "stl-gatieme/Make.defines.freebsd",
    "content": "# Common make definitions, customized for each platform\n\n# Definitions required in all program directories to compile and link\n# C programs using gcc.\n\nCC=gcc\nCOMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c\nLINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\nLDFLAGS=\nLDDIR=-L$(ROOT)/lib\nLDLIBS=$(LDDIR) -lapue $(EXTRALIBS)\nCFLAGS=-ansi -I$(ROOT)/include -Wall -DBSD -D__BSD_VISIBLE $(EXTRA)\nRANLIB=ranlib\nAR=ar\nAWK=awk\nLIBAPUE=$(ROOT)/lib/libapue.a\n\n# Common temp files to delete from each directory.\nTEMPFILES=core core.* *.o temp.* *.out\n"
  },
  {
    "path": "stl-gatieme/Make.defines.linux",
    "content": "# Common make definitions, customized for each platform\n\n# Definitions required in all program directories to compile and link\n# C programs using gcc.\n\n\nifeq ($(DEBUG), y)\nDEFFLAGS=-DDEBUG -DLINUX\nelse\nDEFFLAGS=-DRELEASE -DLINUX\nendif\n\n\nCC=gcc\nCOMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c\nLINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\nLDFLAGS=-lm\nLDDIR=-L$(ROOT)/lib\nLDLIBS=\nCFLAGS=-std=c99 -Wall $(DEFFLAGS)\nRANLIB=echo\nAR=ar\nAWK=awk\nLIBAPUE=\n\n\n# Common temp files to delete from each directory.\nTEMPFILES=core core.* *.o temp.* *.out\n"
  },
  {
    "path": "stl-gatieme/Make.defines.macos",
    "content": "# Common make definitions, customized for each platform\n\n# Definitions required in all program directories to compile and link\n# C programs using gcc.\n\nCC=gcc\nCOMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c\nLINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\nLDFLAGS=\nLDDIR=-L$(ROOT)/lib\nLDLIBS=$(LDDIR) -lapue $(EXTRALIBS)\nCFLAGS=-ansi -I$(ROOT)/include -Wall -DMACOS -D_DARWIN_C_SOURCE $(EXTRA)\nRANLIB=ranlib\nAR=ar\nAWK=awk\nLIBAPUE=$(ROOT)/lib/libapue.a\n\n# Common temp files to delete from each directory.\nTEMPFILES=core core.* *.o temp.* *.out\n"
  },
  {
    "path": "stl-gatieme/Make.defines.solaris",
    "content": "# Common make definitions, customized for each platform\n\n# Definitions required in all program directories to compile and link\n# C programs using gcc.\n\nCC=gcc\nCOMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c\nLINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\nLDFLAGS=\nLDDIR=-L$(ROOT)/lib\nLDLIBS=$(LDDIR) -lapue $(EXTRALIBS)\nCFLAGS=-std=c99 -m64 -I$(ROOT)/include -Wall -DSOLARIS -D__EXTENSIONS__ $(EXTRA)\nRANLIB=echo\nAR=ar\nAWK=nawk\nLIBAPUE=$(ROOT)/lib/libapue.a\nNAMEMAX=-DNAME_MAX=_XOPEN_NAME_MAX\n\n# Common temp files to delete from each directory.\nTEMPFILES=core core.* *.o temp.* *.out\n"
  },
  {
    "path": "stl-gatieme/Makefile",
    "content": "ROOT=.\nPLATFORM=$(shell $(ROOT)/systype.sh)\ninclude $(ROOT)/Make.defines.$(PLATFORM)\n\nDIRS=1-stl_config 2-defalloc  3-iterator\n\n\nall:\n\tfor i in $(DIRS); do \\\n\t\t(cd $$i && echo \"making $$i\" && $(MAKE) ) || exit 1; \\\n\tdone\n\nclean:\n\tfor i in $(DIRS); do \\\n\t\t(cd $$i && echo \"cleaning $$i\" && $(MAKE) clean) || exit 1; \\\n\tdone\n"
  },
  {
    "path": "stl-gatieme/systype.sh",
    "content": "# (leading space required for Xenix /bin/sh)\n\n#\n# Determine the type of *ix operating system that we're\n# running on, and echo an appropriate value.\n# This script is intended to be used in Makefiles.\n# (This is a kludge.  Gotta be a better way.)\n#\n\ncase `uname -s` in\n\"FreeBSD\")\n\tPLATFORM=\"freebsd\"\n\t;;\n\"Linux\")\n\tPLATFORM=\"linux\"\n\t;;\n\"Darwin\")\n\tPLATFORM=\"macos\"\n\t;;\n\"SunOS\")\n\tPLATFORM=\"solaris\"\n\t;;\n*)\n\techo \"Unknown platform\" >&2\n\texit 1\nesac\necho $PLATFORM\nexit 0\n"
  },
  {
    "path": "stl侯杰源码/Makefile",
    "content": "include Makefile.h\n\nall::\n\nCODE_DIRS = util stl cont iter fo algo string num io i18n memory\nall::\n\t@for DIR in $(CODE_DIRS); \\\n        do \\\n            (cd $$DIR; make all) \\\n        done\nclean::\n\t@for DIR in $(CODE_DIRS); \\\n        do \\\n            (cd $$DIR; make clean) \\\n        done\n\n"
  },
  {
    "path": "stl侯杰源码/Makefile.h",
    "content": "##################################################################\n# Makefile with general settings for the book \"The C++ Standard Library\"\n# - is included by each individual Makefile\n# - please send updates and suggestions to libbook@josuttis.com\n##################################################################\n\n############################\n# GCC settings (general)\n############################\nGCCFLAGS=-g -ansi -W -Wall -Wwrite-strings -pedantic\nCXX = g++\nCXXFLAGS = $(GCCFLAGS)\nLDFLAGS = -lm\n\n\n############################\n# GCC settings (special)\n############################\n#GCCFLAGS=-g -ansi -W -Wall -Wwrite-strings -pedantic\n#GCCDIR=/local/gcc/rundir\n#CXX =  $(GCCDIR)/bin/g++\n#CXXFLAGS = $(GCCFLAGS)\n#LIBCPPDIR = $(GCCDIR)/lib\n#LDFLAGS = -L$(LIBCPPDIR) -Wl,--rpath -Wl,$(LIBCPPDIR) -lm\n\n\n############################\n# EDG (and my personal std headers)\n############################\n#CXX = /local/edg/bin/eccp --exceptions --strict\n#CXXFLAGS = -Imystd -I../mystd\n#LDFLAGS = -lm\n\n\n##################################################################\n\nhelp::\n\t@echo \"all:    progs\"\n\nall:: progs\n\n.SUFFIXES: .ctt .htt .cpp .hpp\n\n.cpp.o:\n\t$(CXX) $(CXXFLAGS) -c $*.cpp\n.o:\n\t$(CXX) $*.o $(LDFLAGS) -o $*\n\nhelp::\n\t@echo 'progs:  create all in $$(CPPPROGS) and in $$(OUTPROGS)'\n\t@echo \"        (failed progs in MAKE.LOG)\"\nprogs::\n\t@cat /dev/null > MAKE.LOG\n\t@if test \"$(CPPPROGS)\" != \"\" ; \\\n\tthen \\\n\t    for PROG in $(CPPPROGS)\"\"; \\\n\t    do \\\n\t        echo \"MAKE $$PROG\"; \\\n\t        make $$PROG || echo \" + make $$PROG failed !!!\" >> MAKE.LOG; \\\n\t    done; \\\n\tfi\n\t@if test \"$(OUTPROGS)\" != \"\" ; \\\n\tthen \\\n\t    for PROG in $(OUTPROGS)\"\"; \\\n\t    do \\\n\t        echo \"MAKE $$PROG\"; \\\n\t        make $$PROG || echo \" + make $$PROG failed !!!\" >> MAKE.LOG; \\\n\t    done; \\\n\tfi\n\t@if test -s MAKE.LOG ; \\\n\tthen \\\n\t    echo \"failures:\"; \\\n\t    cat MAKE.LOG; \\\n\telse \\\n\t    echo \"no failure\"; \\\n\tfi\n\nhelp::\n\t@echo 'clean:  clean all generated'\nclean::\n\trm -rf MAKE.LOG *.o *.exe *.ii *.ti *~\n\trm -rf $(CPPPROGS) $(OUTPROGS)\n\t@for DATEI in *.ctt; \\\n\tdo \\\n\t    BASE=`basename $$DATEI .ctt`; \\\n\t    if test -r $$BASE.cpp; \\\n\t    then \\\n\t        echo \" remove $$BASE.cpp\"; \\\n\t\trm $$BASE.cpp; \\\n\t    fi; \\\n\t    if test -x $$BASE; \\\n            then \\\n                echo \" remove $$BASE\"; \\\n                rm $$BASE; \\\n            fi; \\\n\tdone\n\t@for DATEI in *.cpp; \\\n\tdo \\\n\t    BASE=`basename $$DATEI .cpp`; \\\n\t    if test -x $$BASE; \\\n            then \\\n                echo \" remove $$BASE\"; \\\n                rm $$BASE; \\\n            fi; \\\n\tdone\n\t@for DATEI in *.htt; \\\n\tdo \\\n            BASE=`basename $$DATEI .htt`; \\\n            if test -r $$BASE.hpp; \\\n            then \\\n                echo \" remove $$BASE.hpp\"; \\\n                rm $$BASE.hpp; \\\n            fi; \\\n\tdone\n\n"
  },
  {
    "path": "stl侯杰源码/README",
    "content": "These are the examples from the following book:\n Nicolai M. Josuttis\n The C++ Standard Library - A Tutorial and Reference\n Addison Wesley Longman, 1999\n ISBN 0-201-37926-0\n\nFor further informations see:\n    http://www.josuttis.com/libbook/\n\nI welcome your feedback.\nThe best way to reach me is by Email:\n    libbook@josuttis.com\n\nCopyright 1999 by Addison Wesley Longman, Inc. and Nicolai M. Josuttis.\nAll rights reserved.\n\nPermission to use, copy, modify and distribute this software for personal\nand educational use is hereby granted without fee, provided that the above\ncopyright notice appears in all copies and that both that copyright notice\nand this permission notice appear in supporting documentation, and that the\nnames of Addison Wesley Longman or the author are not used in advertising or\npublicity pertaining to distribution of the software without specific,\nwritten prior permission.  Addison Wesley Longman and the author make no\nrepresentations about the suitability of this software for any purpose.\nIt is provided \"as is\" without express or implied warranty.\n\nADDISON WESLEY LONGMAN AND THE AUTHOR DISCLAIM ALL WARRANTIES WITH REGARD\nTO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS.\nIN NO EVENT SHALL ADDISON WESLEY LONGMAN OR THE AUTHOR BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER\nRESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF\nCONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\nCONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n"
  },
  {
    "path": "stl侯杰源码/algo/Makefile",
    "content": "OUTPROGS = \\\n\t\tforeach1 foreach2 foreach3 \\\n\t\tcount1 minmax1 \\\n\t\tfind1 find2 \\\n\t\tsearchn1 search1 search2 \\\n\t\tfindend1 findof1 adjfind1 \\\n\t\tequal1 misma1 lexico1 \\\n\t\tcopy1 copy2 \\\n\t\ttransf1 transf2 \\\n\t\tswap1 fill1 generate \\\n\t\treplace1 replace2 \\\n\t\tremove1 remove2 \\\n\t\tunique1 unique2 unique3 \\\n\t\treverse1 rotate1 rotate2  \\\n\t\tperm1 random1 \\\n\t\tpart1 sort1 sort2 psort1 psort2 nth1 \\\n\t\theap1  \\\n\t\tbsearch1 includes bounds1 eqrange1 \\\n\t\tmerge1 setalgos imerge1 \\\n\t\taccu1 inner1 partsum1 adjdiff1 relabs\n\nCPPPROGS =\tcopy3\n\nHEADERS =\talgostuff.hpp\n\t\ninclude ../Makefile.h\n\n"
  },
  {
    "path": "stl侯杰源码/algo/accu1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll);\n\n    // process sum of elements\n    cout << \"sum: \"\n         << accumulate (coll.begin(), coll.end(),    // range\n                        0)                           // initial value\n         << endl;\n\n    // process sum of elements less 100\n    cout << \"sum: \"\n         << accumulate (coll.begin(), coll.end(),    // range\n                        -100)                        // initial value\n         << endl;\n\n    // process product of elements\n    cout << \"product: \"\n         << accumulate (coll.begin(), coll.end(),    // range\n                        1,                           // initial value\n                        multiplies<int>())           // operation\n         << endl;\n\n    // process product of elements (use 0 as initial value)\n    cout << \"product: \"\n         << accumulate (coll.begin(), coll.end(),    // range\n                        0,                           // initial value\n                        multiplies<int>())           // operation\n         << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/adjdiff1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n   deque<int> coll;\n\n   INSERT_ELEMENTS(coll,1,6);\n   PRINT_ELEMENTS(coll);\n\n   // print all differences between elements\n   adjacent_difference (coll.begin(), coll.end(),         // source\n                        ostream_iterator<int>(cout,\" \")); // dest.\n   cout << endl;\n\n   // print all sums with the predecessors\n   adjacent_difference (coll.begin(), coll.end(),         // source\n                        ostream_iterator<int>(cout,\" \"),  // dest.\n                        plus<int>());                     // operation\n   cout << endl;\n\n   // print all products between elements\n   adjacent_difference (coll.begin(), coll.end(),         // source\n                        ostream_iterator<int>(cout,\" \"),  // dest.\n                        multiplies<int>());               // operation\n   cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/adjfind1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\n// return whether the second object has double the value of the first\nbool doubled (int elem1, int elem2)\n{\n   return elem1 * 2 == elem2;\n}\n\nint main()\n{\n   vector<int> coll;\n\n   coll.push_back(1);\n   coll.push_back(3);\n   coll.push_back(2);\n   coll.push_back(4);\n   coll.push_back(5);\n   coll.push_back(5);\n   coll.push_back(0);\n\n   PRINT_ELEMENTS(coll,\"coll: \");\n\n   // search first two elements with equal value\n   vector<int>::iterator pos;\n   pos = adjacent_find (coll.begin(), coll.end());\n\n   if (pos != coll.end()) {\n       cout << \"first two elements with equal value have position \"\n            << distance(coll.begin(),pos) + 1\n            << endl;\n   }\n\n   // search first two elements for which the second has double the value of the first\n   pos = adjacent_find (coll.begin(), coll.end(),   // range\n                        doubled);                   // criterion\n\n   if (pos != coll.end()) {\n       cout << \"first two elements with second value twice the \"\n            << \"first have pos. \"\n            << distance(coll.begin(),pos) + 1\n            << endl;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/algostuff.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#ifndef ALGOSTUFF_HPP\n#define ALGOSTUFF_HPP\n\n#include <iostream>\n#include <vector>\n#include <deque>\n#include <list>\n#include <set>\n#include <map>\n#include <string>\n#include <algorithm>\n#include <iterator>\n#include <functional>\n#include <numeric>\n\n/* PRINT_ELEMENTS()\n * - prints optional C-string optcstr followed by\n * - all elements of the collection coll\n * - separated by spaces\n */\ntemplate <class T>\ninline void PRINT_ELEMENTS (const T& coll, const char* optcstr=\"\")\n{\n    typename T::const_iterator pos;\n\n    std::cout << optcstr;\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n\n/* INSERT_ELEMENTS (collection, first, last)\n * - fill values from first to last into the collection\n * - NOTE: NO half-open range\n */\ntemplate <class T>\ninline void INSERT_ELEMENTS (T& coll, int first, int last)\n{\n    for (int i=first; i<=last; ++i) {\n        coll.insert(coll.end(),i);\n    }\n}\n\n#endif /*ALGOSTUFF_HPP*/\n"
  },
  {
    "path": "stl侯杰源码/algo/bounds1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    INSERT_ELEMENTS(coll,1,9);\n    coll.sort ();\n    PRINT_ELEMENTS(coll);\n\n    // print first and last position 5 could get inserted\n    list<int>::iterator pos1, pos2;\n\n    pos1 = lower_bound (coll.begin(), coll.end(),\n                        5);\n    pos2 = upper_bound (coll.begin(), coll.end(),\n                        5);\n\n    cout << \"5 could get position \"\n         << distance(coll.begin(),pos1) + 1\n         << \" up to \"\n         << distance(coll.begin(),pos2) + 1\n         << \" without breaking the sorting\" << endl;\n\n    // insert 3 at the first possible position without breaking the sorting\n    coll.insert (lower_bound(coll.begin(),coll.end(),\n                             3),\n                 3);\n\n    // insert 7 at the last possible position without breaking the sorting\n    coll.insert (upper_bound(coll.begin(),coll.end(),\n                             7),\n                 7);\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/bsearch1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll);\n\n    // check existence of element with value 5\n    if (binary_search(coll.begin(), coll.end(), 5)) {\n        cout << \"5 is present\" << endl;\n    }\n    else {\n        cout << \"5 is not present\" << endl;\n    }\n\n    // check existence of element with value 42\n    if (binary_search(coll.begin(), coll.end(), 42)) {\n        cout << \"42 is present\" << endl;\n    }\n    else {\n        cout << \"42 is not present\" << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/copy1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;\n    list<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,9);\n\n    /* copy elements of coll1 into coll2\n     * - use back inserter to insert instead of overwrite\n     */\n    copy (coll1.begin(), coll1.end(),         // source range\n          back_inserter(coll2));              // destination range\n\n    /* print elements of coll2\n     * - copy elements to cout using an ostream iterator\n     */\n    copy (coll2.begin(), coll2.end(),         // source range\n          ostream_iterator<int>(cout,\" \"));   // destination range\n    cout << endl;\n\n    /* copy elements of coll1 into coll2 in reverse order\n     * - now overwriting\n     */\n    copy (coll1.rbegin(), coll1.rend(),       // source range\n          coll2.begin());                     // destination range\n\n    // print elements of coll2 again\n    copy (coll2.begin(), coll2.end(),         // source range\n          ostream_iterator<int>(cout,\" \"));   // destination range\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/copy2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    /* initialize source collection with ``..........abcdef..........''\n     */\n    vector<char> source(10,'.');\n    for (int c='a'; c<='f'; c++) {\n        source.push_back(c);\n    }\n    source.insert(source.end(),10,'.');\n    PRINT_ELEMENTS(source,\"source: \");\n\n    // copy all letters three elements in front of the 'a'\n    vector<char> c1(source.begin(),source.end());\n    copy (c1.begin()+10, c1.begin()+16,  // source range\n          c1.begin()+7);                 // destination range\n    PRINT_ELEMENTS(c1,\"c1:     \");\n\n    // copy all letters three elements behind the 'f'\n    vector<char> c2(source.begin(),source.end());\n    copy_backward (c2.begin()+10, c2.begin()+16,  // source range\n                   c2.begin()+19);                // destination range\n    PRINT_ELEMENTS(c2,\"c2:     \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/copy3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <algorithm>\n#include <iterator>\n#include <string>\nusing namespace std;\n\nint main()\n{\n    copy (istream_iterator<string>(cin),         // beginning of source\n          istream_iterator<string>(),            // end of source\n          ostream_iterator<string>(cout,\"\\n\"));  // destination\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/count1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nbool isEven (int elem)\n{\n    return elem % 2 == 0;\n}\n\nint main()\n{\n    vector<int> coll;\n    int num;\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // count and print elements with value 4\n    num = count (coll.begin(), coll.end(),       // range\n                 4);                             // value\n    cout << \"number of elements equal to 4:      \" << num << endl;\n\n    // count elements with even value\n    num = count_if (coll.begin(), coll.end(),    // range\n                    isEven);                     // criterion\n    cout << \"number of elements with even value: \" << num << endl;\n\n    // count elements that are greater than value 4\n    num = count_if (coll.begin(), coll.end(),    // range\n                    bind2nd(greater<int>(),4));  // criterion\n    cout << \"number of elements greater than 4:  \" << num << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/eqrange1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    INSERT_ELEMENTS(coll,1,9);\n    coll.sort ();\n    PRINT_ELEMENTS(coll);\n\n    // print first and last position 5 could get inserted\n    pair<list<int>::iterator,list<int>::iterator> range;\n\n    range = equal_range (coll.begin(), coll.end(),\n                         5);\n\n    cout << \"5 could get position \"\n         << distance(coll.begin(),range.first) + 1\n         << \" up to \"\n         << distance(coll.begin(),range.second) + 1\n         << \" without breaking the sorting\" << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/equal1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nbool bothEvenOrOdd (int elem1, int elem2)\n{\n    return elem1 % 2 == elem2 % 2;\n}\n\nint main()\n{\n    vector<int> coll1;\n    list<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,7);\n    INSERT_ELEMENTS(coll2,3,9);\n\n    PRINT_ELEMENTS(coll1,\"coll1: \");\n    PRINT_ELEMENTS(coll2,\"coll2: \");\n\n    // check whether both collections are equal\n    if (equal (coll1.begin(), coll1.end(),  // first range\n               coll2.begin())) {            // second range\n        cout << \"coll1 == coll2\" << endl;\n    }\n    else {\n        cout << \"coll1 != coll2\" << endl;\n    }\n\n    // check for corresponding even and odd elements\n    if (equal (coll1.begin(), coll1.end(),  // first range\n               coll2.begin(),               // second range\n               bothEvenOrOdd)) {            // comparison criterion\n        cout << \"even and odd elements correspond\" << endl;\n    }\n    else {\n        cout << \"even and odd elements do not correspond\" << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/fill1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    // print ten times 7.7\n    fill_n(ostream_iterator<float>(cout, \" \"), // beginning of destination\n           10,                                 // count\n           7.7);                               // new value\n    cout << endl;\n\n    list<string> coll;\n\n    // insert \"hello\" nine times\n    fill_n(back_inserter(coll),       // beginning of destination\n           9,                         // count\n           \"hello\");                  // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // overwrite all elements with \"again\"\n    fill(coll.begin(), coll.end(),    // destination\n         \"again\");                    // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // replace all but two elements with \"hi\"\n    fill_n(coll.begin(),              // beginning of destination\n           coll.size()-2,             // count\n           \"hi\");                     // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // replace the second and up to the last element but one with \"hmmm\"\n    list<string>::iterator pos1, pos2;\n    pos1 = coll.begin();\n    pos2 = coll.end();\n    fill (++pos1, --pos2,              // destination\n          \"hmmm\");                     // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/find1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    INSERT_ELEMENTS(coll,1,9);\n\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // find first element with value 4\n    list<int>::iterator pos1;\n    pos1 = find (coll.begin(), coll.end(),    // range\n                 4);                          // value\n\n    /* find second element with value 4\n     * - note: continue the search behind the first 4 (if any)\n     */\n    list<int>::iterator pos2;\n    if (pos1 != coll.end()) {\n        pos2 = find (++pos1, coll.end(),      // range\n                     4);                      // value\n    }\n\n    /* print all elements from first to second 4 (both included)\n     * - note: now we need the position of the first 4 again (if any)\n     * - note: we have to pass the position behind the second 4 (if any)\n     */\n    if (pos1!=coll.end() && pos2!=coll.end()) {\n        copy (--pos1, ++pos2,\n              ostream_iterator<int>(cout,\" \"));\n        cout << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/find2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n    vector<int>::iterator pos;\n\n    INSERT_ELEMENTS(coll,1,9);\n\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // find first element greater than 3\n    pos = find_if (coll.begin(), coll.end(),    // range\n                   bind2nd(greater<int>(),3));  // criterion\n\n    // print its position\n    cout << \"the \"\n         << distance(coll.begin(),pos) + 1\n         << \". element is the first greater than 3\" << endl;\n\n    // find first element divisible by 3\n    pos = find_if (coll.begin(), coll.end(),\n                   not1(bind2nd(modulus<int>(),3)));\n\n    // print its position\n    cout << \"the \"\n         << distance(coll.begin(),pos) + 1\n         << \". element is the first divisible by 3\" << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/findend1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll;\n    list<int> subcoll;\n\n    INSERT_ELEMENTS(coll,1,7);\n    INSERT_ELEMENTS(coll,1,7);\n\n    INSERT_ELEMENTS(subcoll,3,6);\n\n    PRINT_ELEMENTS(coll,   \"coll:    \");\n    PRINT_ELEMENTS(subcoll,\"subcoll: \");\n\n    // search last occurrence of subcoll in coll\n    deque<int>::iterator pos;\n    pos = find_end (coll.begin(), coll.end(),         // range\n                    subcoll.begin(), subcoll.end());  // subrange\n\n    // loop while subcoll found as subrange of coll\n    deque<int>::iterator end(coll.end());\n    while (pos != end) { \n        // print position of first element\n        cout << \"subcoll found starting with element \"\n             << distance(coll.begin(),pos) + 1\n             << endl;\n\n        // search next occurrence of subcoll\n        end = pos;\n        pos = find_end (coll.begin(), end,               // range\n                        subcoll.begin(), subcoll.end()); // subrange\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/findof1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n    list<int> searchcoll;\n\n    INSERT_ELEMENTS(coll,1,11);\n    INSERT_ELEMENTS(searchcoll,3,5);\n\n    PRINT_ELEMENTS(coll,      \"coll:       \");\n    PRINT_ELEMENTS(searchcoll,\"searchcoll: \");\n\n    // search first occurrence of an element of searchcoll in coll\n    vector<int>::iterator pos;\n    pos = find_first_of (coll.begin(), coll.end(),     // range\n                         searchcoll.begin(),   // beginning of search set\n                         searchcoll.end());    // end of search set\n    cout << \"first element of searchcoll in coll is element \"\n         << distance(coll.begin(),pos) + 1\n         << endl;\n\n    // search last occurrence of an element of searchcoll in coll\n    vector<int>::reverse_iterator rpos;\n    rpos = find_first_of (coll.rbegin(), coll.rend(),  // range\n                          searchcoll.begin(),  // beginning of search set\n                          searchcoll.end());   // end of search set\n    cout << \"last element of searchcoll in coll is element \"\n         << distance(coll.begin(),rpos.base())\n         << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/foreach1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\n// function called for each element\nvoid print (int elem)\n{\n    cout << elem << ' ';\n}\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n\n    // call print() for each element\n    for_each (coll.begin(), coll.end(),  // range\n              print);                    // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/foreach2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\n// function object that adds the value with which it is initialized\ntemplate <class T>\nclass AddValue {\n  private:\n    T theValue;    // value to add\n  public:\n    // constructor initializes the value to add\n    AddValue (const T& v) : theValue(v) {\n    }\n\n    // the function call for the element adds the value\n    void operator() (T& elem) const {\n        elem += theValue;\n    }\n};\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n\n    // add ten to each element\n    for_each (coll.begin(), coll.end(),       // range\n              AddValue<int>(10));             // operation\n    PRINT_ELEMENTS(coll);\n\n    // add value of first element to each element\n    for_each (coll.begin(), coll.end(),       // range\n              AddValue<int>(*coll.begin()));  // operation\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/foreach3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\n// function object to process the mean value\nclass MeanValue {\n  private:\n    long num;    // number of elements\n    long sum;    // sum of all element values\n  public:\n    // constructor\n    MeanValue () : num(0), sum(0) {\n    }\n\n    // function call\n    // - process one more element of the sequence\n    void operator() (int elem) {\n        num++;          // increment count\n        sum += elem;    // add value\n    }\n\n    // return mean value (implicit type conversion)\n    operator double() {\n        return static_cast<double>(sum) / static_cast<double>(num);\n    }\n};\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,8);\n\n    // process and print mean value\n    double mv = for_each (coll.begin(), coll.end(),  // range\n                          MeanValue());              // operation\n    cout << \"mean value: \" << mv << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/generate.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdlib>\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert five random numbers\n    generate_n (back_inserter(coll),      // beginning of destination range\n                5,                        // count\n                rand);                    // new value generator\n    PRINT_ELEMENTS(coll);\n\n    // overwrite with five new random numbers\n    generate (coll.begin(), coll.end(),   // destination range\n              rand);                      // new value generator\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/heap1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,3,7);\n    INSERT_ELEMENTS(coll,5,9);\n    INSERT_ELEMENTS(coll,1,4);\n\n    PRINT_ELEMENTS (coll, \"on entry:           \");\n\n    // convert collection into a heap\n    make_heap (coll.begin(), coll.end());\n\n    PRINT_ELEMENTS (coll, \"after make_heap():  \");\n\n    // pop next element out of the heap\n    pop_heap (coll.begin(), coll.end());\n    coll.pop_back();\n\n    PRINT_ELEMENTS (coll, \"after pop_heap():   \");\n\n    // push new element into the heap\n    coll.push_back (17);\n    push_heap (coll.begin(), coll.end());\n\n    PRINT_ELEMENTS (coll, \"after push_heap():  \");\n\n    /* convert heap into a sorted collection\n     * - NOTE: after the call it is no longer a heap\n     */\n    sort_heap (coll.begin(), coll.end());\n\n    PRINT_ELEMENTS (coll, \"after sort_heap():  \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/imerge1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert two sorted sequences\n    INSERT_ELEMENTS(coll,1,7);\n    INSERT_ELEMENTS(coll,1,8);\n    PRINT_ELEMENTS(coll);\n\n    // find beginning of second part (element after 7)\n    list<int>::iterator pos;\n    pos = find (coll.begin(), coll.end(),    // range\n                7);                          // value\n    ++pos;\n\n    // merge into one sorted range\n    inplace_merge (coll.begin(), pos, coll.end());\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/includes.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n    vector<int> search;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll:   \");\n\n    search.push_back(3);\n    search.push_back(4);\n    search.push_back(7);\n    PRINT_ELEMENTS(search,\"search: \");\n\n    // check whether all elements in search are also in coll\n    if (includes (coll.begin(), coll.end(),\n                  search.begin(), search.end())) {\n        cout << \"all elements of search are also in coll\"\n             << endl;\n    }\n    else {\n        cout << \"not all elements of search are also in coll\"\n             << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/inner1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,1,6);\n    PRINT_ELEMENTS(coll);\n\n    /* process sum of all products\n     * (0 + 1*1 + 2*2 + 3*3 + 4*4 + 5*5 + 6*6)\n     */\n    cout << \"inner product: \"\n         << inner_product (coll.begin(), coll.end(),  // first range\n                           coll.begin(),              // second range\n                           0)                         // initial value\n         << endl;\n\n    /* process sum of 1*6 ... 6*1\n     * (0 + 1*6 + 2*5 + 3*4 + 4*3 + 5*2 + 6*1)\n     */\n    cout << \"inner reverse product: \"\n         << inner_product (coll.begin(), coll.end(),  // first range\n                           coll.rbegin(),             // second range\n                           0)                         // initial value\n         << endl;\n\n    /* process product of all sums\n     * (1 * 1+1 * 2+2 * 3+3 * 4+4 * 5+5 * 6+6)\n     */\n    cout << \"product of sums: \"\n         << inner_product (coll.begin(), coll.end(),  // first range\n                           coll.begin(),              // second range\n                           1,                         // initial value\n                           multiplies<int>(),       // outer operation\n                           plus<int>())             // inner operation\n         << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/lexico1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nvoid printCollection (const list<int>& l)\n{\n    PRINT_ELEMENTS(l);\n}\n\nbool lessForCollection (const list<int>& l1, const list<int>& l2)\n{\n    return lexicographical_compare\n                (l1.begin(), l1.end(),   // first range\n                 l2.begin(), l2.end());  // second range\n}\n\nint main()\n{\n    list<int> c1, c2, c3, c4;\n\n    // fill all collections with the same starting values\n    INSERT_ELEMENTS(c1,1,5);\n    c4 = c3 = c2 = c1;\n\n    // and now some differences\n    c1.push_back(7);\n    c3.push_back(2);\n    c3.push_back(0);\n    c4.push_back(2);\n\n    // create collection of collections\n    vector<list<int> > cc;\n\n    cc.push_back(c1);\n    cc.push_back(c2);\n    cc.push_back(c3);\n    cc.push_back(c4);\n    cc.push_back(c3);\n    cc.push_back(c1);\n    cc.push_back(c4);\n    cc.push_back(c2);\n\n    // print all collections\n    for_each (cc.begin(), cc.end(),\n              printCollection);\n    cout << endl;\n\n    // sort collection lexicographically\n    sort (cc.begin(), cc.end(),    // range\n          lessForCollection);      // sorting criterion\n\n    // print all collections again\n    for_each (cc.begin(), cc.end(),\n              printCollection);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/merge1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll1;\n    set<int> coll2;\n\n    // fill both collections with some sorted elements\n    INSERT_ELEMENTS(coll1,1,6);\n    INSERT_ELEMENTS(coll2,3,8);\n\n    PRINT_ELEMENTS(coll1,\"coll1:  \");\n    PRINT_ELEMENTS(coll2,\"coll2:  \");\n\n    // print merged sequence\n    cout << \"merged: \";\n    merge (coll1.begin(), coll1.end(),\n           coll2.begin(), coll2.end(),\n           ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/minmax1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdlib>\n#include \"algostuff.hpp\"\nusing namespace std;\n\nbool absLess (int elem1, int elem2)\n{\n    return abs(elem1) < abs(elem2);\n}\n\nint main()\n{\n    deque<int> coll;\n\n    INSERT_ELEMENTS(coll,2,8);\n    INSERT_ELEMENTS(coll,-3,5);\n\n    PRINT_ELEMENTS(coll);\n\n    // process and print minimum and maximum\n    cout << \"minimum: \"\n         << *min_element(coll.begin(),coll.end())\n         << endl;\n    cout << \"maximum: \"\n         << *max_element(coll.begin(),coll.end())\n         << endl;\n\n    // process and print minimum and maximum of absolute values\n    cout << \"minimum of absolute values: \"\n         << *min_element(coll.begin(),coll.end(),\n                         absLess)\n         << endl;\n    cout << \"maximum of absolute values: \"\n         << *max_element(coll.begin(),coll.end(),\n                         absLess)\n         << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/misma1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;\n    list<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,6);\n\n    for (int i=1; i<=16; i*=2) {\n        coll2.push_back(i);\n    }\n    coll2.push_back(3);\n\n    PRINT_ELEMENTS(coll1,\"coll1: \");\n    PRINT_ELEMENTS(coll2,\"coll2: \");\n\n    // find first mismatch\n    pair<vector<int>::iterator,list<int>::iterator> values;\n    values = mismatch (coll1.begin(), coll1.end(),  // first range\n                       coll2.begin());              // second range\n    if (values.first == coll1.end()) {\n        cout << \"no mismatch\" << endl;\n    }\n    else {\n        cout << \"first mismatch: \"\n             << *values.first  << \" and \"\n             << *values.second << endl;\n    }\n\n    /* find first position where the element of coll1 is not\n     * less than the corresponding element of coll2\n     */\n    values = mismatch (coll1.begin(), coll1.end(),  // first range\n                       coll2.begin(),               // second range\n                       less_equal<int>());          // criterion\n    if (values.first == coll1.end()) {\n        cout << \"always less-or-equal\" << endl;\n    }\n    else {\n        cout << \"not less-or-equal: \"\n             << *values.first << \" and \"\n             << *values.second << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/nth1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll;\n\n    INSERT_ELEMENTS(coll,3,7);\n    INSERT_ELEMENTS(coll,2,6);\n    INSERT_ELEMENTS(coll,1,5);\n    PRINT_ELEMENTS(coll);\n\n    // extract the four lowest elements\n    nth_element (coll.begin(),     // beginning of range\n                 coll.begin()+3,   // element that should be sorted correctly\n                 coll.end());      // end of range\n\n    // print them\n    cout << \"the four lowest elements are:  \";\n    copy (coll.begin(), coll.begin()+4,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // extract the four highest elements\n    nth_element (coll.begin(),     // beginning of range\n                 coll.end()-4,     // element that should be sorted correctly\n                 coll.end());      // end of range\n\n    // print them\n    cout << \"the four highest elements are: \";\n    copy (coll.end()-4, coll.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // extract the four highest elements (second version)\n    nth_element (coll.begin(),     // beginning of range\n                 coll.begin()+3,   // element that should be sorted correctly\n                 coll.end(),       // end of range\n                 greater<int>());  // sorting criterion\n\n    // print them\n    cout << \"the four highest elements are: \";\n    copy (coll.begin(), coll.begin()+4,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/part1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n   vector<int> coll1;\n   vector<int> coll2;\n\n   INSERT_ELEMENTS(coll1,1,9);\n   INSERT_ELEMENTS(coll2,1,9);\n   PRINT_ELEMENTS(coll1,\"coll1: \");\n   PRINT_ELEMENTS(coll2,\"coll2: \");\n   cout << endl;\n\n   // move all even elements to the front\n   vector<int>::iterator pos1, pos2;\n   pos1 = partition(coll1.begin(), coll1.end(),         // range\n                    not1(bind2nd(modulus<int>(),2)));   // criterion\n   pos2 = stable_partition(coll2.begin(), coll2.end(),       // range\n                           not1(bind2nd(modulus<int>(),2))); // crit.\n\n   // print collections and first odd element\n   PRINT_ELEMENTS(coll1,\"coll1: \");\n   cout << \"first odd element: \" << *pos1 << endl;\n   PRINT_ELEMENTS(coll2,\"coll2: \");\n   cout << \"first odd element: \" << *pos2 << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/partsum1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,6);\n    PRINT_ELEMENTS(coll);\n\n    // print all partial sums\n    partial_sum (coll.begin(), coll.end(),          // source range\n                 ostream_iterator<int>(cout,\" \"));  // destination\n    cout << endl;\n\n    // print all partial products\n    partial_sum (coll.begin(), coll.end(),          // source range\n                 ostream_iterator<int>(cout,\" \"),   // destination\n                 multiplies<int>());                // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/perm1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n    INSERT_ELEMENTS(coll,1,3);\n    PRINT_ELEMENTS(coll,\"on entry:  \");\n\n    /* permute elements until they are sorted\n     * - runs through all permutations because the elements are sorted now\n     */\n    while (next_permutation(coll.begin(),coll.end())) {\n        PRINT_ELEMENTS(coll,\" \");\n    }\n    PRINT_ELEMENTS(coll,\"afterward: \");\n\n    /* permute until descending sorted\n     * - this is the next permutation after ascending sorting\n     * - so the loop ends immediately\n     */\n    while (prev_permutation(coll.begin(),coll.end())) {\n        PRINT_ELEMENTS(coll,\" \");\n    }\n    PRINT_ELEMENTS(coll,\"now:       \");\n\n    /* permute elements until they are sorted in descending order\n     * - runs through all permutations because the elements are sorted\n     *    in descending order now\n     */\n    while (prev_permutation(coll.begin(),coll.end())) {\n        PRINT_ELEMENTS(coll,\" \");\n    }\n    PRINT_ELEMENTS(coll,\"afterward: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/psort1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll;\n\n    INSERT_ELEMENTS(coll,3,7);\n    INSERT_ELEMENTS(coll,2,6);\n    INSERT_ELEMENTS(coll,1,5);\n    PRINT_ELEMENTS(coll);\n\n    // sort until the first five elements are sorted\n    partial_sort (coll.begin(),      // beginning of the range\n                  coll.begin()+5,    // end of sorted range\n                  coll.end());       // end of full range\n    PRINT_ELEMENTS(coll);\n\n    // sort inversely until the first five elements are sorted\n    partial_sort (coll.begin(),      // beginning of the range\n                  coll.begin()+5,    // end of sorted range\n                  coll.end(),        // end of full range\n                  greater<int>());   // sorting criterion\n    PRINT_ELEMENTS(coll);\n\n    // sort all elements\n    partial_sort (coll.begin(),      // beginning of the range\n                  coll.end(),        // end of sorted range\n                  coll.end());       // end of full range\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/psort2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll1;\n    vector<int> coll6(6);      // initialize with 6 elements\n    vector<int> coll30(30);    // initialize with 30 elements\n\n    INSERT_ELEMENTS(coll1,3,7);\n    INSERT_ELEMENTS(coll1,2,6);\n    INSERT_ELEMENTS(coll1,1,5);\n    PRINT_ELEMENTS(coll1);\n\n    // copy elements of coll1 sorted into coll6\n    vector<int>::iterator pos6;\n    pos6 = partial_sort_copy (coll1.begin(), coll1.end(),\n                              coll6.begin(), coll6.end());\n\n    // print all copied elements\n    copy (coll6.begin(), pos6,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // copy elements of coll1 sorted into coll30\n    vector<int>::iterator pos30;\n    pos30 = partial_sort_copy (coll1.begin(), coll1.end(),\n                               coll30.begin(), coll30.end(),\n                               greater<int>());\n\n    // print all copied elements\n    copy (coll30.begin(), pos30,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/random1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdlib>\n#include \"algostuff.hpp\"\nusing namespace std;\n\nclass MyRandom {\n  public:\n    ptrdiff_t operator() (ptrdiff_t max) {\n        double tmp;\n        tmp = static_cast<double>(rand())\n                / static_cast<double>(RAND_MAX);\n        return static_cast<ptrdiff_t>(tmp * max);\n    }\n};\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll:     \");\n\n    // shuffle all elements randomly\n    random_shuffle (coll.begin(), coll.end());\n\n    PRINT_ELEMENTS(coll,\"shuffled: \");\n\n    // sort them again\n    sort (coll.begin(), coll.end());\n    PRINT_ELEMENTS(coll,\"sorted:   \");\n\n    /* shuffle elements with self-written random number generator\n     * - to pass an lvalue we have to use a temporary object\n     */\n    MyRandom rd;\n    random_shuffle (coll.begin(), coll.end(),    // range\n                    rd);                 // random number generator\n\n    PRINT_ELEMENTS(coll,\"shuffled: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/relabs.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    coll.push_back(17);\n    coll.push_back(-3);\n    coll.push_back(22);\n    coll.push_back(13);\n    coll.push_back(13);\n    coll.push_back(-9);\n    PRINT_ELEMENTS(coll,\"coll:     \");\n\n    // convert into relative values\n    adjacent_difference (coll.begin(), coll.end(),   // source\n                         coll.begin());              // destination\n    PRINT_ELEMENTS(coll,\"relative: \");\n     \n    // convert into absolute values\n    partial_sum (coll.begin(), coll.end(),           // source\n                 coll.begin());                      // destination\n    PRINT_ELEMENTS(coll,\"absolute: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/remove1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,2,6);\n    INSERT_ELEMENTS(coll,4,9);\n    INSERT_ELEMENTS(coll,1,7);\n    PRINT_ELEMENTS(coll,\"coll:               \");\n\n    // remove all elements with value 5\n    vector<int>::iterator pos;\n    pos = remove(coll.begin(), coll.end(),   // range\n                 5);                         // value to remove\n\n    PRINT_ELEMENTS(coll,\"size not changed:   \");\n\n    // erase the ``removed'' elements in the container\n    coll.erase(pos, coll.end());\n    PRINT_ELEMENTS(coll,\"size changed:       \");\n\n    // remove all elements less than 4\n    coll.erase(remove_if(coll.begin(), coll.end(),  // range\n                         bind2nd(less<int>(),4)),   // remove criterion\n               coll.end());\n    PRINT_ELEMENTS(coll,\"<4 removed:         \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/remove2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll1;\n\n    INSERT_ELEMENTS(coll1,1,6);\n    INSERT_ELEMENTS(coll1,1,9);\n    PRINT_ELEMENTS(coll1);\n\n    // print elements without those having the value 3\n    remove_copy(coll1.begin(), coll1.end(),       // source\n                ostream_iterator<int>(cout,\" \"),  // destination\n                3);                               // removed value\n    cout << endl;\n\n    // print elements without those having a value greater than 4\n    remove_copy_if(coll1.begin(), coll1.end(),      // source\n                   ostream_iterator<int>(cout,\" \"), // destination\n                   bind2nd(greater<int>(),4));      // removed elements\n    cout << endl;\n\n    // copy all elements greater than 3 into a multiset\n    multiset<int> coll2;\n    remove_copy_if(coll1.begin(), coll1.end(),    // source\n                   inserter(coll2,coll2.end()),   // destination\n                   bind2nd(less<int>(),4));       // elements not copied\n    PRINT_ELEMENTS(coll2);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/replace1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,2,7);\n    INSERT_ELEMENTS(coll,4,9);\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // replace all elements with value 6 with 42\n    replace (coll.begin(), coll.end(),     // range\n             6,                            // old value\n             42);                          // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // replace all elements with value less than 5 with 0\n    replace_if (coll.begin(), coll.end(),  // range\n                bind2nd(less<int>(),5),    // criterion for replacement\n                0);                        // new value\n    PRINT_ELEMENTS(coll,\"coll: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/replace2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    INSERT_ELEMENTS(coll,2,6);\n    INSERT_ELEMENTS(coll,4,9);\n    PRINT_ELEMENTS(coll);\n\n    // print all elements with value 5 replaced with 55\n    replace_copy(coll.begin(), coll.end(),           // source\n                 ostream_iterator<int>(cout,\" \"),    // destination\n                 5,                                  // old value\n                 55);                                // new value\n    cout << endl;\n\n    // print all elements with a value less than 5 replaced with 42\n    replace_copy_if(coll.begin(), coll.end(),        // source\n                    ostream_iterator<int>(cout,\" \"), // destination\n                    bind2nd(less<int>(),5),     // replacement criterion\n                    42);                        // new value\n    cout << endl;\n\n    // print each element while each odd element is replaced with 0\n    replace_copy_if(coll.begin(), coll.end(),        // source\n                    ostream_iterator<int>(cout,\" \"), // destination\n                    bind2nd(modulus<int>(),2),  // replacement criterion\n                    0);                         // new value\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/reverse1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // reverse order of elements\n    reverse (coll.begin(), coll.end());\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // reverse order from second to last element but one\n    reverse (coll.begin()+1, coll.end()-1);\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    // print all of them in reverse order\n    reverse_copy (coll.begin(), coll.end(),           // source\n                  ostream_iterator<int>(cout,\" \"));   // destination\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/rotate1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll:      \");\n\n    // rotate one element to the left\n    rotate (coll.begin(),      // beginning of range\n            coll.begin() + 1,  // new first element\n            coll.end());       // end of range\n    PRINT_ELEMENTS(coll,\"one left:  \");\n\n    // rotate two elements to the right\n    rotate (coll.begin(),      // beginning of range\n            coll.end() - 2,    // new first element\n            coll.end());       // end of range\n    PRINT_ELEMENTS(coll,\"two right: \");\n\n    // rotate so that element with value 4 is the beginning\n    rotate (coll.begin(),                     // beginning of range\n            find(coll.begin(),coll.end(),4),  // new first element\n            coll.end());                      // end of range\n    PRINT_ELEMENTS(coll,\"4 first:   \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/rotate2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    set<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll);\n\n    // print elements rotated one element to the left\n    set<int>::iterator pos = coll.begin();\n    advance(pos,1);\n    rotate_copy(coll.begin(),                     // beginning of source\n                pos,                              // new first element\n                coll.end(),                       // end of source\n                ostream_iterator<int>(cout,\" \")); // destination\n    cout << endl;\n\n    // print elements rotated two elements to the right\n    pos = coll.end();\n    advance(pos,-2);\n    rotate_copy(coll.begin(),                     // beginning of source\n                pos,                              // new first element\n                coll.end(),                       // end of source\n                ostream_iterator<int>(cout,\" \")); // destination\n    cout << endl;\n\n    // print elements rotated so that element with value 4 is the beginning\n    rotate_copy(coll.begin(),                     // beginning of source\n                coll.find(4),                     // new first element\n                coll.end(),                       // end of source\n                ostream_iterator<int>(cout,\" \")); // destination\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/search1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll;\n    list<int> subcoll;\n\n    INSERT_ELEMENTS(coll,1,7);\n    INSERT_ELEMENTS(coll,1,7);\n\n    INSERT_ELEMENTS(subcoll,3,6);\n\n    PRINT_ELEMENTS(coll,   \"coll:    \");\n    PRINT_ELEMENTS(subcoll,\"subcoll: \");\n\n    // search first occurrence of subcoll in coll\n    deque<int>::iterator pos;\n    pos = search (coll.begin(), coll.end(),         // range\n                  subcoll.begin(), subcoll.end());  // subrange\n\n    // loop while subcoll found as subrange of coll\n    while (pos != coll.end()) { \n        // print position of first element\n        cout << \"subcoll found starting with element \"\n             << distance(coll.begin(),pos) + 1\n             << endl;\n\n        // search next occurrence of subcoll\n        ++pos;\n        pos = search (pos, coll.end(),                  // range\n                      subcoll.begin(), subcoll.end());  // subrange\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/search2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\n// checks whether an element is even or odd\nbool checkEven (int elem, bool even)\n{\n    if (even) {\n        return elem % 2 == 0;\n    }\n    else {\n        return elem % 2 == 1;\n    }\n}\n\nint main()\n{\n    vector<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    PRINT_ELEMENTS(coll,\"coll: \");\n\n    /* arguments for checkEven()\n     * - check for: ``even odd even''\n     */\n    bool checkEvenArgs[3] = { true, false, true };\n\n    // search first subrange in coll\n    vector<int>::iterator pos;\n    pos = search (coll.begin(), coll.end(),       // range\n                  checkEvenArgs, checkEvenArgs+3, // subrange values\n                  checkEven);                     // subrange criterion\n\n    // loop while subrange found\n    while (pos != coll.end()) {\n        // print position of first element\n        cout << \"subrange found starting with element \"\n             << distance(coll.begin(),pos) + 1\n             << endl;\n\n        // search next subrange in coll\n        pos = search (++pos, coll.end(),              // range\n                      checkEvenArgs, checkEvenArgs+3, // subr. values\n                      checkEven);                     // subr. criterion\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/searchn1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n   deque<int> coll;\n\n   INSERT_ELEMENTS(coll,1,9);\n   PRINT_ELEMENTS(coll);\n\n   // find four consecutive elements with value 3\n   deque<int>::iterator pos;\n   pos = search_n (coll.begin(), coll.end(),    // range\n                   4,                           // count\n                   3);                          // value\n\n   // print result\n   if (pos != coll.end()) {\n       cout << \"four consecutive elements with value 3 \"\n            << \"start with \" << distance(coll.begin(),pos) +1\n            << \". element\" << endl;\n   }\n   else {\n       cout << \"no four consecutive elements with value 3 found\"\n            << endl;\n   }\n\n   // find four consecutive elements with value greater than 3\n   pos = search_n (coll.begin(), coll.end(),    // range\n                   4,                           // count\n                   3,                           // value\n                   greater<int>());             // criterion\n\n   // print result\n   if (pos != coll.end()) {\n       cout << \"four consecutive elements with value > 3 \"\n            << \"start with \" << distance(coll.begin(),pos) +1\n            << \". element\" << endl;\n   }\n   else {\n       cout << \"no four consecutive elements with value > 3 found\"\n            << endl;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/setalgos.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    int c1[] = { 1, 2, 2, 4, 6, 7, 7, 9 };\n    int num1 = sizeof(c1) / sizeof(int);\n\n    int c2[] = { 2, 2, 2, 3, 6, 6, 8, 9 };\n    int num2 = sizeof(c2) / sizeof(int);\n\n    // print source ranges\n    cout << \"c1:                         \" ;\n    copy (c1, c1+num1,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n    cout << \"c2:                         \" ;\n    copy (c2, c2+num2,\n          ostream_iterator<int>(cout,\" \"));\n    cout << '\\n' << endl;\n\n    // sum the ranges by using merge()\n    cout << \"merge():                    \";\n    merge (c1, c1+num1,\n           c2, c2+num2,\n           ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // unite the ranges by using set_union()\n    cout << \"set_union():                \";\n    set_union (c1, c1+num1,\n               c2, c2+num2,\n               ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // intersect the ranges by using set_intersection()\n    cout << \"set_intersection():         \";\n    set_intersection (c1, c1+num1,\n                      c2, c2+num2,\n                      ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // determine elements of first range without elements of second range\n    // by using set_difference()\n    cout << \"set_difference():           \";\n    set_difference (c1, c1+num1,\n                    c2, c2+num2,\n                    ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // determine difference the ranges with set_symmetric_difference()\n    cout << \"set_symmetric_difference(): \";\n    set_symmetric_difference (c1, c1+num1,\n                              c2, c2+num2,\n                              ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/sort1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    deque<int> coll;\n\n    INSERT_ELEMENTS(coll,1,9);\n    INSERT_ELEMENTS(coll,1,9);\n\n    PRINT_ELEMENTS(coll,\"on entry: \");\n\n    // sort elements\n    sort (coll.begin(), coll.end());\n\n    PRINT_ELEMENTS(coll,\"sorted:   \");\n\n    // sorted reverse\n    sort (coll.begin(), coll.end(),    // range\n          greater<int>());             // sorting criterion\n\n    PRINT_ELEMENTS(coll,\"sorted >: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/sort2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nbool lessLength (const string& s1, const string& s2)\n{\n    return s1.length() < s2.length();\n}\n\nint main()\n{\n    vector<string> coll1;\n    vector<string> coll2;\n\n    // fill both collections with the same elements\n    coll1.push_back (\"1xxx\");\n    coll1.push_back (\"2x\");\n    coll1.push_back (\"3x\");\n    coll1.push_back (\"4x\");\n    coll1.push_back (\"5xx\");\n    coll1.push_back (\"6xxxx\");\n    coll1.push_back (\"7xx\");\n    coll1.push_back (\"8xxx\");\n    coll1.push_back (\"9xx\");\n    coll1.push_back (\"10xxx\");\n    coll1.push_back (\"11\");\n    coll1.push_back (\"12\");\n    coll1.push_back (\"13\");\n    coll1.push_back (\"14xx\");\n    coll1.push_back (\"15\");\n    coll1.push_back (\"16\");\n    coll1.push_back (\"17\");\n    coll2 = coll1;\n\n    PRINT_ELEMENTS(coll1,\"on entry:\\n \");\n\n    // sort (according to the length of the strings)\n    sort (coll1.begin(), coll1.end(),           // range\n          lessLength);                          // criterion\n    stable_sort (coll2.begin(), coll2.end(),    // range\n                 lessLength);                   // criterion\n\n    PRINT_ELEMENTS(coll1,\"\\nwith sort():\\n \");\n    PRINT_ELEMENTS(coll2,\"\\nwith stable_sort():\\n \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/swap1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;\n    deque<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,9);\n    INSERT_ELEMENTS(coll2,11,23);\n\n    PRINT_ELEMENTS(coll1,\"coll1: \");\n    PRINT_ELEMENTS(coll2,\"coll2: \");\n\n    // swap elements of coll1 with corresponding elements of coll2\n    deque<int>::iterator pos;\n    pos = swap_ranges (coll1.begin(), coll1.end(),  // first range\n                       coll2.begin());              // second range\n\n    PRINT_ELEMENTS(coll1,\"\\ncoll1: \");\n    PRINT_ELEMENTS(coll2,\"coll2: \");\n    if (pos != coll2.end()) {\n        cout << \"first element not modified: \"\n             << *pos << endl;\n    }\n\n    // mirror first three with last three elements in coll2\n    swap_ranges (coll2.begin(), coll2.begin()+3,    // first range\n                 coll2.rbegin());                   // second range\n\n    PRINT_ELEMENTS(coll2,\"\\ncoll2: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/transf1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;\n    list<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,9);\n    PRINT_ELEMENTS(coll1,\"coll1:   \");\n\n    // negate all elements in coll1\n    transform (coll1.begin(), coll1.end(),      // source range\n               coll1.begin(),                   // destination range\n               negate<int>());                  // operation\n    PRINT_ELEMENTS(coll1,\"negated: \");\n\n    // transform elements of coll1 into coll2 with ten times their value\n    transform (coll1.begin(), coll1.end(),      // source range\n               back_inserter(coll2),            // destination range\n               bind2nd(multiplies<int>(),10));  // operation\n    PRINT_ELEMENTS(coll2,\"coll2:   \");\n\n    // print coll2 negatively and in reverse order\n    transform (coll2.rbegin(), coll2.rend(),    // source range\n               ostream_iterator<int>(cout,\" \"), // destination range\n               negate<int>());                  // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/transf2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;\n    list<int> coll2;\n\n    INSERT_ELEMENTS(coll1,1,9);\n    PRINT_ELEMENTS(coll1,\"coll1:   \");\n\n    // square each element\n    transform (coll1.begin(), coll1.end(),       // first source range\n               coll1.begin(),                    // second source range\n               coll1.begin(),                    // destination range\n               multiplies<int>());               // operation\n    PRINT_ELEMENTS(coll1,\"squared: \");\n\n    /* add each element traversed forward with each element traversed backward\n     * and insert result into coll2\n     */\n    transform (coll1.begin(), coll1.end(),       // first source range\n               coll1.rbegin(),                   // second source range\n               back_inserter(coll2),             // destination range\n               plus<int>());                     // operation\n    PRINT_ELEMENTS(coll2,\"coll2:   \");\n\n    // print differences of two corresponding elements\n    cout << \"diff:    \";\n    transform (coll1.begin(), coll1.end(),       // first source range\n               coll2.begin(),                    // second source range\n               ostream_iterator<int>(cout, \" \"), // destination range\n               minus<int>());                    // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/unique1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nint main()\n{\n    // source data\n    int source[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7,\n                      5, 4, 4 };\n    int sourceNum = sizeof(source)/sizeof(source[0]);\n\n    list<int> coll;\n\n    // initialize coll with elements from source\n    copy (source, source+sourceNum,           // source\n          back_inserter(coll));               // destination\n    PRINT_ELEMENTS(coll);\n\n    // remove consecutive duplicates\n    list<int>::iterator pos;\n    pos = unique (coll.begin(), coll.end());\n\n    /* print elements not removed\n     * - use new logical end\n     */\n    copy (coll.begin(), pos,                  // source\n          ostream_iterator<int>(cout,\" \"));   // destination\n    cout << \"\\n\\n\";\n\n    // reinitialize coll with elements from source\n    copy (source, source+sourceNum,           // source\n          coll.begin());                      // destination\n    PRINT_ELEMENTS(coll);\n\n    // remove elements if there was a previous greater element\n    coll.erase (unique (coll.begin(), coll.end(),\n                        greater<int>()),\n                coll.end());\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/unique2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"algostuff.hpp\"\nusing namespace std;\n\nbool differenceOne (int elem1, int elem2)\n{\n    return elem1 + 1 == elem2 || elem1 - 1 == elem2;\n}\n\nint main()\n{\n    // source data\n    int source[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7,\n                      5, 4, 4 };\n    int sourceNum = sizeof(source)/sizeof(source[0]);\n\n    // initialize coll with elements from source\n    list<int> coll;\n    copy(source, source+sourceNum,      // source\n         back_inserter(coll));          // destination\n    PRINT_ELEMENTS(coll);\n\n    // print elements with consecutive duplicates removed\n    unique_copy(coll.begin(), coll.end(),          // source\n                ostream_iterator<int>(cout,\" \"));  // destination\n    cout << endl;\n\n    // print elements without consecutive entries that differ by one\n    unique_copy(coll.begin(), coll.end(),         // source\n                ostream_iterator<int>(cout,\" \"),  // destination\n                differenceOne);                   // duplicates criterion\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/algo/unique3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nbool bothSpaces (char elem1, char elem2)\n{\n    return elem1 == ' ' && elem2 == ' ';\n}\n\nint main()\n{\n    // don't skip leading whitespaces by default\n    cin.unsetf(ios::skipws);\n\n    /* copy standard input to standard output\n     * - while compressing spaces\n     */\n    unique_copy(istream_iterator<char>(cin),  // beginning of source: cin\n                istream_iterator<char>(),     // end of source: end-of-file\n                ostream_iterator<char>(cout), // destination: cout\n                bothSpaces);                  // duplicate criterion\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/Makefile",
    "content": "OUTPROGS =\tvector1 deque1 list1 \\\n\t\tset2 set1 mset1 setcmp \\\n\t\tmap1 mmap1 mapfind mapcmp \\\n\t\tarray1 carray1 refsem1 \\\n\t\tstack1 stack2 queue1 queue2 pqueue1 \\\n\t\tbitset2\n\nCPPPROGS =\tsortset sortvec bitset1\n\nHEADERS =\tnewkey.hpp carray.hpp countptr.hpp Stack.hpp Queue.hpp print.hpp\n\ninclude ../Makefile.h\n\n\nrefsem1: countptr.hpp refsem1.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\ncarray1: carray.hpp carray1.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\nstack2: Stack.hpp stack2.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\nqueue2: Queue.hpp queue2.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\n"
  },
  {
    "path": "stl侯杰源码/cont/Queue.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n/* ************************************************************\n *  Queue.hpp\n *   - safer and more convenient queue class\n * ************************************************************/\n#ifndef QUEUE_HPP\n#define QUEUE_HPP\n\n#include <deque>\n#include <exception>\n\ntemplate <class T>\nclass Queue {\n  protected:\n    std::deque<T> c;        // container for the elements\n\n  public:\n    /* exception class for pop() and top() with empty queue\n     */\n    class ReadEmptyQueue : public std::exception {\n      public:\n        virtual const char* what() const throw() {\n            return \"read empty queue\";\n        }\n    };\n  \n    // number of elements\n    typename std::deque<T>::size_type size() const {\n        return c.size();\n    }\n\n    // is queue empty?\n    bool empty() const {\n        return c.empty();\n    }\n\n    // insert element into the queue\n    void push (const T& elem) {\n        c.push_back(elem);\n    }\n\n    // read element from the queue and return its value\n    T pop () {\n        if (c.empty()) {\n            throw ReadEmptyQueue();\n        }\n        T elem(c.front());\n        c.pop_front();\n        return elem;\n    }\n\n    // return value of next element\n    T& front () {\n        if (c.empty()) {\n            throw ReadEmptyQueue();\n        }\n        return c.front();\n    }\n};\n\n#endif /* QUEUE_HPP */\n"
  },
  {
    "path": "stl侯杰源码/cont/Stack.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n/* ************************************************************\n *  Stack.hpp\n *   - safer and more convenient stack class\n * ************************************************************/\n#ifndef STACK_HPP\n#define STACK_HPP\n\n#include <deque>\n#include <exception>\n\ntemplate <class T>\nclass Stack {\n  protected:\n    std::deque<T> c;        // container for the elements\n\n  public:\n    /* exception class for pop() and top() with empty stack\n     */\n    class ReadEmptyStack : public std::exception {\n      public:\n        virtual const char* what() const throw() {\n            return \"read empty stack\";\n        }\n    };\n  \n    // number of elements\n    typename std::deque<T>::size_type size() const {\n        return c.size();\n    }\n\n    // is stack empty?\n    bool empty() const {\n        return c.empty();\n    }\n\n    // push element into the stack\n    void push (const T& elem) {\n        c.push_back(elem);\n    }\n\n    // pop element out of the stack and return its value\n    T pop () {\n        if (c.empty()) {\n            throw ReadEmptyStack();\n        }\n        T elem(c.back());\n        c.pop_back();\n        return elem;\n    }\n\n    // return value of next element\n    T& top () {\n        if (c.empty()) {\n            throw ReadEmptyStack();\n        }\n        return c.back();\n    }\n};\n\n#endif /* STACK_HPP */\n"
  },
  {
    "path": "stl侯杰源码/cont/array1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <algorithm>\n#include <functional>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    int coll[] = { 5, 6, 2, 4, 1, 3 };\n\n    // square all elements\n    transform (coll, coll+6,        // first source\n               coll,                // second source\n               coll,                // destination\n               multiplies<int>());  // operation\n\n    // sort beginning with the second element\n    sort (coll+1, coll+6);\n\n    // print all elements\n    copy (coll, coll+6,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/bitset1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <bitset>\n#include <iostream>\nusing namespace std;\n\nint main()\n{\n    /* enumeration type for the bits\n     * - each bit represents a color\n     */\n    enum Color { red, yellow, green, blue, white, black, //...,\n                 numColors };\n\n    // create bitset for all bits/colors\n    bitset<numColors> usedColors;\n\n    // set bits for two colors\n    usedColors.set(red);\n    usedColors.set(blue);\n\n    // print some bitset data\n    cout << \"bitfield of used colors:   \" << usedColors\n         << endl;\n    cout << \"number   of used colors:   \" << usedColors.count()\n         << endl;\n    cout << \"bitfield of unused colors: \" << ~usedColors\n         << endl;\n\n    // if any color is used\n    if (usedColors.any()) {\n        // loop over all colors\n        for (int c = 0; c < numColors; ++c) {\n            // if the actual color is used\n            if (usedColors[(Color)c]) {\n                //...\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/bitset2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <bitset>\n#include <iostream>\n#include <string>\n#include <limits>\nusing namespace std;\n\nint main()\n{\n    /* print some numbers in binary representation\n     */\n    cout << \"267 as binary short:     \"\n         << bitset<numeric_limits<unsigned short>::digits>(267)\n         << endl;\n\n    cout << \"267 as binary long:      \"\n         << bitset<numeric_limits<unsigned long>::digits>(267)\n         << endl;\n\n    cout << \"10,000,000 with 24 bits: \"\n         << bitset<24>(1e7) << endl;\n\n    /* transform binary representation into integral number\n     */\n    cout << \"\\\"1000101011\\\" as number:  \"\n         << bitset<100>(string(\"1000101011\")).to_ulong() << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/carray.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstddef>\n\ntemplate<class T, std::size_t thesize>\nclass carray {\n  private:\n    T v[thesize];    // fixed-size array of elements of type T\n\n  public:\n    // type definitions\n    typedef T        value_type;\n    typedef T*       iterator;\n    typedef const T* const_iterator;\n    typedef T&       reference;\n    typedef const T& const_reference;\n    typedef std::size_t    size_type;\n    typedef std::ptrdiff_t difference_type;\n\n    // iterator support\n    iterator begin() { return v; }\n    const_iterator begin() const { return v; }\n    iterator end() { return v+thesize; }\n    const_iterator end() const { return v+thesize; }\n\n    // direct element access\n    reference operator[](std::size_t i) { return v[i]; }\n    const_reference operator[](std::size_t i) const { return v[i]; }\n\n    // size is constant\n    size_type size() const { return thesize; }\n    size_type max_size() const { return thesize; }\n\n    // conversion to ordinary array\n    T* as_array() { return v; }\n};\n\n"
  },
  {
    "path": "stl侯杰源码/cont/carray1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <algorithm>\n#include <functional>\n#include \"carray.hpp\"\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    carray<int,10> a;\n\n    for (unsigned i=0; i<a.size(); ++i) {\n        a[i] = i+1;\n    }\n    PRINT_ELEMENTS(a);\n\n    reverse(a.begin(),a.end());\n    PRINT_ELEMENTS(a);\n\n    transform(a.begin(),a.end(),    // source\n              a.begin(),            // destination\n              negate<int>());       // operation\n    PRINT_ELEMENTS(a);\n}\n\n"
  },
  {
    "path": "stl侯杰源码/cont/countptr.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#ifndef COUNTED_PTR_HPP\n#define COUNTED_PTR_HPP\n\n/* class for counted reference semantics\n * - deletes the object to which it refers when the last CountedPtr\n *   that refers to it is destroyed\n */\ntemplate <class T>\nclass CountedPtr {\n  private:\n    T* ptr;        // pointer to the value\n    long* count;   // shared number of owners\n\n  public:\n    // initialize pointer with existing pointer\n    // - requires that the pointer p is a return value of new\n    explicit CountedPtr (T* p=0)\n     : ptr(p), count(new long(1)) {\n    }\n\n    // copy pointer (one more owner)\n    CountedPtr (const CountedPtr<T>& p) throw()\n     : ptr(p.ptr), count(p.count) {\n        ++*count;\n    }\n\n    // destructor (delete value if this was the last owner)\n    ~CountedPtr () throw() {\n        dispose();\n    }\n\n    // assignment (unshare old and share new value)\n    CountedPtr<T>& operator= (const CountedPtr<T>& p) throw() {\n        if (this != &p) {\n            dispose();\n            ptr = p.ptr;\n            count = p.count;\n            ++*count;\n        }\n        return *this;\n    }\n\n    // access the value to which the pointer refers\n    T& operator*() const throw() {\n        return *ptr;\n    }\n    T* operator->() const throw() {\n        return ptr;\n    }\n\n  private:\n    void dispose() {\n        if (--*count == 0) {\n             delete count;\n             delete ptr;\n        }\n    }\n    \n};\n\n#endif /*COUNTED_PTR_HPP*/\n"
  },
  {
    "path": "stl侯杰源码/cont/deque1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <deque>\n#include <string>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    // create empty deque of strings\n    deque<string> coll;\n\n    // insert several elements\n    coll.assign (3, string(\"string\"));\n    coll.push_back (\"last string\");\n    coll.push_front (\"first string\");\n\n    // print elements separated by newlines\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<string>(cout,\"\\n\"));\n    cout << endl;\n\n    // remove first and last element\n    coll.pop_front();\n    coll.pop_back();\n\n    // insert ``another'' into every element but the first\n    for (unsigned i=1; i<coll.size(); ++i) {\n        coll[i] = \"another \" + coll[i];\n    }\n\n    // change size to four elements\n    coll.resize (4, \"resized string\");\n\n    // print elements separated by newlines\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<string>(cout,\"\\n\"));\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/list1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nvoid printLists (const list<int>& l1, const list<int>& l2)\n{\n    cout << \"list1: \";\n    copy (l1.begin(), l1.end(), ostream_iterator<int>(cout,\" \"));\n    cout << endl << \"list2: \";\n    copy (l2.begin(), l2.end(), ostream_iterator<int>(cout,\" \"));\n    cout << endl << endl;\n}\n\nint main()\n{\n    // create two empty lists\n    list<int> list1, list2;\n\n    // fill both lists with elements\n    for (int i=0; i<6; ++i) {\n        list1.push_back(i);\n        list2.push_front(i);\n    }\n    printLists(list1, list2);\n\n    // insert all elements of list1 before the first element with value 3 of list2\n    // - find() returns an iterator to the first element with value 3\n    list2.splice(find(list2.begin(),list2.end(),  // destination position\n                      3),\n                 list1);                          // source list\n    printLists(list1, list2);\n\n    // move first element to the end\n    list2.splice(list2.end(),        // destination position\n                 list2,              // source list\n                 list2.begin());     // source position\n    printLists(list1, list2);\n\n    // sort second list, assign to list1 and remove duplicates\n    list2.sort();\n    list1 = list2;\n    list2.unique();\n    printLists(list1, list2);\n\n    // merge both sorted lists into the first list\n    list1.merge(list2);\n    printLists(list1, list2);\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/map1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <map>\n#include <string>\nusing namespace std;\n\nint main()\n{\n    /* create map / associative array\n     * - keys are strings\n     * - values are floats\n     */\n    typedef map<string,float> StringFloatMap;\n\n    StringFloatMap stocks;      // create empty container\n\n    // insert some elements\n    stocks[\"BASF\"] = 369.50;\n    stocks[\"VW\"] = 413.50;\n    stocks[\"Daimler\"] = 819.00;\n    stocks[\"BMW\"] = 834.00;\n    stocks[\"Siemens\"] = 842.20;\n\n    // print all elements\n    StringFloatMap::iterator pos;\n    for (pos = stocks.begin(); pos != stocks.end(); ++pos) {\n        cout << \"stock: \" << pos->first << \"\\t\"\n             << \"price: \" << pos->second << endl;\n    }\n    cout << endl;\n\n    // boom (all prices doubled)\n    for (pos = stocks.begin(); pos != stocks.end(); ++pos) {\n        pos->second *= 2;\n    }\n\n    // print all elements\n    for (pos = stocks.begin(); pos != stocks.end(); ++pos) {\n        cout << \"stock: \" << pos->first << \"\\t\"\n             << \"price: \" << pos->second << endl;\n    }\n    cout << endl;\n\n    /* rename key from \"VW\" to \"Volkswagen\"\n     * - only provided by exchanging element\n     */\n    stocks[\"Volkswagen\"] = stocks[\"VW\"];\n    stocks.erase(\"VW\");\n\n    // print all elements\n    for (pos = stocks.begin(); pos != stocks.end(); ++pos) {\n        cout << \"stock: \" << pos->first << \"\\t\"\n             << \"price: \" << pos->second << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/mapcmp.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <iomanip>\n#include <map>\n#include <string>\n#include <algorithm>\nusing namespace std;\n\n/* function object to compare strings\n * - allows you to set the comparison criterion at runtime\n * - allows you to compare case insensitive\n */\nclass RuntimeStringCmp {\n  public:\n    // constants for the comparison criterion\n    enum cmp_mode {normal, nocase};\n  private:\n    // actual comparison mode\n    const cmp_mode mode;\n\n    // auxiliary function to compare case insensitive\n    static bool nocase_compare (char c1, char c2)\n    {\n        return toupper(c1) < toupper(c2);\n    }\n\n  public:  \n    // constructor: initializes the comparison criterion\n    RuntimeStringCmp (cmp_mode m=normal) : mode(m) {\n    }\n\n    // the comparison\n    bool operator() (const string& s1, const string& s2) const {\n        if (mode == normal) {\n            return s1<s2;\n        }\n        else {\n            return lexicographical_compare (s1.begin(), s1.end(),\n                                            s2.begin(), s2.end(),\n                                            nocase_compare);\n        }\n    }\n};\n\n/* container type:\n * - map with\n *       - string keys\n *       - string values\n *       - the special comparison object type\n */\ntypedef map<string,string,RuntimeStringCmp> StringStringMap;\n\n// function that fills and prints such containers\nvoid fillAndPrint(StringStringMap& coll);\n\nint main()\n{\n    // create a container with the default comparison criterion\n    StringStringMap coll1;\n    fillAndPrint(coll1);\n\n    // create an object for case-insensitive comparisons\n    RuntimeStringCmp ignorecase(RuntimeStringCmp::nocase);\n\n    // create a container with the case-insensitive comparisons criterion\n    StringStringMap coll2(ignorecase);\n    fillAndPrint(coll2);\n}\n\nvoid fillAndPrint(StringStringMap& coll)\n{\n    // fill insert elements in random order\n    coll[\"Deutschland\"] = \"Germany\";\n    coll[\"deutsch\"] = \"German\";\n    coll[\"Haken\"] = \"snag\";\n    coll[\"arbeiten\"] = \"work\";\n    coll[\"Hund\"] = \"dog\";\n    coll[\"gehen\"] = \"go\";\n    coll[\"Unternehmen\"] = \"enterprise\";\n    coll[\"unternehmen\"] = \"undertake\";\n    coll[\"gehen\"] = \"walk\";\n    coll[\"Bestatter\"] = \"undertaker\";\n\n    // print elements\n    StringStringMap::iterator pos;\n    cout.setf(ios::left, ios::adjustfield);\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        cout << setw(15) << pos->first.c_str() << \" \"\n             << pos->second << endl;\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/mapfind.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <algorithm>\n#include <map>\nusing namespace std;\n\n/* function object to check the value of a map element\n */\ntemplate <class K, class V>\nclass value_equals {\n  private:\n    V value;\n  public:\n    // constructor (initialize value to compare with)\n    value_equals (const V& v)\n     : value(v) {\n    }\n    // comparison\n    bool operator() (pair<const K, V> elem) {\n        return elem.second == value;\n    }\n};\n\nint main()\n{\n    typedef map<float,float> FloatFloatMap;\n    FloatFloatMap coll;\n    FloatFloatMap::iterator pos;\n\n    // fill container\n    coll[1]=7;\n    coll[2]=4;\n    coll[3]=2;\n    coll[4]=3;\n    coll[5]=6;\n    coll[6]=1;\n    coll[7]=3;\n\n    // search an element with key 3.0\n    pos = coll.find(3.0);                     // logarithmic complexity\n    if (pos != coll.end()) {\n        cout << pos->first << \": \"\n             << pos->second << endl;\n    }\n\n    // search an element with value 3.0\n    pos = find_if(coll.begin(),coll.end(),    // linear complexity\n                  value_equals<float,float>(3.0));\n    if (pos != coll.end()) {\n        cout << pos->first << \": \"\n             << pos->second << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/mmap1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <map>\n#include <string>\n#include <iomanip>\nusing namespace std;\n\nint main()\n{\n    // define multimap type as string/string dictionary\n    typedef multimap<string,string> StrStrMMap;\n\n    // create empty dictionary\n    StrStrMMap dict;\n\n    // insert some elements in random order\n    dict.insert(make_pair(\"day\",\"Tag\"));\n    dict.insert(make_pair(\"strange\",\"fremd\"));\n    dict.insert(make_pair(\"car\",\"Auto\"));\n    dict.insert(make_pair(\"smart\",\"elegant\"));\n    dict.insert(make_pair(\"trait\",\"Merkmal\"));\n    dict.insert(make_pair(\"strange\",\"seltsam\"));\n    dict.insert(make_pair(\"smart\",\"raffiniert\"));\n    dict.insert(make_pair(\"smart\",\"klug\"));\n    dict.insert(make_pair(\"clever\",\"raffiniert\"));\n\n    // print all elements\n    StrStrMMap::iterator pos;\n    cout.setf (ios::left, ios::adjustfield);\n    cout << ' ' << setw(10) << \"english \"\n         << \"german \" << endl;\n    cout << setfill('-') << setw(20) << \"\"\n         << setfill(' ') << endl;\n    for (pos = dict.begin(); pos != dict.end(); ++pos) {\n        cout << ' ' << setw(10) << pos->first.c_str()\n             << pos->second << endl;\n    }\n    cout << endl;\n\n    // print all values for key \"smart\"\n    string word(\"smart\");\n    cout << word << \": \" << endl;\n    for (pos = dict.lower_bound(word);\n         pos != dict.upper_bound(word); ++pos) {\n            cout << \"    \" << pos->second << endl;\n    }\n\n    // print all keys for value \"raffiniert\"\n    word = (\"raffiniert\");\n    cout << word << \": \" << endl;\n    for (pos = dict.begin(); pos != dict.end(); ++pos) {\n        if (pos->second == word) {\n            cout << \"    \" << pos->first << endl;\n        }\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/mset1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    /* type of the collection:\n     * - duplicates allowed\n     * - elements are integral values\n     * - descending order\n     */\n    typedef multiset<int,greater<int> > IntSet;\n\n    IntSet coll1;        // empty multiset container\n\n    // insert elements in random order\n    coll1.insert(4);\n    coll1.insert(3);\n    coll1.insert(5);\n    coll1.insert(1);\n    coll1.insert(6);\n    coll1.insert(2);\n    coll1.insert(5);\n\n    // iterate over all elements and print them\n    IntSet::iterator pos;\n    for (pos = coll1.begin(); pos != coll1.end(); ++pos) {\n        cout << *pos << ' ';\n    }\n    cout << endl;\n\n    // insert 4 again and process return value\n    IntSet::iterator ipos = coll1.insert(4);\n    cout << \"4 inserted as element \"\n         << distance(coll1.begin(),ipos) + 1 << endl;\n\n    // assign elements to another multiset with ascending order\n    multiset<int> coll2(coll1.begin(),\n                        coll1.end());\n    \n    // print all elements of the copy\n    copy (coll2.begin(), coll2.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // remove all elements up to element with value 3\n    coll2.erase (coll2.begin(), coll2.find(3));\n\n    // remove all elements with value 5\n    int num;\n    num = coll2.erase (5);\n    cout << num << \" element(s) removed\" << endl;\n\n    // print all elements\n    copy (coll2.begin(), coll2.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/newkey.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\nnamespace MyLib {\n    template <class Cont>\n    inline\n    bool replace_key (Cont& c,\n                      const typename Cont::key_type& old_key,\n                      const typename Cont::key_type& new_key)\n    {\n        typename Cont::iterator pos;\n        pos = c.find(old_key);\n        if (pos != c.end()) {\n            // insert new element with value of old element\n            c.insert(typename Cont::value_type(new_key,\n                                               pos->second));\n            // remove old element\n            c.erase(pos);\n            return true;\n        }\n        else {\n            // key not found\n            return false;\n        }\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/pqueue1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <queue>\nusing namespace std;\n\nint main()\n{\n    priority_queue<float> q;\n\n    // insert three elements into the priority queue\n    q.push(66.6);\n    q.push(22.2);\n    q.push(44.4);\n\n    // read and print two elements\n    cout << q.top() << ' ';\n    q.pop();\n    cout << q.top() << endl;\n    q.pop();\n\n    // insert three more elements\n    q.push(11.1);\n    q.push(55.5);\n    q.push(33.3);\n\n    // skip one element\n    q.pop();\n\n    // pop and print remaining elements\n    while (!q.empty()) {\n        cout << q.top() << ' ';\n        q.pop();\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/print.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\n/* PRINT_ELEMENTS()\n * - prints optional C-string optcstr followed by\n * - all elements of the collection coll\n * - separated by spaces\n */\ntemplate <class T>\ninline void PRINT_ELEMENTS (const T& coll, const char* optcstr=\"\")\n{\n    typename T::const_iterator pos;\n\n    std::cout << optcstr;\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/queue1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <queue>\n#include <string>\nusing namespace std;\n\nint main()\n{\n    queue<string> q;\n\n    // insert three elements into the queue\n    q.push(\"These \");\n    q.push(\"are \");\n    q.push(\"more than \");\n\n    // read and print two elements from the queue\n    cout << q.front();\n    q.pop();\n    cout << q.front();\n    q.pop();\n\n    // insert two new elements\n    q.push(\"four \");\n    q.push(\"words!\");\n\n    // skip one element\n    q.pop();\n\n    // read and print two elements\n    cout << q.front();\n    q.pop();\n    cout << q.front() << endl;\n    q.pop();\n\n    // print number of elements in the queue\n    cout << \"number of elements in the queue: \" << q.size()\n         << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/queue2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include \"Queue.hpp\"      // use special queue class\nusing namespace std;\n\nint main()\n{\n   try {    \n      Queue<string> q;\n\n      // insert three elements into the queue\n      q.push(\"These \");\n      q.push(\"are \");\n      q.push(\"more than \");\n\n      // read and print two elements from the queue\n      cout << q.pop();\n      cout << q.pop();\n\n      // push two new elements\n      q.push(\"four \");\n      q.push(\"words!\");\n\n      // skip one element\n      q.pop();\n\n      // read and print two elements from the queue\n      cout << q.pop();\n      cout << q.pop() << endl;\n\n      // print number of remaining elements\n      cout << \"number of elements in the queue: \" << q.size()\n           << endl;\n\n      // read and print one element\n      cout << q.pop() << endl;\n   }\n   catch (const exception& e) {\n      cerr << \"EXCEPTION: \" << e.what() << endl;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/refsem1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <deque>\n#include <algorithm>\n#include \"countptr.hpp\"\nusing namespace std;\n\nvoid printCountedPtr (CountedPtr<int> elem)\n{\n    cout << *elem << ' ';\n}\n\nint main()\n{\n    // array of integers (to share in different containers)\n    static int values[] = { 3, 5, 9, 1, 6, 4 };\n\n    // two different collections\n    typedef CountedPtr<int> IntPtr;\n    deque<IntPtr> coll1;\n    list<IntPtr> coll2;\n\n    /* insert shared objects into the collections\n     * - same order in coll1\n     * - reverse order in coll2\n     */\n    for (int i=0; i<sizeof(values)/sizeof(values[0]); ++i) {\n        IntPtr ptr(new int(values[i]));\n        coll1.push_back(ptr);\n        coll2.push_front(ptr);\n    }\n\n    // print contents of both collections\n    for_each (coll1.begin(), coll1.end(),\n              printCountedPtr);\n    cout << endl;\n    for_each (coll2.begin(), coll2.end(),\n              printCountedPtr);\n    cout << endl << endl;\n\n    /* modify values at different places\n     * - square third value in coll1\n     * - negate first value in coll1\n     * - set first value in coll2 to 0\n     */\n    *coll1[2] *= *coll1[2];\n    (**coll1.begin()) *= -1;\n    (**coll2.begin()) = 0;\n\n    // print contents of both collections again\n    for_each (coll1.begin(), coll1.end(),\n              printCountedPtr);\n    cout << endl;\n    for_each (coll2.begin(), coll2.end(),\n              printCountedPtr);\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/set1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    /* type of the collection:\n     * - no duplicates\n     * - elements are integral values\n     * - descending order\n     */\n    typedef set<int,greater<int> > IntSet;\n\n    IntSet coll1;        // empty set container\n\n    // insert elements in random order\n    coll1.insert(4);\n    coll1.insert(3);\n    coll1.insert(5);\n    coll1.insert(1);\n    coll1.insert(6);\n    coll1.insert(2);\n    coll1.insert(5);\n\n    // iterate over all elements and print them\n    IntSet::iterator pos;\n    for (pos = coll1.begin(); pos != coll1.end(); ++pos) {\n        cout << *pos << ' ';\n    }\n    cout << endl;\n\n    // insert 4 again and process return value\n    pair<IntSet::iterator,bool> status = coll1.insert(4);\n    if (status.second) {\n        cout << \"4 inserted as element \"\n             << distance(coll1.begin(),status.first) + 1\n             << endl;\n    }\n    else {\n        cout << \"4 already exists\" << endl;\n    }\n\n    // assign elements to another set with ascending order\n    set<int> coll2(coll1.begin(),\n                   coll1.end());\n    \n    // print all elements of the copy\n    copy (coll2.begin(), coll2.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // remove all elements up to element with value 3\n    coll2.erase (coll2.begin(), coll2.find(3));\n\n    // remove all elements with value 5\n    int num;\n    num = coll2.erase (5);\n    cout << num << \" element(s) removed\" << endl;\n\n    // print all elements\n    copy (coll2.begin(), coll2.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/set2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\nusing namespace std;\n\nint main ()\n{\n    set<int> c;\n\n    c.insert(1);\n    c.insert(2);\n    c.insert(4);\n    c.insert(5);\n    c.insert(6);\n\n    cout << \"lower_bound(3): \" << *c.lower_bound(3) << endl;\n    cout << \"upper_bound(3): \" << *c.upper_bound(3) << endl;\n    cout << \"equal_range(3): \" << *c.equal_range(3).first << \" \"\n                               << *c.equal_range(3).second << endl;\n    cout << endl;\n    cout << \"lower_bound(5): \" << *c.lower_bound(5) << endl;\n    cout << \"upper_bound(5): \" << *c.upper_bound(5) << endl;\n    cout << \"equal_range(5): \" << *c.equal_range(5).first << \" \"\n                               << *c.equal_range(5).second << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/setcmp.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include \"print.hpp\"\nusing namespace std;\n\n// type for sorting criterion\ntemplate <class T>\nclass RuntimeCmp {\n  public:\n    enum cmp_mode {normal, reverse};\n  private:\n    cmp_mode mode;\n  public:  \n    // constructor for sorting criterion\n    // - default criterion uses value normal\n    RuntimeCmp (cmp_mode m=normal) : mode(m) {\n    }\n    // comparison of elements\n    bool operator() (const T& t1, const T& t2) const {\n        return mode == normal ? t1 < t2 : t2 < t1;\n    }\n    // comparison of sorting criteria\n    bool operator== (const RuntimeCmp& rc) {\n        return mode == rc.mode;\n    }\n};\n\n// type of a set that uses this sorting criterion\ntypedef set<int,RuntimeCmp<int> > IntSet;\n\n// forward declaration\nvoid fill (IntSet& set);\n\nint main()\n{\n    // create, fill, and print set with normal element order\n    // - uses default sorting criterion\n    IntSet coll1;\n    fill(coll1);\n    PRINT_ELEMENTS (coll1, \"coll1: \");\n\n    // create sorting criterion with reverse element order\n    RuntimeCmp<int> reverse_order(RuntimeCmp<int>::reverse);\n\n    // create, fill, and print set with reverse element order\n    IntSet coll2(reverse_order);\n    fill(coll2);\n    PRINT_ELEMENTS (coll2, \"coll2: \");\n\n    // assign elements AND sorting criterion\n    coll1 = coll2;\n    coll1.insert(3);\n    PRINT_ELEMENTS (coll1, \"coll1: \");\n\n    // just to make sure...\n    if (coll1.value_comp() == coll2.value_comp()) {\n        cout << \"coll1 and coll2 have same sorting criterion\"\n             << endl;\n    }\n    else {\n        cout << \"coll1 and coll2 have different sorting criterion\"\n             << endl;\n    }\n}\n\nvoid fill (IntSet& set)\n{\n    // fill insert elements in random order\n    set.insert(4);\n    set.insert(7);\n    set.insert(5);\n    set.insert(1);\n    set.insert(6);\n    set.insert(2);\n    set.insert(5);\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/sortset.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <algorithm>\n#include <iterator>\n#include <set>\nusing namespace std;\n\nint main()\n{\n    /* create a string set\n     * - initialized by all words from standard input\n     */\n    set<string> coll((istream_iterator<string>(cin)),\n                     istream_iterator<string>());\n\n    // print all elements\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<string>(cout, \"\\n\"));\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/sortvec.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <algorithm>\n#include <iterator>\n#include <vector>\nusing namespace std;\n\nint main()\n{\n    /* create a string vector\n     * - initialized by all words from standard input\n     */\n    vector<string> coll((istream_iterator<string>(cin)),\n                        istream_iterator<string>());\n\n    // sort elements\n    sort (coll.begin(), coll.end());\n\n    // print all elements ignoring subsequent duplicates\n    unique_copy (coll.begin(), coll.end(),\n                 ostream_iterator<string>(cout, \"\\n\"));\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/stack1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <stack>\nusing namespace std;\n\nint main()\n{\n    stack<int> st;\n\n    // push three elements into the stack\n    st.push(1);\n    st.push(2);\n    st.push(3);\n\n    // pop and print two elements from the stack\n    cout << st.top() << ' ';\n    st.pop();\n    cout << st.top() << ' ';\n    st.pop();\n\n    // modify top element\n    st.top() = 77;\n\n    // push two new elements\n    st.push(4);\n    st.push(5);\n\n    // pop one element without processing it\n    st.pop();\n\n    // pop and print remaining elements\n    while (!st.empty()) {\n        cout << st.top() << ' ';\n        st.pop();\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/stack2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"Stack.hpp\"      // use special stack class\nusing namespace std;\n\nint main()\n{\n   try {\n      Stack<int> st;\n\n      // push three elements into the stack\n      st.push(1);\n      st.push(2);\n      st.push(3);\n\n      // pop and print two elements from the stack\n      cout << st.pop() << ' ';\n      cout << st.pop() << ' ';\n\n      // modify top element\n      st.top() = 77;\n\n      // push two new elements\n      st.push(4);\n      st.push(5);\n\n      // pop one element without processing it\n      st.pop();\n\n      /* pop and print three elements\n       * - ERROR: one element too many\n       */\n      cout << st.pop() << ' ';\n      cout << st.pop() << endl;\n      cout << st.pop() << endl;\n   }\n   catch (const exception& e) {\n      cerr << \"EXCEPTION: \" << e.what() << endl;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/cont/vector1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <string>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    // create empty vector for strings\n    vector<string> sentence;\n\n    // reserve memory for five elements to avoid reallocation\n    sentence.reserve(5);\n\n    // append some elements\n    sentence.push_back(\"Hello,\");\n    sentence.push_back(\"how\");\n    sentence.push_back(\"are\");\n    sentence.push_back(\"you\");\n    sentence.push_back(\"?\");\n\n    // print elements separated with spaces\n    copy (sentence.begin(), sentence.end(),\n          ostream_iterator<string>(cout,\" \"));\n    cout << endl;\n\n    // print ``technical data''\n    cout << \"  max_size(): \" << sentence.max_size() << endl;\n    cout << \"  size():     \" << sentence.size()     << endl;\n    cout << \"  capacity(): \" << sentence.capacity() << endl;\n\n    // swap second and fourth element\n    swap (sentence[1], sentence[3]);\n\n    // insert element \"always\" before element \"?\"\n    sentence.insert (find(sentence.begin(),sentence.end(),\"?\"),\n                     \"always\");\n\n    // assign \"!\" to the last element\n    sentence.back() = \"!\";\n    \n    // print elements separated with spaces\n    copy (sentence.begin(), sentence.end(),\n          ostream_iterator<string>(cout,\" \"));\n    cout << endl;\n\n    // print ``technical data'' again\n    cout << \"  max_size(): \" << sentence.max_size() << endl;\n    cout << \"  size():     \" << sentence.size()     << endl;\n    cout << \"  capacity(): \" << sentence.capacity() << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/Makefile",
    "content": "include ../Makefile.h\n\nOUTPROGS =\tsort1 genera1 genera2 foreach3 removeif \\\n\t   \tfopow1 \\\n\t  \tcompose1 compose2 compose3 compose4\n\nCPPPROGS =\tmemfun1\n\nHEADERS =\tfopow.hpp compose11.hpp compose12.hpp compose21.hpp \\\n\t\tcompose22.hpp compose10.hpp nullary.hpp print.hpp\n\n\nfopow1: fopow.hpp fopow1.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\ncompose1: print.hpp compose11.hpp compose1.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\ncompose2: compose21.hpp print.hpp compose2.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\ncompose3: compose3.cpp compose22.hpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\n"
  },
  {
    "path": "stl侯杰源码/fo/compose1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <functional>\n#include <iterator>\n#include \"print.hpp\"\n#include \"compose11.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n    PRINT_ELEMENTS(coll);\n\n    // for each element add 10 and multiply by 5\n    transform (coll.begin(),coll.end(),\n               ostream_iterator<int>(cout,\" \"),\n               compose_f_gx(bind2nd(multiplies<int>(),5),\n                            bind2nd(plus<int>(),10)));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose10.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n#include \"nullary.hpp\"\n\n/* class for the compose_f_g adapter\n */\ntemplate <class OP1, class OP2>\nclass compose_f_g_t\n : public boost::nullary_function<typename OP1::result_type>\n{\n  private:\n    OP1 op1;    // process: op1(op2())\n    OP2 op2;\n  public:\n    // constructor\n    compose_f_g_t(const OP1& o1, const OP2& o2)\n     : op1(o1), op2(o2) {\n    }\n\n    // function call\n    typename OP1::result_type\n    operator()() const {\n        return op1(op2());\n    }\n};\n\n/* convenience function for the compose_f_g adapter\n */\ntemplate <class OP1, class OP2>\ninline compose_f_g_t<OP1,OP2>\ncompose_f_g (const OP1& o1, const OP2& o2) {\n    return compose_f_g_t<OP1,OP2>(o1,o2);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose11.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n\n/* class for the compose_f_gx adapter\n */\ntemplate <class OP1, class OP2>\nclass compose_f_gx_t\n : public std::unary_function<typename OP2::argument_type,\n                              typename OP1::result_type>\n{\n  private:\n    OP1 op1;    // process: op1(op2(x))\n    OP2 op2;\n  public:\n    // constructor\n    compose_f_gx_t(const OP1& o1, const OP2& o2)\n     : op1(o1), op2(o2) {\n    }\n\n    // function call\n    typename OP1::result_type\n    operator()(const typename OP2::argument_type& x) const {\n        return op1(op2(x));\n    }\n};\n\n/* convenience function for the compose_f_gx adapter\n */\ntemplate <class OP1, class OP2>\ninline compose_f_gx_t<OP1,OP2>\ncompose_f_gx (const OP1& o1, const OP2& o2) {\n    return compose_f_gx_t<OP1,OP2>(o1,o2);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose12.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n\n/* class for the compose_f_gxy adapter\n */\ntemplate <class OP1, class OP2>\nclass compose_f_gxy_t\n : public std::binary_function<typename OP2::first_argument_type,\n                               typename OP2::second_argument_type,\n                               typename OP1::result_type>\n{\n  private:\n    OP1 op1;    // process: op1(op2(x,y))\n    OP2 op2;\n  public:\n    // constructor\n    compose_f_gxy_t (const OP1& o1, const OP2& o2)\n     : op1(o1), op2(o2) {\n    }\n\n    // function call\n    typename OP1::result_type\n    operator()(const typename OP2::first_argument_type& x,\n               const typename OP2::second_argument_type& y) const {\n        return op1(op2(x,y));\n    }\n};\n\n/* convenience function for the compose_f_gxy adapter\n */\ntemplate <class OP1, class OP2>\ninline compose_f_gxy_t<OP1,OP2>\ncompose_f_gxy (const OP1& o1, const OP2& o2) {\n    return compose_f_gxy_t<OP1,OP2>(o1,o2);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <functional>\n#include \"print.hpp\"\n#include \"compose21.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n    PRINT_ELEMENTS(coll);\n\n    // remove all elements that are greater than four and less than seven\n    // - retain new end\n    vector<int>::iterator pos;\n    pos = remove_if (coll.begin(),coll.end(),\n                     compose_f_gx_hx(logical_and<bool>(),\n                                     bind2nd(greater<int>(),4),\n                                     bind2nd(less<int>(),7)));\n\n    // remove ``removed'' elements in coll\n    coll.erase(pos,coll.end());\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose21.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n\n/* class for the compose_f_gx_hx adapter\n */\ntemplate <class OP1, class OP2, class OP3>\nclass compose_f_gx_hx_t\n : public std::unary_function<typename OP2::argument_type,\n                              typename OP1::result_type>\n{\n  private:\n    OP1 op1;    // process: op1(op2(x),op3(x))\n    OP2 op2;\n    OP3 op3;\n  public:\n    // constructor\n    compose_f_gx_hx_t (const OP1& o1, const OP2& o2, const OP3& o3)\n     : op1(o1), op2(o2), op3(o3) {\n    }\n\n    // function call\n    typename OP1::result_type\n    operator()(const typename OP2::argument_type& x) const {\n        return op1(op2(x),op3(x));\n    }\n};\n\n/* convenience function for the compose_f_gx_hx adapter\n */\ntemplate <class OP1, class OP2, class OP3>\ninline compose_f_gx_hx_t<OP1,OP2,OP3>\ncompose_f_gx_hx (const OP1& o1, const OP2& o2, const OP3& o3) {\n    return compose_f_gx_hx_t<OP1,OP2,OP3>(o1,o2,o3);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose22.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n\n/* class for the compose_f_gx_hy adapter\n */\ntemplate <class OP1, class OP2, class OP3>\nclass compose_f_gx_hy_t\n : public std::binary_function<typename OP2::argument_type,\n                               typename OP3::argument_type,\n                               typename OP1::result_type>\n{\n  private:\n    OP1 op1;    // process: op1(op2(x),op3(y))\n    OP2 op2;\n    OP3 op3;\n  public:\n    // constructor\n    compose_f_gx_hy_t (const OP1& o1, const OP2& o2, const OP3& o3)\n     : op1(o1), op2(o2), op3(o3) {\n    }\n\n    // function call\n    typename OP1::result_type\n    operator()(const typename OP2::argument_type& x,\n               const typename OP3::argument_type& y) const {\n        return op1(op2(x),op3(y));\n    }\n};\n\n/* convenience function for the compose_f_gx_hy adapter\n */\ntemplate <class OP1, class OP2, class OP3>\ninline compose_f_gx_hy_t<OP1,OP2,OP3>\ncompose_f_gx_hy (const OP1& o1, const OP2& o2, const OP3& o3) {\n    return compose_f_gx_hy_t<OP1,OP2,OP3>(o1,o2,o3);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <algorithm>\n#include <functional>\n#include <string>\n#include <cctype>\n#include \"compose22.hpp\"\nusing namespace std;\n\nint main()\n{\n    string s(\"Internationalization\");\n    string sub(\"Nation\");\n\n    // search substring case insensitive\n    string::iterator pos;\n    pos = search (s.begin(),s.end(),           // string to search in\n                  sub.begin(),sub.end(),       // substring to search\n                  compose_f_gx_hy(equal_to<int>(), // compar. criterion\n                                  ptr_fun(::toupper),\n                                  ptr_fun(::toupper)));\n\n    if (pos != s.end()) {\n        cout << \"\\\"\" << sub << \"\\\" is part of \\\"\" << s << \"\\\"\"\n             << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/compose4.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <list>\n#include <algorithm>\n#include <functional>\n#include <cstdlib>\n#include \"print.hpp\"\n#include \"compose10.hpp\"\nusing namespace std;\nusing namespace boost;\n\n\nint main()\n{\n    list<int> coll;\n\n    // insert five random numbers\n    generate_n (back_inserter(coll),      // beginning of destination range\n                5,                        // count\n                rand);                    // new value generator\n    PRINT_ELEMENTS(coll);\n\n    // overwrite with five new random numbers\n    // in the range between 0 (including) and 10 (excluding)\n    generate (coll.begin(), coll.end(),   // destination range\n              compose_f_g(bind2nd(modulus<int>(),10),\n                          ptr_fun(rand)));\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/fopow.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <functional>\n#include <cmath>\n\ntemplate <class T1, class T2>         \nstruct fopow : public std::binary_function<T1, T2, T1>\n{\n    T1 operator() (T1 base, T2 exp) const {\n        return std::pow(base,exp);\n    }\n}; \n"
  },
  {
    "path": "stl侯杰源码/fo/fopow1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\n// include self-defined fopow<>\n#include \"fopow.hpp\"\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // print 3 raised to the power of all elements\n    transform (coll.begin(), coll.end(),           // source\n               ostream_iterator<float>(cout,\" \"),  // destination\n               bind1st(fopow<float,int>(),3));     // operation\n    cout << endl;\n\n    // print all elements raised to the power of 3\n    transform (coll.begin(), coll.end(),           // source\n               ostream_iterator<float>(cout,\" \"),  // destination\n               bind2nd(fopow<float,int>(),3));     // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/foreach3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\n// function object to process the mean value\nclass MeanValue {\n  private:\n    long num;    // number of elements\n    long sum;    // sum of all element values\n  public:\n    // constructor\n    MeanValue () : num(0), sum(0) {\n    }\n\n    // ``function call''\n    // - process one more element of the sequence\n    void operator() (int elem) {\n        num++;          // increment count\n        sum += elem;    // add value\n    }\n\n    // return mean value\n    double value () {\n        return static_cast<double>(sum) / static_cast<double>(num);\n    }\n};\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elments from 1 to 8\n    for (int i=1; i<=8; ++i) {\n        coll.push_back(i);\n    }\n\n    // process and print mean value\n    MeanValue mv = for_each (coll.begin(), coll.end(),  // range\n                             MeanValue());              // operation\n    cout << \"mean value: \" << mv.value() << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/genera1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nclass IntSequence {\n  private:\n    int value;\n  public:\n    // constructor\n    IntSequence (int initialValue)\n     : value(initialValue) {\n    }\n\n    // ``function call''\n    int operator() () {\n        return value++;\n    }\n};\n\nint main()\n{\n    list<int> coll;\n\n    // insert values from 1 to 9\n    generate_n (back_inserter(coll),    // start\n                9,                      // number of elements\n                IntSequence(1));        // generates values\n\n    PRINT_ELEMENTS(coll);\n\n    // replace second to last element but one with values starting at 42\n    generate (++coll.begin(),           // start\n              --coll.end(),             // end\n              IntSequence(42));         // generates values\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/genera2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nclass IntSequence {\n  private:\n    int value;\n  public:\n    // constructor\n    IntSequence (int initialValue)\n     : value(initialValue) {\n    }\n\n    // ``function call''\n    int operator() () {\n        return value++;\n    }\n};\n\nint main()\n{\n    list<int> coll;\n    IntSequence seq(1);    // integral sequence starting with 1\n\n    // insert values from 1 to 4\n    // - pass function object by reference\n    //     so that it will continue with 5\n    generate_n<back_insert_iterator<list<int> >,\n               int, IntSequence&>(back_inserter(coll),    // start\n                                  4,      // number of elements\n                                  seq);   // generates values\n    PRINT_ELEMENTS(coll);\n\n    // insert values from 42 to 45\n    generate_n (back_inserter(coll),      // start\n                4,                        // number of elements\n                IntSequence(42));         // generates values\n    PRINT_ELEMENTS(coll);\n\n    // continue with first sequence\n    // - pass function object by value\n    //     so that it will continue with 5 again\n    generate_n (back_inserter(coll),      // start\n                4,                        // number of elements\n                seq);                     // generates values\n    PRINT_ELEMENTS(coll);\n    \n    // continue with first sequence again\n    generate_n (back_inserter(coll),      // start\n                4,                        // number of elements\n                seq);                     // generates values\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/memfun1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n//#define mem_fun1 mem_fun\n#include <iostream>\n#include <vector>\n#include <string>\n#include <algorithm>\n#include <functional>\n\n\nclass Person {\n  private:\n    std::string name;\n  public:\n    //...\n    void print () const {\n        std::cout << name << std::endl;\n    }\n    void printWithPrefix (std::string prefix) const {\n        std::cout << prefix << name << std::endl;\n    }\n};\n\nvoid foo (const std::vector<Person>& coll)\n{\n    using std::for_each;\n    using std::bind2nd;\n    using std::mem_fun_ref;\n\n    // call member function print() for each element\n    for_each (coll.begin(), coll.end(),\n              mem_fun_ref(&Person::print));\n\n    // call member function printWithPrefix() for each element\n    // - \"person: \" is passed as an argument to the member function\n    for_each (coll.begin(), coll.end(),\n              bind2nd(mem_fun_ref(&Person::printWithPrefix),\n                      \"person: \"));\n}\n\n\nvoid ptrfoo (const std::vector<Person*>& coll)\n                                   // ^^^ pointer !\n{\n    using std::for_each;\n    using std::bind2nd;\n    using std::mem_fun;\n\n    // call member function print() for each referred object\n    for_each (coll.begin(), coll.end(),\n              mem_fun(&Person::print));\n\n    // call member function printWithPrefix() for each referred object\n    // - \"person: \" is passed as an argument to the member function\n    for_each (coll.begin(), coll.end(),\n              bind2nd(mem_fun(&Person::printWithPrefix),\n                      \"person: \"));\n}\n\n\nint main()\n{\n    std::vector<Person> coll(5);\n    foo(coll);\n\n    std::vector<Person*> coll2;\n    coll2.push_back(new Person);\n    ptrfoo(coll2);\n}\n\n"
  },
  {
    "path": "stl侯杰源码/fo/nullary.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\nnamespace boost {\n\n/**********************************************************\n * type nullary_function\n * - as supplement to unary_function and binary_function\n **********************************************************/\ntemplate <class Result>\nstruct nullary_function {\n    typedef Result result_type;\n};\n\n/**********************************************************\n * ptr_fun for functions with no argument\n **********************************************************/\ntemplate <class Result>\nclass pointer_to_nullary_function : public nullary_function<Result>\n{\n  protected:\n    Result (*ptr)();\n  public:\n    pointer_to_nullary_function() {\n    }\n    explicit pointer_to_nullary_function(Result (*x)()) : ptr(x) {\n    }\n    Result operator()() const { \n        return ptr();\n    }\n};\n\ntemplate <class Result>\ninline pointer_to_nullary_function<Result> ptr_fun(Result (*x)())\n{\n  return pointer_to_nullary_function<Result>(x);\n}\n\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/print.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\n/* PRINT_ELEMENTS()\n * - prints optional C-string optcstr followed by\n * - all elements of the collection coll\n * - separated by spaces\n */\ntemplate <class T>\ninline void PRINT_ELEMENTS (const T& coll, const char* optcstr=\"\")\n{\n    typename T::const_iterator pos;\n\n    std::cout << optcstr;\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/removeif.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nclass Nth {    // function object that returns true for the nth call\n  private:\n    int nth;       // call for which to return true\n    int count;     // call counter\n  public:\n    Nth (int n) : nth(n), count(0) {\n    }\n    bool operator() (int) {\n        return ++count == nth;\n    }\n};\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n    PRINT_ELEMENTS(coll,\"coll:        \");\n\n    // remove third element\n    list<int>::iterator pos;\n    pos = remove_if(coll.begin(),coll.end(),  // range\n                    Nth(3));                  // remove criterion\n    coll.erase(pos,coll.end());\n\n    PRINT_ELEMENTS(coll,\"nth removed: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/fo/sort1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <deque>\n#include <set>\n#include <algorithm>\nusing namespace std;\n\n\n/* class Person\n */\nclass Person {\n  private:\n    string fn;    // first name\n    string ln;    // last name\n  public:\n    Person() {\n    }\n    Person(const string& f, const string& n)\n     : fn(f), ln(n) {\n    }\n    string firstname() const;\n    string lastname() const;\n    // ...\n};\n\ninline string Person::firstname() const {\n    return fn;\n}\n\ninline string Person::lastname() const {\n    return ln;\n}\n\nostream& operator<< (ostream& s, const Person& p)\n{\n    s << \"[\" << p.firstname() << \" \" << p.lastname() << \"]\";\n    return s;\n}\n\n\n/* class for function predicate\n * - operator () returns whether a person is less than another person\n */\nclass PersonSortCriterion {\n  public:\n    bool operator() (const Person& p1, const Person& p2) const {\n        /* a person is less than another person\n         * - if the last name is less\n         * - if the last name is equal and the first name is less\n         */\n        return p1.lastname()<p2.lastname() ||\n               (p1.lastname()==p2.lastname() &&\n                p1.firstname()<p2.firstname());\n    }\n};\n\n\nint main()\n{\n    Person p1(\"nicolai\",\"josuttis\");\n    Person p2(\"ulli\",\"josuttis\");\n    Person p3(\"anica\",\"josuttis\");\n    Person p4(\"lucas\",\"josuttis\");\n    Person p5(\"lucas\",\"otto\");\n    Person p6(\"lucas\",\"arm\");\n    Person p7(\"anica\",\"holle\");\n    \n    // declare set type with special sorting criterion\n    typedef set<Person,PersonSortCriterion> PersonSet;\n\n    // create such a collection\n    PersonSet coll;\n    coll.insert(p1);\n    coll.insert(p2);\n    coll.insert(p3);\n    coll.insert(p4);\n    coll.insert(p5);\n    coll.insert(p6);\n    coll.insert(p7);\n\n    // do something with the elements\n    // - in this case: output them\n    cout << \"set:\" << endl;\n    PersonSet::iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << *pos << endl;\n    }\n}\n\n"
  },
  {
    "path": "stl侯杰源码/i18n/Makefile",
    "content": "include ../Makefile.h\n\n# Programme fuer die make PROG.out aufgerufen wird\n#\nOUTPROGS = loc1 loc2\nCPPPROGS = numget\n\n"
  },
  {
    "path": "stl侯杰源码/i18n/loc1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <locale>\nusing namespace std;\n\nint main()\n{\n    // use classic C locale to read data from standard input\n    cin.imbue(locale::classic());\n\n    // use a German locale to write data to standard ouput\n    cout.imbue(locale(\"de_DE\"));\n\n    // read and output floating-point values in a loop\n    double value;\n    while (cin >> value) {\n        cout << value << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/i18n/loc2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <locale>\n#include <string>\n#include <cstdlib>\nusing namespace std;\n\nint main()\n{\n    // create the default locale from the user's environment\n    locale langLocale(\"\");\n\n    // and assign it to the standard ouput channel\n    cout.imbue(langLocale);\n\n    // process the name of the locale\n    bool isGerman;\n    if (langLocale.name() == \"de_DE\" ||\n        langLocale.name() == \"de\" ||\n        langLocale.name() == \"german\") {\n          isGerman = true;\n    }\n    else {\n          isGerman = false;\n    }\n\n    // read locale for the input\n    if (isGerman) {\n        cout << \"Sprachumgebung fuer Eingaben: \";\n    }\n    else {\n        cout << \"Locale for input: \";\n    }\n    string s;\n    cin >> s;\n    if (!cin) {\n        if (isGerman) {\n            cerr << \"FEHLER beim Einlesen der Sprachumgebung\"\n                 << endl;\n        }\n        else {\n            cerr << \"ERROR while reading the locale\" << endl;\n        }\n        return EXIT_FAILURE;\n    }\n    locale cinLocale(s.c_str());\n\n    // and assign it to the standard input channel\n    cin.imbue(cinLocale);\n\n    // read and output floating-point values in a loop\n    double value;\n    while (cin >> value) {\n        cout << value << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/i18n/numget.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <locale>\n#include <iostream>\n#include <cstdlib>\n#include <iterator>\n\nint main()\n{\n    // create copy of current global locale\n    std::locale loc;\n\n    // iterator to read from standard input\n    typedef std::istreambuf_iterator<char> InIt;\n    InIt beg = InIt(std::cin);\n    InIt end = InIt();\n\n    // stream which defines input format\n    std::ios_base& fmt = std::cin;\n\n    // declare output arguments\n    std::ios_base::iostate err;\n    float value;\n\n    // get numeric input facet of the locale loc\n    std::num_get<char, InIt> const& ng\n      = std::use_facet<std::num_get<char, InIt> >(loc);\n\n    // read value with numeric input facet\n    ng.get(beg, end, fmt, err, value);\n\n    // print value or error message\n    if (err == std::ios_base::goodbit) {\n        std::cout << \"value: \" << value << '\\n';\n    }\n    else if (err == std::ios_base::eofbit) {\n        std::cout << \"value: \" << value << \" (EOF encountered)\\n\";\n    }\n    else if (err & std::ios_base::badbit) {\n        std::cerr << \"fatal error while reading numeric value\\n\";\n        return EXIT_FAILURE;\n    }\n    else if (err & std::ios_base::failbit) {\n        std::cerr << \"format error while reading numeric value\\n\";\n        return EXIT_FAILURE;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/Makefile",
    "content": "CPPPROGS = io1 sum1 sum2 charcat1 \\\n\t   ignore1 ignoreparam1 charset \\\n\t   cat1 cat2 charcat2 \\\n\t   inbuf1 \\\n\t   copy1 copy2 \\\n\t   countlines\n\nOUTPROGS = rdbuf1 rdbuf2 redirect \\\n\t   rw1 sstr1 \\\n\t   outbuf1 outbuf1x outbuf2 outbuf3 \n\nHEADERS = ignore.hpp ignoreparam.hpp \\\n          frac1out.hpp frac2out.hpp frac1in.hpp frac2in.hpp \\\n\t  outbuf1.hpp outbuf1x.hpp outbuf2.hpp outbuf3.hpp \\\n\t  inbuf1.hpp\n\ninclude ../Makefile.h\n\noutbuf1: outbuf1.hpp outbuf1.cpp\n\t$(CXX) $(CXXFLAGS) $@.cpp $(LDFLAGS) -o $@\noutbuf1x: outbuf1x.hpp outbuf1x.cpp\n\t$(CXX) $(CXXFLAGS) $@.cpp $(LDFLAGS) -o $@\noutbuf2: outbuf2.hpp outbuf2.cpp\n\t$(CXX) $(CXXFLAGS) $@.cpp $(LDFLAGS) -o $@\noutbuf3: outbuf3.hpp outbuf3.cpp\n\t$(CXX) $(CXXFLAGS) $@.cpp $(LDFLAGS) -o $@\n\nignoreparam1: ignoreparam1.cpp ignoreparam.hpp\n\t$(CXX) $(CXXFLAGS) $@.cpp $(LDFLAGS) -o $@\n\n"
  },
  {
    "path": "stl侯杰源码/io/cat1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n// header files for file I/O\n#include <fstream>\n#include <iostream>\nusing namespace std;\n\n/* for all file names passed as command-line arguments\n * - open, print contents, and close file\n */\nint main (int argc, char* argv[])\n{\n    ifstream file;\n\n    // for all command-line arguments\n    for (int i=1; i<argc; ++i) {\n\n        // open file\n        file.open(argv[i]);\n\n        // write file contents to cout\n        char c;\n        while (file.get(c)) {\n            cout.put(c);\n        }\n\n        // clear eofbit and failbit set due to end-of-file\n        file.clear();\n\n        // close file\n        file.close();\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/cat2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n// header files for file I/O\n#include <iostream>\n#include <fstream>\n\nvoid printFileTwice (const char* filename)\n{\n    // open file\n    std::ifstream file(filename);\n\n    // print contents the first time\n    std::cout << file.rdbuf();\n\n    // seek to the beginning\n    file.seekg(0);\n\n    // print contents the second time\n    std::cout << file.rdbuf();\n}\n\nint main (int argc, char* argv[])\n{\n    // print all files passed as a command-line argument twice\n    for (int i=1; i<argc; ++i) {\n        printFileTwice(argv[i]);\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/charcat1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\nusing namespace std;\n\nint main()\n{\n    char c;\n\n    // while it is possible to read a character\n    while (cin.get(c)) {\n        // print it\n        cout.put(c);\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/charcat2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    // input stream buffer iterator for cin\n    istreambuf_iterator<char> inpos(cin);\n\n    // end-of-stream iterator\n    istreambuf_iterator<char> endpos;\n\n    // output stream buffer iterator for cout\n    ostreambuf_iterator<char> outpos(cout);\n\n    // while input iterator is valid\n    while (inpos != endpos) {\n        *outpos = *inpos;    // assign its value to the output iterator\n        ++inpos;\n        ++outpos;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/charset.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <string>       // for strings\n#include <iostream>     // for I/O\n#include <fstream>      // for file I/O\n#include <iomanip>      // for setw()\n#include <cstdlib>      // for exit()\nusing namespace std;\n\n// forward declarations\nvoid writeCharsetToFile (const string& filename);\nvoid outputFile (const string& filename);\n\nint main ()\n{\n    writeCharsetToFile(\"charset.out\");\n    outputFile(\"charset.out\");\n}\n\nvoid writeCharsetToFile (const string& filename)\n{\n    // open output file\n    ofstream file(filename.c_str());\n\n    // file opened?\n    if (! file) {\n        // NO, abort program\n        cerr << \"can't open output file \\\"\" << filename << \"\\\"\"\n             << endl;\n        exit(EXIT_FAILURE);\n    }\n\n    // write character set\n    for (int i=32; i<256; i++) {\n        file << \"value: \" << setw(3) << i << \"   \"\n             << \"char:  \" << static_cast<char>(i) << endl;\n    }\n\n}   // closes file automatically\n\nvoid outputFile (const string& filename)\n{\n    // open input file\n    ifstream file(filename.c_str());\n\n    // file opened?\n    if (! file) {\n        // NO, abort program\n        cerr << \"can't open input file \\\"\" << filename << \"\\\"\"\n             << endl;\n        exit(EXIT_FAILURE);\n    }\n\n    // copy file contents to cout\n    char c;\n    while (file.get(c)) {\n        cout.put(c);\n    }\n\n}   // closes file automatically\n"
  },
  {
    "path": "stl侯杰源码/io/copy1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\nint main ()\n{\n    // copy all standard input to standard output\n    std::cout << std::cin.rdbuf();\n}\n"
  },
  {
    "path": "stl侯杰源码/io/copy2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\nint main ()\n{\n    // copy all standard input to standard output\n    std::cin >> std::noskipws >> std::cout.rdbuf();\n}\n"
  },
  {
    "path": "stl侯杰源码/io/countlines.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iterator>\n#include <algorithm>\n#include <fstream>\n#include <iostream>\n\nint countLines (std::istream& in);\n\nint main (int argc, char* argv[])\n{\n    int count;\n\n    if (argc == 1) {\n       // no argument => count lines of standard input\n       count = countLines(std::cin);\n    }\n    else {\n       // count number of lines of all files passed as argument\n       std::ifstream in;\n       count = 0;\n       for (int i=1; i<argc; ++i) {\n           in.open(argv[i]);\n           if (!in) {\n               std::cerr << \"failed to open \" << argv[1] << \"\\n\";\n           }\n           else {\n               count += countLines(in);\n               in.close();\n           }\n       }\n    }\n    std::cout << count << std::endl;\n}\n\nint countLines (std::istream& in)\n{\n    return std::count(std::istreambuf_iterator<char>(in),\n                      std::istreambuf_iterator<char>(),\n                      '\\n');\n}\n"
  },
  {
    "path": "stl侯杰源码/io/frac1in.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\ninline\nstd::istream& operator >> (std::istream& strm, Fraction& f)\n{\n    int n, d;\n\n    strm >> n;      // read value of the numerator\n    strm.ignore();  // skip '/'\n    strm >> d;      // read value of the denominator\n\n    f = Fraction(n,d);  // assign the whole fraction\n\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/frac1out.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\ninline\nstd::ostream& operator << (std::ostream& strm, const Fraction& f)\n{\n    strm << f.numerator() << '/' << f.denominator();\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/frac2in.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\ntemplate <class charT, class traits>\ninline\nstd::basic_istream<charT,traits>&\noperator >> (std::basic_istream<charT,traits>& strm, Fraction& f)\n{\n    int n, d;\n\n    // read value of numerator\n    strm >> n;\n\n    /* if available\n     * - read '/' and value of demonimator\n     */\n    if (strm.peek() == '/') {\n        strm.ignore();\n        strm >> d;\n    }\n    else {\n        d = 1;\n    }\n\n    /* if denominator is zero\n     * - set failbit as I/O format error\n     */\n    if (d == 0) {\n        strm.setstate(std::ios::failbit);\n        return strm;\n    }\n\n    /* if everything is fine so far\n     * change the value of the fraction\n     */\n    if (strm) {\n        f = Fraction(n,d);\n    }\n\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/frac2out.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <sstream>\n\ntemplate <class charT, class traits>\ninline\nstd::basic_ostream<charT,traits>&\noperator << (std::basic_ostream<charT,traits>& strm,\n             const Fraction& f)\n{\n    /* string stream\n     * - with same format\n     * - without special field width\n     */\n    std::basic_ostringstream<charT,traits> s;\n    s.copyfmt(strm);\n    s.width(0);\n\n    // fill string stream\n    s << f.numerator() << '/' << f.denominator();\n\n    // print string stream\n    strm << s.str();\n\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/ignore.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <istream>\n#include <limits>\n\ntemplate <class charT, class traits>\ninline\nstd::basic_istream<charT,traits>&\nignoreLine (std::basic_istream<charT,traits>& strm)\n{\n    // skip until end-of-line\n    strm.ignore(std::numeric_limits<int>::max(),strm.widen('\\n'));\n\n    // return stream for concatenation\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/ignore1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"ignore.hpp\"\n\nint main()\n{\n    int i;\n    std::cout << \"read int and ignore rest of the line\" << std::endl;\n    std::cin >> i;\n\n    // ignore the rest of the line\n    std::cin >> ignoreLine;\n\n    std::cout << \"int: \" << i << std::endl;\n\n    std::cout << \"read int and ignore two lines\" << std::endl;\n    std::cin >> i;\n\n    // ignore two lines\n    std::cin >> ignoreLine >> ignoreLine;\n\n    std::cout << \"int: \" << i << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/ignoreparam.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <limits>\n\n// Ignore: manipulator that ignores N lines\nclass Ignore {\n  public:\n    int num;\n    Ignore(int n) : num(n) {\n    }\n};\n    \n// convenience function\nIgnore ignore(int n)\n{\n    return Ignore(n);\n}\n\nstd::istream& operator >> (std::istream& strm, const Ignore& manip)\n{\n    for (int i=0; i<manip.num; ++i) {\n        strm.ignore(std::numeric_limits<int>::max(),'\\n'); \n    }\n    return strm;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/ignoreparam1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"ignoreparam.hpp\"\n\nint main()\n{\n    char c;\n    std::cout << \"ignore two lines and print frist character following them\\n\";\n    std::cin >> ignore(2) >> c;\n    std::cout << \"c: \" << c << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/inbuf1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"inbuf1.hpp\"\n\nint main()\n{\n    inbuf ib;                // create special stream buffer\n    std::istream in(&ib);    // initialize input stream with that buffer\n\n    char c;\n    for (int i=1; i<=20; i++) {\n        // read next character (out of the buffer)\n        in.get(c);\n\n        // print that character (and flush)\n        std::cout << c << std::flush;\n\n        // after eight characters, put two characters back into the stream\n        if (i == 8) {\n            in.unget();\n            in.unget();\n        }\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/inbuf1.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdio>\n#include <cstring>\n#include <streambuf>\n\n// for read():\n#ifdef _MSC_VER\n# include <io.h>\n#else\n# include <unistd.h>\n#endif\n\nclass inbuf : public std::streambuf {\n  protected:\n    /* data buffer:\n     * - at most, four characters in putback area plus\n     * - at most, six characters in ordinary read buffer\n     */\n    static const int bufferSize = 10;    // size of the data buffer\n    char buffer[bufferSize];             // data buffer\n  public:\n    /* constructor\n     * - initialize empty data buffer\n     * - no putback area\n     * => force underflow()\n     */\n    inbuf() {\n        setg (buffer+4,     // beginning of putback area\n              buffer+4,     // read position\n              buffer+4);    // end position\n    }\n  protected:\n    // insert new characters into the buffer\n    virtual int_type underflow () {\n\n        // is read position before end of buffer?\n        if (gptr() < egptr()) {\n            return traits_type::to_int_type(*gptr());\n        }\n\n        /* process size of putback area\n         * - use number of characters read\n         * - but at most four\n         */\n        int numPutback;\n        numPutback = gptr() - eback();\n        if (numPutback > 4) {\n            numPutback = 4;\n        }\n\n        /* copy up to four characters previously read into\n         * the putback buffer (area of first four characters)\n         */\n        std::memmove (buffer+(4-numPutback), gptr()-numPutback,\n                      numPutback);\n\n        // read new characters\n        int num;\n        num = read (0, buffer+4, bufferSize-4);\n        if (num <= 0) {\n            // ERROR or EOF\n            return EOF;\n        }\n\n        // reset buffer pointers\n        setg (buffer+(4-numPutback),   // beginning of putback area\n              buffer+4,                // read position\n              buffer+4+num);           // end of buffer\n\n        // return next character\n        return traits_type::to_int_type(*gptr());\n    }\n};\n"
  },
  {
    "path": "stl侯杰源码/io/io1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdlib>\n#include <iostream>\nusing namespace std;\n\nint main()\n{\n    double x, y;        // operands\n\n    // print header string\n    cout << \"Multiplication of two floating point values\" << endl;\n\n    // read first operand\n    cout << \"first operand:  \";\n    if (! (cin >> x)) {\n        /* input error\n         *  => error message and exit program with error status\n         */\n        cerr << \"error while reading the first floating value\"\n             << endl;\n        return EXIT_FAILURE;\n    }\n\n    // read second operand\n    cout << \"second operand: \";\n    if (! (cin >> y)) {\n        /* input error\n         *  => error message and exit program with error status\n         */\n        cerr << \"error while reading the second floating value\"\n             << endl;\n        return EXIT_FAILURE;\n    }\n\n    // print operands and result\n    cout << x << \" times \" << y << \" equals \" << x * y << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"outbuf1.hpp\"\n\nint main()\n{\n    outbuf ob;                // create special output buffer\n    std::ostream out(&ob);    // initialize output stream with that output buffer\n\n    out << \"31 hexadecimal: \" << std::hex << 31 << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf1.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <streambuf>\n#include <locale>\n#include <cstdio>\n\nclass outbuf : public std::streambuf\n{\n  protected:\n    /* central output function\n     * - print characters in uppercase mode\n     */\n    virtual int_type overflow (int_type c) {\n        if (c != EOF) {\n            // convert lowercase to uppercase\n            c = std::toupper(c,getloc());\n\n            // and write the character to the standard output\n            if (putchar(c) == EOF) {\n                return EOF;\n            }\n        }\n        return c;\n    }\n};\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf1x.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"outbuf1x.hpp\"\n\nint main()\n{\n    outbuf ob;                // create special output buffer\n    std::ostream out(&ob);    // initialize output stream with that output buffer\n\n    out << \"31 hexadecimal: \" << std::hex << 31 << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf1x.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <streambuf>\n#include <locale>\n#include <cstdio>\n\ntemplate <class charT, class traits = std::char_traits<charT> >\nclass basic_outbuf : public std::basic_streambuf<charT,traits>\n{\n  protected:\n    /* central output function\n     * - print characters in uppercase mode\n     */\n    virtual typename traits::int_type\n            overflow (typename traits::int_type c) {\n        if (!traits::eq_int_type(c,traits::eof())) {\n            // convert lowercase to uppercase\n            c = std::toupper(c,getloc());\n\n            // and write the character to the standard output\n            if (putchar(c) == EOF) {\n                return traits::eof();\n            }\n        }\n        return traits::not_eof(c);\n    }\n};\n\ntypedef basic_outbuf<char>    outbuf;\ntypedef basic_outbuf<wchar_t> woutbuf;\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"outbuf2.hpp\"\n\nint main()\n{\n    fdostream out(1);    // stream with buffer writing to file descriptor 1\n\n    out << \"31 hexadecimal: \" << std::hex << 31 << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf2.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <streambuf>\n#include <cstdio>\n\n// for write():\n#ifdef _MSC_VER\n# include <io.h>\n#else\n# include <unistd.h>\n#endif\n\nclass fdoutbuf : public std::streambuf {\n  protected:\n    int fd;    // file descriptor\n  public:\n    // constructor\n    fdoutbuf (int _fd) : fd(_fd) {\n    }\n  protected:\n    // write one character\n    virtual int_type overflow (int_type c) {\n        if (c != EOF) {\n            char z = c;\n            if (write (fd, &z, 1) != 1) {\n                return EOF;\n            }\n        }\n        return c;\n    }\n    // write multiple characters\n    virtual std::streamsize xsputn (const char* s,\n                                    std::streamsize num) {\n        return write(fd,s,num);\n    }\n};\n\nclass fdostream : public std::ostream {\n  protected:\n    fdoutbuf buf;\n  public:\n    fdostream (int fd) : std::ostream(0), buf(fd) {\n        rdbuf(&buf);\n    }\n};\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include \"outbuf3.hpp\"\n\nint main()\n{\n    outbuf ob;                // create special output buffer\n    std::ostream out(&ob);    // initialize output stream with that output buffer\n\n    out << \"31 hexadecimal: \" << std::hex << 31 << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/outbuf3.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <cstdio>\n#include <streambuf>\n\n// for write():\n#ifdef _MSC_VER\n# include <io.h>\n#else\n# include <unistd.h>\n#endif\n\nclass outbuf : public std::streambuf {\n  protected:\n    static const int bufferSize = 10;   // size of data buffer\n    char buffer[bufferSize];            // data buffer\n\n  public:\n    /* constructor\n     * - initialize data buffer\n     * - one character less to let the bufferSizeth character\n     *    cause a call of overflow()\n     */\n    outbuf() {\n        setp (buffer, buffer+(bufferSize-1));\n    }\n\n    /* destructor\n     * - flush data buffer\n     */\n    virtual ~outbuf() {\n        sync();\n    }\n\n  protected:\n    // flush the characters in the buffer\n    int flushBuffer () {\n        int num = pptr()-pbase();\n        if (write (1, buffer, num) != num) {\n            return EOF;\n        }\n        pbump (-num);    // reset put pointer accordingly\n        return num;\n    }\n\n    /* buffer full\n     * - write c and all previous characters\n     */\n    virtual int_type overflow (int_type c) {\n        if (c != EOF) {\n            // insert character into the buffer\n            *pptr() = c;\n            pbump(1);\n        }\n        // flush the buffer\n        if (flushBuffer() == EOF) {\n            // ERROR\n            return EOF;\n        }\n        return c;\n    }\n\n    /* synchronize data with file/destination\n     * - flush the data in the buffer\n     */\n    virtual int sync () {\n        if (flushBuffer() == EOF) {\n            // ERROR\n            return -1;\n        }\n        return 0;\n    }\n};\n"
  },
  {
    "path": "stl侯杰源码/io/rdbuf1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <fstream>\nusing namespace std;\n\nint main()\n{\n    // stream for hexadecimal standard output\n    ostream hexout(cout.rdbuf());\n    hexout.setf (ios::hex, ios::basefield);\n    hexout.setf (ios::showbase);\n\n    // switch between decimal and hexadecimal output\n    hexout << \"hexout: \" << 177 << \" \";\n    cout   << \"cout: \"   << 177 << \" \";\n    hexout << \"hexout: \" << -49 << \" \";\n    cout   << \"cout: \"   << -49 << \" \";\n    hexout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/rdbuf2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <fstream>\n\nvoid hexMultiplicationTable (std::streambuf* buffer, int num)\n{\n    std::ostream hexout(buffer);\n    hexout << std::hex << std::showbase;\n\n    for (int i=1; i<=num; ++i) {\n        for (int j=1; j<=10; ++j) {\n            hexout << i*j << ' ';\n        }\n        hexout << std::endl;\n    }\n\n}   // does NOT close buffer\n\nint main()\n{\n    using namespace std;\n    int num = 5;\n\n    cout << \"We print \" << num\n         << \" lines hexadecimal\" << endl;\n\n    hexMultiplicationTable(cout.rdbuf(),num);\n\n    cout << \"That was the output of \" << num\n         << \" hexadecimal lines \" << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/redirect.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <fstream>\nusing namespace std;\n\nvoid redirect(ostream&);\n\nint main()\n{\n    cout << \"the first row\" << endl;\n\n    redirect(cout);\n\n    cout << \"the last row\" << endl;\n}\n\nvoid redirect (ostream& strm)\n{\n    ofstream file(\"redirect.txt\");\n    \n    // save output buffer of the stream\n    streambuf* strm_buffer = strm.rdbuf();\n\n    // redirect ouput into the file\n    strm.rdbuf (file.rdbuf());\n\n    file << \"one row for the file\" << endl;\n    strm << \"one row for the stream\" << endl;\n\n    // restore old output buffer\n    strm.rdbuf (strm_buffer);\n\n}    // closes file AND its buffer automatically\n"
  },
  {
    "path": "stl侯杰源码/io/rw1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <fstream>\nusing namespace std;\n\nint main()\n{\n    // open file ``example.dat'' for reading and writing\n    filebuf buffer;\n    ostream output(&buffer);\n    istream input(&buffer);\n    buffer.open (\"example.dat\", ios::in | ios::out | ios::trunc);\n\n    for (int i=1; i<=4; i++) {\n        // write one line\n        output << i << \". line\" << endl;\n\n        // print all file contents\n        input.seekg(0);          // seek to the beginning\n        char c;\n        while (input.get(c)) {\n            cout.put(c);\n        }\n        cout << endl;\n        input.clear();           // clear  eofbit and  failbit\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/sstr1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <sstream>\n#include <bitset>\nusing namespace std;\n\nint main()\n{\n    ostringstream os;\n\n    // decimal and hexadecimal value\n    os << \"dec: \" << 15 << hex << \" hex: \" << 15 << endl;\n    cout << os.str() << endl;\n\n    // append floating value and bitset\n    bitset<15> b(5789);\n    os << \"float: \" << 4.67 << \" bitset: \" << b << endl;\n\n    // overwrite with octal value\n    os.seekp(0);\n    os << \"oct: \" << oct << 15;\n    cout << os.str() << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/io/sum1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <cstdlib>\n\nnamespace MyLib {\n    double readAndProcessSum (std::istream&);\n}\n\nint main()\n{\n    using namespace std;\n    double sum;\n\n    try {\n        sum = MyLib::readAndProcessSum(cin);\n    }\n    catch (const ios::failure& error) {\n        cerr << \"I/O exception: \" << error.what() << endl;\n        return EXIT_FAILURE;\n    }\n    catch (const exception& error) {\n        cerr << \"standard exception: \" << error.what() << endl;\n        return EXIT_FAILURE;\n    }\n    catch (...) {\n        cerr << \"unknown exception\" << endl;\n        return EXIT_FAILURE;\n    }\n\n    // print sum\n    cout << \"sum: \" << sum << endl;\n}\n\n#include <istream>\n\nnamespace MyLib {\n    double readAndProcessSum (std::istream& strm)\n    {\n        using std::ios;\n        double value, sum;\n    \n        // save current state of exception flags\n        ios::iostate oldExceptions = strm.exceptions();\n    \n        /* let failbit and badbit throw exceptions\n         * - NOTE: failbit is also set at end-of-file\n         */\n        strm.exceptions (ios::failbit | ios::badbit);\n    \n        try {\n            /* while stream is OK\n             * - read value and add it to sum\n             */\n            sum = 0;\n            while (strm >> value) {\n                sum += value;\n            }\n        }\n        catch (...) {\n            /* if exception not caused by end-of-file\n             * - restore old state of exception flags\n             * - rethrow exception\n             */\n            if (!strm.eof()) {\n                strm.exceptions(oldExceptions);  // restore exception flags\n                throw;                           // rethrow\n            }\n        }\n    \n        // restore old state of exception flags\n        strm.exceptions (oldExceptions);\n    \n        // return sum\n        return sum;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/io/sum2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <cstdlib>\n\nnamespace MyLib {\n    double readAndProcessSum (std::istream&);\n}\n\nint main()\n{\n    using namespace std;\n    double sum;\n\n    try {\n        sum = MyLib::readAndProcessSum(cin);\n    }\n    catch (const ios::failure& error) {\n        cerr << \"I/O exception: \" << error.what() << endl;\n        return EXIT_FAILURE;\n    }\n    catch (const exception& error) {\n        cerr << \"standard exception: \" << error.what() << endl;\n        return EXIT_FAILURE;\n    }\n    catch (...) {\n        cerr << \"unknown exception\" << endl;\n        return EXIT_FAILURE;\n    }\n\n    // print sum\n    cout << \"sum: \" << sum << endl;\n}\n\n#include <istream>\n\nnamespace MyLib {\n    double readAndProcessSum (std::istream& strm)\n    {\n        double value, sum;\n    \n        /* while stream is OK\n         * - read value and add it to sum\n         */\n        sum = 0;\n        while (strm >> value) {\n            sum += value;\n        }\n    \n        if (!strm.eof()) {\n            throw std::ios::failure\n                    (\"input error in readAndProcessSum()\");\n        }\n    \n        // return sum\n        return sum;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/Makefile",
    "content": "OUTPROGS = itercat advance1 distance swap1 \\\n\t\treviter1 reviter2 reviter3 reviter4 \\\n\t\tbackins frontins inserter \\\n\t\tostriter \\\n\t\tassoiter\n\nCPPPROGS = \tistriter advance2 \n\nHEADERS =\tdistance.hpp assoiter.hpp print.hpp\n\nEXPORT =\tistriter.in advance2.in\n\ninclude ../Makefile.h\n\nassoiter: assoiter.hpp assoiter.cpp\n\t$(CXX) $(CXXFLAGS) $(LDFLAGS) $@.cpp -o $@\n\n"
  },
  {
    "path": "stl侯杰源码/iter/advance1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    list<int>::iterator pos = coll.begin();\n\n    // print actual element\n    cout << *pos << endl;\n\n    // step three elements forward\n    advance (pos, 3);\n\n    // print actual element\n    cout << *pos << endl;\n\n    // step one element backward\n    advance (pos, -1);\n\n    // print actual element\n    cout << *pos << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/advance2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    istream_iterator<string> cinPos(cin);\n    ostream_iterator<string> coutPos(cout,\" \");\n\n    /* while input is not at the end of the file\n     * - write every third string\n     */\n    while (cinPos != istream_iterator<string>()) {\n        // ignore the following two strings\n        advance (cinPos, 2);\n\n        // read and write the third string\n        if (cinPos != istream_iterator<string>()) {\n            *coutPos++ = *cinPos++;\n        }\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/assoiter.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <algorithm>\nusing namespace std;\n\n#include \"print.hpp\"\n\n#include \"assoiter.hpp\"\n\nint main()\n{\n    set<int> coll;   \n\n    // create inserter for coll\n    // - inconvenient way\n    asso_insert_iterator<set<int> > iter(coll);\n\n    // insert elements with the usual iterator interface\n    *iter = 1;\n    iter++;\n    *iter = 2;\n    iter++;\n    *iter = 3;\n\n    PRINT_ELEMENTS(coll);\n\n    // create inserter for coll and insert elements\n    // - convenient way\n    asso_inserter(coll) = 44;\n    asso_inserter(coll) = 55;\n\n    PRINT_ELEMENTS(coll);\n\n    // use inserter with an algorithm\n    int vals[] = { 33, 67, -4, 13, 5, 2 };\n    copy (vals, vals+(sizeof(vals)/sizeof(vals[0])),  // source\n          asso_inserter(coll));                       // destination\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/assoiter.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iterator>\n\n/* template class for insert iterator for associative containers\n */\ntemplate <class Container>\nclass asso_insert_iterator\n : public std::iterator <std::output_iterator_tag,\n                         void, void, void, void>\n{\n  protected:\n    Container& container;    // container in which elements are inserted\n\n  public:\n    // constructor\n    explicit asso_insert_iterator (Container& c) : container(c) {\n    }\n\n    // assignment operator\n    // - inserts a value into the container\n    asso_insert_iterator<Container>&\n    operator= (const typename Container::value_type& value) { \n        container.insert(value);\n        return *this;\n    }\n\n    // dereferencing is a no-op that returns the iterator itself\n    asso_insert_iterator<Container>& operator* () {\n        return *this;\n    }\n\n    // increment operation is a no-op that returns the iterator itself\n    asso_insert_iterator<Container>& operator++ () {\n        return *this;\n    }\n    asso_insert_iterator<Container>& operator++ (int) {\n        return *this;\n    }\n};\n\n/* convenience function to create the inserter\n */\ntemplate <class Container>\ninline asso_insert_iterator<Container> asso_inserter (Container& c)\n{\n    return asso_insert_iterator<Container>(c);\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/backins.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    // create back inserter for coll\n    // - inconvenient way\n    back_insert_iterator<vector<int> > iter(coll);\n\n    // insert elements with the usual iterator interface\n    *iter = 1;\n    iter++;\n    *iter = 2;\n    iter++;\n    *iter = 3;\n    PRINT_ELEMENTS(coll);\n\n    // create back inserter and insert elements\n    // - convenient way\n    back_inserter(coll) = 44;\n    back_inserter(coll) = 55;\n    PRINT_ELEMENTS(coll);\n\n    // use back inserter to append all elements again\n    // - reserve enough memory to avoid reallocation\n    coll.reserve(2*coll.size());\n    copy (coll.begin(), coll.end(),    // source\n          back_inserter(coll));        // destination\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/distance.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from -3 to 9\n    for (int i=-3; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // search element with value 5\n    list<int>::iterator pos;\n    pos = find (coll.begin(), coll.end(),    // range\n                5);                          // value\n\n    if (pos != coll.end()) {\n        // process and print difference from the beginning\n        cout << \"difference between beginning and 5: \"\n             << distance(coll.begin(),pos) << endl;\n    }\n    else {\n        cout << \"5 not found\" << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/distance.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\ntemplate <class Iterator>\ninline long distance (Iterator pos1, Iterator pos2)\n{\n    long d = 0;\n    distance (pos1, pos2, d);\n    return d;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/frontins.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // create front inserter for coll\n    // - inconvenient way\n    front_insert_iterator<list<int> > iter(coll);\n\n    // insert elements with the usual iterator interface\n    *iter = 1;\n    iter++;\n    *iter = 2;\n    iter++;\n    *iter = 3;\n\n    PRINT_ELEMENTS(coll);\n\n    // create front inserter and insert elements\n    // - convenient way\n    front_inserter(coll) = 44;\n    front_inserter(coll) = 55;\n\n    PRINT_ELEMENTS(coll);\n\n    // use front inserter to insert all elements again\n    copy (coll.begin(), coll.end(),    // source\n          front_inserter(coll));       // destination\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/inserter.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    set<int> coll;\n\n    // create insert iterator for coll\n    // - inconvenient way\n    insert_iterator<set<int> > iter(coll,coll.begin());\n\n    // insert elements with the usual iterator interface\n    *iter = 1;\n    iter++;\n    *iter = 2;\n    iter++;\n    *iter = 3;\n\n    PRINT_ELEMENTS(coll,\"set:  \");\n\n    // create inserter and insert elements\n    // - convenient way\n    inserter(coll,coll.end()) = 44;\n    inserter(coll,coll.end()) = 55;\n\n    PRINT_ELEMENTS(coll,\"set:  \");\n\n    // use inserter to insert all elements into a list\n    list<int> coll2;\n    copy (coll.begin(), coll.end(),           // source\n          inserter(coll2,coll2.begin()));     // destination\n\n    PRINT_ELEMENTS(coll2,\"list: \");\n\n    // use inserter to reinsert all elements into the list before the second element\n    copy (coll.begin(), coll.end(),           // source\n          inserter(coll2,++coll2.begin()));   // destination\n\n    PRINT_ELEMENTS(coll2,\"list: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/istriter.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    // create istream iterator that reads integers from cin\n    istream_iterator<int> intReader(cin);\n\n    // create end-of-stream iterator\n    istream_iterator<int> intReaderEOF;\n\n    /* while able to read tokens with istream iterator\n     * - write them twice\n     */\n    while (intReader != intReaderEOF) {\n        cout << \"once:       \" << *intReader << endl;\n        cout << \"once again: \" << *intReader << endl;\n        ++intReader;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/itercat.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <vector>\n#include <iostream>\nusing namespace std;\n\nint main()\n{\n   vector<int> coll;\n\n   // insert elements from -3 to 9\n   for (int i=-3; i<=9; ++i) {\n       coll.push_back (i);\n   }\n\n   /* print number of elements by processing the distance between beginning and end\n    * - NOTE: uses operator - for iterators\n    */\n   cout << \"number/distance: \" << coll.end()-coll.begin() << endl;\n\n   /* print all elements\n    * - NOTE: uses operator < instead of operator !=\n    */\n   vector<int>::iterator pos;\n   for (pos=coll.begin(); pos<coll.end(); ++pos) {\n       cout << *pos << ' ';\n   }\n   cout << endl;\n\n   /* print all elements\n    * - NOTE: uses operator [] instead of operator *\n    */\n   for (int i=0; i<coll.size(); ++i) {\n       cout << coll.begin()[i] << ' ';\n   }\n   cout << endl;\n\n   /* print every second element\n    * - NOTE: uses operator +=\n    */\n   for (pos = coll.begin(); pos < coll.end()-1; pos += 2) {\n       cout << *pos << ' ';\n   }\n   cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/ostriter.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    // create ostream iterator for stream cout\n    // - values are separated by a newline character\n    ostream_iterator<int> intWriter(cout,\"\\n\");\n\n    // write elements with the usual iterator interface\n    *intWriter = 42;\n    intWriter++;\n    *intWriter = 77;\n    intWriter++;\n    *intWriter = -5;\n\n    // create collection with elements from 1 to 9\n    vector<int> coll;\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // write all elements without any delimiter\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout));\n    cout << endl;\n\n    // write all elements with \" < \" as delimiter\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout,\" < \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/print.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\n/* PRINT_ELEMENTS()\n * - prints optional C-string optcstr followed by\n * - all elements of the collection coll\n * - separated by spaces\n */\ntemplate <class T>\ninline void PRINT_ELEMENTS (const T& coll, const char* optcstr=\"\")\n{\n    typename T::const_iterator pos;\n\n    std::cout << optcstr;\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/reviter1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nvoid print (int elem)\n{\n    cout << elem << ' ';\n}\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // print all elements in normal order\n    for_each (coll.begin(), coll.end(),      // range\n              print);                        // operation\n    cout << endl;\n\n    // print all elements in reverse order\n    for_each (coll.rbegin(), coll.rend(),    // range\n              print);                        // operations\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/reviter2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // find position of element with value 5\n    vector<int>::iterator pos;\n    pos = find (coll.begin(), coll.end(),\n                5);\n\n    // print value to which iterator pos refers\n    cout << \"pos:  \" << *pos << endl;\n\n    // convert iterator to reverse iterator rpos\n    vector<int>::reverse_iterator rpos(pos);\n\n    // print value to which reverse iterator rpos refers\n    cout << \"rpos: \" << *rpos << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/reviter3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <deque>\n#include <algorithm>\nusing namespace std;\n\nvoid print (int elem)\n{\n    cout << elem << ' ';\n}\n\nint main()\n{\n    deque<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // find position of element with value 2\n    deque<int>::iterator pos1;\n    pos1 = find (coll.begin(), coll.end(),    // range\n                 2);                          // value\n\n    // find position of element with value 7\n    deque<int>::iterator pos2;\n    pos2 = find (coll.begin(), coll.end(),    // range\n                 7);                          // value\n\n    // print all elements in range [pos1,pos2)\n    for_each (pos1, pos2,     // range\n              print);         // operation\n    cout << endl;\n\n    // convert iterators to reverse iterators\n    deque<int>::reverse_iterator rpos1(pos1);\n    deque<int>::reverse_iterator rpos2(pos2);\n\n    // print all elements in range [pos1,pos2) in reverse order\n    for_each (rpos2, rpos1,   // range\n              print);         // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/reviter4.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // find position of element with value 5\n    list<int>::iterator pos;\n    pos = find (coll.begin(), coll.end(),    // range\n                5);                          // value\n\n    // print value of the element\n    cout << \"pos:   \" << *pos << endl;\n\n    // convert iterator to reverse iterator\n    list<int>::reverse_iterator rpos(pos);\n\n    // print value of the element to which the reverse iterator refers\n    cout << \"rpos:  \" << *rpos << endl;\n\n    // convert reverse iterator back to normal iterator\n    list<int>::iterator rrpos;\n    rrpos = rpos.base();\n\n    // print value of the element to which the normal iterator refers\n    cout << \"rrpos: \" << *rrpos << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/iter/swap1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    PRINT_ELEMENTS(coll);\n\n    // swap first and second value\n    iter_swap (coll.begin(), ++coll.begin());\n\n    PRINT_ELEMENTS(coll);\n\n    // swap first and last value\n    iter_swap (coll.begin(), --coll.end());\n\n    PRINT_ELEMENTS(coll);\n}\n"
  },
  {
    "path": "stl侯杰源码/memory/Makefile",
    "content": "include ../Makefile.h\n\nOUTPROGS = myalloc1\n\nHEADERS = myalloc.hpp\n\n\nuninit.o: uninit_fill.cpp uninit_fill_n.cpp uninit_copy.cpp \\\n\t\tallocvoid.cpp defalloc.cpp\n\n"
  },
  {
    "path": "stl侯杰源码/memory/myalloc.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <limits>\n#include <iostream>\n\nnamespace MyLib {\n   template <class T>\n   class MyAlloc {\n     public:\n       // type definitions\n       typedef T        value_type;\n       typedef T*       pointer;\n       typedef const T* const_pointer;\n       typedef T&       reference;\n       typedef const T& const_reference;\n       typedef std::size_t    size_type;\n       typedef std::ptrdiff_t difference_type;\n\n       // rebind allocator to type U\n       template <class U>\n       struct rebind {\n           typedef MyAlloc<U> other;\n       };\n\n       // return address of values\n       pointer address (reference value) const {\n           return &value;\n       }\n       const_pointer address (const_reference value) const {\n           return &value;\n       }\n\n       /* constructors and destructor\n        * - nothing to do because the allocator has no state\n        */\n       MyAlloc() throw() {\n       }\n       MyAlloc(const MyAlloc&) throw() {\n       }\n       template <class U>\n         MyAlloc (const MyAlloc<U>&) throw() {\n       }\n       ~MyAlloc() throw() {\n       }\n\n       // return maximum number of elements that can be allocated\n       size_type max_size () const throw() {\n           return std::numeric_limits<std::size_t>::max() / sizeof(T);\n       }\n\n       // allocate but don't initialize num elements of type T\n       pointer allocate (size_type num, const void* = 0) {\n           // print message and allocate memory with global new\n           std::cerr << \"allocate \" << num << \" element(s)\"\n                     << \" of size \" << sizeof(T) << std::endl;\n           pointer ret = (pointer)(::operator new(num*sizeof(T)));\n           std::cerr << \" allocated at: \" << (void*)ret << std::endl;\n           return ret;\n       }\n\n       // initialize elements of allocated storage p with value value\n       void construct (pointer p, const T& value) {\n           // initialize memory with placement new\n           new((void*)p)T(value);\n       }\n\n       // destroy elements of initialized storage p\n       void destroy (pointer p) {\n           // destroy objects by calling their destructor\n           p->~T();\n       }\n\n       // deallocate storage p of deleted elements\n       void deallocate (pointer p, size_type num) {\n           // print message and deallocate memory with global delete\n           std::cerr << \"deallocate \" << num << \" element(s)\"\n                     << \" of size \" << sizeof(T)\n                     << \" at: \" << (void*)p << std::endl;\n           ::operator delete((void*)p);\n       }\n   };\n\n   // return that all specializations of this allocator are interchangeable\n   template <class T1, class T2>\n   bool operator== (const MyAlloc<T1>&,\n                    const MyAlloc<T2>&) throw() {\n       return true;\n   }\n   template <class T1, class T2>\n   bool operator!= (const MyAlloc<T1>&,\n                    const MyAlloc<T2>&) throw() {\n       return false;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/memory/myalloc1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <vector>\n#include \"myalloc.hpp\"\n\nint main()\n{\n    // create a vector, using MyAlloc<> as allocator\n    std::vector<int,MyLib::MyAlloc<int> > v;\n\n    // insert elements\n    // - causes reallocations\n    v.push_back(42);\n    v.push_back(56);\n    v.push_back(11);\n    v.push_back(22);\n    v.push_back(33);\n    v.push_back(44);\n}\n\n"
  },
  {
    "path": "stl侯杰源码/num/Makefile",
    "content": "include ../Makefile.h\n\nCPPPROGS = \\\n        complex2\n\nOUTPROGS = \\\n        complex1 \\\n        val1 val2 slice1 gslice1 masked1 indi1\n\nOTHERS = complextests valtests\n\n"
  },
  {
    "path": "stl侯杰源码/num/complex1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <complex>\nusing namespace std;\n\nint main()\n{\n    /* complex number with real and imaginary parts\n     * - real part: 4.0\n     * - imaginary part: 3.0\n     */\n    complex<double> c1(4.0,3.0);\n\n    /* create complex number from polar coordinates\n     * - magnitude: 5.0\n     * - phase angle: 0.75\n     */\n    complex<float> c2(polar(5.0,0.75));\n\n    // print complex numbers with real and imaginary parts\n    cout << \"c1: \" << c1 << endl;\n    cout << \"c2: \" << c2 << endl;\n\n    // print complex numbers as polar coordinates\n    cout << \"c1: magnitude: \" << abs(c1)\n         << \" (squared magnitude: \" << norm(c1) << \") \"\n         <<    \" phase angle: \" << arg(c1) << endl;\n    cout << \"c2: magnitude: \" << abs(c2)\n         << \" (squared magnitude: \" << norm(c2) << \") \"\n         <<    \" phase angle: \" << arg(c2) << endl;\n\n    // print complex conjugates\n    cout << \"c1 conjugated:  \" << conj(c1) << endl;\n    cout << \"c2 conjugated:  \" << conj(c2) << endl;\n\n    // print result of a computation\n    cout << \"4.4 + c1 * 1.8: \" << 4.4 + c1 * 1.8 << endl;\n\n    /* print sum of c1 and c2:\n     * - note: different types\n     */\n    cout << \"c1 + c2:        \"\n         << c1 + complex<double>(c2.real(),c2.imag()) << endl;\n\n    // add square root of c1 to c1 and print the result\n    cout << \"c1 += sqrt(c1): \" << (c1 += sqrt(c1)) << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/num/complex2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <complex>\n#include <cstdlib>\n#include <limits>\nusing namespace std;\n\nint main()\n{\n    complex<long double> c1, c2;\n\n    while (cin.peek() != EOF) {\n\n        // read first complex number\n        cout << \"complex number c1: \";\n        cin >> c1;\n        if (!cin) {\n            cerr << \"input error\" << endl;\n            return EXIT_FAILURE;\n        }\n\n        // read second complex number\n        cout << \"complex number c2: \";\n        cin >> c2;\n        if (!cin) {\n            cerr << \"input error\" << endl;\n            return EXIT_FAILURE;\n        }\n\n        if (c1 == c2) {\n            cout << \"c1 and c2 are equal !\" << endl;\n        }\n\n        cout << \"c1 raised to the c2: \" << pow(c1,c2)\n             << endl << endl;\n\n        // skip rest of line\n        cin.ignore(numeric_limits<int>::max(),'\\n');\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/num/gslice1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print three-dimensional valarray line-by-line\ntemplate<class T>\nvoid printValarray3D (const valarray<T>& va, int dim1, int dim2)\n{\n    for (int i=0; i<va.size()/(dim1*dim2); ++i) {\n        for (int j=0; j<dim2; ++j) {\n            for (int k=0; k<dim1; ++k) {\n                cout << va[i*dim1*dim2+j*dim1+k] << ' ';\n            }\n            cout << '\\n';\n        }\n        cout << '\\n';\n    }\n    cout << endl;\n}\n\nint main()\n{\n    /* valarray with 24 elements\n     * - two groups\n     * - four rows\n     * - three columns\n     */\n    valarray<double> va(24);\n\n    // fill valarray with values\n    for (int i=0; i<24; i++) {\n        va[i] = i;\n    }\n\n    // print valarray\n    printValarray3D (va, 3, 4);\n\n    // we need two two-dimensional subsets of three times 3 values\n    // in two 12-element arrays\n    size_t lengthvalues[] = {  2, 3 };\n    size_t stridevalues[] = { 12, 3 };\n    valarray<size_t> length(lengthvalues,2);\n    valarray<size_t> stride(stridevalues,2);\n\n    // assign the second column of the first three rows\n    // to the first column of the first three rows\n    va[gslice(0,length,stride)]\n        = valarray<double>(va[gslice(1,length,stride)]);\n\n    // add and assign the third of the first three rows\n    // to the first of the first three rows\n    va[gslice(0,length,stride)]\n        += valarray<double>(va[gslice(2,length,stride)]);\n    \n    // print valarray\n    printValarray3D (va, 3, 4);\n}\n"
  },
  {
    "path": "stl侯杰源码/num/indi1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print valarray as two-dimensional array\ntemplate<class T>\nvoid printValarray (const valarray<T>& va, int num)\n{\n    for (int i=0; i<va.size()/num; i++) {\n        for (int j=0; j<num; j++) {\n            cout << va[i*num+j] << ' ';\n        }\n        cout << endl;\n    }\n    cout << endl;\n}\n\nint main()\n{\n    // create valarray for 12 elements\n    valarray<double> va(12);\n\n    // initialize valarray by values 1.01, 2.02, ... 12.12\n    for (int i=0; i<12; i++) {\n        va[i] = (i+1) * 1.01;\n    }\n    printValarray(va,4);\n\n    /* create array of indexes\n     * - note: element type has to be size_t\n     */\n    valarray<size_t> idx(4);\n    idx[0] = 8;\n    idx[1] = 0;\n    idx[2] = 3;\n    idx[3] = 7;\n\n    // use array of indexes to print the ninth, first, fourth, and eighth elements\n    printValarray(valarray<double>(va[idx]), 4);\n\n    // change the first and fourth elements and print them again indirectly\n    va[0] = 11.11;\n    va[3] = 44.44;\n    printValarray(valarray<double>(va[idx]), 4);\n\n    // now select the second, third, sixth, and ninth elements\n    // and assign 99 to them\n    idx[0] = 1;\n    idx[1] = 2;\n    idx[2] = 5;\n    idx[3] = 8;\n    va[idx] = 99;\n\n    // print the whole valarray again\n    printValarray (va, 4);\n}\n"
  },
  {
    "path": "stl侯杰源码/num/masked1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print valarray line-by-line\ntemplate<class T>\nvoid printValarray (const valarray<T>& va, int num)\n{\n    for (int i=0; i<va.size()/num; ++i) {\n        for (int j=0; j<num; ++j) {\n            cout << va[i*num+j] << ' ';\n        }\n        cout << endl;\n    }\n    cout << endl;\n}\n\nint main()\n{\n    /* valarray with 12 elements\n     * - four rows\n     * - three columns\n     */\n    valarray<double> va(12);\n\n    // fill valarray with values\n    for (int i=0; i<12; i++) {\n        va[i] = i;\n    }\n\n    printValarray (va, 3);\n\n    // assign 77 to all values that are less than 5\n    va[va<5.0] = 77.0;\n\n    // add 100 to all values that are greater than 5 and less than 9\n    va[va>5.0 && va<9.0]\n        = valarray<double>(va[va>5.0 && va<9.0]) + 100.0;\n\n    printValarray (va, 3);\n}\n"
  },
  {
    "path": "stl侯杰源码/num/slice1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print valarray line-by-line\ntemplate<class T>\nvoid printValarray (const valarray<T>& va, int num)\n{\n    for (int i=0; i<va.size()/num; ++i) {\n        for (int j=0; j<num; ++j) {\n            cout << va[i*num+j] << ' ';\n        }\n        cout << endl;\n    }\n    cout << endl;\n}\n\nint main()\n{\n    /* valarray with 12 elements\n     * - four rows\n     * - three columns\n     */\n    valarray<double> va(12);\n\n    // fill valarray with values\n    for (int i=0; i<12; i++) {\n        va[i] = i;\n    }\n\n    printValarray (va, 3);\n\n    // first column = second column raised to the third column\n    va[slice(0,4,3)] = pow (valarray<double>(va[slice(1,4,3)]),\n                            valarray<double>(va[slice(2,4,3)]));\n\n    printValarray (va, 3);\n\n    // create valarray with three times the third element of va\n    valarray<double> vb(va[slice(2,4,0)]);\n\n    // multiply the third column by the elements of vb\n    va[slice(2,4,3)] *= vb;\n\n    printValarray (va, 3);\n\n    // print the square root of the elements in the second row\n    printValarray (sqrt(valarray<double>(va[slice(3,3,1)])));\n\n    // double the elements in the third row\n    va[slice(2,4,3)] = valarray<double>(va[slice(2,4,3)]) * 2.0;\n\n    printValarray (va, 3);\n}\n"
  },
  {
    "path": "stl侯杰源码/num/val1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print valarray\ntemplate <class T>\nvoid printValarray (const valarray<T>& va)\n{\n    for (int i=0; i<va.size(); i++) {\n        cout << va[i] << ' ';\n    }\n    cout << endl;\n}\n\nint main()\n{\n    // define two valarrays with ten elements\n    valarray<double> va1(10), va2(10);\n\n    // assign values 0.0, 1.1, up to 9.9 to the first valarray\n    for (int i=0; i<10; i++) {\n        va1[i] = i * 1.1;\n    }\n\n    // assign -1 to all elements of the second valarray\n    va2 = -1;\n\n    // print both valarrays\n    printValarray(va1);\n    printValarray(va2);\n\n    // print minimum, maximum, and sum of the first valarray\n    cout << \"min(): \" << va1.min() << endl;\n    cout << \"max(): \" << va1.max() << endl;\n    cout << \"sum(): \" << va1.sum() << endl;\n\n    // assign values of the first to the second valarray\n    va2 = va1;\n\n    // remove all elements of the first valarray\n    va1.resize(0);\n\n    // print both valarrays again\n    printValarray(va1);\n    printValarray(va2);\n}\n"
  },
  {
    "path": "stl侯杰源码/num/val2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <valarray>\nusing namespace std;\n\n// print valarray\ntemplate <class T>\nvoid printValarray (const valarray<T>& va)\n{\n    for (int i=0; i<va.size(); i++) {\n        cout << va[i] << ' ';\n    }\n    cout << endl;\n}\n\nint main()\n{\n    // create and initialize valarray with nine elements\n    valarray<double> va(9);\n    for (int i=0; i<va.size(); i++) {\n        va[i] = i * 1.1;\n    }\n\n    // print valarray\n    printValarray(va);\n\n    // double values in the valarray\n    va *= 2.0;\n\n    // print valarray again\n    printValarray(va);\n\n    // create second valarray initialized by the values of the first plus 10\n    valarray<double> vb(va+10.0);\n\n    // print second valarray\n    printValarray(vb);\n\n    // create third valarray as a result of processing both existing valarrays\n    valarray<double> vc(9);\n    vc = sqrt(va) + vb/2.0 - 1.0;\n    \n    // print third valarray\n    printValarray(vc);\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/Makefile",
    "content": "include ../Makefile.h\n\nOUTPROGS = \tvector1 deque1 list1 set1 \\\n\t\tmmap1 map1 algo1 riter1 \\\n\t\tremove1 remove2 remove3 \\\n\t\tforeach1 transform1 prime1 \\\n\t\tsort1 fo1\n\nCPPPROGS =\tlist2 find1 copy1 copy2 copy3 ioiter1 \\\n\t\tremove4 foreach2 add1 iterbug1\n\nHEADERS =\tprint.hpp\n\n"
  },
  {
    "path": "stl侯杰源码/stl/add1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\n// function object that adds the value with which it is initialized\nclass AddValue {\n  private:\n    int theValue;    // the value to add\n  public:\n    // constructor initializes the value to add\n    AddValue(int v) : theValue(v) {\n    }\n\n    // the ``function call'' for the element adds the value\n    void operator() (int& elem) const {\n        elem += theValue;\n    }\n};\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    PRINT_ELEMENTS(coll,\"initialized:                \");\n\n    // add value 10 to each element\n    for_each (coll.begin(), coll.end(),    // range\n              AddValue(10));               // operation\n\n    PRINT_ELEMENTS(coll,\"after adding 10:            \");\n\n    // add value of first element to each element\n    for_each (coll.begin(), coll.end(),    // range\n              AddValue(*coll.begin()));    // operation\n\n    PRINT_ELEMENTS(coll,\"after adding first element: \");\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/algo1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n    vector<int>::iterator pos;\n\n    // insert elements from 1 to 6 in arbitrary order\n    coll.push_back(2);\n    coll.push_back(5);\n    coll.push_back(4);\n    coll.push_back(1);\n    coll.push_back(6);\n    coll.push_back(3);\n\n    // find and print minimum and maximum elements\n    pos = min_element (coll.begin(), coll.end());\n    cout << \"min: \" << *pos << endl;\n    pos = max_element (coll.begin(), coll.end());\n    cout << \"max: \" << *pos << endl;\n\n    // sort all elements\n    sort (coll.begin(), coll.end());\n\n    // find the first element with value 3\n    pos = find (coll.begin(), coll.end(),  // range\n                3);                        // value\n\n    // reverse the order of the found element with value 3 and all following elements\n    reverse (pos, coll.end());\n\n    // print all elements\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        cout << *pos << ' ';\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/copy1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int>   coll1;\n    vector<int> coll2;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll1.push_back(i);\n    }\n\n    // RUNTIME ERROR:\n    // - overwrites nonexisting elements in the destination\n    copy (coll1.begin(), coll1.end(),     // source\n          coll2.begin());                 // destination\n    //...\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/copy2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <list>\n#include <deque>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int>   coll1;\n    vector<int> coll2;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll1.push_back(i);\n    }\n\n    // resize destination to have enough room for the overwriting algorithm\n    coll2.resize (coll1.size());\n\n    /* copy elements from first into second collection\n     * - overwrites existing elements in destination\n     */\n    copy (coll1.begin(), coll1.end(),     // source\n          coll2.begin());                 // destination\n\n    /* create third collection with enough room\n     * - initial size is passed as parameter\n     */\n    deque<int> coll3(coll1.size());\n\n    // copy elements from first into third collection\n    copy (coll1.begin(), coll1.end(),     // source\n          coll3.begin());                 // destination\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/copy3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <list>\n#include <deque>\n#include <set>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll1;\n\n    // insert elements from 1 to 9 into the first collection\n    for (int i=1; i<=9; ++i) {\n        coll1.push_back(i);\n    }\n\n    // copy the elements of coll1 into coll2 by appending them\n    vector<int> coll2;\n    copy (coll1.begin(), coll1.end(),      // source\n          back_inserter(coll2));           // destination\n\n    // copy the elements of coll1 into coll3 by inserting them at the front\n    // - reverses the order of the elements\n    deque<int> coll3;\n    copy (coll1.begin(), coll1.end(),      // source\n          front_inserter(coll3));          // destination\n\n    // copy elements of coll1 into coll4\n    // - only inserter that works for associative collections\n    set<int> coll4;\n    copy (coll1.begin(), coll1.end(),      // source\n          inserter(coll4,coll4.begin()));  // destination\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/deque1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <deque>\nusing namespace std;\n\nint main()\n{\n    deque<float> coll;    // deque container for floating-point elements\n\n    // insert elements from 1.1 to 6.6 each at the front\n    for (int i=1; i<=6; ++i) {\n        coll.push_front(i*1.1);      // insert at the front\n    }\n\n    // print all elements followed by a space\n    for (int i=0; i<coll.size(); ++i) {\n        cout << coll[i] << ' ';\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/find1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n    list<int>::iterator pos;\n\n    // insert elements from 20 to 40\n    for (int i=20; i<=40; ++i) {\n        coll.push_back(i);\n    }\n\n    /* find position of element with value 3\n     * - there is none, so pos gets coll.end()\n     */\n    pos = find (coll.begin(), coll.end(),    // range\n                3);                          // value\n    \n    /* reverse the order of elements between found element and the end\n     * - because pos is coll.end() it reverses an empty range\n     */\n    reverse (pos, coll.end());\n\n    // find positions of values 25 and 35\n    list<int>::iterator pos25, pos35;\n    pos25 = find (coll.begin(), coll.end(),  // range\n                  25);                       // value\n    pos35 = find (coll.begin(), coll.end(),  // range\n                  35);                       // value\n\n    /* print the maximum of the corresponding range\n     * - note: including pos25 but excluding pos35\n     */\n    cout << \"max: \" << *max_element (pos25, pos35) << endl;\n\n    // process the elements including the last position\n    cout << \"max: \" << *max_element (pos25, ++pos35) << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/fo1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <deque>\n#include <algorithm>\n#include \"print.hpp\"\nusing namespace std;\n\nint main()\n{\n    set<int,greater<int> > coll1;\n    deque<int> coll2;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll1.insert(i);\n    }\n\n    PRINT_ELEMENTS(coll1,\"initialized: \");\n\n    // transform all elements into coll2 by multiplying 10\n    transform (coll1.begin(),coll1.end(),        // source\n               back_inserter(coll2),             // destination\n               bind2nd(multiplies<int>(),10));   // operation\n\n    PRINT_ELEMENTS(coll2,\"transformed: \");\n\n    // replace value equal to 70 with 42\n    replace_if (coll2.begin(),coll2.end(),       // range\n                bind2nd(equal_to<int>(),70),     // replace criterion\n                42);                             // new value\n\n    PRINT_ELEMENTS(coll2,\"replaced:    \");\n\n    // remove all elements with values less than 50\n    coll2.erase(remove_if(coll2.begin(),coll2.end(), // range\n                          bind2nd(less<int>(),50)),  // remove criterion\n                coll2.end());\n\n    PRINT_ELEMENTS(coll2,\"removed:     \");\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/foreach1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\n// function that prints the passed argument\nvoid print (int elem)\n{\n    cout << elem << ' ';\n}\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // print all elements\n    for_each (coll.begin(), coll.end(),    // range\n              print);                      // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/foreach2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\n// simple function object that prints the passed argument\nclass PrintInt {\n  public:\n    void operator() (int elem) const {\n        cout << elem << ' ';\n    }\n};\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // print all elements\n    for_each (coll.begin(), coll.end(),    // range\n              PrintInt());                 // operation\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/ioiter1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <string>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    vector<string> coll;\n\n    /* read all words from the standard input\n     * - source: all strings until end-of-file (or error)\n     * - destination: coll (inserting)\n     */\n    copy (istream_iterator<string>(cin),    // start of source\n          istream_iterator<string>(),       // end of source\n          back_inserter(coll));             // destination\n\n    // sort elements\n    sort (coll.begin(), coll.end());\n\n    /* print all elements without duplicates\n     * - source: coll\n     * - destination: standard output (with newline between elements)\n     */\n    unique_copy (coll.begin(), coll.end(),             // source\n                 ostream_iterator<string>(cout,\"\\n\")); // destination\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/iterbug1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    vector<int> coll1;    // empty collection\n    vector<int> coll2;    // empty collection\n\n    /* RUNTIME ERROR:\n     * - beginning is behind the end of the range\n     */\n    vector<int>::iterator pos = coll1.begin();\n    reverse (++pos, coll1.end());\n\n    // insert elements from 1 to 9 into coll2\n    for (int i=1; i<=9; ++i) {\n        coll2.push_back (i);\n    }\n\n    /* RUNTIME ERROR:\n     * - overwriting nonexisting elements\n     */\n    copy (coll2.begin(), coll2.end(),    // source\n          coll1.begin());                // destination\n\n    /* RUNTIME ERROR:\n     * - collections mistaken\n     * - begin() and end() mistaken\n     */\n    copy (coll1.begin(), coll2.end(),    // source\n          coll1.end());                  // destination\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/list1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\nusing namespace std;\n\nint main()\n{\n    list<char> coll;      // list container for character elements\n\n    // append elements from 'a' to 'z'\n    for (char c='a'; c<='z'; ++c) {\n        coll.push_back(c);\n    }\n\n    /* print all elements\n     * - while there are elements\n     * - print and remove the first element\n     */\n    while (! coll.empty()) {\n        cout << coll.front() << ' ';\n        coll.pop_front();\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/list2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\nusing namespace std;\n\nint main()\n{\n    list<char> coll;      // list container for character elements\n\n    // append elements from 'a' to 'z'\n    for (char c='a'; c<='z'; ++c) {\n        coll.push_back(c);\n    }\n\n    /* print all elements\n     * - iterate over all elements\n     */\n    list<char>::const_iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << *pos << ' ';\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/map1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <map>\n#include <string>\nusing namespace std;\n\nint main()\n{\n    /* type of the container:\n     * - map: elements key/value pairs\n     * - string: keys have type string\n     * - float: values have type float\n     */\n    typedef map<string,float> StringFloatMap;\n\n    StringFloatMap coll;\n\n    // insert some elements into the collection\n    coll[\"VAT\"] = 0.15;\n    coll[\"Pi\"] = 3.1415;\n    coll[\"an arbitrary number\"] = 4983.223;\n    coll[\"Null\"] = 0;\n\n    /* print all elements\n     * - iterate over all elements\n     * - element member first is the key\n     * - element member second is the value\n     */\n    StringFloatMap::iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << \"key: \\\"\" << pos->first << \"\\\" \"\n             << \"value: \" << pos->second << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/mmap1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <map>\n#include <string>\nusing namespace std;\n\nint main()\n{\n    // type of the collection\n    typedef multimap<int,string> IntStringMMap;\n\n    IntStringMMap coll;        // container for int/string values\n\n    // insert some elements in arbitrary order\n    // - a value with key 1 gets inserted twice\n    coll.insert(make_pair(5,\"tagged\"));\n    coll.insert(make_pair(2,\"a\"));\n    coll.insert(make_pair(1,\"this\"));\n    coll.insert(make_pair(4,\"of\"));\n    coll.insert(make_pair(6,\"strings\"));\n    coll.insert(make_pair(1,\"is\"));\n    coll.insert(make_pair(3,\"multimap\"));\n\n    /* print all element values\n     * - iterate over all elements\n     * - element member second is the value\n     */\n    IntStringMMap::iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << pos->second << ' ';\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/prime1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include <cstdlib>      // for abs()\nusing namespace std;\n\n// predicate, which returns whether an integer is a prime number\nbool isPrime (int number)\n{\n    // ignore negative sign\n    number = abs(number);\n\n    // 0 and 1 are no prime numbers\n    if (number == 0 || number == 1) {\n        return false;\n    }\n        \n    // find divisor that divides without a remainder\n    int divisor;\n    for (divisor = number/2; number%divisor != 0; --divisor) {\n        ;\n    }\n\n    // if no divisor greater than 1 is found, it is a prime number\n    return divisor == 1;\n}\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 24 to 30\n    for (int i=24; i<=30; ++i) {\n        coll.push_back(i);\n    }\n\n    // search for prime number\n    list<int>::iterator pos;\n    pos = find_if (coll.begin(), coll.end(),    // range\n                   isPrime);                    // predicate\n    if (pos != coll.end()) {\n        // found\n        cout << *pos << \" is first prime number found\" << endl;\n    }\n    else {\n        // not found\n        cout << \"no prime number found\" << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/print.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n\n/* PRINT_ELEMENTS()\n * - prints optional C-string optcstr followed by\n * - all elements of the collection coll\n * - separated by spaces\n */\ntemplate <class T>\ninline void PRINT_ELEMENTS (const T& coll, const char* optcstr=\"\")\n{\n    typename T::const_iterator pos;\n\n    std::cout << optcstr;\n    for (pos=coll.begin(); pos!=coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/remove1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 6 to 1 and 1 to 6\n    for (int i=1; i<=6; ++i) {\n        coll.push_front(i);\n        coll.push_back(i);\n    }\n\n    // print all elements of the collection\n    cout << \"pre:  \";\n    copy (coll.begin(), coll.end(),           // source\n          ostream_iterator<int>(cout,\" \"));   // destination\n    cout << endl;\n\n    // remove all elements with value 3\n    remove (coll.begin(), coll.end(),         // range\n            3);                               // value\n\n    // print all elements of the collection\n    cout << \"post: \";\n    copy (coll.begin(), coll.end(),           // source\n          ostream_iterator<int>(cout,\" \"));   // destination\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/remove2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 6 to 1 and 1 to 6\n    for (int i=1; i<=6; ++i) {\n        coll.push_front(i);\n        coll.push_back(i);\n    }\n\n    // print all elements of the collection\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // remove all elements with value 3\n    // - retain new end\n    list<int>::iterator end = remove (coll.begin(), coll.end(),\n                                      3);\n\n    // print resulting elements of the collection\n    copy (coll.begin(), end,\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    // print number of resulting elements\n    cout << \"number of removed elements: \"\n         << distance(end,coll.end()) << endl;\n\n    // remove ``removed'' elements\n    coll.erase (end, coll.end());\n\n    // print all elements of the modified collection\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/remove3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    set<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.insert(i);\n    }\n\n    // print all elements of the collection\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n\n    /* Remove all elements with value 3\n     * - algorithm remove() does not work\n     * - instead member function erase() works\n     */\n    int num = coll.erase(3);\n\n    // print number of removed elements\n    cout << \"number of removed elements: \" << num << endl;\n\n    // print all elements of the modified collection\n    copy (coll.begin(), coll.end(),\n          ostream_iterator<int>(cout,\" \"));\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/remove4.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <list>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    list<int> coll;\n\n    // insert elements from 6 to 1 and 1 to 6\n    for (int i=1; i<=6; ++i) {\n        coll.push_front(i);\n        coll.push_back(i);\n    }\n\n    // remove all elements with value 3\n    // - poor performance\n    coll.erase (remove(coll.begin(),coll.end(),\n                       3),\n                coll.end());\n\n    // remove all elements with value 4\n    // - good performance\n    coll.remove (4);\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/riter1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <iterator>\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;\n\n    // insert elements from 1 to 9\n    for (int i=1; i<=9; ++i) {\n        coll.push_back(i);\n    }\n\n    // print all element in reverse order\n    copy (coll.rbegin(), coll.rend(),        // source\n          ostream_iterator<int>(cout,\" \"));  // destination\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/set1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <set>\n\nint main()\n{\n    // type of the collection\n    typedef std::set<int> IntSet;\n\n    IntSet coll;        // set container for int values\n\n    /* insert elements from 1 to 6 in arbitrary order\n     * - value 1 gets inserted twice\n     */\n    coll.insert(3);\n    coll.insert(1);\n    coll.insert(5);\n    coll.insert(4);\n    coll.insert(1);\n    coll.insert(6);\n    coll.insert(2);\n\n    /* print all elements\n     * - iterate over all elements\n     */\n    IntSet::const_iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        std::cout << *pos << ' ';\n    }\n    std::cout << std::endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/sort1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <deque>\n#include <set>\n#include <algorithm>\nusing namespace std;\n\n\n/* class Person\n */\nclass Person {\n  private:\n    string fn;    // first name\n    string ln;    // last name\n  public:\n    Person() {\n    }\n    Person(const string& f, const string& n)\n     : fn(f), ln(n) {\n    }\n    string firstname() const;\n    string lastname() const;\n    // ...\n};\n\ninline string Person::firstname() const {\n    return fn;\n}\n\ninline string Person::lastname() const {\n    return ln;\n}\n\nostream& operator<< (ostream& s, const Person& p)\n{\n    s << \"[\" << p.firstname() << \" \" << p.lastname() << \"]\";\n    return s;\n}\n\n\n/* binary function predicate:\n * - returns whether a person is less than another person\n */\nbool personSortCriterion (const Person& p1, const Person& p2)\n{\n    /* a person is less than another person\n     * - if the last name is less\n     * - if the last name is equal and the first name is less\n     */\n    return p1.lastname()<p2.lastname() ||\n           (p1.lastname()==p2.lastname() &&\n            p1.firstname()<p2.firstname());\n}\n\nint main()\n{\n    // create some persons\n    Person p1(\"nicolai\",\"josuttis\");\n    Person p2(\"ulli\",\"josuttis\");\n    Person p3(\"anica\",\"josuttis\");\n    Person p4(\"lucas\",\"josuttis\");\n    Person p5(\"lucas\",\"otto\");\n    Person p6(\"lucas\",\"arm\");\n    Person p7(\"anica\",\"holle\");\n    \n    // insert person into collection coll\n    deque<Person> coll;\n    coll.push_back(p1);\n    coll.push_back(p2);\n    coll.push_back(p3);\n    coll.push_back(p4);\n    coll.push_back(p5);\n    coll.push_back(p6);\n    coll.push_back(p7);\n\n    // print elements\n    cout << \"deque before sort():\" << endl;\n    deque<Person>::iterator pos;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << *pos << endl;\n    }\n\n    // sort elements\n    sort(coll.begin(),coll.end(),    // range\n         personSortCriterion);       // sort criterion\n\n    // print elements\n    cout << \"deque after sort():\" << endl;\n    for (pos = coll.begin(); pos != coll.end(); ++pos) {\n        cout << *pos << endl;\n    }\n}\n\n"
  },
  {
    "path": "stl侯杰源码/stl/transform1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\n#include <set>\n#include <algorithm>\n#include \"print.hpp\"\n\nint square (int value)\n{\n    return value*value;\n}\n\nint main()\n{\n    std::set<int>    coll1;\n    std::vector<int> coll2;\n\n    // insert elements from 1 to 9 into coll1\n    for (int i=1; i<=9; ++i) {\n        coll1.insert(i);\n    }\n    PRINT_ELEMENTS(coll1,\"initialized: \");\n\n    // transform each element from coll1 to coll2\n    // - square transformed values\n    std::transform (coll1.begin(),coll1.end(),    // source\n                    std::back_inserter(coll2),    // destination\n                    square);                      // operation\n\n    PRINT_ELEMENTS(coll2,\"squared:     \");\n}\n"
  },
  {
    "path": "stl侯杰源码/stl/vector1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <vector>\nusing namespace std;\n\nint main()\n{\n    vector<int> coll;    // vector container for integer elements\n\n    // append elements with values 1 to 6\n    for (int i=1; i<=6; ++i) {\n        coll.push_back(i);\n    }\n\n    // print all elements followed by a space\n    for (int i=0; i<coll.size(); ++i) {\n        cout << coll[i] << ' ';\n    }\n    cout << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/string/Makefile",
    "content": "CPPPROGS =\titer2 unique\n\nOUTPROGS =\tstring1 string2 iter1 iter3 icstring1\n\nHEADERS =\ticstring.hpp\n\ninclude ../Makefile.h\n\n"
  },
  {
    "path": "stl侯杰源码/string/icstring.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#ifndef ICSTRING_HPP\n#define ICSTRING_HPP\n\n#include <string>\n#include <iostream>\n#include <cctype>\n\n/* replace functions of the standard char_traits<char>\n * so that strings behave in a case-insensitive way\n */\nstruct ignorecase_traits : public std::char_traits<char> {\n    // return whether c1 and c2 are equal\n    static bool eq(const char& c1, const char& c2) {\n        return std::toupper(c1)==std::toupper(c2);\n    }\n    // return whether c1 is less than c2\n    static bool lt(const char& c1, const char& c2) {\n        return std::toupper(c1)<std::toupper(c2);\n    }\n    // compare up to n characters of s1 and s2\n    static int compare(const char* s1, const char* s2,\n                       std::size_t n) {\n        for (std::size_t i=0; i<n; ++i) {\n            if (!eq(s1[i],s2[i])) {\n                return lt(s1[i],s2[i])?-1:1;\n            }\n        }\n        return 0;\n    }\n    // search c in s\n    static const char* find(const char* s, std::size_t n,\n                            const char& c) {\n        for (std::size_t i=0; i<n; ++i) {\n            if (eq(s[i],c)) {\n                return &(s[i]);\n            }\n        }\n        return 0;\n    }\n};\n\n// define a special type for such strings\ntypedef std::basic_string<char,ignorecase_traits> icstring;\n\n/* define an output operator\n * because the traits type is different than that for std::ostream\n */\ninline\nstd::ostream& operator << (std::ostream& strm, const icstring& s)\n{\n    // simply convert the icstring into a normal string\n    return strm << std::string(s.data(),s.length());\n}\n\n#endif    // ICSTRING_HPP\n"
  },
  {
    "path": "stl侯杰源码/string/icstring1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include \"icstring.hpp\"\n\nint main()\n{\n    using std::cout;\n    using std::endl;\n\n    icstring s1(\"hallo\");\n    icstring s2(\"otto\");\n    icstring s3(\"hALLo\");\n    \n    cout << std::boolalpha;\n    cout << s1 << \" == \" << s2 << \" : \" << (s1==s2) << endl;\n    cout << s1 << \" == \" << s3 << \" : \" << (s1==s3) << endl;\n\n    icstring::size_type idx = s1.find(\"All\");\n    if (idx != icstring::npos) {\n        cout << \"index of \\\"All\\\" in \\\"\" << s1 << \"\\\": \"\n             << idx << endl;\n    }\n\n    else {\n        cout << \"\\\"All\\\" not found in \\\"\" << s1 << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/string/iter1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <string>\n#include <iostream>\n#include <algorithm>\n#include <cctype>\nusing namespace std;\n\nint main()\n{\n    // create a string\n    string s(\"The zip code of Hondelage in Germany is 38108\");\n    cout << \"original: \" << s << endl;\n\n    // lowercase all characters\n    transform (s.begin(), s.end(),    // source\n               s.begin(),             // destination\n               tolower);              // operation\n    cout << \"lowered:  \" << s << endl;\n\n    // uppercase all characters\n    transform (s.begin(), s.end(),    // source\n               s.begin(),             // destination\n               toupper);              // operation\n    cout << \"uppered:  \" << s << endl;\n}\n\n"
  },
  {
    "path": "stl侯杰源码/string/iter2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <string>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\nbool nocase_compare (char c1, char c2)\n{\n    return toupper(c1) == toupper(c2);\n}\n\nint main()\n{\n    string s1(\"This is a string\");\n    string s2(\"STRING\");\n    \n    // compare case insensitive\n    if (s1.size() == s2.size() &&        // ensure same sizes\n        equal (s1.begin(),s1.end(),      // first source string\n               s2.begin(),               // second source string\n               nocase_compare)) {        // comparison criterion\n        cout << \"the strings are equal\" << endl;\n    }\n    else {\n        cout << \"the strings are not equal\" << endl;\n    }\n\n    // search case insensitive\n    string::iterator pos;\n    pos = search (s1.begin(),s1.end(),   // source string in which to search\n                  s2.begin(),s2.end(),   // substring to search\n                  nocase_compare);       // comparison criterion\n    if (pos == s1.end()) {\n        cout << \"s2 is not a substring of s1\" << endl;\n    }\n    else {\n        cout << '\"' << s2 << \"\\\" is a substring of \\\"\"\n             << s1 << \"\\\" (at index \" << pos - s1.begin() << \")\"\n             << endl;\n    }\n}\n\n"
  },
  {
    "path": "stl侯杰源码/string/iter3.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <string>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\nint main()\n{\n    // create constant string\n    const string hello(\"Hello, how are you?\");\n\n    // initialize string s with all characters of string hello\n    string s(hello.begin(),hello.end());\n\n    // iterate through all of the characters\n    string::iterator pos;\n    for (pos = s.begin(); pos != s.end(); ++pos) {\n        cout << *pos;\n    }\n    cout << endl;\n\n    // reverse the order of all characters inside the string\n    reverse (s.begin(), s.end());\n    cout << \"reverse:       \" << s << endl;\n\n    // sort all characters inside the string\n    sort (s.begin(), s.end());\n    cout << \"ordered:       \" << s << endl;\n\n    /* remove adjacent duplicates\n     * - unique() reorders and returns new end\n     * - erase() shrinks accordingly\n     */\n    s.erase (unique(s.begin(),\n                    s.end()),\n             s.end());\n    cout << \"no duplicates: \" << s << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/string/string1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\nusing namespace std;\n\nint main (int argc, char* argv[])\n{\n    string filename, basename, extname, tmpname;\n    const string suffix(\"tmp\");\n\n    /* for each command-line argument\n     * (which is an ordinary C-string)\n     */\n    for (int i=1; i<argc; ++i) {\n        // process argument as file name\n        filename = argv[i];\n        \n        // search period in file name\n        string::size_type idx = filename.find('.');\n        if (idx == string::npos) {\n            // file name does not contain any period\n            tmpname = filename + '.' + suffix;\n        }\n        else {\n            /* split file name into base name and extension\n             * - base name contains all characters before the period\n             * - extension contains all characters after the period\n             */\n            basename = filename.substr(0, idx);\n            extname = filename.substr(idx+1);\n            if (extname.empty()) {\n                // contains period but no extension: append tmp\n                tmpname = filename;\n                tmpname += suffix;\n            }\n            else if (extname == suffix) {\n                // replace extension tmp with xxx\n                tmpname = filename;\n                tmpname.replace (idx+1, extname.size(), \"xxx\");\n            }\n            else {\n                // replace any extension with tmp\n                tmpname = filename;\n                tmpname.replace (idx+1, string::npos, suffix);\n            }\n        }\n\n        // print file name and temporary name\n        cout << filename << \" => \" << tmpname << endl;\n    }\n}\n"
  },
  {
    "path": "stl侯杰源码/string/string2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\nusing namespace std;\n\nint main (int argc, char** argv)\n{\n   const string delims(\" \\t,.;\");\n   string line;\n\n   // for every line read successfully\n   while (getline(cin,line)) {\n       string::size_type begIdx, endIdx;\n\n       // search beginning of the first word\n       begIdx = line.find_first_not_of(delims);\n\n       // while beginning of a word found\n       while (begIdx != string::npos) {\n           // search end of the actual word\n           endIdx = line.find_first_of (delims, begIdx);\n           if (endIdx == string::npos) {\n               // end of word is end of line\n               endIdx = line.length();\n           }\n\n           // print characters in reverse order\n           for (int i=endIdx-1; i>=static_cast<int>(begIdx); --i) {\n               cout << line[i];\n           }\n           cout << ' ';\n\n           // search beginning of the next word\n           begIdx = line.find_first_not_of (delims, endIdx);\n       }\n       cout << endl;\n   }\n}\n"
  },
  {
    "path": "stl侯杰源码/string/unique.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <string>\n#include <algorithm>\n#include <iterator>\n#include <locale>\nusing namespace std;\n\nclass bothWhiteSpaces {\n  private:\n    const locale& loc;    // locale\n  public:\n    /* constructor\n     * - save the locale object\n     */\n    bothWhiteSpaces (const locale& l) : loc(l) {\n    }\n    /* function call\n     * - returns whether both characters are whitespaces\n     */\n    bool operator() (char elem1, char elem2) {\n        return isspace(elem1,loc) && isspace(elem2,loc);\n    }\n};\n\nint main()\n{\n    string contents;\n\n    // don't skip leading whitespaces\n    cin.unsetf (ios::skipws);\n\n    // read all characters while compressing whitespaces\n    unique_copy(istream_iterator<char>(cin),    // beginning of source\n                istream_iterator<char>(),       // end of source\n                back_inserter(contents),        // destination\n                bothWhiteSpaces(cin.getloc())); // criterion for removing\n\n    // process contents\n    // - here: write it to the standard output\n    cout << contents;\n}\n"
  },
  {
    "path": "stl侯杰源码/util/Makefile",
    "content": "OUTPROGS = autoptr1 autoptr2 limits1 minmax1\n\nHEADERS = autoptr.hpp defalloc.hpp\n\ninclude ../Makefile.h\n\n"
  },
  {
    "path": "stl侯杰源码/util/autoptr.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n/* class auto_ptr\n * - improved standard conforming implementation\n */\nnamespace std {\n    // auxiliary type to enable copies and assignments (now global)\n    template<class Y>\n    struct auto_ptr_ref {\n        Y* yp;\n        auto_ptr_ref (Y* rhs)\n         : yp(rhs) {\n        }\n    };\n\n    template<class T>\n    class auto_ptr {\n      private:\n        T* ap;    // refers to the actual owned object (if any)\n      public:\n        typedef T element_type;\n\n        // constructor\n        explicit auto_ptr (T* ptr = 0) throw()\n         : ap(ptr) {\n        }\n\n        // copy constructors (with implicit conversion)\n        // - note: nonconstant parameter\n        auto_ptr (auto_ptr& rhs) throw()\n         : ap(rhs.release()) {\n        }\n        template<class Y>\n        auto_ptr (auto_ptr<Y>& rhs) throw()\n         : ap(rhs.release()) {\n        }\n        \n        // assignments (with implicit conversion)\n        // - note: nonconstant parameter\n        auto_ptr& operator= (auto_ptr& rhs) throw() {\n            reset(rhs.release());\n            return *this;\n        }\n        template<class Y>\n        auto_ptr& operator= (auto_ptr<Y>& rhs) throw() {\n            reset(rhs.release());\n            return *this;\n        }\n        \n        // destructor\n        ~auto_ptr() throw() {\n            delete ap;\n        }\n\n        // value access\n        T* get() const throw() {\n            return ap;\n        }\n        T& operator*() const throw() {\n            return *ap;\n        }\n        T* operator->() const throw() {\n            return ap;\n        }\n\n        // release ownership\n        T* release() throw() {\n            T* tmp(ap);\n            ap = 0;\n            return tmp;\n        }\n\n        // reset value\n        void reset (T* ptr=0) throw() {\n            if (ap != ptr) {\n                delete ap;\n                ap = ptr;\n            }\n        }\n\n        /* special conversions with auxiliary type to enable copies and assignments\n         */\n        auto_ptr(auto_ptr_ref<T> rhs) throw()\n         : ap(rhs.yp) {\n        }\n        auto_ptr& operator= (auto_ptr_ref<T> rhs) throw() {  // new\n             reset(rhs.yp);\n             return *this;\n        }\n        template<class Y>\n        operator auto_ptr_ref<Y>() throw() {\n            return auto_ptr_ref<Y>(release());\n        }\n        template<class Y>\n        operator auto_ptr<Y>() throw() {\n            return auto_ptr<Y>(release());\n        }\n    };\n}\n"
  },
  {
    "path": "stl侯杰源码/util/autoptr1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <memory>\nusing namespace std;\n\n/* define output operator for auto_ptr\n * - print object value or NULL\n */\ntemplate <class T>\nostream& operator<< (ostream& strm, const auto_ptr<T>& p)\n{\n    // does p own an object ?\n    if (p.get() == NULL) {\n        strm << \"NULL\";         // NO: print NULL\n    }\n    else {\n        strm << *p;             // YES: print the object\n    }\n    return strm;\n}\n\nint main()\n{\n    auto_ptr<int> p(new int(42));\n    auto_ptr<int> q;\n\n    cout << \"after initialization:\" << endl;\n    cout << \" p: \" << p << endl;\n    cout << \" q: \" << q << endl;\n\n    q = p;\n    cout << \"after assigning auto pointers:\" << endl;\n    cout << \" p: \" << p << endl;\n    cout << \" q: \" << q << endl;\n\n    *q += 13;                   // change value of the object q owns\n    p = q;\n    cout << \"after change and reassignment:\" << endl;\n    cout << \" p: \" << p << endl;\n    cout << \" q: \" << q << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/util/autoptr2.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <memory>\nusing namespace std;\n\n/* define output operator for auto_ptr\n * - print object value or NULL\n */\ntemplate <class T>\nostream& operator<< (ostream& strm, const auto_ptr<T>& p)\n{\n    // does p own an object ?\n    if (p.get() == NULL) {\n        strm << \"NULL\";         // NO: print NULL\n    }\n    else {\n        strm << *p;             // YES: print the object\n    }\n    return strm;\n}\n\nint main()\n{\n    const auto_ptr<int> p(new int(42));\n    const auto_ptr<int> q(new int(0));\n    const auto_ptr<int> r;\n\n    cout << \"after initialization:\" << endl;\n    cout << \" p: \" << p << endl;\n    cout << \" q: \" << q << endl;\n    cout << \" r: \" << r << endl;\n\n    *q = *p;\n//  *r = *p;    // ERROR: undefined behavior\n    *p = -77;\n    cout << \"after assigning values:\" << endl;\n    cout << \" p: \" << p << endl;\n    cout << \" q: \" << q << endl;\n    cout << \" r: \" << r << endl;\n\n//  q = p;      // ERROR at compile time\n//  r = p;      // ERROR at compile time\n}\n"
  },
  {
    "path": "stl侯杰源码/util/defalloc.hpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\nnamespace std {\n   template <class T>\n   class allocator {\n     public:\n       // type definitions\n       typedef size_t    size_type;\n       typedef ptrdiff_t difference_type;\n       typedef T*        pointer;\n       typedef const T*  const_pointer;\n       typedef T&        reference;\n       typedef const T&  const_reference;\n       typedef T         value_type;\n\n       // rebind allocator to type U\n       template <class U>\n       struct rebind {\n           typedef allocator<U> other;\n       };\n\n       // return address of values\n       pointer address (reference value) const {\n           return &value;\n       }\n       const_pointer address (const_reference value) const {\n           return &value;\n       }\n\n       /* constructors and destructor\n        * - nothing to do because the allocator has no state\n        */\n       allocator() throw() {\n       }\n       allocator(const allocator&) throw() {\n       }\n       template <class U>\n         allocator (const allocator<U>&) throw() {\n       }\n       ~allocator() throw() {\n       }\n\n       // return maximum number of elements that can be allocated\n       size_type max_size () const throw() {\n           return numeric_limits<size_t>::max() / sizeof(T);\n       }\n\n       // allocate but don't initialize num elements of type T\n       pointer allocate (size_type num,\n                         allocator<void>::const_pointer hint = 0) {\n           // allocate memory with global new\n           return (pointer)(::operator new(num*sizeof(T)));\n       }\n\n       // initialize elements of allocated storage p with value value\n       void construct (pointer p, const T& value) {\n           // initialize memory with placement new\n           new((void*)p)T(value);\n       }\n\n       // destroy elements of initialized storage p\n       void destroy (pointer p) {\n           // destroy objects by calling their destructor\n           p->~T();\n       }\n\n       // deallocate storage p of deleted elements\n       void deallocate (pointer p, size_type num) {\n           // deallocate memory with global delete\n           ::operator delete((void*)p);\n       }\n   };\n\n   // return that all specializations of this allocator are interchangeable\n   template <class T1, class T2>\n   bool operator== (const allocator<T1>&,\n                    const allocator<T2>&) throw() {\n       return true;\n   }\n   template <class T1, class T2>\n   bool operator!= (const allocator<T1>&,\n                    const allocator<T2>&) throw() {\n       return false;\n   }\n}\n\n"
  },
  {
    "path": "stl侯杰源码/util/limits1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <iostream>\n#include <limits>\n#include <string>\nusing namespace std;\n\nint main()\n{\n   // use textual representation for bool\n   cout << boolalpha;\n\n   // print maximum of integral types\n   cout << \"max(short): \" << numeric_limits<short>::max() << endl;\n   cout << \"max(int):   \" << numeric_limits<int>::max() << endl;\n   cout << \"max(long):  \" << numeric_limits<long>::max() << endl;\n   cout << endl;\n\n   // print maximum of floating-point types\n   cout << \"max(float):       \"\n        << numeric_limits<float>::max() << endl;\n   cout << \"max(double):      \"\n        << numeric_limits<double>::max() << endl;\n   cout << \"max(long double): \"\n        << numeric_limits<long double>::max() << endl;\n   cout << endl;\n\n   // print whether char is signed\n   cout << \"is_signed(char): \"\n        << numeric_limits<char>::is_signed << endl;\n   cout << endl;\n\n   // print whether numeric limits for type string exist\n   cout << \"is_specialized(string): \"\n        << numeric_limits<string>::is_specialized << endl;\n}\n"
  },
  {
    "path": "stl侯杰源码/util/minmax1.cpp",
    "content": "/* The following code example is taken from the book\n * \"The C++ Standard Library - A Tutorial and Reference\"\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided \"as is\" without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n */\n#include <algorithm>\nusing namespace std;\n\n/* function that compares two pointers by comparing the values to which they point\n */\nbool int_ptr_less (int* a, int* b)\n{\n    return *a < *b;\n}\n\nint main()\n{\n    int x = 17;\n    int y = 42;\n    int* px = &x;\n    int* py = &y;\n    int* pmax;\n\n    // call max() with special comparison function\n    pmax = max (px, py, int_ptr_less);\n    //...\n}\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/JJHOU.TXT",
    "content": "all files copy from \\cygnus\\cygwin-b20\\include\\g++.\r\nbundle with G++ 2.91.57\r\n\u001a\r\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/PlotFile.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* \n  a very simple implementation of a class to output unix \"plot\"\n  format plotter files. See corresponding unix man pages for\n  more details. \n\n  written by Doug Lea (dl@rocky.oswego.edu)\n  converted to use iostream library by Per Bothner (bothner@cygnus.com)\n*/\n\n#ifndef _PlotFile_h\n#ifdef __GNUG__\n#pragma interface\n#endif\n#define _PlotFile_h\n\n#include <fstream.h>\n\n/*   \n   Some plot libraries have the `box' command to draw boxes. Some don't.\n   `box' is included here via moves & lines to allow both possiblilties.\n*/\n\nextern \"C++\" {\nclass PlotFile : public ofstream\n{\nprotected:\n  PlotFile& cmd(char c);\n  PlotFile& operator << (const int x);\n  PlotFile& operator << (const char *s);\n  \npublic:\n  \n  PlotFile() : ofstream() { }\n  PlotFile(int fd) : ofstream(fd) { }\n  PlotFile(const char *name, int mode=ios::out, int prot=0664)\n      : ofstream(name, mode, prot) { }\n  \n//  PlotFile& remove() { ofstream::remove(); return *this; }\n  \n//  int           filedesc() { return ofstream::filedesc(); }\n//  const char*   name() { return File::name(); }\n//  void          setname(const char* newname) { File::setname(newname); }\n//  int           iocount() { return File::iocount(); }\n  \n  PlotFile& arc(const int xi, const int yi,\n                const int x0, const int y0,\n                const int x1, const int y1);\n  PlotFile& box(const int x0, const int y0,\n                const int x1, const int y1);\n  PlotFile& circle(const int x, const int y, const int r);\n  PlotFile& cont(const int xi, const int yi);\n  PlotFile& dot(const int xi, const int yi, const int dx,\n                int n, const int* pat);\n  PlotFile& erase(); \n  PlotFile& label(const char* s);\n  PlotFile& line(const int x0, const int y0,\n                 const int x1, const int y1);\n  PlotFile& linemod(const char* s);\n  PlotFile& move(const int xi, const int yi);\n  PlotFile& point(const int xi, const int yi);\n  PlotFile& space(const int x0, const int y0,\n                  const int x1, const int y1);\n};\n} // extern \"C++\"\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/SFile.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1988, 1992, 1993 Free Software Foundation\n    written by Doug Lea (dl@rocky.oswego.edu)\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _SFile_h\n#ifdef __GNUG__\n#pragma interface\n#endif\n#define _SFile_h 1\n\n#include <fstream.h>\n\nextern \"C++\" {\nclass SFile: public fstream\n{\n  protected:\n    int       sz;                   // unit size for structured binary IO\n\npublic:\n    SFile() : fstream() { }\n    SFile(int fd, int size);\n    SFile(const char *name, int size, int mode, int prot=0664);\n    void open(const char *name, int size, int mode, int prot=0664);\n    \n    int       size() { return sz; }\n    int       setsize(int s) { int old = sz; sz = s; return old; }\n    \n    SFile&    get(void* x);\n    SFile&    put(void* x);\n    SFile&    operator[](long i);\n};\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/algo.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGO_H\n#define __SGI_STL_ALGO_H\n\n#include <algobase.h>\n#include <tempbuf.h>\n#include <stl_algo.h>\n#include <stl_numeric.h>\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from <stl_algo.h>\nusing __STD::for_each; \nusing __STD::find; \nusing __STD::find_if; \nusing __STD::adjacent_find; \nusing __STD::count; \nusing __STD::count_if; \nusing __STD::search; \nusing __STD::search_n; \nusing __STD::swap_ranges; \nusing __STD::transform; \nusing __STD::replace; \nusing __STD::replace_if; \nusing __STD::replace_copy; \nusing __STD::replace_copy_if; \nusing __STD::generate; \nusing __STD::generate_n; \nusing __STD::remove; \nusing __STD::remove_if; \nusing __STD::remove_copy; \nusing __STD::remove_copy_if; \nusing __STD::unique; \nusing __STD::unique_copy; \nusing __STD::reverse; \nusing __STD::reverse_copy; \nusing __STD::rotate; \nusing __STD::rotate_copy; \nusing __STD::random_shuffle; \nusing __STD::random_sample; \nusing __STD::random_sample_n; \nusing __STD::partition; \nusing __STD::stable_partition; \nusing __STD::sort; \nusing __STD::stable_sort; \nusing __STD::partial_sort; \nusing __STD::partial_sort_copy; \nusing __STD::nth_element; \nusing __STD::lower_bound; \nusing __STD::upper_bound; \nusing __STD::equal_range; \nusing __STD::binary_search; \nusing __STD::merge; \nusing __STD::inplace_merge; \nusing __STD::includes; \nusing __STD::set_union; \nusing __STD::set_intersection; \nusing __STD::set_difference; \nusing __STD::set_symmetric_difference; \nusing __STD::min_element; \nusing __STD::max_element; \nusing __STD::next_permutation; \nusing __STD::prev_permutation; \nusing __STD::find_first_of; \nusing __STD::find_end; \nusing __STD::is_sorted; \nusing __STD::is_heap; \n\n// Names from stl_heap.h\nusing __STD::push_heap;\nusing __STD::pop_heap;\nusing __STD::make_heap;\nusing __STD::sort_heap;\n\n// Names from <stl_numeric.h>\nusing __STD::accumulate; \nusing __STD::inner_product; \nusing __STD::partial_sum; \nusing __STD::adjacent_difference; \nusing __STD::power; \nusing __STD::iota; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALGO_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/algobase.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGOBASE_H\n#define __SGI_STL_ALGOBASE_H\n\n#ifndef __SGI_STL_PAIR_H\n#include <pair.h>\n#endif\n#ifndef __SGI_STL_ITERATOR_H\n#include <iterator.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_ALGOBASE_H\n#include <stl_algobase.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H\n#include <stl_uninitialized.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_algobase.h\nusing __STD::iter_swap; \nusing __STD::swap; \nusing __STD::min; \nusing __STD::max; \nusing __STD::copy; \nusing __STD::copy_backward; \nusing __STD::copy_n; \nusing __STD::fill; \nusing __STD::fill_n; \nusing __STD::mismatch; \nusing __STD::equal; \nusing __STD::lexicographical_compare; \nusing __STD::lexicographical_compare_3way; \n\n// Names from stl_uninitialized.h\nusing __STD::uninitialized_copy;\nusing __STD::uninitialized_copy_n;\nusing __STD::uninitialized_fill;\nusing __STD::uninitialized_fill_n;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALGOBASE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/algorithm",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALGORITHM\n#define __SGI_STL_ALGORITHM\n\n#include <stl_algobase.h>\n#include <stl_construct.h>\n#include <stl_tempbuf.h>\n#include <stl_algo.h>\n\n#endif /* __SGI_STL_ALGORITHM */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ALLOC_H\n#define __SGI_STL_ALLOC_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_ALLOC_H\n#include <stl_alloc.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::__malloc_alloc_template; \nusing __STD::malloc_alloc; \nusing __STD::simple_alloc; \nusing __STD::debug_alloc; \nusing __STD::__default_alloc_template; \nusing __STD::alloc; \nusing __STD::single_client_alloc; \n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\nusing __STD::__malloc_alloc_oom_handler; \n#endif /* __STL_STATIC_TEMPLATE_MEMBER_BUG */\n\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/builtinbuf.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _BUILTINBUF_H\n#define _BUILTINBUF_H\n\n#ifdef __GNUC__\n#pragma interface\n#endif\n\n#include <streambuf.h>\n\n#if !_IO_UNIFIED_JUMPTABLES\n// A builtinbuf is a streambuf where all the virtual operations\n// call the _IO_jump_t table.\n\nextern \"C++\" {\nclass builtinbuf : public streambuf {\n  friend ios;\n  virtual int overflow(int);\n  virtual int underflow();\n  virtual streamsize xsgetn(char *, streamsize);\n  virtual streamsize xsputn(const char *, streamsize);\n  virtual streambuf* setbuf(char*, int);\n  virtual int doallocate();\n  virtual ~builtinbuf();\n  virtual int sync();\n\n  virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n  virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);\n  virtual int pbackfail(int c);\n  virtual streamsize sys_read(char* buf, streamsize size);\n  virtual streampos sys_seek(streamoff, _seek_dir);\n  virtual streamsize sys_write(const char*, streamsize);\n  virtual int sys_stat(void*); // Actually, a (struct stat*)\n  virtual int sys_close();\n#if 0\n  virtual int get_column();\n  virtual int set_column(int);\n#endif\n private:\n  builtinbuf() { }\n};\n} // extern \"C++\"\n#endif\n\n#endif /* _BUILTINBUF_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/bvector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_BVECTOR_H\n#define __SGI_STL_BVECTOR_H\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n#include <vector.h>\n#else\n#include <algobase.h>\n#include <alloc.h>\n#endif \n\n#include <stl_bvector.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::bit_vector;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_BVECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n\n\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cassert",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CASSERT__\n#define __CASSERT__\n#include <assert.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cctype",
    "content": "// The -*- C++ -*- character type header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CCTYPE__\n#define __CCTYPE__\n#include <ctype.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cerrno",
    "content": "// The -*- C++ -*- error number header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CERRNO__\n#define __CERRNO__\n#include <errno.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cfloat",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CFLOAT__\n#define __CFLOAT__\n#include <float.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/ciso646",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CISO646__\n#define __CISO646__\n#include <iso646.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/climits",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CLIMITS__\n#define __CLIMITS__\n#include <limits.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/clocale",
    "content": "// The -*- C++ -*- locale support header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CLOCALE__\n#define __CLOCALE__\n#include <locale.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cmath",
    "content": "// The -*- C++ -*- math functions header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CMATH__\n#define __CMATH__\n#include <_G_config.h>\n#include <math.h>\n\n#ifdef __GNUG__\n#pragma interface \"cmath\"\n#endif\n\nextern \"C++\" {\n#if 0\nfloat acos (float);\nfloat asin (float);\nfloat atan (float);\nfloat atan2(float, float);\nfloat ceil (float);\nfloat cos  (float);\nfloat cosh (float);\nfloat exp  (float);\nfloat fabs (float);\nfloat floor(float);\nfloat fmod (float, float);\nfloat frexp(float, int*);\nfloat modf (float, float*);\nfloat ldexp(float, int);\nfloat log  (float);\nfloat log10(float);\nfloat pow  (float, float);\nfloat pow  (float, int);\nfloat sin  (float);\nfloat sinh (float);\nfloat sqrt (float);\nfloat tan  (float);\nfloat tanh (float);\n#endif\n\ninline float  abs (float  x) { return fabs (x); }\n#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */\ninline double abs (double x) { return fabs (x); }\n#endif\n\n#if 0\ndouble pow(double, int);\n\nlong double acos (long double);\nlong double asin (long double);\nlong double atan (long double);\nlong double atan2(long double, long double);\nlong double ceil (long double);\nlong double cos  (long double);\nlong double cosh (long double);\nlong double exp  (long double);\nlong double fabs (long double);\nlong double floor(long double);\nlong double frexp(long double, int*);\nlong double fmod (long double, long double);\nlong double frexp(long double, int*);\nlong double log  (long double);\nlong double log10(long double);\nlong double modf (long double, long double*);\nlong double pow  (long double, long double);\nlong double pow  (long double, int);\nlong double sin  (long double);\nlong double sinh (long double);\nlong double sqrt (long double);\nlong double tan  (long double);\nlong double tanh (long double);\n#endif\ninline long double abs (long double x) { return fabs (x); }\n\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/complex",
    "content": "// Main header for the -*- C++ -*- complex number classes.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __COMPLEX__\n#define __COMPLEX__\n\n#include <std/complext.h>\n\nextern \"C++\" {\n#define __STD_COMPLEX\n\n// ANSI complex types\ntypedef complex<float> float_complex;\ntypedef complex<double> double_complex;\ntypedef complex<long double> long_double_complex;\n}\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/complex.h",
    "content": "// -*- C++ -*- backward compatiblity header.\n// Copyright (C) 1994 Free Software Foundation\n\n#ifndef __COMPLEX_H__\n#include <complex>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/csetjmp",
    "content": "// The -*- C++ -*- setjmp/longjmp header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSETJMP__\n#define __CSETJMP__\n#include <setjmp.h>\n#endif\n\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/csignal",
    "content": "// The -*- C++ -*- signal handling header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSIGNAL__\n#define __CSIGNAL__\n#include <signal.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cstdarg",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSTDARG__\n#define __CSTDARG__\n#include <stdarg.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cstddef",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSTDDEF__\n#define __CSTDDEF__\n#include <stddef.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cstdio",
    "content": "// The -*- C++ -*- standard I/O header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSTDIO__\n#define __CSTDIO__\n#include <stdio.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cstdlib",
    "content": "// The -*- C++ -*- standard library header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSTDLIB__\n#define __CSTDLIB__\n#include <stdlib.h>\n\n#ifdef __GNUG__\n#pragma interface \"cstdlib\"\n#endif\n\nextern \"C++\" {\n\n#if _G_HAS_LABS\ninline long   abs(long x)\t\t{ return labs (x); }\n#else\ninline long   abs(long x)\t\t{ return x >= 0 ? x : -x; }\n#endif\n//inline ldiv_t div(long x, long y)\t{ return ldiv (x, y); }\n\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cstring",
    "content": "// The -*- C++ -*- null-terminated string header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CSTRING__\n#define __CSTRING__\n\n#include <string.h>\n\n#if 0 // Let's not bother with this just yet.\n#include <cstddef>\n\n#ifdef __GNUG__\n#pragma interface \"cstring\"\n#endif\n\n// The ANSI C prototypes for these functions have a const argument type and\n// non-const return type, so we can't use them.\n\nextern \"C++\" {\nextern inline const char *\n_G_strchr (const char *s, int c)\n{\n  return strchr (s, c);\n}\n\nextern inline char *\n_G_strchr (char *s, int c)\n{\n  return const_cast<char *> (strchr (s, c));\n}\n\nextern inline const char *\n_G_strpbrk (const char *s1, const char *s2)\n{\n  return strpbrk (s1, s2);\n}\n\nextern inline char *\n_G_strpbrk (char *s1, const char *s2)\n{\n  return const_cast<char *> (strpbrk (s1, s2));\n}\n\nextern inline const char *\n_G_strrchr (const char *s, int c)\n{\n  return strrchr (s, c);\n}\n\nextern inline char *\n_G_strrchr (char *s, int c)\n{\n  return const_cast<char *> (strrchr (s, c));\n}\n\nextern inline const char *\n_G_strstr (const char *s1, const char *s2)\n{\n  return strstr (s1, s2);\n}\n\nextern inline char *\n_G_strstr (char *s1, const char *s2)\n{\n  return const_cast<char *> (strstr (s1, s2));\n}\n\nextern inline const void *\n_G_memchr (const void *s, int c, size_t n)\n{\n  return memchr (s, c, n);\n}\n\nextern inline void *\n_G_memchr (void *s, int c, size_t n)\n{\n  return const_cast<void *> (memchr (s, c, n));\n}\n} // extern \"C++\"\n\n// Lose any vendor macros for these functions.\n#undef strchr\n#undef strpbrk\n#undef strrchr\n#undef strstr\n#undef memchr\n\n// Ewww, namespace pollution.  Anyone have a better idea?\n#define strchr  _G_strchr\n#define strpbrk _G_strpbrk\n#define strrchr _G_strrchr\n#define strstr  _G_strstr\n#define memchr  _G_memchr\n#endif // 0\n\n#endif // !defined (__CSTRING__)\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/ctime",
    "content": "// The -*- C++ -*- time header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CTIME__\n#define __CTIME__\n#include <time.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cwchar",
    "content": "// The -*- C++ -*- wide character header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CWCHAR__\n#define __CWCHAR__\n#include <wchar.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/cwctype",
    "content": "// The -*- C++ -*- wide character type header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __CWCTYPE__\n#define __CWCTYPE__\n#include <wctype.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/defalloc.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n// Inclusion of this file is DEPRECATED.  This is the original HP\n// default allocator.  It is provided only for backward compatibility.\n// \n// DO NOT USE THIS FILE unless you have an old container implementation\n// that requires an allocator with the HP-style interface.  SGI STL\n// uses a different allocator interface.  SGI-style allocators are not\n// parametrized with respect to the object type; they traffic in void *\n// pointers.  This file is not included by any other SGI STL header.\n\n#ifndef DEFALLOC_H\n#define DEFALLOC_H\n\n#include <new.h>\n#include <stddef.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <iostream.h>\n#include <algobase.h>\n\n\ntemplate <class T>\ninline T* allocate(ptrdiff_t size, T*) {\n    set_new_handler(0);\n    T* tmp = (T*)(::operator new((size_t)(size * sizeof(T))));\n    if (tmp == 0) {\n\tcerr << \"out of memory\" << endl; \n\texit(1);\n    }\n    return tmp;\n}\n\n\ntemplate <class T>\ninline void deallocate(T* buffer) {\n    ::operator delete(buffer);\n}\n\ntemplate <class T>\nclass allocator {\npublic:\n    typedef T value_type;\n    typedef T* pointer;\n    typedef const T* const_pointer;\n    typedef T& reference;\n    typedef const T& const_reference;\n    typedef size_t size_type;\n    typedef ptrdiff_t difference_type;\n    pointer allocate(size_type n) { \n\treturn ::allocate((difference_type)n, (pointer)0);\n    }\n    void deallocate(pointer p) { ::deallocate(p); }\n    pointer address(reference x) { return (pointer)&x; }\n    const_pointer const_address(const_reference x) { \n\treturn (const_pointer)&x; \n    }\n    size_type init_page_size() { \n\treturn max(size_type(1), size_type(4096/sizeof(T))); \n    }\n    size_type max_size() const { \n\treturn max(size_type(1), size_type(UINT_MAX/sizeof(T))); \n    }\n};\n\nclass allocator<void> {\npublic:\n    typedef void* pointer;\n};\n\n\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/deque",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_DEQUE\n#define __SGI_STL_DEQUE\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_deque.h>\n\n#endif /* __SGI_STL_DEQUE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/deque.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_DEQUE_H\n#define __SGI_STL_DEQUE_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_deque.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::deque;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_DEQUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/editbuf.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License.\n\nWritten by Per Bothner (bothner@cygnus.com). */\n\n#ifndef _EDITBUF_H\n#define _EDITBUF_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#include <stdio.h>\n#include <fstream.h>\n\nextern \"C++\" {\ntypedef unsigned long mark_pointer;\n// At some point, it might be nice to parameterize this code\n// in terms of buf_char.\ntypedef /*unsigned*/ char buf_char;\n\n// Logical pos from start of buffer (does not count gap).\ntypedef long buf_index;\n\t\t\t\n// Pos from start of buffer, possibly including gap_size.\ntypedef long buf_offset; \n\n#if 0\nstruct buf_cookie {\n    FILE *file;\n    struct edit_string *str;\n    struct buf_cookie *next;\n    buf_index tell();\n};\n#endif\n\nstruct edit_buffer;\nstruct edit_mark;\n\n// A edit_string is defined as the region between the 'start' and 'end' marks.\n// Normally (always?) 'start->insert_before()' should be false,\n// and 'end->insert_before()' should be true.\n\nstruct edit_string {\n    struct edit_buffer *buffer; // buffer that 'start' and 'end' belong to\n    struct edit_mark *start, *end;\n    int length() const; // count of buf_chars currently in string\n    edit_string(struct edit_buffer *b,\n\t\t      struct edit_mark *ms, struct edit_mark *me)\n\t{ buffer = b; start = ms; end = me; }\n/* Make a fresh, contiguous copy of the data in STR.\n   Assign length of STR to *LENP.\n   (Output has extra NUL at out[*LENP].) */\n    buf_char *copy_bytes(int *lenp) const;\n//    FILE *open_file(char *mode);\n    void assign(struct edit_string *src); // copy bytes from src to this\n};\n\nstruct edit_streambuf : public streambuf {\n    friend edit_buffer;\n    edit_string *str;\n    edit_streambuf* next; // Chain of edit_streambuf's for a edit_buffer.\n    short _mode;\n    edit_streambuf(edit_string* bstr, int mode);\n    ~edit_streambuf();\n    virtual int underflow();\n    virtual int overflow(int c = EOF);\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    void flush_to_buffer();\n    void flush_to_buffer(edit_buffer* buffer);\n    int _inserting;\n    int inserting() { return _inserting; }\n    void inserting(int i) { _inserting = i; }\n//    int delete_chars(int count, char* cut_buf); Not implemented.\n    int truncate();\n    int is_reading() { return gptr() != NULL; }\n    buf_char* current() { return is_reading() ? gptr() : pptr(); }\n    void set_current(char *p, int is_reading);\n  protected:\n    void disconnect_gap_from_file(edit_buffer* buffer);\n};\n\n// A 'edit_mark' indicates a position in a buffer.\n// It is \"attached\" the text (rather than the offset).\n// There are two kinds of mark, which have different behavior\n// when text is inserted at the mark:\n// If 'insert_before()' is true the mark will be adjusted to be\n// *after* the new text.\n\nstruct edit_mark {\n    struct edit_mark *chain;\n    mark_pointer _pos;\n    inline int insert_before() { return _pos & 1; }\n    inline unsigned long index_in_buffer(struct edit_buffer *)\n\t{ return _pos >> 1; }\n    inline buf_char *ptr(struct edit_buffer *buf);\n    buf_index tell();\n    edit_mark() { }\n    edit_mark(struct edit_string *str, long delta);\n    edit_buffer *buffer();\n    ~edit_mark();\n};\n\n// A 'edit_buffer' consists of a sequence of buf_chars (the data),\n// a list of edit_marks pointing into the data, and a list of FILEs\n// also pointing into the data.\n// A 'edit_buffer' coerced to a edit_string is the string of\n// all the buf_chars in the buffer.\n\n// This implementation uses a conventional buffer gap (as in Emacs).\n// The gap start is defined by de-referencing a (buf_char**).\n// This is because sometimes a FILE is inserting into the buffer,\n// so rather than having each putc adjust the gap, we use indirection\n// to have the gap be defined as the write pointer of the FILE.\n// (This assumes that putc adjusts a pointer (as in GNU's libc), not an index.)\n\nstruct edit_buffer {\n    buf_char *data; /* == emacs buffer_text.p1+1 */\n    buf_char *_gap_start;\n    edit_streambuf* _writer; // If non-NULL, currently writing stream\n    inline buf_char *gap_start()\n\t{ return _writer ? _writer->pptr() : _gap_start; }\n    buf_offset __gap_end_pos; // size of part 1 + size of gap\n    /* int gap; implicit: buf_size - size1 - size2 */\n    int buf_size;\n    struct edit_streambuf *files;\n    struct edit_mark start_mark;\n    struct edit_mark end_mark;\n    edit_buffer();\n    inline buf_offset gap_end_pos() { return __gap_end_pos; }\n    inline struct edit_mark *start_marker() { return &start_mark; }\n    inline struct edit_mark *end_marker() { return &end_mark; }\n/* these should be protected, ultimately */\n    buf_index tell(edit_mark*);\n    buf_index tell(buf_char*);\n    inline buf_char *gap_end() { return data + gap_end_pos(); }\n    inline int gap_size() { return gap_end() - gap_start(); }\n    inline int size1() { return gap_start() - data; }\n    inline int size2() { return buf_size - gap_end_pos(); }\n    inline struct edit_mark * mark_list() { return &start_mark; }\n    void make_gap (buf_offset);\n    void move_gap (buf_offset pos);\n    void move_gap (buf_char *pos) { move_gap(pos - data); }\n    void gap_left (int pos);\n    void gap_right (int pos);\n    void adjust_markers(mark_pointer low, mark_pointer high,\n\t\t\tint amount, buf_char *old_data);\n    void delete_range(buf_index from, buf_index to);\n    void delete_range(struct edit_mark *start, struct edit_mark *end);\n};\n\nextern buf_char * bstr_copy(struct edit_string *str, int *lenp);\n\n// Convert a edit_mark to a (buf_char*)\n\ninline buf_char *edit_mark::ptr(struct edit_buffer *buf)\n\t{ return buf->data + index_in_buffer(buf); }\n\ninline void edit_streambuf::flush_to_buffer()\n{\n    edit_buffer* buffer = str->buffer;\n    if (buffer->_writer == this) flush_to_buffer(buffer);\n}\n} // extern \"C++\"\n#endif /* !_EDITBUF_H*/\n\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/floatio.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/*\n * Copyright (c) 1990 The Regents of the University of California.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms are permitted\n * provided that the above copyright notice and this paragraph are\n * duplicated in all such forms and that any documentation,\n * advertising materials, and other materials related to such\n * distribution and use acknowledge that the software was developed\n * by the University of California, Berkeley.  The name of the\n * University may not be used to endorse or promote products derived\n * from this software without specific prior written permission.\n * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\n *\n *\t%W% (Berkeley) %G%\n */\n\n/*\n * Floating point scanf/printf (input/output) definitions.\n */\n\n/* 11-bit exponent (VAX G floating point) is 308 decimal digits */\n#define\tMAXEXP\t\t308\n/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */\n#define\tMAXFRACT\t39\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/fstream",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __FSTREAM__\n#define __FSTREAM__\n#include <fstream.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/fstream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _FSTREAM_H\n#define _FSTREAM_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#include <iostream.h>\n\nextern \"C++\" {\nclass fstreambase : virtual public ios {\n#ifdef _IO_NEW_STREAMS\n    mutable filebuf __my_fb; // mutable so rdbuf() can be const\n#endif\n    void __fb_init ();\n  public:\n    fstreambase();\n    fstreambase(int fd);\n    fstreambase(int fd, char *p, int l); /* Deprecated */\n    fstreambase(const char *name, int mode, int prot=0664);\n    void close();\n#ifdef _IO_NEW_STREAMS\n    filebuf* rdbuf() const { return &__my_fb; }\n#else\n    filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }\n#endif\n    void open(const char *name, int mode, int prot=0664);\n    int is_open() const { return rdbuf()->is_open(); }\n    void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); }\n    void attach(int fd);\n#ifdef _STREAM_COMPAT\n    int filedesc() { return rdbuf()->fd(); }\n    fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; }\n#endif\n};\n\nclass ifstream : public fstreambase, public istream {\n  public:\n    ifstream() : fstreambase() { }\n    ifstream(int fd) : fstreambase(fd) { }\n    ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/\n    ifstream(const char *name, int mode=ios::in, int prot=0664)\n\t: fstreambase(name, mode, prot) { }\n    void open(const char *name, int mode=ios::in, int prot=0664)\n\t{ fstreambase::open(name, mode, prot); }\n};\n\nclass ofstream : public fstreambase, public ostream {\n  public:\n    ofstream() : fstreambase() { }\n    ofstream(int fd) : fstreambase(fd) { }\n    ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/\n    ofstream(const char *name, int mode=ios::out, int prot=0664)\n\t: fstreambase(name, mode, prot) { }\n    void open(const char *name, int mode=ios::out, int prot=0664)\n\t{ fstreambase::open(name, mode, prot); }\n};\n\nclass fstream : public fstreambase, public iostream {\n  public:\n    fstream() : fstreambase() { }\n    fstream(int fd) : fstreambase(fd) { }\n    fstream(const char *name, int mode, int prot=0664)\n\t: fstreambase(name, mode, prot) { }\n    fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/\n    void open(const char *name, int mode, int prot=0664)\n\t{ fstreambase::open(name, mode, prot); }\n};\n} // extern \"C++\"\n#endif /*!_FSTREAM_H*/\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/function.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_FUNCTION_H\n#define __SGI_STL_FUNCTION_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#include <stddef.h>\n#ifndef __SGI_STL_INTERNAL_FUNCTION_H\n#include <stl_function.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACE_FOR_RELOPS\n\n// Names from stl_relops.h\nusing __STD_RELOPS::operator!=;\nusing __STD_RELOPS::operator>;\nusing __STD_RELOPS::operator<=;\nusing __STD_RELOPS::operator>=;\n\n#endif /* __STL_USE_NAMESPACE_FOR_RELOPS */\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_function.h\nusing __STD::unary_function; \nusing __STD::binary_function; \nusing __STD::plus; \nusing __STD::minus; \nusing __STD::multiplies; \nusing __STD::divides; \nusing __STD::identity_element; \nusing __STD::modulus; \nusing __STD::negate; \nusing __STD::equal_to; \nusing __STD::not_equal_to; \nusing __STD::greater; \nusing __STD::less; \nusing __STD::greater_equal; \nusing __STD::less_equal; \nusing __STD::logical_and; \nusing __STD::logical_or; \nusing __STD::logical_not; \nusing __STD::unary_negate; \nusing __STD::binary_negate; \nusing __STD::not1; \nusing __STD::not2; \nusing __STD::binder1st; \nusing __STD::binder2nd; \nusing __STD::bind1st; \nusing __STD::bind2nd; \nusing __STD::unary_compose; \nusing __STD::binary_compose; \nusing __STD::compose1; \nusing __STD::compose2; \nusing __STD::pointer_to_unary_function; \nusing __STD::pointer_to_binary_function; \nusing __STD::ptr_fun; \nusing __STD::identity; \nusing __STD::select1st; \nusing __STD::select2nd; \nusing __STD::project1st; \nusing __STD::project2nd; \nusing __STD::constant_void_fun; \nusing __STD::constant_unary_fun; \nusing __STD::constant_binary_fun; \nusing __STD::constant0; \nusing __STD::constant1; \nusing __STD::constant2; \nusing __STD::subtractive_rng; \nusing __STD::mem_fun_t; \nusing __STD::const_mem_fun_t; \nusing __STD::mem_fun_ref_t; \nusing __STD::const_mem_fun_ref_t; \nusing __STD::mem_fun1_t; \nusing __STD::const_mem_fun1_t; \nusing __STD::mem_fun1_ref_t; \nusing __STD::const_mem_fun1_ref_t; \nusing __STD::mem_fun; \nusing __STD::mem_fun_ref; \nusing __STD::mem_fun1; \nusing __STD::mem_fun1_ref; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_FUNCTION_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/functional",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_FUNCTIONAL\n#define __SGI_STL_FUNCTIONAL\n\n#include <stl_config.h>\n#include <stddef.h>\n#include <stl_function.h>\n\n#endif /* __SGI_STL_FUNCTIONAL */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/hash_map",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_MAP\n#define __SGI_STL_HASH_MAP\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_map.h>\n\n#endif /* __SGI_STL_HASH_MAP */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/hash_map.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_MAP_H\n#define __SGI_STL_HASH_MAP_H\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_map.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\nusing __STD::hash_map;\nusing __STD::hash_multimap;\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_HASH_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/hash_set",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_SET\n#define __SGI_STL_HASH_SET\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_set.h>\n\n#endif /* __SGI_STL_HASH_SET */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/hash_set.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_HASH_SET_H\n#define __SGI_STL_HASH_SET_H\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#include <stl_hashtable.h>\n#endif \n\n#include <stl_hash_set.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\nusing __STD::hash_set;\nusing __STD::hash_multiset;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_HASH_SET_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/hashtable.h",
    "content": "/*\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_HASHTABLE_H\n#define __SGI_STL_HASHTABLE_H\n\n#include <stl_hashtable.h>\n#include <algo.h>\n#include <alloc.h>\n#include <vector.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::hash;\nusing __STD::hashtable;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_HASHTABLE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/heap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_HEAP_H\n#define __SGI_STL_HEAP_H\n\n#include <stl_config.h>\n#include <stl_heap.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::push_heap;\nusing __STD::pop_heap;\nusing __STD::make_heap;\nusing __STD::sort_heap;\n\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_HEAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/indstream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License.\n\nWritten by Per Bothner (bothner@cygnus.com). */\n\n#ifndef _INDSTREAM_H\n#define _INDSTREAM_H\n\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n#include <iostream.h>\n\nextern \"C++\" {\n// An indirectbuf is one that forwards all of its I/O requests\n// to another streambuf.\n// All get-related requests are sent to get_stream().\n// All put-related requests are sent to put_stream().\n\n// An indirectbuf can be used to implement Common Lisp\n// synonym-streams and two-way-streams.\n//\n// class synonymbuf : public indirectbuf {\n//    Symbol *sym;\n//    synonymbuf(Symbol *s) { sym = s; }\n//    virtual streambuf *lookup_stream(int mode) {\n//        return coerce_to_streambuf(lookup_value(sym)); }\n// };\n\nclass indirectbuf : public streambuf {\n  protected:\n    streambuf *_get_stream;  // Optional cache for get_stream().\n    streambuf *_put_stream;  // Optional cache for put_stream().\n    int _delete_flags;\n  public:\n    streambuf *get_stream()\n\t{ return _get_stream ? _get_stream : lookup_stream(ios::in); }\n    streambuf *put_stream()\n\t{ return _put_stream ? _put_stream : lookup_stream(ios::out); }\n    virtual streambuf *lookup_stream(int/*mode*/) { return NULL; } // ERROR!\n    indirectbuf(streambuf *get=NULL, streambuf *put=NULL, int delete_mode=0);\n    virtual ~indirectbuf();\n    virtual streamsize xsputn(const char* s, streamsize n);\n    virtual streamsize xsgetn(char* s, streamsize n);\n    virtual int underflow();\n    virtual int uflow();\n    virtual int overflow(int c = EOF);\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);\n    virtual int sync();\n    virtual int pbackfail(int c);\n};\n} // extern \"C++\"\n\n#endif /* !_INDSTREAM_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iolibio.h",
    "content": "#include \"libio.h\"\n\n/* These emulate stdio functionality, but with a different name\n   (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nextern int _IO_fclose __P((_IO_FILE*));\nextern _IO_FILE *_IO_fdopen __P((int, const char*));\nextern int _IO_fflush __P((_IO_FILE*));\nextern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*));\nextern char* _IO_fgets __P((char*, int, _IO_FILE*));\nextern _IO_FILE *_IO_fopen __P((const char*, const char*));\nextern int _IO_fprintf __P((_IO_FILE*, const char*, ...));\nextern int _IO_fputs __P((const char*, _IO_FILE*));\nextern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *));\nextern long int _IO_ftell __P((_IO_FILE*));\nextern _IO_size_t _IO_fread __P((void*, _IO_size_t, _IO_size_t, _IO_FILE*));\nextern _IO_size_t _IO_fwrite __P((const void*,\n\t\t\t\t      _IO_size_t, _IO_size_t, _IO_FILE*));\nextern char* _IO_gets __P((char*));\nextern void _IO_perror __P((const char*));\nextern int _IO_printf __P((const char*, ...));\nextern int _IO_puts __P((const char*));\nextern int _IO_scanf __P((const char*, ...));\nextern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t));\nextern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t));\nextern int _IO_sscanf __P((const char*, const char*, ...));\nextern int _IO_sprintf __P((char *, const char*, ...));\nextern int _IO_ungetc __P((int, _IO_FILE*));\nextern int _IO_vsscanf __P((const char *, const char *, _IO_va_list));\nextern int _IO_vsprintf __P((char*, const char*, _IO_va_list));\n\nstruct obstack;\nextern int _IO_obstack_vprintf __P ((struct obstack *, const char *,\n                                    _IO_va_list));\nextern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));\n#ifndef _IO_pos_BAD\n#define _IO_pos_BAD ((_IO_fpos_t)(-1))\n#endif\n#define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN))\n#define _IO_fseek(__fp, __offset, __whence) \\\n  (_IO_seekoff(__fp, __offset, __whence, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD ? EOF : 0)\n#define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT)\n#define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS)\n#if _G_IO_IO_FILE_VERSION == 0x20001\n#define _IO_freopen(FILENAME, MODE, FP) \\\n  (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 0))\n#else\n#define _IO_freopen(FILENAME, MODE, FP) \\\n  (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE))\n#endif\n#define _IO_fileno(FP) ((FP)->_fileno)\nextern _IO_FILE* _IO_popen __P((const char*, const char*));\n#define _IO_pclose _IO_fclose\n#define _IO_setbuf(_FP, _BUF) _IO_setbuffer(_FP, _BUF, _IO_BUFSIZ)\n#define _IO_setlinebuf(_FP) _IO_setvbuf(_FP, NULL, 1, 0)\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iomanip",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __IOMANIP__\n#define __IOMANIP__\n#include <iomanip.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iomanip.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _IOMANIP_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#define _IOMANIP_H\n\n#include <iostream.h>\n\nextern \"C++\" {\n//-----------------------------------------------------------------------------\n//\tParametrized Manipulators as specified by ANSI draft\n//-----------------------------------------------------------------------------\n\n//-----------------------------------------------------------------------------\n//\tStream Manipulators\n//-----------------------------------------------------------------------------\n//\ntemplate<class TP> class smanip; // TP = Type Param\n\ntemplate<class TP> class sapp {\n    ios& (*_f)(ios&, TP);\npublic: \n    sapp(ios& (*f)(ios&, TP)) : _f(f) {}\n    //\n    smanip<TP> operator()(TP a) \n      { return smanip<TP>(_f, a); }\n};\n\ntemplate<class TP>\ninline istream& operator>>(istream& i, const smanip<TP>& m);\ntemplate<class TP>\ninline ostream& operator<<(ostream& o, const smanip<TP>& m);\n\ntemplate <class TP> class smanip {\n    ios& (*_f)(ios&, TP);\n    TP _a;\npublic:\n    smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {}\n    //\n    friend \n      istream& operator>> <>(istream& i, const smanip<TP>& m);\n    friend\n      ostream& operator<< <>(ostream& o, const smanip<TP>& m);\n};\n\n#ifdef __GNUG__\nextern template class smanip<int>;\nextern template class smanip<ios::fmtflags>;\n#endif\n\ntemplate<class TP>\ninline istream& operator>>(istream& i, const smanip<TP>& m)\n{ (*m._f)(i, m._a); return i; }\n\ntemplate<class TP>\ninline ostream& operator<<(ostream& o, const smanip<TP>& m)\n{ (*m._f)(o, m._a); return o;}\n\n#ifdef __GNUG__\nextern template istream& operator>>(istream&, const smanip<int>&);\nextern template istream& operator>>(istream&, const smanip<ios::fmtflags>&);\nextern template ostream& operator<<(ostream&, const smanip<int>&);\nextern template ostream& operator<<(ostream&, const smanip<ios::fmtflags>&);\n#endif\n\n//-----------------------------------------------------------------------------\n//\tInput-Stream Manipulators\n//-----------------------------------------------------------------------------\n//\ntemplate<class TP> class imanip; \n\ntemplate<class TP> class iapp {\n    istream& (*_f)(istream&, TP);\npublic: \n    iapp(istream& (*f)(istream&,TP)) : _f(f) {}\n    //\n    imanip<TP> operator()(TP a)\n       { return imanip<TP>(_f, a); }\n};\n\ntemplate <class TP>\ninline istream& operator>>(istream&, const imanip<TP>&);\n\ntemplate <class TP> class imanip {\n    istream& (*_f)(istream&, TP);\n    TP _a;\npublic:\n    imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {}\n    //\n    friend\n      istream& operator>> <>(istream& i, const imanip<TP>& m);\n};\n\ntemplate <class TP>\ninline istream& operator>>(istream& i, const imanip<TP>& m)\n{ return (*m._f)( i, m._a); }\n\n//-----------------------------------------------------------------------------\n//\tOutput-Stream Manipulators\n//-----------------------------------------------------------------------------\n//\ntemplate<class TP> class omanip; \n\ntemplate<class TP> class oapp {\n    ostream& (*_f)(ostream&, TP);\npublic: \n    oapp(ostream& (*f)(ostream&,TP)) : _f(f) {}\n    //\n    omanip<TP> operator()(TP a)\n      { return omanip<TP>(_f, a); }\n};\n\ntemplate <class TP>\ninline ostream& operator<<(ostream&, const omanip<TP>&);\n\ntemplate <class TP> class omanip {\n    ostream& (*_f)(ostream&, TP);\n    TP _a;\npublic:\n    omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {}\n    //\n    friend\n      ostream& operator<< <>(ostream& o, const omanip<TP>& m);\n};\n\ntemplate <class TP>\ninline ostream& operator<<(ostream& o, const omanip<TP>& m)\n{ return (*m._f)(o, m._a); }\n\n//-----------------------------------------------------------------------------\n//\tAvailable Manipulators\n//-----------------------------------------------------------------------------\n\n//\n// Macro to define an iomanip function, with one argument\n// The underlying function is `__iomanip_<name>' \n//\n#define __DEFINE_IOMANIP_FN1(type,param,function)         \\\n\textern ios& __iomanip_##function (ios&, param); \\\n\tinline type<param> function (param n)           \\\n\t\t        { return type<param> (__iomanip_##function, n); }\n\n__DEFINE_IOMANIP_FN1( smanip, int, setbase)\n__DEFINE_IOMANIP_FN1( smanip, int, setfill)\n__DEFINE_IOMANIP_FN1( smanip, int, setprecision)\n__DEFINE_IOMANIP_FN1( smanip, int, setw)\n\n__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, resetiosflags)\n__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, setiosflags)\n} // extern \"C++\"\n\n#endif /*!_IOMANIP_H*/\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iosfwd",
    "content": "// -*- C++ -*- I/O forward declaration header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __IOSFWD__\n#define __IOSFWD__\nclass ios;\nclass streambuf;\nclass istream;\nclass ostream;\nclass iostream;\nclass filebuf;\nclass ifstream;\nclass ofstream;\nclass fstream;\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iostdio.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* This file defines a stdio-like environment, except that it avoid\n   link-time name clashes with an existing stdio.\n   It allows for testing the libio using stdio-using programs\n   with an incompatible libc.a.\n   It is not predantically correct - e.g. some macros are used\n   that may evaluate a stream argument more than once.  */\n\n#ifndef _IOSTDIO_H\n#define _IOSTDIO_H\n\n#include \"iolibio.h\"\n\ntypedef _IO_FILE FILE;\n#ifndef EOF\n#define EOF (-1)\n#endif\n#ifndef BUFSIZ\n#define BUFSIZ 1024\n#endif\n\n/* #define size_t, fpos_t L_tmpname TMP_MAX */\n\n#define _IOFBF 0 /* Fully buffered. */\n#define _IOLBF 1 /* Line buffered. */\n#define _IONBF 2 /* No buffering. */\n\n#define SEEK_SET 0\n#define SEEK_CUR 1\n#define SEEK_END 2\n\n#define stdin _IO_stdin\n#define stdout _IO_stdout\n#define stderr _IO_stderr\n\n#define getc(_fp) _IO_getc(_fp)\n#define putc(_ch, _fp) _IO_putc(_ch, _fp)\n\n#define clearerr _IO_clearerr\n#define fclose _IO_fclose\n#define feof _IO_feof\n#define ferror _IO_ferror\n#define fflush _IO_fflush\n#define fgetc(__fp) _IO_getc(_fp)\n#define fgetpos _IO_fgetpos\n#define fgets _IO_fgets\n#define fopen _IO_fopen\n#define fprintf _IO_fprintf\n#define fputc(_ch, _fp) _IO_putc(_ch, _fp)\n#define fputs _IO_fputs\n#define fread _IO_fread\n#define freopen _IO_freopen\n#define fscanf _IO_fscanf\n#define fseek _IO_fseek\n#define fsetpos _IO_fsetpos\n#define ftell _IO_ftell\n#define fwrite _IO_fwrite\n#define gets _IO_gets\n#define perror _IO_perror\n#define printf _IO_printf\n#define puts _IO_puts\n#define rewind _IO_rewind\n#define scanf _IO_scanf\n#define setbuf _IO_setbuf\n#define setbuffer _IO_setbuffer\n#define setvbuf _IO_setvbuf\n#define sprintf _IO_sprintf\n#define sscanf _IO_sscanf\n#define ungetc _IO_ungetc\n#define vfprintf _IO_vfprintf\n#define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args)\n#define vsprintf _IO_vsprintf\n\n#if 0\n/* We can use the libc versions of these, since they don't pass FILE*s. */\n#define remove ??? __P((const char*))\n#define rename ??? __P((const char* _old, const char* _new))\n#define tmpfile ??? __P((void))\n#define tmpnam ??? __P((char*))\n#endif\n\n#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)\n#define fdopen _IO_fdopen\n#define fileno _IO_fileno\n#define popen _IO_popen\n#define pclose _IO_pclose\n#define setbuf _IO_setbuf\n#define setlinebuf _IO_setlinebuf\n#endif\n\n#endif /* _IOSTDIO_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iostream",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __IOSTREAM__\n#define __IOSTREAM__\n#include <iostream.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iostream.h",
    "content": "/*  This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _IOSTREAM_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#define _IOSTREAM_H\n\n#include <streambuf.h>\n\nextern \"C++\" {\nclass istream; class ostream;\ntypedef ios& (*__manip)(ios&);\ntypedef istream& (*__imanip)(istream&);\ntypedef ostream& (*__omanip)(ostream&);\n\nextern istream& ws(istream& ins);\nextern ostream& flush(ostream& outs);\nextern ostream& endl(ostream& outs);\nextern ostream& ends(ostream& outs);\n\nclass ostream : virtual public ios\n{\n    // NOTE: If fields are changed, you must fix _fake_ostream in stdstreams.C!\n    void do_osfx();\n  public:\n    ostream() { }\n    ostream(streambuf* sb, ostream* tied=NULL);\n    int opfx() {\n\tif (!good()) return 0;\n\telse { if (_tie) _tie->flush(); _IO_flockfile(_strbuf); return 1;} }\n    void osfx() { _IO_funlockfile(_strbuf);\n\t\t  if (flags() & (ios::unitbuf|ios::stdio))\n\t\t      do_osfx(); }\n    ostream& flush();\n    ostream& put(char c) { _strbuf->sputc(c); return *this; }\n#ifdef _STREAM_COMPAT\n    /* Temporary binary compatibility.  REMOVE IN NEXT RELEASE. */\n    ostream& put(unsigned char c) { return put((char)c); }\n    ostream& put(signed char c) { return put((char)c); }\n#endif\n    ostream& write(const char *s, streamsize n);\n    ostream& write(const unsigned char *s, streamsize n)\n      { return write((const char*)s, n);}\n    ostream& write(const signed char *s, streamsize n)\n      { return write((const char*)s, n);}\n    ostream& write(const void *s, streamsize n)\n      { return write((const char*)s, n);}\n    ostream& seekp(streampos);\n    ostream& seekp(streamoff, _seek_dir);\n    streampos tellp();\n    ostream& form(const char *format ...);\n    ostream& vform(const char *format, _IO_va_list args);\n\n    ostream& operator<<(char c);\n    ostream& operator<<(unsigned char c) { return (*this) << (char)c; }\n    ostream& operator<<(signed char c) { return (*this) << (char)c; }\n    ostream& operator<<(const char *s);\n    ostream& operator<<(const unsigned char *s)\n\t{ return (*this) << (const char*)s; }\n    ostream& operator<<(const signed char *s)\n\t{ return (*this) << (const char*)s; }\n    ostream& operator<<(const void *p);\n    ostream& operator<<(int n);\n    ostream& operator<<(unsigned int n);\n    ostream& operator<<(long n);\n    ostream& operator<<(unsigned long n);\n#if defined(__GNUC__)\n    __extension__ ostream& operator<<(long long n);\n    __extension__ ostream& operator<<(unsigned long long n);\n#endif\n    ostream& operator<<(short n) {return operator<<((int)n);}\n    ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}\n#if _G_HAVE_BOOL\n    ostream& operator<<(bool b) { return operator<<((int)b); }\n#endif\n    ostream& operator<<(double n);\n    ostream& operator<<(float n) { return operator<<((double)n); }\n#if _G_HAVE_LONG_DOUBLE_IO\n    ostream& operator<<(long double n);\n#else\n    ostream& operator<<(long double n) { return operator<<((double)n); }\n#endif\n    ostream& operator<<(__omanip func) { return (*func)(*this); }\n    ostream& operator<<(__manip func) {(*func)(*this); return *this;}\n    ostream& operator<<(streambuf*);\n#ifdef _STREAM_COMPAT\n    streambuf* ostreambuf() const { return _strbuf; }\n#endif\n};\n\nclass istream : virtual public ios\n{\n    // NOTE: If fields are changed, you must fix _fake_istream in stdstreams.C!\nprotected:\n    _IO_size_t _gcount;\n\n    int _skip_ws();\n  public:\n    istream(): _gcount (0) { }\n    istream(streambuf* sb, ostream*tied=NULL);\n    istream& get(char* ptr, int len, char delim = '\\n');\n    istream& get(unsigned char* ptr, int len, char delim = '\\n')\n\t{ return get((char*)ptr, len, delim); }\n    istream& get(char& c);\n    istream& get(unsigned char& c) { return get((char&)c); }\n    istream& getline(char* ptr, int len, char delim = '\\n');\n    istream& getline(unsigned char* ptr, int len, char delim = '\\n')\n\t{ return getline((char*)ptr, len, delim); }\n    istream& get(signed char& c)  { return get((char&)c); }\n    istream& get(signed char* ptr, int len, char delim = '\\n')\n\t{ return get((char*)ptr, len, delim); }\n    istream& getline(signed char* ptr, int len, char delim = '\\n')\n\t{ return getline((char*)ptr, len, delim); }\n    istream& read(char *ptr, streamsize n);\n    istream& read(unsigned char *ptr, streamsize n)\n      { return read((char*)ptr, n); }\n    istream& read(signed char *ptr, streamsize n)\n      { return read((char*)ptr, n); }\n    istream& read(void *ptr, streamsize n)\n      { return read((char*)ptr, n); }\n    istream& get(streambuf& sb, char delim = '\\n');\n    istream& gets(char **s, char delim = '\\n');\n    int ipfx(int need = 0) {\n\tif (!good()) { set(ios::failbit); return 0; }\n\telse {\n\t  _IO_flockfile(_strbuf);\n\t  if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();\n\t  if (!need && (flags() & ios::skipws)) return _skip_ws();\n\t  else return 1;\n\t}\n    }\n    int ipfx0() { // Optimized version of ipfx(0).\n\tif (!good()) { set(ios::failbit); return 0; }\n\telse {\n\t  _IO_flockfile(_strbuf);\n\t  if (_tie) _tie->flush();\n\t  if (flags() & ios::skipws) return _skip_ws();\n\t  else return 1;\n\t}\n    }\n    int ipfx1() { // Optimized version of ipfx(1).\n\tif (!good()) { set(ios::failbit); return 0; }\n\telse {\n\t  _IO_flockfile(_strbuf);\n\t  if (_tie && rdbuf()->in_avail() == 0) _tie->flush();\n\t  return 1;\n\t}\n    }\n    void isfx() { _IO_funlockfile(_strbuf); }\n    int get() { if (!ipfx1()) return EOF;\n\t\telse { int ch = _strbuf->sbumpc();\n\t\t       if (ch == EOF) set(ios::eofbit);\n\t\t       return ch;\n\t\t     } }\n    int peek();\n    _IO_size_t gcount() { return _gcount; }\n    istream& ignore(int n=1, int delim = EOF);\n    int sync ();\n    istream& seekg(streampos);\n    istream& seekg(streamoff, _seek_dir);\n    streampos tellg();\n    istream& putback(char ch) {\n\tif (good() && _strbuf->sputbackc(ch) == EOF) clear(ios::badbit);\n\treturn *this;}\n    istream& unget() {\n\tif (good() && _strbuf->sungetc() == EOF) clear(ios::badbit);\n\treturn *this;}\n    istream& scan(const char *format ...);\n    istream& vscan(const char *format, _IO_va_list args);\n#ifdef _STREAM_COMPAT\n    istream& unget(char ch) { return putback(ch); }\n    int skip(int i);\n    streambuf* istreambuf() const { return _strbuf; }\n#endif\n\n    istream& operator>>(char*);\n    istream& operator>>(unsigned char* p) { return operator>>((char*)p); }\n    istream& operator>>(signed char*p) { return operator>>((char*)p); }\n    istream& operator>>(char& c);\n    istream& operator>>(unsigned char& c) {return operator>>((char&)c);}\n    istream& operator>>(signed char& c) {return operator>>((char&)c);}\n    istream& operator>>(int&);\n    istream& operator>>(long&);\n#if defined(__GNUC__)\n    __extension__ istream& operator>>(long long&);\n    __extension__ istream& operator>>(unsigned long long&);\n#endif\n    istream& operator>>(short&);\n    istream& operator>>(unsigned int&);\n    istream& operator>>(unsigned long&);\n    istream& operator>>(unsigned short&);\n#if _G_HAVE_BOOL\n    istream& operator>>(bool&);\n#endif\n    istream& operator>>(float&);\n    istream& operator>>(double&);\n    istream& operator>>(long double&);\n    istream& operator>>( __manip func) {(*func)(*this); return *this;}\n    istream& operator>>(__imanip func) { return (*func)(*this); }\n    istream& operator>>(streambuf*);\n};\n\nclass iostream : public istream, public ostream\n{\n  public:\n    iostream() { }\n    iostream(streambuf* sb, ostream*tied=NULL);\n};\n\nclass _IO_istream_withassign : public istream {\npublic:\n  _IO_istream_withassign& operator=(istream&);\n  _IO_istream_withassign& operator=(_IO_istream_withassign& rhs)\n    { return operator= (static_cast<istream&> (rhs)); }\n};\n\nclass _IO_ostream_withassign : public ostream {\npublic:\n  _IO_ostream_withassign& operator=(ostream&);\n  _IO_ostream_withassign& operator=(_IO_ostream_withassign& rhs)\n    { return operator= (static_cast<ostream&> (rhs)); }\n};\n\nextern _IO_istream_withassign cin;\n// clog->rdbuf() == cerr->rdbuf()\nextern _IO_ostream_withassign cout, cerr;\n\nextern _IO_ostream_withassign clog\n#if _G_CLOG_CONFLICT\n__asm__ (\"__IO_clog\")\n#endif\n;\n\nextern istream& lock(istream& ins);\nextern istream& unlock(istream& ins);\nextern ostream& lock(ostream& outs);\nextern ostream& unlock(ostream& outs);\n\nstruct Iostream_init { } ;  // Compatibility hack for AT&T library.\n\ninline ios& dec(ios& i)\n{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }\ninline ios& hex(ios& i)\n{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }\ninline ios& oct(ios& i)\n{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }\n} // extern \"C++\"\n\n#endif /*!_IOSTREAM_H*/\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iostreamP.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#include \"streambuf.h\"\n#include \"libioP.h\"\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/istream.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#include <stream.h>\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iterator",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ITERATOR\n#define __SGI_STL_ITERATOR\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stddef.h>\n#include <iostream.h>\n#include <stl_iterator.h>\n\n#endif /* __SGI_STL_ITERATOR */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/iterator.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ITERATOR_H\n#define __SGI_STL_ITERATOR_H\n\n#ifndef __SGI_STL_FUNCTION_H\n#include <function.h>\n#endif\n#include <stddef.h>\n#include <iostream.h>\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#include <stl_iterator.h>\n#endif\n#ifndef __TYPE_TRAITS_H\n#include <type_traits.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#include <stl_construct.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n#include <stl_raw_storage_iter.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\n// Names from stl_iterator.h\n\nusing __STD::input_iterator_tag;\nusing __STD::output_iterator_tag;\nusing __STD::forward_iterator_tag;\nusing __STD::bidirectional_iterator_tag;\nusing __STD::random_access_iterator_tag;\n\n#if 0\nusing __STD::iterator;\n#endif\nusing __STD::input_iterator;\nusing __STD::output_iterator;\nusing __STD::forward_iterator;\nusing __STD::bidirectional_iterator;\nusing __STD::random_access_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\nusing __STD::iterator_traits;\n#endif\n\nusing __STD::iterator_category;\nusing __STD::distance_type;\nusing __STD::value_type;\n\nusing __STD::distance; \nusing __STD::advance; \n\nusing __STD::insert_iterator;\nusing __STD::front_insert_iterator;\nusing __STD::back_insert_iterator;\nusing __STD::inserter;\nusing __STD::front_inserter;\nusing __STD::back_inserter;\n\nusing __STD::reverse_iterator;\nusing __STD::reverse_bidirectional_iterator;\n\nusing __STD::istream_iterator;\nusing __STD::ostream_iterator;\n\n// Names from stl_construct.h\nusing __STD::construct;\nusing __STD::destroy;\n\n// Names from stl_raw_storage_iter.h\nusing __STD::raw_storage_iterator;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ITERATOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/libio.h",
    "content": "/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.\n   This file is part of the GNU IO Library.\n   Written by Per Bothner <bothner@cygnus.com>.\n\n   This library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU General Public License as\n   published by the Free Software Foundation; either version 2, or (at\n   your option) any later version.\n\n   This library is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this library; see the file COPYING.  If not, write to\n   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,\n   MA 02111-1307, USA.\n\n   As a special exception, if you link this library with files\n   compiled with a GNU compiler to produce an executable, this does\n   not cause the resulting executable to be covered by the GNU General\n   Public License.  This exception does not however invalidate any\n   other reasons why the executable file might be covered by the GNU\n   General Public License.  */\n\n#ifndef _IO_STDIO_H\n#define _IO_STDIO_H\n\n#include <_G_config.h>\n#define _IO_pos_t _G_fpos_t /* obsolete */\n#define _IO_fpos_t _G_fpos_t\n#define _IO_size_t _G_size_t\n#define _IO_ssize_t _G_ssize_t\n#define _IO_off_t _G_off_t\n#define _IO_pid_t _G_pid_t\n#define _IO_uid_t _G_uid_t\n#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT\n#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE\n#define _IO_BUFSIZ _G_BUFSIZ\n#define _IO_va_list _G_va_list\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n#define _IO_fpos64_t _G_fpos64_t\n#define _IO_off64_t _G_off64_t\n#endif\n\n#ifdef _G_NEED_STDARG_H\n/* This define avoids name pollution if we're using GNU stdarg.h */\n# define __need___va_list\n# include <stdarg.h>\n# ifdef __GNUC_VA_LIST\n#  undef _IO_va_list\n#  define _IO_va_list __gnuc_va_list\n# endif /* __GNUC_VA_LIST */\n#endif\n\n#ifndef __P\n# if _G_HAVE_SYS_CDEFS\n#  include <sys/cdefs.h>\n# else\n#  ifdef __STDC__\n#   define __P(p) p\n#  else\n#   define __P(p) ()\n#  endif\n# endif\n#endif /*!__P*/\n\n/* For backward compatibility */\n#ifndef _PARAMS\n# define _PARAMS(protos) __P(protos)\n#endif /*!_PARAMS*/\n\n#ifndef __STDC__\n# define const\n#endif\n#define _IO_UNIFIED_JUMPTABLES 1\n#if !_G_HAVE_PRINTF_FP\n# define _IO_USE_DTOA 1\n#endif\n\n#ifndef EOF\n# define EOF (-1)\n#endif\n#ifndef NULL\n# if defined __GNUG__ && \\\n    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n#  define NULL (__null)\n# else\n#  if !defined(__cplusplus)\n#   define NULL ((void*)0)\n#  else\n#   define NULL (0)\n#  endif\n# endif\n#endif\n\n#define _IOS_INPUT\t1\n#define _IOS_OUTPUT\t2\n#define _IOS_ATEND\t4\n#define _IOS_APPEND\t8\n#define _IOS_TRUNC\t16\n#define _IOS_NOCREATE\t32\n#define _IOS_NOREPLACE\t64\n#define _IOS_BIN\t128\n\n/* Magic numbers and bits for the _flags field.\n   The magic numbers use the high-order bits of _flags;\n   the remaining bits are available for variable flags.\n   Note: The magic numbers must all be negative if stdio\n   emulation is desired. */\n\n#define _IO_MAGIC 0xFBAD0000 /* Magic number */\n#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */\n#define _IO_MAGIC_MASK 0xFFFF0000\n#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */\n#define _IO_UNBUFFERED 2\n#define _IO_NO_READS 4 /* Reading not allowed */\n#define _IO_NO_WRITES 8 /* Writing not allowd */\n#define _IO_EOF_SEEN 0x10\n#define _IO_ERR_SEEN 0x20\n#define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */\n#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/\n#define _IO_IN_BACKUP 0x100\n#define _IO_LINE_BUF 0x200\n#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */\n#define _IO_CURRENTLY_PUTTING 0x800\n#define _IO_IS_APPENDING 0x1000\n#define _IO_IS_FILEBUF 0x2000\n#define _IO_BAD_SEEN 0x4000\n\n/* These are \"formatting flags\" matching the iostream fmtflags enum values. */\n#define _IO_SKIPWS 01\n#define _IO_LEFT 02\n#define _IO_RIGHT 04\n#define _IO_INTERNAL 010\n#define _IO_DEC 020\n#define _IO_OCT 040\n#define _IO_HEX 0100\n#define _IO_SHOWBASE 0200\n#define _IO_SHOWPOINT 0400\n#define _IO_UPPERCASE 01000\n#define _IO_SHOWPOS 02000\n#define _IO_SCIENTIFIC 04000\n#define _IO_FIXED 010000\n#define _IO_UNITBUF 020000\n#define _IO_STDIO 040000\n#define _IO_DONT_CLOSE 0100000\n#define _IO_BOOLALPHA 0200000\n\n\nstruct _IO_jump_t;  struct _IO_FILE;\n\n/* Handle lock.  */\n#ifdef _IO_MTSAFE_IO\n# if defined __GLIBC__ && __GLIBC__ >= 2\n#  if __GLIBC_MINOR__ > 0\n#   include <bits/stdio-lock.h>\n#  else\n#   include <stdio-lock.h>\n#  endif\n#  define _IO_LOCK_T _IO_lock_t *\n# else\n/*# include <comthread.h>*/\n# endif\n#else\n# if defined(__GLIBC__) && __GLIBC__ >= 2\n   typedef void _IO_lock_t;\n#  define _IO_LOCK_T void *\n# else\n#  ifdef __linux__\n    struct _IO_lock_t { void *ptr; short int field1; short int field2; };\n#   define _IO_LOCK_T struct _IO_lock_t\n#  else\n    typedef void _IO_lock_t;\n#  endif\n# endif\n#endif\n\n\n/* A streammarker remembers a position in a buffer. */\n\nstruct _IO_marker {\n  struct _IO_marker *_next;\n  struct _IO_FILE *_sbuf;\n  /* If _pos >= 0\n it points to _buf->Gbase()+_pos. FIXME comment */\n  /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */\n  int _pos;\n#if 0\n    void set_streampos(streampos sp) { _spos = sp; }\n    void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }\n  public:\n    streammarker(streambuf *sb);\n    ~streammarker();\n    int saving() { return  _spos == -2; }\n    int delta(streammarker&);\n    int delta();\n#endif\n};\n\nstruct _IO_FILE {\n  int _flags;\t\t/* High-order word is _IO_MAGIC; rest is flags. */\n#define _IO_file_flags _flags\n\n  /* The following pointers correspond to the C++ streambuf protocol. */\n  /* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */\n  char* _IO_read_ptr;\t/* Current read pointer */\n  char* _IO_read_end;\t/* End of get area. */\n  char* _IO_read_base;\t/* Start of putback+get area. */\n  char* _IO_write_base;\t/* Start of put area. */\n  char* _IO_write_ptr;\t/* Current put pointer. */\n  char* _IO_write_end;\t/* End of put area. */\n  char* _IO_buf_base;\t/* Start of reserve area. */\n  char* _IO_buf_end;\t/* End of reserve area. */\n  /* The following fields are used to support backing up and undo. */\n  char *_IO_save_base; /* Pointer to start of non-current get area. */\n  char *_IO_backup_base;  /* Pointer to first valid character of backup area */\n  char *_IO_save_end; /* Pointer to end of non-current get area. */\n\n  struct _IO_marker *_markers;\n\n  struct _IO_FILE *_chain;\n\n  int _fileno;\n  int _blksize;\n#ifdef _G_IO_IO_FILE_VERSION\n  _IO_off_t _old_offset;\n#else\n  _IO_off_t _offset;\n#endif\n\n#define __HAVE_COLUMN /* temporary */\n  /* 1+column number of pbase(); 0 is unknown. */\n  unsigned short _cur_column;\n  char _unused;\n  char _shortbuf[1];\n\n  /*  char* _save_gptr;  char* _save_egptr; */\n\n#ifdef _IO_LOCK_T\n  _IO_LOCK_T _lock;\n#endif\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n  _IO_off64_t _offset;\n  int _unused2[16];\t/* Make sure we don't get into trouble again.  */\n#endif\n};\n\n#ifndef __cplusplus\ntypedef struct _IO_FILE _IO_FILE;\n#endif\n\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n#define _IO_stdin_ _IO_2_1_stdin_\n#define _IO_stdout_ _IO_2_1_stdout_\n#define _IO_stderr_ _IO_2_1_stderr_\n#endif\n\nstruct _IO_FILE_plus;\nextern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;\n#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))\n#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))\n#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))\n\n\n/* Define the user-visible type, with user-friendly member names.  */\ntypedef struct\n{\n  _IO_ssize_t (*read) __P ((struct _IO_FILE *, void *, _IO_ssize_t));\n  _IO_ssize_t (*write) __P ((struct _IO_FILE *, const void *, _IO_ssize_t));\n  _IO_fpos_t (*seek) __P ((struct _IO_FILE *, _IO_off_t, int));\n  int (*close) __P ((struct _IO_FILE *));\n} _IO_cookie_io_functions_t;\n\n/* Special file type for fopencookie function.  */\nstruct _IO_cookie_file\n{\n  struct _IO_FILE file;\n  const void *vtable;\n  void *cookie;\n  _IO_cookie_io_functions_t io_functions;\n};\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nextern int __underflow __P ((_IO_FILE *));\nextern int __uflow __P ((_IO_FILE *));\nextern int __overflow __P ((_IO_FILE *, int));\n\n#define _IO_getc_unlocked(_fp) \\\n       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \\\n\t: *(unsigned char *) (_fp)->_IO_read_ptr++)\n#define _IO_peekc_unlocked(_fp) \\\n       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \\\n\t  && __underflow (_fp) == EOF ? EOF \\\n\t: *(unsigned char *) (_fp)->_IO_read_ptr)\n\n#define _IO_putc_unlocked(_ch, _fp) \\\n   (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \\\n    ? __overflow (_fp, (unsigned char) (_ch)) \\\n    : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))\n\n#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)\n#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)\n\nextern int _IO_getc __P ((_IO_FILE *__fp));\nextern int _IO_putc __P ((int __c, _IO_FILE *__fp));\nextern int _IO_feof __P ((_IO_FILE *__fp));\nextern int _IO_ferror __P ((_IO_FILE *__fp));\n\nextern int _IO_peekc_locked __P ((_IO_FILE *__fp));\n\n/* This one is for Emacs. */\n#define _IO_PENDING_OUTPUT_COUNT(_fp)\t\\\n\t((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)\n\nextern void _IO_flockfile __P ((_IO_FILE *));\nextern void _IO_funlockfile __P ((_IO_FILE *));\nextern int _IO_ftrylockfile __P ((_IO_FILE *));\n\n#ifdef _IO_MTSAFE_IO\n# define _IO_peekc(_fp) _IO_peekc_locked (_fp)\n#else\n# define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)\n# define _IO_flockfile(_fp) /**/\n# define _IO_funlockfile(_fp) /**/\n# define _IO_ftrylockfile(_fp) /**/\n# define _IO_cleanup_region_start(_fct, _fp) /**/\n# define _IO_cleanup_region_end(_Doit) /**/\n#endif /* !_IO_MTSAFE_IO */\n\n\nextern int _IO_vfscanf __P ((_IO_FILE *, const char *, _IO_va_list, int *));\nextern int _IO_vfprintf __P ((_IO_FILE *, const char *, _IO_va_list));\nextern _IO_ssize_t _IO_padn __P ((_IO_FILE *, int, _IO_ssize_t));\nextern _IO_size_t _IO_sgetn __P ((_IO_FILE *, void *, _IO_size_t));\n\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));      \nextern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));\n#else\nextern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));\nextern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));\n#endif\n\nextern void _IO_free_backup_area __P ((_IO_FILE *));\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _IO_STDIO_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/libioP.h",
    "content": "/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.\n   This file is part of the GNU IO Library.\n\n   This library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU General Public License as\n   published by the Free Software Foundation; either version 2, or (at\n   your option) any later version.\n\n   This library is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this library; see the file COPYING.  If not, write to\n   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,\n   MA 02111-1307, USA.\n\n   As a special exception, if you link this library with files\n   compiled with a GNU compiler to produce an executable, this does\n   not cause the resulting executable to be covered by the GNU General\n   Public License.  This exception does not however invalidate any\n   other reasons why the executable file might be covered by the GNU\n   General Public License.  */\n\n#include <errno.h>\n#ifndef __set_errno\n# define __set_errno(Val) errno = (Val)\n#endif\n#if defined __GLIBC__ && __GLIBC__ >= 2\n# if __GLIBC_MINOR__ > 0\n#  include <bits/libc-lock.h>\n# else\n#  include <libc-lock.h>\n# endif\n#else\n/*# include <comthread.h>*/\n#endif\n\n#include \"iolibio.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define _IO_seek_set 0\n#define _IO_seek_cur 1\n#define _IO_seek_end 2\n\n/* THE JUMPTABLE FUNCTIONS.\n\n * The _IO_FILE type is used to implement the FILE type in GNU libc,\n * as well as the streambuf class in GNU iostreams for C++.\n * These are all the same, just used differently.\n * An _IO_FILE (or FILE) object is allows followed by a pointer to\n * a jump table (of pointers to functions).  The pointer is accessed\n * with the _IO_JUMPS macro.  The jump table has a eccentric format,\n * so as to be compatible with the layout of a C++ virtual function table.\n * (as implemented by g++).  When a pointer to a streambuf object is\n * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just\n * happens to point to the virtual function table of the streambuf.\n * Thus the _IO_JUMPS function table used for C stdio/libio does\n * double duty as the virtual function table for C++ streambuf.\n *\n * The entries in the _IO_JUMPS function table (and hence also the\n * virtual functions of a streambuf) are described below.\n * The first parameter of each function entry is the _IO_FILE/streambuf\n * object being acted on (i.e. the 'this' parameter).\n */\n\n#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus *) (THIS))->vtable\n#ifdef _G_USING_THUNKS\n# define JUMP_FIELD(TYPE, NAME) TYPE NAME\n# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC (THIS)\n# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC (THIS, X1)\n# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC (THIS, X1, X2)\n# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC (THIS, X1,X2, X3)\n# define JUMP_INIT(NAME, VALUE) VALUE\n# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)\n#else\n/* These macros will change when we re-implement vtables to use \"thunks\"! */\n# define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME\n# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn (THIS)\n# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1)\n# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1, X2)\n# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1,X2,X3)\n# define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}\n# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)\n#endif\n\n/* The 'finish' function does any final cleaning up of an _IO_FILE object.\n   It does not delete (free) it, but does everything else to finalize it/\n   It matches the streambuf::~streambuf virtual destructor.  */\ntypedef void (*_IO_finish_t) __P ((_IO_FILE *, int)); /* finalize */\n#define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)\n\n/* The 'overflow' hook flushes the buffer.\n   The second argument is a character, or EOF.\n   It matches the streambuf::overflow virtual function. */\ntypedef int (*_IO_overflow_t) __P ((_IO_FILE *, int));\n#define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)\n\n/* The 'underflow' hook tries to fills the get buffer.\n   It returns the next character (as an unsigned char) or EOF.  The next\n   character remains in the get buffer, and the get position is not changed.\n   It matches the streambuf::underflow virtual function. */\ntypedef int (*_IO_underflow_t) __P ((_IO_FILE *));\n#define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)\n\n/* The 'uflow' hook returns the next character in the input stream\n   (cast to unsigned char), and increments the read position;\n   EOF is returned on failure.\n   It matches the streambuf::uflow virtual function, which is not in the\n   cfront implementation, but was added to C++ by the ANSI/ISO committee. */\n#define _IO_UFLOW(FP) JUMP0 (__uflow, FP)\n\n/* The 'pbackfail' hook handles backing up.\n   It matches the streambuf::pbackfail virtual function. */\ntypedef int (*_IO_pbackfail_t) __P ((_IO_FILE *, int));\n#define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)\n\n/* The 'xsputn' hook writes upto N characters from buffer DATA.\n   Returns the number of character actually written.\n   It matches the streambuf::xsputn virtual function. */\ntypedef _IO_size_t (*_IO_xsputn_t) __P ((_IO_FILE *FP, const void *DATA,\n\t\t\t\t\t _IO_size_t N));\n#define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)\n\n/* The 'xsgetn' hook reads upto N characters into buffer DATA.\n   Returns the number of character actually read.\n   It matches the streambuf::xsgetn virtual function. */\ntypedef _IO_size_t (*_IO_xsgetn_t) __P ((_IO_FILE *FP, void *DATA,\n\t\t\t\t\t _IO_size_t N));\n#define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)\n\n/* The 'seekoff' hook moves the stream position to a new position\n   relative to the start of the file (if DIR==0), the current position\n   (MODE==1), or the end of the file (MODE==2).\n   It matches the streambuf::seekoff virtual function.\n   It is also used for the ANSI fseek function. */\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\ntypedef _IO_fpos64_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off64_t OFF,\n\t\t\t\t\t  int DIR, int MODE));\n#else\ntypedef _IO_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,\n\t\t\t\t\t  int DIR, int MODE));\n#endif\n#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)\n\n/* The 'seekpos' hook also moves the stream position,\n   but to an absolute position given by a fpos_t (seekpos).\n   It matches the streambuf::seekpos virtual function.\n   It is also used for the ANSI fgetpos and fsetpos functions.  */\n/* The _IO_seek_cur and _IO_seek_end options are not allowed. */\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\ntypedef _IO_fpos64_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos64_t, int));\n#else\ntypedef _IO_fpos_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos_t, int));\n#endif\n#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)\n\n/* The 'setbuf' hook gives a buffer to the file.\n   It matches the streambuf::setbuf virtual function. */\ntypedef _IO_FILE* (*_IO_setbuf_t) __P ((_IO_FILE *, char *, _IO_ssize_t));\n#define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)\n\n/* The 'sync' hook attempts to synchronize the internal data structures\n   of the file with the external state.\n   It matches the streambuf::sync virtual function. */\ntypedef int (*_IO_sync_t) __P ((_IO_FILE *));\n#define _IO_SYNC(FP) JUMP0 (__sync, FP)\n\n/* The 'doallocate' hook is used to tell the file to allocate a buffer.\n   It matches the streambuf::doallocate virtual function, which is not\n   in the ANSI/ISO C++ standard, but is part traditional implementations. */\ntypedef int (*_IO_doallocate_t) __P ((_IO_FILE *));\n#define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)\n\n/* The following four hooks (sysread, syswrite, sysclose, sysseek, and\n   sysstat) are low-level hooks specific to this implementation.\n   There is no correspondence in the ANSI/ISO C++ standard library.\n   The hooks basically correspond to the Unix system functions\n   (read, write, close, lseek, and stat) except that a _IO_FILE*\n   parameter is used instead of a integer file descriptor;  the default\n   implementation used for normal files just calls those functions.\n   The advantage of overriding these functions instead of the higher-level\n   ones (underflow, overflow etc) is that you can leave all the buffering\n   higher-level functions.  */\n\n/* The 'sysread' hook is used to read data from the external file into\n   an existing buffer.  It generalizes the Unix read(2) function.\n   It matches the streambuf::sys_read virtual function, which is\n   specific to this implementation. */\ntypedef _IO_ssize_t (*_IO_read_t) __P ((_IO_FILE *, void *, _IO_ssize_t));\n#define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)\n\n/* The 'syswrite' hook is used to write data from an existing buffer\n   to an external file.  It generalizes the Unix write(2) function.\n   It matches the streambuf::sys_write virtual function, which is\n   specific to this implementation. */\ntypedef _IO_ssize_t (*_IO_write_t) __P ((_IO_FILE *,const void *,_IO_ssize_t));\n#define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)\n\n/* The 'sysseek' hook is used to re-position an external file.\n   It generalizes the Unix lseek(2) function.\n   It matches the streambuf::sys_seek virtual function, which is\n   specific to this implementation. */\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\ntypedef _IO_fpos64_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off64_t, int));\n#else\ntypedef _IO_fpos_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off_t, int));\n#endif\n#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)\n\n/* The 'sysclose' hook is used to finalize (close, finish up) an\n   external file.  It generalizes the Unix close(2) function.\n   It matches the streambuf::sys_close virtual function, which is\n   specific to this implementation. */\ntypedef int (*_IO_close_t) __P ((_IO_FILE *)); /* finalize */\n#define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)\n\n/* The 'sysstat' hook is used to get information about an external file\n   into a struct stat buffer.  It generalizes the Unix fstat(2) call.\n   It matches the streambuf::sys_stat virtual function, which is\n   specific to this implementation. */\ntypedef int (*_IO_stat_t) __P ((_IO_FILE *, void *));\n#define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)\n\n#if _G_IO_IO_FILE_VERSION == 0x20001\n/* The 'showmany' hook can be used to get an image how much input is\n   available.  In many cases the answer will be 0 which means unknown\n   but some cases one can provide real information.  */\ntypedef int (*_IO_showmanyc_t) __P ((_IO_FILE *));\n#define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)\n\n/* The 'imbue' hook is used to get information about the currently\n   installed locales.  */\ntypedef void (*_IO_imbue_t) __P ((_IO_FILE *, void *));\n#define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)\n#endif\n\n\n#define _IO_CHAR_TYPE char /* unsigned char ? */\n#define _IO_INT_TYPE int\n\nstruct _IO_jump_t\n{\n    JUMP_FIELD(_G_size_t, __dummy);\n#ifdef _G_USING_THUNKS\n    JUMP_FIELD(_G_size_t, __dummy2);\n#endif\n    JUMP_FIELD(_IO_finish_t, __finish);\n    JUMP_FIELD(_IO_overflow_t, __overflow);\n    JUMP_FIELD(_IO_underflow_t, __underflow);\n    JUMP_FIELD(_IO_underflow_t, __uflow);\n    JUMP_FIELD(_IO_pbackfail_t, __pbackfail);\n    /* showmany */\n    JUMP_FIELD(_IO_xsputn_t, __xsputn);\n    JUMP_FIELD(_IO_xsgetn_t, __xsgetn);\n    JUMP_FIELD(_IO_seekoff_t, __seekoff);\n    JUMP_FIELD(_IO_seekpos_t, __seekpos);\n    JUMP_FIELD(_IO_setbuf_t, __setbuf);\n    JUMP_FIELD(_IO_sync_t, __sync);\n    JUMP_FIELD(_IO_doallocate_t, __doallocate);\n    JUMP_FIELD(_IO_read_t, __read);\n    JUMP_FIELD(_IO_write_t, __write);\n    JUMP_FIELD(_IO_seek_t, __seek);\n    JUMP_FIELD(_IO_close_t, __close);\n    JUMP_FIELD(_IO_stat_t, __stat);\n#if _G_IO_IO_FILE_VERSION == 0x20001\n    JUMP_FIELD(_IO_showmanyc_t, __showmanyc);\n    JUMP_FIELD(_IO_imbue_t, __imbue);\n#endif\n#if 0\n    get_column;\n    set_column;\n#endif\n};\n\n/* We always allocate an extra word following an _IO_FILE.\n   This contains a pointer to the function jump table used.\n   This is for compatibility with C++ streambuf; the word can\n   be used to smash to a pointer to a virtual function table. */\n\nstruct _IO_FILE_plus\n{\n  _IO_FILE file;\n  const struct _IO_jump_t *vtable;\n};\n\n/* Generic functions */\n\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));\nextern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));\n#else\nextern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));\nextern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));\n#endif\n\nextern void _IO_switch_to_main_get_area __P ((_IO_FILE *));\nextern void _IO_switch_to_backup_area __P ((_IO_FILE *));\nextern int _IO_switch_to_get_mode __P ((_IO_FILE *));\nextern void _IO_init __P ((_IO_FILE *, int));\nextern int _IO_sputbackc __P ((_IO_FILE *, int));\nextern int _IO_sungetc __P ((_IO_FILE *));\nextern void _IO_un_link __P ((_IO_FILE *));\nextern void _IO_link_in __P ((_IO_FILE *));\nextern void _IO_doallocbuf __P ((_IO_FILE *));\nextern void _IO_unsave_markers __P ((_IO_FILE *));\nextern void _IO_setb __P ((_IO_FILE *, char *, char *, int));\nextern unsigned _IO_adjust_column __P ((unsigned, const char *, int));\n#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)\n\n/* Marker-related function. */\n\nextern void _IO_init_marker __P ((struct _IO_marker *, _IO_FILE *));\nextern void _IO_remove_marker __P ((struct _IO_marker *));\nextern int _IO_marker_difference __P ((struct _IO_marker *,\n\t\t\t\t       struct _IO_marker *));\nextern int _IO_marker_delta __P ((struct _IO_marker *));\nextern int _IO_seekmark __P ((_IO_FILE *, struct _IO_marker *, int));\n\n/* Default jumptable functions. */\n\nextern int _IO_default_underflow __P ((_IO_FILE *));\nextern int _IO_default_uflow __P ((_IO_FILE *));\nextern int _IO_default_doallocate __P ((_IO_FILE *));\nextern void _IO_default_finish __P ((_IO_FILE *, int));\nextern int _IO_default_pbackfail __P ((_IO_FILE *, int));\nextern _IO_FILE* _IO_default_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));\nextern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,\n\t\t\t\t\t   _IO_size_t));\nextern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_default_seekoff __P ((_IO_FILE *,\n\t\t\t\t\t      _IO_off64_t, int, int));\nextern _IO_fpos64_t _IO_default_seekpos __P ((_IO_FILE *,\n\t\t\t\t\t      _IO_fpos64_t, int));\n#else\nextern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));\nextern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));\n#endif\nextern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,\n\t\t\t\t\t   _IO_ssize_t));\nextern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));\nextern int _IO_default_stat __P ((_IO_FILE *, void *));\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int));\n#else\nextern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));\n#endif\nextern int _IO_default_sync __P ((_IO_FILE *));\n#define _IO_default_close ((_IO_close_t) _IO_default_sync)\n\nextern struct _IO_jump_t _IO_file_jumps;\nextern struct _IO_jump_t _IO_streambuf_jumps;\nextern struct _IO_jump_t _IO_proc_jumps;\nextern struct _IO_jump_t _IO_str_jumps;\nextern int _IO_do_write __P ((_IO_FILE *, const char *, _IO_size_t));\nextern int _IO_flush_all __P ((void));\nextern void _IO_cleanup __P ((void));\nextern void _IO_flush_all_linebuffered __P ((void));\n\n#define _IO_do_flush(_f) \\\n  _IO_do_write(_f, (_f)->_IO_write_base, \\\n\t       (_f)->_IO_write_ptr-(_f)->_IO_write_base)\n#define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)\n#define _IO_mask_flags(fp, f, mask) \\\n       ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))\n#define _IO_setg(fp, eb, g, eg)  ((fp)->_IO_read_base = (eb),\\\n\t(fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))\n#define _IO_setp(__fp, __p, __ep) \\\n       ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep))\n#define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL)\n#define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)\n#define _IO_have_markers(fp) ((fp)->_markers != NULL)\n#define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)\n\n/* Jumptable functions for files. */\n\nextern int _IO_file_doallocate __P ((_IO_FILE *));\nextern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));\nextern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));\n#else\nextern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));\nextern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));\n#endif\nextern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));\nextern int _IO_file_stat __P ((_IO_FILE *, void *));\nextern int _IO_file_close __P ((_IO_FILE *));\nextern int _IO_file_underflow __P ((_IO_FILE *));\nextern int _IO_file_overflow __P ((_IO_FILE *, int));\n#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)\nextern void _IO_file_init __P ((_IO_FILE *));\nextern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));\nextern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,\n\t\t\t\t     int, int));\n#if _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *,\n\t\t\t\t      int));\n#else\nextern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *));\n#endif\nextern _IO_ssize_t _IO_file_write __P ((_IO_FILE *, const void *,\n\t\t\t\t\t_IO_ssize_t));\nextern _IO_ssize_t _IO_file_read __P ((_IO_FILE *, void *, _IO_ssize_t));\nextern int _IO_file_sync __P ((_IO_FILE *));\nextern int _IO_file_close_it __P ((_IO_FILE *));\nextern void _IO_file_finish __P ((_IO_FILE *, int));\n\n/* Jumptable functions for proc_files. */\nextern _IO_FILE* _IO_proc_open __P ((_IO_FILE *, const char *, const char *));\nextern int _IO_proc_close __P ((_IO_FILE *));\n\n/* Jumptable functions for strfiles. */\nextern int _IO_str_underflow __P ((_IO_FILE *));\nextern int _IO_str_overflow __P ((_IO_FILE *, int));\nextern int _IO_str_pbackfail __P ((_IO_FILE *, int));\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\nextern _IO_fpos64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));\n#else\nextern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));\n#endif\nextern void _IO_str_finish __P ((_IO_FILE *, int));\n\n/* Other strfile functions */\nextern void _IO_str_init_static __P ((_IO_FILE *, char *, int, char *));\nextern void _IO_str_init_readonly __P ((_IO_FILE *, const char *, int));\nextern _IO_ssize_t _IO_str_count __P ((_IO_FILE *));\n\nextern int _IO_vasprintf __P ((char **result_ptr, __const char *format,\n\t\t\t       _IO_va_list args));\nextern int _IO_vdprintf __P ((int d, __const char *format, _IO_va_list arg));\nextern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen,\n\t\t\t       __const char *format, _IO_va_list args));\n\n\nextern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, int, int));\nextern _IO_size_t _IO_getline_info __P ((_IO_FILE *,char *, _IO_size_t,\n\t\t\t\t\t int, int, int *));\nextern _IO_ssize_t _IO_getdelim __P ((char **, _IO_size_t *, int, _IO_FILE *));\nextern double _IO_strtod __P ((const char *, char **));\nextern char *_IO_dtoa __P ((double __d, int __mode, int __ndigits,\n\t\t\t    int *__decpt, int *__sign, char **__rve));\nextern int _IO_outfloat __P ((double __value, _IO_FILE *__sb, int __type,\n\t\t\t      int __width, int __precision, int __flags,\n\t\t\t      int __sign_mode, int __fill));\n\nextern _IO_FILE *_IO_list_all;\nextern void (*_IO_cleanup_registration_needed) __P ((void));\n\n#ifndef EOF\n# define EOF (-1)\n#endif\n#ifndef NULL\n# if defined __GNUG__ && \\\n    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n#  define NULL (__null)\n# else\n#  if !defined(__cplusplus)\n#   define NULL ((void*)0)\n#  else\n#   define NULL (0)\n#  endif\n# endif\n#endif\n\n#if _G_HAVE_MMAP\n\n# include <unistd.h>\n# include <fcntl.h>\n# include <sys/mman.h>\n# include <sys/param.h>\n\n# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)\n#  define MAP_ANONYMOUS MAP_ANON\n# endif\n\n# if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)\n#  undef _G_HAVE_MMAP\n#  define _G_HAVE_MMAP 0\n# endif\n\n#endif /* _G_HAVE_MMAP */\n\n#if _G_HAVE_MMAP\n\n# ifdef _LIBC\n/* When using this code in the GNU libc we must not pollute the name space.  */\n#  define mmap __mmap\n#  define munmap __munmap\n# endif\n\n# define ROUND_TO_PAGE(_S) \\\n       (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))\n\n# define FREE_BUF(_B, _S) \\\n       munmap ((_B), ROUND_TO_PAGE (_S))\n# define ALLOC_BUF(_B, _S, _R) \\\n       do {\t\t\t\t\t\t\t\t      \\\n\t  (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S),\t\t\t      \\\n\t\t\t\tPROT_READ | PROT_WRITE,\t\t\t      \\\n\t\t\t\tMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\t      \\\n\t  if ((_B) == (char *) -1)\t\t\t\t\t      \\\n\t    return (_R);\t\t\t\t\t\t      \\\n       } while (0)\n\n#else /* _G_HAVE_MMAP */\n\n# define FREE_BUF(_B, _S) \\\n       free(_B)\n# define ALLOC_BUF(_B, _S, _R) \\\n       do {\t\t\t\t\t\t\t\t      \\\n\t  (_B) = (char*)malloc(_S);\t\t\t\t\t      \\\n\t  if ((_B) == NULL)\t\t\t\t\t\t      \\\n\t    return (_R);\t\t\t\t\t\t      \\\n       } while (0)\n\n#endif /* _G_HAVE_MMAP */\n\n#ifndef OS_FSTAT\n# define OS_FSTAT fstat\n#endif\nstruct stat;\nextern _IO_ssize_t _IO_read __P ((int, void *, _IO_size_t));\nextern _IO_ssize_t _IO_write __P ((int, const void *, _IO_size_t));\nextern _IO_off_t _IO_lseek __P ((int, _IO_off_t, int));\nextern int _IO_close __P ((int));\nextern int _IO_fstat __P ((int, struct stat *));\nextern int _IO_vscanf __P ((const char *, _IO_va_list));\n\n/* Operations on _IO_fpos_t.\n   Normally, these are trivial, but we provide hooks for configurations\n   where an _IO_fpos_t is a struct.\n   Note that _IO_off_t must be an integral type. */\n\n/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */\n#ifndef _IO_pos_BAD\n# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n#  define _IO_pos_BAD ((_IO_fpos64_t) -1)\n# else\n#  define _IO_pos_BAD ((_IO_fpos_t) -1)\n# endif\n#endif\n/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */\n#ifndef _IO_pos_as_off\n# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n#  define _IO_pos_as_off(__pos) ((_IO_off64_t) (__pos))\n# else\n#  define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))\n# endif\n#endif\n/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */\n#ifndef _IO_pos_adjust\n# define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))\n#endif\n/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */\n#ifndef _IO_pos_0\n# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\n#  define _IO_pos_0 ((_IO_fpos64_t) 0)\n# else\n#  define _IO_pos_0 ((_IO_fpos_t) 0)\n# endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef _IO_MTSAFE_IO\n/* check following! */\n# define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \\\n       { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \\\n         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \\\n\t   0, 0, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }\n#else\n/* check following! */\n# define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \\\n       { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \\\n\t   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD }\n#endif\n\n/* VTABLE_LABEL defines NAME as of the CLASS class.\n   CNLENGTH is strlen(#CLASS).  */\n#ifdef __GNUC__\n# if _G_VTABLE_LABEL_HAS_LENGTH\n#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \\\n  extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);\n# else\n#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \\\n  extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);\n# endif\n#endif /* __GNUC__ */\n\n#if !defined(builtinbuf_vtable) && defined(__cplusplus)\n# ifdef __GNUC__\nVTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)\n# else\n#  if _G_VTABLE_LABEL_HAS_LENGTH\n#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf\n#  else\n#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf\n#  endif\n# endif\n#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */\n\n#if defined(__STDC__) || defined(__cplusplus)\n# define _IO_va_start(args, last) va_start(args, last)\n#else\n# define _IO_va_start(args, last) va_start(args)\n#endif\n\nextern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;\n\n#if 1\n# define COERCE_FILE(FILE) /* Nothing */\n#else\n/* This is part of the kludge for binary compatibility with old stdio. */\n# define COERCE_FILE(FILE) \\\n  (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \\\n    && (FILE) = *(FILE**)&((int*)fp)[1])\n#endif\n\n#ifdef EINVAL\n# define MAYBE_SET_EINVAL __set_errno (EINVAL)\n#else\n# define MAYBE_SET_EINVAL /* nothing */\n#endif\n\n#ifdef IO_DEBUG\n# define CHECK_FILE(FILE, RET) \\\n\tif ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \\\n\telse { COERCE_FILE(FILE); \\\n\t       if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \\\n\t  { MAYBE_SET_EINVAL; return RET; }}\n#else\n# define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/list",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_LIST\n#define __SGI_STL_LIST\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_list.h>\n\n#endif /* __SGI_STL_LIST */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/list.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_LIST_H\n#define __SGI_STL_LIST_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_list.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::list;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_LIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/map",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MAP\n#define __SGI_STL_MAP\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <stl_map.h>\n#include <stl_multimap.h>\n\n#endif /* __SGI_STL_MAP */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/map.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MAP_H\n#define __SGI_STL_MAP_H\n\n#include <tree.h>\n#include <stl_map.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::map;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/memory",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_MEMORY\n#define __SGI_STL_MEMORY\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_tempbuf.h>\n#include <stl_uninitialized.h>\n#include <stl_raw_storage_iter.h>\n\n// Note: auto_ptr is commented out in this release because the details\n//  of the interface are still being discussed by the C++ standardization\n//  committee.  It will be included once the iterface is finalized.\n\n#if 0\n#if defined(_MUTABLE_IS_KEYWORD) && defined(_EXPLICIT_IS_KEYWORD) && \\\n    defined(__STL_MEMBER_TEMPLATES)\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class X> class auto_ptr {\nprivate:\n  X* ptr;\n  mutable bool owns;\npublic:\n  typedef X element_type;\n  explicit auto_ptr(X* p = 0) __STL_NOTHROW : ptr(p), owns(p) {}\n  auto_ptr(const auto_ptr& a) __STL_NOTHROW : ptr(a.ptr), owns(a.owns) {\n    a.owns = 0;\n  }\n  template <class T> auto_ptr(const auto_ptr<T>& a) __STL_NOTHROW\n    : ptr(a.ptr), owns(a.owns) {\n      a.owns = 0;\n  }\n\n  auto_ptr& operator=(const auto_ptr& a) __STL_NOTHROW {\n    if (&a != this) {\n      if (owns)\n        delete ptr;\n      owns = a.owns;\n      ptr = a.ptr;\n      a.owns = 0;\n    }\n  }\n  template <class T> auto_ptr& operator=(const auto_ptr<T>& a) __STL_NOTHROW {\n    if (&a != this) {\n      if (owns)\n        delete ptr;\n      owns = a.owns;\n      ptr = a.ptr;\n      a.owns = 0;\n    }\n  }\n  ~auto_ptr() {\n    if (owns)\n      delete ptr;\n  }\n\n  X& operator*() const __STL_NOTHROW { return *ptr; }\n  X* operator->() const __STL_NOTHROW { return ptr; }\n  X* get() const __STL_NOTHROW { return ptr; }\n  X* release const __STL_NOTHROW { owns = false; return ptr }\n};\n\n__STL_END_NAMESPACE\n#endif /* mutable && explicit && member templates */\n#endif /* 0 */\n\n\n#endif /* __SGI_STL_MEMORY */\n\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/multimap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MULTIMAP_H\n#define __SGI_STL_MULTIMAP_H\n\n#include <tree.h>\n#include <stl_multimap.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::multimap;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MULTIMAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/multiset.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_MULTISET_H\n#define __SGI_STL_MULTISET_H\n\n#include <tree.h>\n#include <stl_multiset.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::multiset;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_MULTISET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/numeric",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_NUMERIC\n#define __SGI_STL_NUMERIC\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stddef.h>\n#include <iostream.h>\n#include <stl_iterator.h>\n#include <stl_function.h>\n#include <stl_numeric.h>\n\n#endif /* __SGI_STL_NUMERIC */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/ostream.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#include <stream.h>\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/pair.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PAIR_H\n#define __SGI_STL_PAIR_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#include <stl_pair.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::pair;\nusing __STD::make_pair;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_PAIR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/parsestream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License.\n\nWritten by Per Bothner (bothner@cygnus.com). */\n\n#ifndef PARSESTREAM_H\n#define PARSESTREAM_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#include \"streambuf.h\"\n\nextern \"C++\" {\n// A parsebuf is a streambuf optimized for scanning text files.\n// It keeps track of line and column numbers.\n// It is guaranteed to remember the entire current line,\n// as well the '\\n'-s on either side of it (if they exist).\n// You can arbitrarily seek (or unget) within this extended line.\n// Other backward seeks are not supported.\n// Normal read semantics are supported (and hence istream operators like >>).\n\nclass parsebuf : public streambuf {\n  protected:\n    _IO_fpos_t pos_at_line_start;\n    long _line_length;\n    unsigned long __line_number;\n    char *buf_start;\n    char *buf_end;\n\n  public:\n    parsebuf *chain;\n\n    // Return column number (raw - don't handle tabs etc).\n    // Retult can be -1, meaning: at '\\n' before current line.\n    virtual int tell_in_line();\n\n    // seek to (raw) column I in current line.\n    // Result is new (raw) column position - differs from I if unable to seek.\n    // Seek to -1 tries to seek to before previous LF.\n    virtual int seek_in_line(int i);\n\n    // Note: there is no \"current line\" initially, until something is read.\n\n    // Current line number, starting with 0.\n    // If tell_in_line()==-1, then line number of next line.\n    int line_number() { return __line_number; }\n\n    // Length of current line, not counting either '\\n'.\n    int line_length() { return _line_length; }\n    // Current line - not a copy, so file ops may trash it. \n    virtual char* current_line();\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    virtual streambuf* setbuf(char* p, int len);\n  protected:\n    parsebuf() { chain= NULL;\n\t__line_number = 0; pos_at_line_start = 0; _line_length = -1; }\n    virtual int pbackfail(int c);\n};\n\n// A string_parsebuf is a parsebuf whose source is a fixed string.\n\nclass string_parsebuf : public parsebuf {\n  public:\n    int do_delete;\n    string_parsebuf(char *str, int len, int delete_at_close=0);\n    virtual int underflow();\n    virtual char* current_line();\n    virtual int seek_in_line(int i);\n    virtual int tell_in_line();\n    char *left() const { return base(); }\n    char *right() const { return ebuf(); }\n//    streampos seekoff(streamoff, _seek_dir, int);\n};\n\n// A func_parsebuf calls a given function to get new input.\n// Each call returns an entire NUL-terminated line (without the '\\n').\n// That line has been allocated with malloc(), not new.\n// The interface is tailored to the GNU readline library.\n// Example:\n// char* DoReadLine(void* arg)\n// {\n//   char *line = readline((char*)arg); /* 'arg' is used as prompt. */\n//   if line == NULL) { putc('\\n', stderr); return NULL; }\n//   if (line[0] != '\\0') add_history(line);\n//    return line;\n// }\n// char PromptBuffer[100] = \"> \";\n// func_parsebuf my_stream(DoReadLine, PromptBuffer);\n\ntypedef char *(*CharReader)(void *arg);\nclass istream;\n\nclass func_parsebuf : public parsebuf {\n  public:\n    void *arg;\n    CharReader read_func;\n    int backed_up_to_newline;\n    func_parsebuf(CharReader func, void *argm = NULL);\n    int underflow();\n    virtual int tell_in_line();\n    virtual int seek_in_line(int i);\n    virtual char* current_line();\n};\n\n// A general_parsebuf is a parsebuf which gets its input from some\n// other streambuf. It explicitly buffers up an entire line.\n\nclass general_parsebuf : public parsebuf {\n  public:\n    streambuf *sbuf;\n    int delete_buf; // Delete sbuf when destroying this.\n    general_parsebuf(streambuf *buf, int delete_arg_buf = 0);\n    int underflow();\n    virtual int tell_in_line();\n    virtual int seek_in_line(int i);\n    ~general_parsebuf();\n    virtual char* current_line();\n};\n\n#if 0\nclass parsestream : public istream {\n    streammarker marks[2];\n    short _first; // of the two marks; either 0 or 1\n    int _lineno;\n    int first() { return _first; }\n    int second() { return 1-_first; }\n    int line_length() { marks[second].delta(marks[first]); }\n    int line_length() { marks[second].delta(marks[first]); }\n    int seek_in_line(int i);\n    int tell_in_line();\n    int line_number();\n};\n#endif\n} // extern \"C++\"\n#endif /*!defined(PARSESTREAM_H)*/\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/pfstream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* Written by Per Bothner (bothner@cygnus.com). */\n\n#ifndef _PFSTREAM_H\n#define _PFSTREAM_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#include <fstream.h>\n\nextern \"C++\" {\n// ipfstream foo(\"NAME\") is like: ifstream foo(\"NAME\").  However,\n// if NAME starts *or ends* with a '|', the remainder of NAME is\n// evaluated as a shell command (using a procbuf), and all input\n// read from foo is whatever that shell writes to its standard output.\n// E.g. ipfstream foo(\"|zcat foo.Z\") or ipfstream foo(\"zcat foo.Z|\")\n// (These two forms are equivalent.)\n\nclass ipfstream : public ifstream {\n  public:\n    ipfstream(const char *name, int mode=ios::in, int prot=0664);\n};\n\n// opfstream foo(\"NAME\") is like: ofstream foo(\"NAME\").\n// However, if NAME starts with a '|', the remainder of NAME is\n// evaluated as a shell command (using a procbuf), and all output\n// written to foo is piped to the standard input of that shell.\n// E.g. opfstream foo(\"|more\");\n\nclass opfstream : public ofstream {\n  public:\n    opfstream(const char *name, int mode=ios::out, int prot=0664);\n};\n} // extern \"C++\"\n#endif /*!_PFSTREAM_H*/\n\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/procbuf.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* Written by Per Bothner (bothner@cygnus.com). */\n\n#ifndef _PROCBUF_H\n#define _PROCBUF_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n#include <streambuf.h>\n\nextern \"C++\" {\nclass procbuf : public filebuf {\n    /* Following fields must match those in struct _IO_proc_file */\n    _IO_pid_t _pid;\n    procbuf *_next;\n  public:\n    procbuf() : filebuf() { }\n    procbuf(const char *command, int mode);\n    procbuf* open(const char *command, int mode);\n    procbuf *close() { return (procbuf*)filebuf::close(); }\n    virtual int sys_close();\n    ~procbuf();\n};\n} // extern \"C++\"\n\n#endif /* !_PROCBUF_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/pthread_alloc",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PTHREAD_ALLOC\n#define __SGI_STL_PTHREAD_ALLOC\n\n// Pthread-specific node allocator.\n// This is similar to the default allocator, except that free-list\n// information is kept separately for each thread, avoiding locking.\n// This should be reasonably fast even in the presence of threads.\n// The down side is that storage may not be well-utilized.\n// It is not an error to allocate memory in thread A and deallocate\n// it n thread B.  But this effectively transfers ownership of the memory,\n// so that it can only be reallocated by thread B.  Thus this can effectively\n// result in a storage leak if it's done on a regular basis.\n// It can also result in frequent sharing of\n// cache lines among processors, with potentially serious performance\n// consequences.\n\n#include <stl_config.h>\n#include <stl_alloc.h>\n#ifndef __RESTRICT\n#  define __RESTRICT\n#endif\n\n__STL_BEGIN_NAMESPACE\n\n// Note that this class has nonstatic members.  We instantiate it once\n// per thread.\ntemplate <bool dummy>\nclass __pthread_alloc_template {\n\nprivate:\n  enum {ALIGN = 8};\n  enum {MAX_BYTES = 128};  // power of 2\n  enum {NFREELISTS = MAX_BYTES/ALIGN};\n\n  union obj {\n        union obj * free_list_link;\n        char client_data[ALIGN];    /* The client sees this.        */\n  };\n\n  // Per instance state\n  obj* volatile free_list[NFREELISTS]; \n  __pthread_alloc_template<dummy>* next; \t// Free list link\n\n  static size_t ROUND_UP(size_t bytes) {\n\treturn (((bytes) + ALIGN-1) & ~(ALIGN - 1));\n  }\n  static size_t FREELIST_INDEX(size_t bytes) {\n\treturn (((bytes) + ALIGN-1)/ALIGN - 1);\n  }\n\n  // Returns an object of size n, and optionally adds to size n free list.\n  void *refill(size_t n);\n  // Allocates a chunk for nobjs of size \"size\".  nobjs may be reduced\n  // if it is inconvenient to allocate the requested number.\n  static char *chunk_alloc(size_t size, int &nobjs);\n\n  // Chunk allocation state. And other shared state.\n  // Protected by chunk_allocator_lock.\n  static pthread_mutex_t chunk_allocator_lock;\n  static char *start_free;\n  static char *end_free;\n  static size_t heap_size;\n  static __pthread_alloc_template<dummy>* free_allocators;\n  static pthread_key_t key;\n  static bool key_initialized;\n\t// Pthread key under which allocator is stored. \n\t// Allocator instances that are currently unclaimed by any thread.\n  static void destructor(void *instance);\n\t// Function to be called on thread exit to reclaim allocator\n\t// instance.\n  static __pthread_alloc_template<dummy> *new_allocator();\n\t// Return a recycled or new allocator instance.\n  static __pthread_alloc_template<dummy> *get_allocator_instance();\n\t// ensure that the current thread has an associated\n\t// allocator instance.\n  class lock {\n      public:\n\tlock () { pthread_mutex_lock(&chunk_allocator_lock); }\n\t~lock () { pthread_mutex_unlock(&chunk_allocator_lock); }\n  };\n  friend class lock;\n\n\npublic:\n\n  __pthread_alloc_template() : next(0)\n  {\n    memset((void *)free_list, 0, NFREELISTS * sizeof(obj *));\n  }\n\n  /* n must be > 0\t*/\n  static void * allocate(size_t n)\n  {\n    obj * volatile * my_free_list;\n    obj * __RESTRICT result;\n    __pthread_alloc_template<dummy>* a;\n\n    if (n > MAX_BYTES) {\n\treturn(malloc(n));\n    }\n    if (!key_initialized ||\n        !(a = (__pthread_alloc_template<dummy>*)\n\t\tpthread_getspecific(key))) {\n\ta = get_allocator_instance();\n    }\n    my_free_list = a -> free_list + FREELIST_INDEX(n);\n    result = *my_free_list;\n    if (result == 0) {\n    \tvoid *r = a -> refill(ROUND_UP(n));\n\treturn r;\n    }\n    *my_free_list = result -> free_list_link;\n    return (result);\n  };\n\n  /* p may not be 0 */\n  static void deallocate(void *p, size_t n)\n  {\n    obj *q = (obj *)p;\n    obj * volatile * my_free_list;\n    __pthread_alloc_template<dummy>* a;\n\n    if (n > MAX_BYTES) {\n\tfree(p);\n\treturn;\n    }\n    if (!key_initialized ||\n        !(a = (__pthread_alloc_template<dummy>*)\n\t\tpthread_getspecific(key))) {\n\ta = get_allocator_instance();\n    }\n    my_free_list = a->free_list + FREELIST_INDEX(n);\n    q -> free_list_link = *my_free_list;\n    *my_free_list = q;\n  }\n\n  static void * reallocate(void *p, size_t old_sz, size_t new_sz);\n\n} ;\n\ntypedef __pthread_alloc_template<false> pthread_alloc;\n\n\ntemplate <bool dummy>\nvoid __pthread_alloc_template<dummy>::destructor(void * instance)\n{\n    __pthread_alloc_template<dummy>* a =\n\t(__pthread_alloc_template<dummy>*)instance;\n    a -> next = free_allocators;\n    free_allocators = a;\n}\n\ntemplate <bool dummy>\n__pthread_alloc_template<dummy>*\n__pthread_alloc_template<dummy>::new_allocator()\n{\n    if (0 != free_allocators) {\n\t__pthread_alloc_template<dummy>* result = free_allocators;\n\tfree_allocators = free_allocators -> next;\n\treturn result;\n    } else {\n\treturn new __pthread_alloc_template<dummy>;\n    }\n}\n\ntemplate <bool dummy>\n__pthread_alloc_template<dummy>*\n__pthread_alloc_template<dummy>::get_allocator_instance()\n{\n    __pthread_alloc_template<dummy>* result;\n    if (!key_initialized) {\n    \t/*REFERENCED*/\n\tlock lock_instance;\n\tif (!key_initialized) {\n\t    if (pthread_key_create(&key, destructor)) {\n\t\tabort();  // failed\n\t    }\n\t    key_initialized = true;\n\t}\n    }\n    result = new_allocator();\n    if (pthread_setspecific(key, result)) abort();\n    return result;\n}\n\n/* We allocate memory in large chunks in order to avoid fragmenting\t*/\n/* the malloc heap too much.\t\t\t\t\t\t*/\n/* We assume that size is properly aligned.\t\t\t\t*/\ntemplate <bool dummy>\nchar *__pthread_alloc_template<dummy>\n::chunk_alloc(size_t size, int &nobjs)\n{\n  {\n    char * result;\n    size_t total_bytes;\n    size_t bytes_left;\n    /*REFERENCED*/\n    lock lock_instance;\t\t// Acquire lock for this routine\n\n    total_bytes = size * nobjs;\n    bytes_left = end_free - start_free;\n    if (bytes_left >= total_bytes) {\n\tresult = start_free;\n\tstart_free += total_bytes;\n\treturn(result);\n    } else if (bytes_left >= size) {\n\tnobjs = bytes_left/size;\n\ttotal_bytes = size * nobjs;\n\tresult = start_free;\n\tstart_free += total_bytes;\n\treturn(result);\n    } else {\n\tsize_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4);\n\t// Try to make use of the left-over piece.\n\tif (bytes_left > 0) {\n\t    __pthread_alloc_template<dummy>* a = \n\t\t(__pthread_alloc_template<dummy>*)pthread_getspecific(key);\n\t    obj * volatile * my_free_list =\n\t\t\ta->free_list + FREELIST_INDEX(bytes_left);\n\n            ((obj *)start_free) -> free_list_link = *my_free_list;\n            *my_free_list = (obj *)start_free;\n\t}\n#\tifdef _SGI_SOURCE\n\t  // Try to get memory that's aligned on something like a\n\t  // cache line boundary, so as to avoid parceling out\n\t  // parts of the same line to different threads and thus\n\t  // possibly different processors.\n\t  {\n\t    const int cache_line_size = 128;  // probable upper bound\n\t    bytes_to_get &= ~(cache_line_size-1);\n\t    start_free = (char *)memalign(cache_line_size, bytes_to_get); \n\t    if (0 == start_free) {\n\t      start_free = (char *)malloc_alloc::allocate(bytes_to_get);\n\t    }\n\t  }\n#\telse  /* !SGI_SOURCE */\n\t  start_free = (char *)malloc_alloc::allocate(bytes_to_get);\n#       endif\n\theap_size += bytes_to_get;\n\tend_free = start_free + bytes_to_get;\n    }\n  }\n  // lock is released here\n  return(chunk_alloc(size, nobjs));\n}\n\n\n/* Returns an object of size n, and optionally adds to size n free list.*/\n/* We assume that n is properly aligned.\t\t\t\t*/\n/* We hold the allocation lock.\t\t\t\t\t\t*/\ntemplate <bool dummy>\nvoid *__pthread_alloc_template<dummy>\n::refill(size_t n)\n{\n    int nobjs = 128;\n    char * chunk = chunk_alloc(n, nobjs);\n    obj * volatile * my_free_list;\n    obj * result;\n    obj * current_obj, * next_obj;\n    int i;\n\n    if (1 == nobjs)  {\n\treturn(chunk);\n    }\n    my_free_list = free_list + FREELIST_INDEX(n);\n\n    /* Build free list in chunk */\n      result = (obj *)chunk;\n      *my_free_list = next_obj = (obj *)(chunk + n);\n      for (i = 1; ; i++) {\n\tcurrent_obj = next_obj;\n\tnext_obj = (obj *)((char *)next_obj + n);\n\tif (nobjs - 1 == i) {\n\t    current_obj -> free_list_link = 0;\n\t    break;\n\t} else {\n\t    current_obj -> free_list_link = next_obj;\n\t}\n      }\n    return(result);\n}\n\ntemplate <bool dummy>\nvoid *__pthread_alloc_template<dummy>\n::reallocate(void *p, size_t old_sz, size_t new_sz)\n{\n    void * result;\n    size_t copy_sz;\n\n    if (old_sz > MAX_BYTES && new_sz > MAX_BYTES) {\n\treturn(realloc(p, new_sz));\n    }\n    if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p);\n    result = allocate(new_sz);\n    copy_sz = new_sz > old_sz? old_sz : new_sz;\n    memcpy(result, p, copy_sz);\n    deallocate(p, old_sz);\n    return(result);\n}\n\ntemplate <bool dummy>\n__pthread_alloc_template<dummy> *\n__pthread_alloc_template<dummy>::free_allocators = 0;\n\ntemplate <bool dummy>\npthread_key_t __pthread_alloc_template<dummy>::key;\n\ntemplate <bool dummy>\nbool __pthread_alloc_template<dummy>::key_initialized = false;\n\ntemplate <bool dummy>\npthread_mutex_t __pthread_alloc_template<dummy>::chunk_allocator_lock\n= PTHREAD_MUTEX_INITIALIZER;\n\ntemplate <bool dummy>\nchar *__pthread_alloc_template<dummy>\n::start_free = 0;\n\ntemplate <bool dummy>\nchar *__pthread_alloc_template<dummy>\n::end_free = 0;\n\ntemplate <bool dummy>\nsize_t __pthread_alloc_template<dummy>\n::heap_size = 0;\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_PTHREAD_ALLOC */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/pthread_alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_PTHREAD_ALLOC_H\n#define __SGI_STL_PTHREAD_ALLOC_H\n\n#include <pthread_alloc>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::__pthread_alloc_template;\nusing __STL::pthread_alloc;\n\n#endif /* __STL_USE_NAMESPACES */\n\n\n#endif /* __SGI_STL_PTHREAD_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/queue",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_QUEUE\n#define __SGI_STL_QUEUE\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_vector.h>\n#include <stl_bvector.h>\n#include <stl_heap.h>\n#include <stl_deque.h>\n#include <stl_function.h>\n#include <stl_queue.h>\n\n#endif /* __SGI_STL_QUEUE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/rope",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ROPE\n#define __SGI_STL_ROPE\n\n#include <stl_algobase.h>\n#include <tempbuf.h>\n#include <stl_algo.h>\n#include <stl_function.h>\n#include <stl_numeric.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_hash_fun.h>\n#include <stl_rope.h>\n\n#endif /* __SGI_STL_ROPE */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/rope.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_ROPE_H\n#define __SGI_STL_ROPE_H\n\n#include <hashtable.h>\n#include <stl_rope.h>\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::char_producer; \nusing __STD::sequence_buffer; \nusing __STD::rope; \nusing __STD::crope; \nusing __STD::wrope; \n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_ROPE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/ropeimpl.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n# include <stdio.h>\n# include <iostream.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf\n// if necessary.  Assumes path_end[leaf_index] and leaf_pos are correct.\n// Results in a valid buf_ptr if the iterator can be legitimately\n// dereferenced.\ntemplate <class charT, class Alloc>\nvoid __rope_iterator_base<charT,Alloc>::setbuf\n(__rope_iterator_base<charT,Alloc> &x)\n{\n    const RopeBase * leaf = x.path_end[x.leaf_index];\n    size_t leaf_pos = x.leaf_pos;\n    size_t pos = x.current_pos;\n\n    switch(leaf -> tag) {\n\tcase RopeBase::leaf:\n\t    x.buf_start = ((__rope_RopeLeaf<charT,Alloc> *)leaf) -> data;\n\t    x.buf_ptr = x.buf_start + (pos - leaf_pos);\n\t    x.buf_end = x.buf_start + leaf -> size;\n\t    break;\n\tcase RopeBase::function:\n\tcase RopeBase::substringfn:\n\t    {\n\t\tsize_t len = iterator_buf_len;\n\t\tsize_t buf_start_pos = leaf_pos;\n\t\tsize_t leaf_end = leaf_pos + leaf -> size;\n\t\tchar_producer<charT> *fn =\n\t\t\t((__rope_RopeFunction<charT,Alloc> *)leaf) -> fn;\n\n\t\tif (buf_start_pos + len <= pos) {\n\t\t    buf_start_pos = pos - len/4;\n\t\t    if (buf_start_pos + len > leaf_end) {\n\t\t\tbuf_start_pos = leaf_end - len;\n\t\t    }\n\t\t}\n\t\tif (buf_start_pos + len > leaf_end) {\n\t\t    len = leaf_end - buf_start_pos;\n\t\t}\n\t\t(*fn)(buf_start_pos - leaf_pos, len, x.tmp_buf);\n\t\tx.buf_ptr = x.tmp_buf + (pos - buf_start_pos);\n\t\tx.buf_start = x.tmp_buf;\n\t\tx.buf_end = x.tmp_buf + len;\n\t    }\n\t    break;\n\tdefault:\n\t    __stl_assert(0);\n    }\n}\n\n// Set path and buffer inside a rope iterator.  We assume that \n// pos and root are already set.\ntemplate <class charT, class Alloc>\nvoid __rope_iterator_base<charT,Alloc>::setcache\n(__rope_iterator_base<charT,Alloc> &x)\n{\n    const RopeBase * path[RopeBase::max_rope_depth+1];\n    const RopeBase * curr_rope;\n    int curr_depth = -1;  /* index into path    */\n    size_t curr_start_pos = 0;\n    size_t pos = x.current_pos;\n    unsigned char dirns = 0;\t// Bit vector indicating right turns in the path\n\n    __stl_assert(pos <= x.root -> size);\n    if (pos >= x.root -> size) {\n\tx.buf_ptr = 0;\n\treturn;\n    }\n    curr_rope = x.root;\n    if (0 != curr_rope -> c_string) {\n\t/* Treat the root as a leaf. */\n\tx.buf_start = curr_rope -> c_string;\n\tx.buf_end = curr_rope -> c_string + curr_rope -> size;\n\tx.buf_ptr = curr_rope -> c_string + pos;\n\tx.path_end[0] = curr_rope;\n\tx.leaf_index = 0;\n\tx.leaf_pos = 0;\n\treturn;\n    }\n    for(;;) {\n\t++curr_depth;\n\t__stl_assert(curr_depth <= RopeBase::max_rope_depth);\n\tpath[curr_depth] = curr_rope;\n\tswitch(curr_rope -> tag) {\n\t  case RopeBase::leaf:\n\t  case RopeBase::function:\n\t  case RopeBase::substringfn:\n\t    x.leaf_pos = curr_start_pos;\n\t    goto done;\n\t  case RopeBase::concat:\n\t    {\n\t\t__rope_RopeConcatenation<charT,Alloc> *c =\n\t\t\t(__rope_RopeConcatenation<charT,Alloc> *)curr_rope;\n\t\tRopeBase * left = c -> left;\n\t\tsize_t left_len = left -> size;\n\t\t\n\t\tdirns <<= 1;\n\t\tif (pos >= curr_start_pos + left_len) {\n\t\t    dirns |= 1;\n\t\t    curr_rope = c -> right;\n\t\t    curr_start_pos += left_len;\n\t\t} else {\n\t\t    curr_rope = left;\n\t\t}\n\t    }\n\t    break;\n\t}\n    }\n  done:\n    // Copy last section of path into path_end.\n      {\n\tint i = -1;\n\tint j = curr_depth  + 1 - path_cache_len;\n\n\tif (j < 0) j = 0;\n\twhile (j <= curr_depth) {\n\t    x.path_end[++i] = path[j++];\n\t}\n\tx.leaf_index = i;\n      }\n      x.path_directions = dirns;\n    setbuf(x);\n}\n\n// Specialized version of the above.  Assumes that\n// the path cache is valid for the previous position.\ntemplate <class charT, class Alloc>\nvoid __rope_iterator_base<charT,Alloc>::setcache_for_incr\n(__rope_iterator_base<charT,Alloc> &x)\n{\n    int current_index = x.leaf_index;\n    const RopeBase * current_node = x.path_end[current_index];\n    size_t len = current_node -> size;\n    size_t node_start_pos = x.leaf_pos;\n    unsigned char dirns = x.path_directions;\n    __rope_RopeConcatenation<charT,Alloc> * c;\n\n    __stl_assert(x.current_pos <= x.root -> size);\n    if (x.current_pos - node_start_pos < len) {\n\t/* More stuff in this leaf, we just didn't cache it. */\n\tsetbuf(x);\n\treturn;\n    }\n    __stl_assert(node_start_pos + len == x.current_pos);\n    //  node_start_pos is starting position of last_node.\n    while (--current_index >= 0) {\n\tif (!(dirns & 1) /* Path turned left */) break;\n\tcurrent_node = x.path_end[current_index];\n\tc = (__rope_RopeConcatenation<charT,Alloc> *)current_node;\n\t// Otherwise we were in the right child.  Thus we should pop\n\t// the concatenation node.\n\tnode_start_pos -= c -> left -> size;\n\tdirns >>= 1;\n    }\n    if (current_index < 0) {\n\t// We underflowed the cache. Punt.\n\tsetcache(x);\n\treturn;\n    }\n    current_node = x.path_end[current_index];\n    c = (__rope_RopeConcatenation<charT,Alloc> *)current_node;\n    // current_node is a concatenation node.  We are positioned on the first\n    // character in its right child.\n    // node_start_pos is starting position of current_node.\n    node_start_pos += c -> left -> size;\n    current_node = c -> right;\n    x.path_end[++current_index] = current_node;\n    dirns |= 1;\n    while (RopeBase::concat == current_node -> tag) {\n\t++current_index;\n\tif (path_cache_len == current_index) {\n\t    int i;\n\t    for (i = 0; i < path_cache_len-1; i++) {\n\t\tx.path_end[i] = x.path_end[i+1];\n\t    }\n\t    --current_index;\n\t}\n\tcurrent_node =\n\t    ((__rope_RopeConcatenation<charT,Alloc> *)current_node) -> left;\n\tx.path_end[current_index] = current_node;\n\tdirns <<= 1;\n\t// node_start_pos is unchanged.\n    }\n    x.leaf_index = current_index;\n    x.leaf_pos = node_start_pos;\n    x.path_directions = dirns;\n    setbuf(x);\n}\n\ntemplate <class charT, class Alloc>\nvoid __rope_iterator_base<charT,Alloc>::incr(size_t n) {\n    current_pos += n;\n    if (0 != buf_ptr) {\n        size_t chars_left = buf_end - buf_ptr;\n        if (chars_left > n) {\n            buf_ptr += n;\n        } else if (chars_left == n) {\n            buf_ptr += n;\n            setcache_for_incr(*this);\n        } else {\n            buf_ptr = 0;\n        }\n    }\n}\n\ntemplate <class charT, class Alloc>\nvoid __rope_iterator_base<charT,Alloc>::decr(size_t n) {\n    if (0 != buf_ptr) {\n        size_t chars_left = buf_ptr - buf_start;\n        if (chars_left >= n) {\n            buf_ptr -= n;\n        } else {\n            buf_ptr = 0;\n        }\n    }\n    current_pos -= n;\n}\n\ntemplate <class charT, class Alloc>\nvoid __rope_iterator<charT,Alloc>::check() {\n    if (root_rope -> tree_ptr != root) {\n        // Rope was modified.  Get things fixed up.\n        RopeBase::unref(root);\n        root = root_rope -> tree_ptr;\n        RopeBase::ref(root);\n        buf_ptr = 0;\n    }\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_const_iterator<charT, Alloc>::__rope_const_iterator\n(const __rope_iterator<charT,Alloc> & x)\n: __rope_iterator_base<charT,Alloc>(x) { }\n\ntemplate <class charT, class Alloc>\ninline __rope_iterator<charT,Alloc>::__rope_iterator\n(rope<charT,Alloc>& r, size_t pos)\n        : __rope_iterator_base<charT,Alloc>(r.tree_ptr, pos), root_rope(&r) {\n    RopeBase::ref(root);\n}\n\ntemplate <class charT, class Alloc>\ninline size_t rope<charT,Alloc>::char_ptr_len(const charT *s)\n{\n    const charT *p = s;\n\n    while (!is0(*p)) { ++p; }\n    return(p - s);\n}\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeLeaf *\nrope<charT,Alloc>::RopeLeaf_from_char_ptr(__GC_CONST charT *s, size_t size)\n{\n    RopeLeaf *t = LAlloc::allocate();\n\n    t -> tag = RopeBase::leaf;\n    if (__is_basic_char_type((charT *)0)) {\n\t// already eos terminated.\n\tt -> c_string = s;\n    } else {\n\tt -> c_string = 0;\n    }\n    t -> is_balanced = true;\n    t -> depth = 0;\n    t -> size = size;\n    t -> data = s;\n#   ifndef __GC\n\tt -> refcount = 1;\n\tt -> init_refcount_lock();\n#   endif\n    return (t);\n}\n\n# ifdef __GC\ntemplate <class charT, class Alloc>\nvoid __rope_RopeBase<charT,Alloc>::fn_finalization_proc(void * tree, void *)\n{\n    delete ((__rope_RopeFunction<charT,Alloc> *)tree) -> fn;\n}\n# endif\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeFunction *\nrope<charT,Alloc>::RopeFunction_from_fn\n(char_producer<charT> *fn, size_t size, bool delete_fn)\n{\n    if (0 == size) return 0;\n    RopeFunction *t = FAlloc::allocate();\n    t -> tag = RopeBase::function;\n    t -> c_string = 0;\n    t -> is_balanced = true;\n    t -> depth = 0;\n    t -> size = size;\n    t -> fn = fn;\n#   ifdef __GC\n\tif (delete_fn) {\n\t    GC_REGISTER_FINALIZER(t, RopeBase::fn_finalization_proc, 0, 0, 0);\n\t}\n#   else\n\tt -> delete_when_done = delete_fn;\n\tt -> refcount = 1;\n\tt -> init_refcount_lock();\n#   endif\n    return (t);\n}\n\n#ifndef __GC\n\ntemplate <class charT, class Alloc>\ninline void __rope_RopeBase<charT,Alloc>::free_c_string()\n{\n    charT * cstr = c_string;\n    if (0 != cstr) {\n\tsize_t sz = size + 1;\n\tdestroy(cstr, cstr + sz);\n\tDataAlloc::deallocate(cstr, sz);\n    }\n}\n\ntemplate <class charT, class Alloc>\ninline void __rope_RopeBase<charT,Alloc>::free_string(charT* s, size_t n)\n{\n    if (!__is_basic_char_type((charT *)0)) {\n\tdestroy(s, s + n);\n    }\n    DataAlloc::deallocate(s, rounded_up_size(n));\n}\n\ntemplate <class charT, class Alloc>\nvoid __rope_RopeBase<charT,Alloc>::free_tree()\n{\n    switch(tag) {\n\tcase leaf:\n\t    {\n\t        __rope_RopeLeaf<charT,Alloc> * l =\n\t\t\t(__rope_RopeLeaf<charT,Alloc> *)this;\n\t\tcharT * d = l -> data;\n\t\t\n\t\tif (d != c_string) {\n\t\t    free_c_string();\n\t\t}\n\t\tfree_string(d, size);\n\t\tLAlloc::deallocate(l);\n\t    }\n\t    break;\n\tcase concat:\n\t    {\n\t\t__rope_RopeConcatenation<charT,Alloc> * c =\n\t\t\t(__rope_RopeConcatenation<charT,Alloc> *)this;\n\t\t__rope_RopeBase * left = c -> left;\n\t\t__rope_RopeBase * right = c -> right;\n\t\tfree_c_string();\n\t\tleft -> unref_nonnil();\n\t\tright -> unref_nonnil();\n\t\tCAlloc::deallocate(c);\n\t    }\n\t    break;\n\tcase function:\n\t    {\n\t\t__rope_RopeFunction<charT,Alloc> * fn =\n\t\t  \t(__rope_RopeFunction<charT,Alloc> *)this;\n\t        free_c_string();\n\t        if ( fn -> delete_when_done) {\n\t\t    delete fn -> fn;\n\t        }\n\t        FAlloc::deallocate(fn);\n\t        break;\n\t    }\n\tcase substringfn:\n\t    {\n\t        __rope_RopeSubstring<charT,Alloc> * ss =\n\t\t\t(__rope_RopeSubstring<charT,Alloc> *)this;\n\t\t__rope_RopeBase *base = ss -> base;\n\t\tfree_c_string();\n\t\tbase -> unref_nonnil();\n\t\tSAlloc::deallocate(ss);\n\t\tbreak;\n\t    }\n    }\n}\n#else\n\ntemplate <class charT, class Alloc>\ninline void __rope_RopeBase<charT,Alloc>::free_string(charT* s, size_t n)\n{}\n\n#endif\n\n\n// Concatenate a C string onto a leaf rope by copying the rope data.\n// Used for short ropes.\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeLeaf *\nrope<charT,Alloc>::leaf_concat_char_iter\n\t\t(RopeLeaf * r, const charT * iter, size_t len)\n{\n    size_t old_len = r -> size;\n    charT * new_data = (charT *)\n\tDataAlloc::allocate(rounded_up_size(old_len + len));\n    RopeLeaf * result;\n    \n    uninitialized_copy_n(r -> data, old_len, new_data);\n    uninitialized_copy_n(iter, len, new_data + old_len);\n    __cond_store_eos(new_data[old_len + len]);\n    __STL_TRY {\n\tresult = RopeLeaf_from_char_ptr(new_data, old_len + len);\n    }\n    __STL_UNWIND(RopeBase::free_string(new_data, old_len + len));\n    return result;\n}\n\n#ifndef __GC\n// As above, but it's OK to clobber original if refcount is 1\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeLeaf *\nrope<charT,Alloc>::destr_leaf_concat_char_iter\n\t\t(RopeLeaf * r, const charT * iter, size_t len)\n{\n    __stl_assert(r -> refcount >= 1);\n    if (r -> refcount > 1) return leaf_concat_char_iter(r, iter, len);\n    size_t old_len = r -> size;\n    if (allocated_capacity(old_len) >= old_len + len) {\n\t// The space has been partially initialized for the standard\n\t// character types.  But that doesn't matter for those types.\n\tuninitialized_copy_n(iter, len, r -> data + old_len);\n\tif (__is_basic_char_type((charT *)0)) {\n\t    __cond_store_eos(r -> data[old_len + len]);\n\t    __stl_assert(r -> c_string == r -> data);\n\t} else if (r -> c_string != r -> data && 0 != r -> c_string) {\n\t    r -> free_c_string();\n\t    r -> c_string = 0;\n\t}\n\tr -> size = old_len + len;\n\t__stl_assert(r -> refcount == 1);\n\tr -> refcount = 2;\n\treturn r;\n    } else {\n\tRopeLeaf * result = leaf_concat_char_iter(r, iter, len);\n\t__stl_assert(result -> refcount == 1);\n\treturn result;\n    }\n}\n#endif\n\n// Assumes left and right are not 0.\n// Does not increment (nor decrement on exception) child reference counts.\n// Result has ref count 1.\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase *\nrope<charT,Alloc>::tree_concat (RopeBase * left, RopeBase * right)\n{\n    RopeConcatenation * result = CAlloc::allocate();\n    unsigned char child_depth = left -> depth;\n    size_t rsize;\n\n    result -> tag = RopeBase::concat;\n    result -> c_string = 0;\n    result -> is_balanced = false;\n    result -> size = rsize = left -> size + right -> size;\n    if (right -> depth > child_depth) child_depth = right -> depth;\n    unsigned char depth = (unsigned char)(child_depth + 1);\n    result -> depth = depth;\n    result -> left = left;\n    result -> right = right;\n#   ifndef __GC\n\tresult -> refcount = 1;\n\tresult -> init_refcount_lock();\n#   endif\n    if (depth > 20 && (rsize < 1000 || depth > RopeBase::max_rope_depth)) {\n\tRopeBase * balanced;\n\n\t__STL_TRY {\n\t   balanced = balance(result);\n#          ifndef __GC\n\t     if (result != balanced) {\n\t\t__stl_assert(1 == result -> refcount\n\t\t\t     && 1 == balanced -> refcount);\n\t     }\n#          endif\n\t   result -> unref_nonnil();\n        }\n\t__STL_UNWIND(CAlloc::deallocate(result));\n\t\t// In case of exception, we need to deallocate\n\t\t// otherwise dangling result node.  But caller\n\t\t// still owns its children.  Thus unref is\n\t\t// inappropriate.\n\treturn balanced;\n    } else {\n\treturn result;\n    }\n}\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase * rope<charT,Alloc>::concat_char_iter\n\t\t(RopeBase * r, const charT *s, size_t slen)\n{\n    RopeBase *result;\n    if (0 == slen) {\n\tref(r);\n\treturn r;\n    }\n    if (0 == r) return RopeLeaf_from_unowned_char_ptr(s, slen);\n    if (RopeBase::leaf == r -> tag && r -> size + slen <= copy_max) {\n\tresult = leaf_concat_char_iter((RopeLeaf *)r, s, slen);\n#       ifndef __GC\n\t  __stl_assert(1 == result -> refcount);\n#       endif\n\treturn result;\n    }\n    if (RopeBase::concat == r -> tag\n\t&& RopeBase::leaf == ((RopeConcatenation *)r) -> right -> tag) {\n\tRopeLeaf *right = (RopeLeaf *)(((RopeConcatenation *)r) -> right);\n\tif (right -> size + slen <= copy_max) {\n\t  RopeBase * left = ((RopeConcatenation *)r) -> left;\n\t  RopeBase * nright = leaf_concat_char_iter((RopeLeaf *)right, s, slen);\n\t  left -> ref_nonnil();\n\t  __STL_TRY {\n\t    result = tree_concat(left, nright);\n          }\n\t  __STL_UNWIND(unref(left); unref(nright));\n#         ifndef __GC\n\t    __stl_assert(1 == result -> refcount);\n#         endif\n\t  return result;\n\t}\n    }\n    RopeBase * nright = RopeLeaf_from_unowned_char_ptr(s, slen);\n    __STL_TRY {\n      r -> ref_nonnil();\n      result = tree_concat(r, nright);\n    }\n    __STL_UNWIND(unref(r); unref(nright));\n#   ifndef __GC\n      __stl_assert(1 == result -> refcount);\n#   endif\n    return result;\n}\n\n#ifndef __GC\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase * rope<charT,Alloc>\n::destr_concat_char_iter\n\t\t(RopeBase * r, const charT *s, size_t slen)\n{\n    RopeBase *result;\n    if (0 == r) return RopeLeaf_from_unowned_char_ptr(s, slen);\n    size_t count = r -> refcount;\n    size_t orig_size = r -> size;\n    __stl_assert(count >= 1);\n    if (count > 1) return concat_char_iter(r, s, slen);\n    if (0 == slen) {\n\tr -> refcount = 2;      // One more than before\n\treturn r;\n    }\n    if (orig_size + slen <= copy_max && RopeBase::leaf == r -> tag) {\n\tresult = destr_leaf_concat_char_iter((RopeLeaf *)r, s, slen);\n\treturn result;\n    }\n    if (RopeBase::concat == r -> tag) {\n\tRopeLeaf *right = (RopeLeaf *)(((RopeConcatenation *)r) -> right);\n\tif (RopeBase::leaf == right -> tag\n\t    && right -> size + slen <= copy_max) {\n\t  RopeBase * new_right = destr_leaf_concat_char_iter(right, s, slen);\n\t  if (right == new_right) {\n\t      __stl_assert(new_right -> refcount == 2);\n\t      new_right -> refcount = 1;\n\t  } else {\n\t      __stl_assert(new_right -> refcount >= 1);\n\t      right -> unref_nonnil();\n\t  }\n\t  __stl_assert(r -> refcount == 1);\n\t  r -> refcount = 2;    // One more than before.\n\t  ((RopeConcatenation *)r) -> right = new_right;\n\t  r -> size = orig_size + slen;\n\t  if (0 != r -> c_string) {\n\t      r -> free_c_string();\n\t      r -> c_string = 0;\n\t  }\n\t  return r;\n\t}\n    }\n    RopeBase *right = RopeLeaf_from_unowned_char_ptr(s, slen);\n    r -> ref_nonnil();\n    __STL_TRY {\n      result = tree_concat(r, right);\n    }\n    __STL_UNWIND(unref(r); unref(right))\n    __stl_assert(1 == result -> refcount);\n    return result;\n}\n#endif /* !__GC */\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase *\nrope<charT,Alloc>::concat(RopeBase * left, RopeBase * right)\n{\n    if (0 == left) {\n\tref(right);\n\treturn right;\n    }\n    if (0 == right) {\n\tleft -> ref_nonnil();\n\treturn left;\n    }\n    if (RopeBase::leaf == right -> tag) {\n\tif (RopeBase::leaf == left -> tag) {\n\t  if (right -> size + left -> size <= copy_max) {\n\t    return leaf_concat_char_iter((RopeLeaf *)left,\n\t\t\t\t\t ((RopeLeaf *)right) -> data,\n\t\t\t\t\t right -> size);\n\t  }\n\t} else if (RopeBase::concat == left -> tag\n\t\t   && RopeBase::leaf ==\n\t\t      ((RopeConcatenation *)left) -> right -> tag) {\n\t  RopeLeaf * leftright =\n\t\t    (RopeLeaf *)(((RopeConcatenation *)left) -> right); \n\t  if (leftright -> size + right -> size <= copy_max) {\n\t    RopeBase * leftleft = ((RopeConcatenation *)left) -> left;\n\t    RopeBase * rest = leaf_concat_char_iter(leftright,\n\t\t\t\t\t   ((RopeLeaf *)right) -> data,\n\t\t\t\t\t   right -> size);\n\t    leftleft -> ref_nonnil();\n\t    __STL_TRY {\n\t      return(tree_concat(leftleft, rest));\n            }\n\t    __STL_UNWIND(unref(leftleft); unref(rest))\n\t  }\n\t}\n    }\n    left -> ref_nonnil();\n    right -> ref_nonnil();\n    __STL_TRY {\n      return(tree_concat(left, right));\n    }\n    __STL_UNWIND(unref(left); unref(right));\n}\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase *\nrope<charT,Alloc>::substring(RopeBase * base, size_t start, size_t endp1)\n{\n    if (0 == base) return 0;\n    size_t len = base -> size;\n    size_t adj_endp1;\n    const size_t lazy_threshold = 128;\n    \n    if (endp1 >= len) {\n\tif (0 == start) {\n\t    base -> ref_nonnil();\n\t    return base;\n\t} else {\n\t    adj_endp1 = len;\n\t}\n    } else {\n\tadj_endp1 = endp1;\n    }\n    switch(base -> tag) {\n\tcase RopeBase::concat:\n\t    {\n\t\tRopeConcatenation *c = (RopeConcatenation *)base;\n\t\tRopeBase *left = c -> left;\n\t\tRopeBase *right = c -> right;\n\t\tsize_t left_len = left -> size;\n\t\tRopeBase * result;\n\n\t\tif (adj_endp1 <= left_len) {\n\t\t    return substring(left, start, endp1);\n\t\t} else if (start >= left_len) {\n\t\t    return substring(right, start - left_len,\n\t\t\t\t  adj_endp1 - left_len);\n\t\t}\n\t\tself_destruct_ptr left_result(substring(left, start,\n\t\t\t\t\t\t\tleft_len));\n\t\tself_destruct_ptr right_result(\n\t\t\t\tsubstring(right, 0, endp1 - left_len));\n\t\tresult = concat(left_result, right_result);\n#               ifndef __GC\n\t\t  __stl_assert(1 == result -> refcount);\n#               endif\n\t\treturn result;\n\t    }\n\tcase RopeBase::leaf:\n\t    {\n\t\tRopeLeaf * l = (RopeLeaf *)base;\n\t\tRopeLeaf * result;\n\t\tsize_t result_len;\n\t\tif (start >= adj_endp1) return 0;\n\t\tresult_len = adj_endp1 - start;\n\t\tif (result_len > lazy_threshold) goto lazy;\n#               ifdef __GC\n\t\t    const charT *section = l -> data + start;\n\t\t    result = RopeLeaf_from_char_ptr(section, result_len);\n\t\t    result -> c_string = 0;  // Not eos terminated.\n#               else\n\t\t    // We should sometimes create substring node instead.\n\t\t    result = RopeLeaf_from_unowned_char_ptr(\n\t\t\t\t\tl -> data + start, result_len);\n#               endif\n\t\treturn result;\n\t    }\n\tcase RopeBase::substringfn:\n\t    // Avoid introducing mutiple layers of substring nodes.\n\t    {\n\t\tRopeSubstring *old = (RopeSubstring *)base;\n\t\tsize_t result_len;\n\t\tif (start >= adj_endp1) return 0;\n\t\tresult_len = adj_endp1 - start;\n\t\tif (result_len > lazy_threshold) {\n\t\t    RopeSubstring * space = SAlloc::allocate();\n\t\t    RopeSubstring * result =\n\t\t\tnew(space) RopeSubstring(old -> base,\n\t\t\t\t\t\t start + old -> start,\n\t\t\t\t\t\t adj_endp1 - start);\n\t\t    return result;\n\t\t} // else fall through:\n\t    }\n\tcase RopeBase::function:\n\t    {\n\t\tRopeFunction * f = (RopeFunction *)base;\n\t\tcharT *section;\n\t\tsize_t result_len;\n\t\tif (start >= adj_endp1) return 0;\n\t\tresult_len = adj_endp1 - start;\n\n\t\tif (result_len > lazy_threshold) goto lazy;\n\t\tsection = (charT *)\n\t\t\tDataAlloc::allocate(rounded_up_size(result_len));\n\t\t__STL_TRY {\n\t\t  (*(f -> fn))(start, result_len, section);\n                }\n\t\t__STL_UNWIND(RopeBase::free_string(section, result_len));\n\t\t__cond_store_eos(section[result_len]);\n\t\treturn RopeLeaf_from_char_ptr(section, result_len);\n\t    }\n    }\n    /*NOTREACHED*/\n    __stl_assert(false);\n  lazy:\n    {\n\t// Create substring node.\n\tRopeSubstring * space = SAlloc::allocate();\n\tRopeSubstring * result = new(space) RopeSubstring(base, start,\n\t\t\t\t\t\t\t  adj_endp1 - start);\n\treturn result;\n    }\n}\n\ntemplate<class charT>\nclass __rope_flatten_char_consumer : public __rope_char_consumer<charT> {\n    private:\n\tcharT * buf_ptr;\n    public:\n\tcharT * buffer;\n\t__rope_flatten_char_consumer(charT * buffer) {\n\t    buf_ptr = buffer;\n\t};\n\t~__rope_flatten_char_consumer() {}\n\tbool operator() (const charT* leaf, size_t n) {\n\t    uninitialized_copy_n(leaf, n, buf_ptr);\n\t    buf_ptr += n;\n\t    return true;\n\t}\n};\n\t    \ntemplate<class charT>\nclass __rope_find_char_char_consumer : public __rope_char_consumer<charT> {\n    private:\n\tcharT pattern;\n    public:\n\tsize_t count;  // Number of nonmatching characters\n\t__rope_find_char_char_consumer(charT p) : pattern(p), count(0) {}\n\t~__rope_find_char_char_consumer() {}\n\tbool operator() (const charT* leaf, size_t n) {\n\t    size_t i;\n\t    for (i = 0; i < n; i++) {\n\t\tif (leaf[i] == pattern) {\n\t\t    count += i; return false;\n\t\t}\n\t    }\n\t    count += n; return true;\n\t}\n};\n\t    \ntemplate<class charT>\nclass __rope_insert_char_consumer : public __rope_char_consumer<charT> {\n    private:\n\ttypedef ostream insert_ostream;\n\tinsert_ostream & o;\n    public:\n\tcharT * buffer;\n\t__rope_insert_char_consumer(insert_ostream & writer) : o(writer) {};\n\t~__rope_insert_char_consumer() { };\n\t\t// Caller is presumed to own the ostream\n\tbool operator() (const charT* leaf, size_t n);\n\t\t// Returns true to continue traversal.\n};\n\t    \ntemplate<class charT>\nbool __rope_insert_char_consumer<charT>::operator()\n\t\t\t\t\t(const charT * leaf, size_t n)\n{\n    size_t i;\n    //  We assume that formatting is set up correctly for each element.\n    for (i = 0; i < n; i++) o << leaf[i];\n    return true;\n}\n\ninline bool __rope_insert_char_consumer<char>::operator()\n\t\t\t\t\t(const char * leaf, size_t n)\n{\n    size_t i;\n    for (i = 0; i < n; i++) o.put(leaf[i]);\n    return true;\n}\n\n#if !defined(_MSC_VER) && !defined(__BORLANDC__)\n// I couldn't get this to work with the VC++ version of basic_ostream.\ninline bool __rope_insert_char_consumer<wchar_t>::operator()\n\t\t\t\t\t(const wchar_t * leaf, size_t n)\n{\n    size_t i;\n    for (i = 0; i < n; i++) o.put(leaf[i]);\n    return true;\n}\n#endif /* !_MSC_VER  && !BORLAND */\n\ntemplate <class charT, class Alloc>\nbool rope<charT, Alloc>::apply_to_pieces(\n\t\t\t\t__rope_char_consumer<charT>& c,\n\t\t\t\tconst RopeBase * r,\n\t\t\t\tsize_t begin, size_t end)\n{\n    if (0 == r) return true;\n    switch(r -> tag) {\n\tcase RopeBase::concat:\n\t    {\n\t\tRopeConcatenation *conc = (RopeConcatenation *)r;\n\t\tRopeBase *left = conc -> left;\n\t\tsize_t left_len = left -> size;\n\t\tif (begin < left_len) {\n\t\t    size_t left_end = min(left_len, end);\n\t\t    if (!apply_to_pieces(c, left, begin, left_end)) {\n\t\t\treturn false;\n\t\t    }\n\t\t}\n\t\tif (end > left_len) {\n\t\t    RopeBase *right = conc -> right;\n\t\t    size_t right_start = max(left_len, begin);\n\t\t    if (!apply_to_pieces(c, right,\n\t\t\t\t\t right_start - left_len,\n\t\t\t\t\t end - left_len)) {\n\t\t\treturn false;\n\t\t    }\n\t\t}\n\t    }\n\t    return true;\n\tcase RopeBase::leaf:\n\t    {\n\t\tRopeLeaf * l = (RopeLeaf *)r;\n\t\treturn c(l -> data + begin, end - begin);\n\t    }\n\tcase RopeBase::function:\n\tcase RopeBase::substringfn:\n\t    {\n\t\tRopeFunction * f = (RopeFunction *)r;\n\t\tsize_t len = end - begin;\n\t\tbool result;\n\t\tcharT * buffer = DataAlloc::allocate(len);\n\t\t__STL_TRY {\n\t\t  (*(f -> fn))(begin, end, buffer);\n\t\t  result = c(buffer, len);\n                  DataAlloc::deallocate(buffer, len);\n                }\n\t\t__STL_UNWIND(DataAlloc::deallocate(buffer, len))\n\t\treturn result;\n\t    }\n\tdefault:\n\t    __stl_assert(false);\n\t    /*NOTREACHED*/\n\t    return false;\n    }\n}\n\ninline void __rope_fill(ostream& o, size_t n)\n{\n    char f = o.fill();\n    size_t i;\n\n    for (i = 0; i < n; i++) o.put(f);\n}\n    \n\ntemplate <class charT> inline bool __rope_is_simple(charT *) { return false; }\ninline bool __rope_is_simple(char *) { return true; }\ninline bool __rope_is_simple(wchar_t *) { return true; }\n\n\ntemplate<class charT, class Alloc>\nostream& operator<< (ostream& o, const rope<charT, Alloc>& r)\n{\n    size_t w = o.width();\n    bool left = bool(o.flags() & ios::left);\n    size_t pad_len;\n    size_t rope_len = r.size();\n    __rope_insert_char_consumer<charT> c(o);\n    bool is_simple = __rope_is_simple((charT *)0);\n    \n    if (rope_len < w) {\n\tpad_len = w - rope_len;\n    } else {\n\tpad_len = 0;\n    }\n    if (!is_simple) o.width(w/rope_len);\n    __STL_TRY {\n      if (is_simple && !left && pad_len > 0) {\n\t__rope_fill(o, pad_len);\n      }\n      r.apply_to_pieces(0, r.size(), c);\n      if (is_simple && left && pad_len > 0) {\n\t__rope_fill(o, pad_len);\n      }\n      if (!is_simple)\n        o.width(w);\n    }\n    __STL_UNWIND(if (!is_simple) o.width(w))\n    return o;\n}\n\ntemplate <class charT, class Alloc>\ncharT *\nrope<charT,Alloc>::flatten(RopeBase * r,\n\t\t\t\t size_t start, size_t len,\n\t\t\t\t charT * buffer)\n{\n    __rope_flatten_char_consumer<charT> c(buffer);\n    apply_to_pieces(c, r, start, start + len);\n    return(buffer + len);\n}\n\ntemplate <class charT, class Alloc>\nsize_t\nrope<charT,Alloc>::find(charT pattern, size_t start) const\n{\n    __rope_find_char_char_consumer<charT> c(pattern);\n    apply_to_pieces(c, tree_ptr, start, size());\n    return start + c.count;\n}\n\ntemplate <class charT, class Alloc>\ncharT *\nrope<charT,Alloc>::flatten(RopeBase * r, charT * buffer)\n{\n    if (0 == r) return buffer;\n    switch(r -> tag) {\n\tcase RopeBase::concat:\n\t    {\n\t\tRopeConcatenation *c = (RopeConcatenation *)r;\n\t\tRopeBase *left = c -> left;\n\t\tRopeBase *right = c -> right;\n\t\tcharT * rest = flatten(left, buffer);\n\t\treturn flatten(right, rest);\n\t    }\n\tcase RopeBase::leaf:\n\t    {\n\t\tRopeLeaf * l = (RopeLeaf *)r;\n\t\treturn copy_n(l -> data, l -> size, buffer).second;\n\t    }\n\tcase RopeBase::function:\n\tcase RopeBase::substringfn:\n\t    // We dont yet do anything with substring nodes.\n\t    // This needs to be fixed before ropefiles will work well.\n\t    {\n\t\tRopeFunction * f = (RopeFunction *)r;\n\t\t(*(f -> fn))(0, f -> size, buffer);\n\t\treturn buffer + f -> size;\n\t    }\n\tdefault:\n\t    __stl_assert(false);\n\t    /*NOTREACHED*/\n\t    return 0;\n    }\n}\n\n\n// This needs work for charT != char\ntemplate <class charT, class Alloc>\nvoid\nrope<charT,Alloc>::dump(RopeBase * r, int indent)\n{\n    for (int i = 0; i < indent; i++) putchar(' ');\n    if (0 == r) {\n\tprintf(\"NULL\\n\"); return;\n    }\n    if (RopeBase::concat == r -> tag) {\n\tRopeConcatenation *c = (RopeConcatenation *)r;\n\tRopeBase *left = c -> left;\n\tRopeBase *right = c -> right;\n\n#       ifdef __GC\n\t  printf(\"Concatenation %p (depth = %d, len = %ld, %s balanced)\\n\",\n\t\t r, r -> depth, r -> size, r -> is_balanced? \"\" : \"not\");\n#       else\n\t  printf(\"Concatenation %p (rc = %ld, depth = %d, len = %ld, %s balanced)\\n\",\n\t\t r, r -> refcount, r -> depth, r -> size,\n\t\t r -> is_balanced? \"\" : \"not\");\n#       endif\n\tdump(left, indent + 2);\n\tdump(right, indent + 2);\n\treturn;\n    } else {\n\tchar * kind;\n\n\tswitch (r -> tag) {\n\t    case RopeBase::leaf:\n\t\tkind = \"Leaf\";\n\t\tbreak;\n\t    case RopeBase::function:\n\t\tkind = \"Function\";\n\t\tbreak;\n\t    case RopeBase::substringfn:\n\t\tkind = \"Function representing substring\";\n\t\tbreak;\n\t    default:\n\t\tkind = \"(corrupted kind field!)\";\n\t}\n#       ifdef __GC\n\t  printf(\"%s %p (depth = %d, len = %ld) \",\n\t\t kind, r, r -> depth, r -> size);\n#       else\n\t  printf(\"%s %p (rc = %ld, depth = %d, len = %ld) \",\n\t\t kind, r, r -> refcount, r -> depth, r -> size);\n#       endif\n\tif (__is_one_byte_char_type((charT *)0)) {\n\t    const int max_len = 40;\n\t    self_destruct_ptr prefix(substring(r, 0, max_len));\n\t    charT buffer[max_len + 1];\n\t    bool too_big = r -> size > prefix-> size;\n\n\t    flatten(prefix, buffer);\n\t    buffer[prefix -> size] = __eos((charT *)0); \n\t    printf(\"%s%s\\n\", (char *)buffer, too_big? \"...\\n\" : \"\\n\");\n\t} else {\n\t    printf(\"\\n\");\n\t}\n    }\n}\n\ntemplate <class charT, class Alloc>\nconst unsigned long\nrope<charT,Alloc>::min_len[__rope_RopeBase<charT,Alloc>::max_rope_depth + 1] = {\n/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21,\n/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377,\n/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181,\n/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368,\n/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811,\n/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309,\n/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352,\n/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155,\n/* 39 */165580141, /* 40 */267914296, /* 41 */433494437,\n/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903,\n/* 45 */2971215073 };\n// These are Fibonacci numbers < 2**32.\n\ntemplate <class charT, class Alloc>\nrope<charT,Alloc>::RopeBase *\nrope<charT,Alloc>::balance(RopeBase *r)\n{\n    RopeBase * forest[RopeBase::max_rope_depth + 1];\n    RopeBase * result = 0;\n    int i;\n    // Inariant:\n    // The concatenation of forest in descending order is equal to r.\n    // forest[i].size >= min_len[i]\n    // forest[i].depth = i\n    // References from forest are included in refcount.\n\n    for (i = 0; i <= RopeBase::max_rope_depth; ++i) forest[i] = 0;\n    __STL_TRY {\n      add_to_forest(r, forest);\n      for (i = 0; i <= RopeBase::max_rope_depth; ++i) if (0 != forest[i]) {\n#\tifndef __GC\n\t  self_destruct_ptr old(result);\n#\tendif\n\tresult = concat(forest[i], result);\n\tforest[i] -> unref_nonnil();\n#\tif !defined(__GC) && defined(__STL_USE_EXCEPTIONS)\n\t  forest[i] = 0;\n#\tendif\n      }\n    }\n    __STL_UNWIND(for(i = 0; i <= RopeBase::max_rope_depth; i++)\n\t\t unref(forest[i]))\n    if (result -> depth > RopeBase::max_rope_depth) abort();\n    return(result);\n}\n\n\ntemplate <class charT, class Alloc>\nvoid\nrope<charT,Alloc>::add_to_forest(RopeBase *r, RopeBase **forest)\n{\n    if (r -> is_balanced) {\n\tadd_leaf_to_forest(r, forest);\n\treturn;\n    }\n    __stl_assert(r -> tag == RopeBase::concat);\n    {\n\tRopeConcatenation *c = (RopeConcatenation *)r;\n\n\tadd_to_forest(c -> left, forest);\n\tadd_to_forest(c -> right, forest);\n    }\n}\n\n\ntemplate <class charT, class Alloc>\nvoid\nrope<charT,Alloc>::add_leaf_to_forest(RopeBase *r, RopeBase **forest)\n{\n    RopeBase * insertee;   \t\t// included in refcount\n    RopeBase * too_tiny = 0;    \t// included in refcount\n    int i;  \t\t\t\t// forest[0..i-1] is empty\n    size_t s = r -> size;\n\n    for (i = 0; s >= min_len[i+1]/* not this bucket */; ++i) {\n\tif (0 != forest[i]) {\n#\t    ifndef __GC\n\t      self_destruct_ptr old(too_tiny);\n#\t    endif\n\t    too_tiny = concat_and_set_balanced(forest[i], too_tiny);\n\t    forest[i] -> unref_nonnil();\n\t    forest[i] = 0;\n\t}\n    }\n    {\n#\tifndef __GC\n\t  self_destruct_ptr old(too_tiny);\n#\tendif\n\tinsertee = concat_and_set_balanced(too_tiny, r);\n    }\n    // Too_tiny dead, and no longer included in refcount.\n    // Insertee is live and included.\n    __stl_assert(is_almost_balanced(insertee));\n    __stl_assert(insertee -> depth <= r -> depth + 1);\n    for (;; ++i) {\n\tif (0 != forest[i]) {\n#\t    ifndef __GC\n\t      self_destruct_ptr old(insertee);\n#\t    endif\n\t    insertee = concat_and_set_balanced(forest[i], insertee);\n\t    forest[i] -> unref_nonnil();\n\t    forest[i] = 0;\n\t    __stl_assert(is_almost_balanced(insertee));\n\t}\n\t__stl_assert(min_len[i] <= insertee -> size);\n\t__stl_assert(forest[i] == 0);\n\tif (i == RopeBase::max_rope_depth\n\t    || insertee -> size < min_len[i+1]) {\n\t    forest[i] = insertee;\n\t    // refcount is OK since insertee is now dead.\n\t    return;\n\t}\n    }\n}\n\ntemplate <class charT, class Alloc>\ncharT\nrope<charT,Alloc>::fetch(RopeBase *r, size_type i)\n{\n    __GC_CONST charT * cstr = r -> c_string;\n\n    __stl_assert(i < r -> size);\n    if (0 != cstr) return cstr[i]; \n    for(;;) {\n      switch(r -> tag) {\n\tcase RopeBase::concat:\n\t    {\n\t\tRopeConcatenation *c = (RopeConcatenation *)r;\n\t\tRopeBase *left = c -> left;\n\t\tsize_t left_len = left -> size;\n\n\t\tif (i >= left_len) {\n\t\t    i -= left_len;\n\t\t    r = c -> right;\n\t\t} else {\n\t\t    r = left;\n\t\t}\n\t    }\n\t    break;\n\tcase RopeBase::leaf:\n\t    {\n\t\tRopeLeaf * l = (RopeLeaf *)r;\n\t\treturn l -> data[i];\n\t    }\n\tcase RopeBase::function:\n\tcase RopeBase::substringfn:\n\t    {\n\t\tRopeFunction * f = (RopeFunction *)r;\n\t\tcharT result;\n\n\t\t(*(f -> fn))(i, 1, &result);\n\t\treturn result;\n\t    }\n      }\n    }\n}\n\n# ifndef __GC\n// Return a uniquely referenced character slot for the given\n// position, or 0 if that's not possible.\ntemplate <class charT, class Alloc>\ncharT*\nrope<charT,Alloc>::fetch_ptr(RopeBase *r, size_type i)\n{\n    RopeBase * clrstack[RopeBase::max_rope_depth];\n    size_t csptr = 0;\n\n    for(;;) {\n      if (r -> refcount > 1) return 0;\n      switch(r -> tag) {\n\tcase RopeBase::concat:\n\t    {\n\t\tRopeConcatenation *c = (RopeConcatenation *)r;\n\t\tRopeBase *left = c -> left;\n\t\tsize_t left_len = left -> size;\n\n\t\tif (c -> c_string != 0) clrstack[csptr++] = c;\n\t\tif (i >= left_len) {\n\t\t    i -= left_len;\n\t\t    r = c -> right;\n\t\t} else {\n\t\t    r = left;\n\t\t}\n\t    }\n\t    break;\n\tcase RopeBase::leaf:\n\t    {\n\t\tRopeLeaf * l = (RopeLeaf *)r;\n\t\tif (l -> c_string != l -> data && l -> c_string != 0)\n\t\t    clrstack[csptr++] = l;\n\t\twhile (csptr > 0) {\n\t\t    -- csptr;\n\t\t    RopeBase * d = clrstack[csptr];\n\t\t    d -> free_c_string();\n\t\t    d -> c_string = 0;\n\t\t}\n\t\treturn l -> data + i;\n\t    }\n\tcase RopeBase::function:\n\tcase RopeBase::substringfn:\n\t    return 0;\n      }\n    }\n}\n# endif /* __GC */\n\n// The following could be implemented trivially using\n// lexicographical_compare_3way.\n// We do a little more work to avoid dealing with rope iterators for\n// flat strings.\ntemplate <class charT, class Alloc>\nint\nrope<charT,Alloc>::compare (const RopeBase *left, const RopeBase *right)\n{\n    size_t left_len;\n    size_t right_len;\n\n    if (0 == right) return 0 != left;\n    if (0 == left) return -1;\n    left_len = left -> size;\n    right_len = right -> size;\n    if (RopeBase::leaf == left -> tag) {\n\tRopeLeaf *l = (RopeLeaf *) left;\n\tif (RopeBase::leaf == right -> tag) {\n\t    RopeLeaf *r = (RopeLeaf *) right;\n\t    return lexicographical_compare_3way(\n\t\t\tl -> data, l -> data + left_len,\n\t\t\tr -> data, r -> data + right_len);\n\t} else {\n\t    const_iterator rstart(right, 0);\n\t    const_iterator rend(right, right_len);\n\t    return lexicographical_compare_3way(\n\t\t\tl -> data, l -> data + left_len,\n\t\t\trstart, rend);\n\t}\n    } else {\n\tconst_iterator lstart(left, 0);\n\tconst_iterator lend(left, left_len);\n\tif (RopeBase::leaf == right -> tag) {\n\t    RopeLeaf *r = (RopeLeaf *) right;\n\t    return lexicographical_compare_3way(\n\t\t\t\t   lstart, lend,\n\t\t\t\t   r -> data, r -> data + right_len);\n\t} else {\n\t    const_iterator rstart(right, 0);\n\t    const_iterator rend(right, right_len);\n\t    return lexicographical_compare_3way(\n\t\t\t\t   lstart, lend,\n\t\t\t\t   rstart, rend);\n\t}\n    }\n}\n\n// Assignment to reference proxies.\ntemplate <class charT, class Alloc>\n__rope_charT_ref_proxy<charT, Alloc>&\n__rope_charT_ref_proxy<charT, Alloc>::operator= (charT c) {\n    RopeBase * old = root -> tree_ptr;\n#   ifndef __GC\n\t// First check for the case in which everything is uniquely\n\t// referenced.  In that case we can do this destructively.\n\tcharT * charT_ptr = my_rope::fetch_ptr(old, pos);\n\tif (0 != charT_ptr) {\n\t    *charT_ptr = c;\n\t    return *this;\n\t}\n#   endif\n    self_destruct_ptr left(my_rope::substring(old, 0, pos));\n    self_destruct_ptr right(my_rope::substring(old, pos+1, old -> size));\n    self_destruct_ptr result_left(my_rope::destr_concat_char_iter(left, &c, 1));\n#   ifndef __GC\n      __stl_assert(left == result_left || 1 == result_left -> refcount);\n#   endif\n    RopeBase * result =\n\t\tmy_rope::concat(result_left, right);\n#   ifndef __GC\n      __stl_assert(1 <= result -> refcount);\n      RopeBase::unref(old);\n#   endif\n    root -> tree_ptr = result;\n    return *this;\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_charT_ref_proxy<charT, Alloc>::operator charT () const\n{\n    if (current_valid) {\n\treturn current;\n    } else {\n        return my_rope::fetch(root->tree_ptr, pos);\n    }\n}\ntemplate <class charT, class Alloc>\n__rope_charT_ptr_proxy<charT, Alloc>\n__rope_charT_ref_proxy<charT, Alloc>::operator& () const {\n    return __rope_charT_ptr_proxy<charT, Alloc>(*this);\n}\n\ntemplate <class charT, class Alloc>\nrope<charT, Alloc>::rope(size_t n, charT c)\n{\n    rope result;\n    const size_t exponentiate_threshold = 32;\n    size_t exponent;\n    size_t rest;\n    charT *rest_buffer;\n    RopeBase * remainder;\n    rope remainder_rope;\n\n    if (0 == n) { tree_ptr = 0; return; }\n    exponent = n / exponentiate_threshold;\n    rest = n % exponentiate_threshold;\n    if (0 == rest) {\n\tremainder = 0;\n    } else {\n\trest_buffer = DataAlloc::allocate(rounded_up_size(rest));\n\tuninitialized_fill_n(rest_buffer, rest, c);\n\t__cond_store_eos(rest_buffer[rest]);\n\t__STL_TRY {\n\t    remainder = RopeLeaf_from_char_ptr(rest_buffer, rest);\n        }\n\t__STL_UNWIND(RopeBase::free_string(rest_buffer, rest))\n    }\n    remainder_rope.tree_ptr = remainder;\n    if (exponent != 0) {\n\tcharT * base_buffer =\n\t\tDataAlloc::allocate(rounded_up_size(exponentiate_threshold));\n\tRopeLeaf * base_leaf;\n\trope base_rope;\n\tuninitialized_fill_n(base_buffer, exponentiate_threshold, c);\n\t__cond_store_eos(base_buffer[exponentiate_threshold]);\n\t__STL_TRY {\n          base_leaf = RopeLeaf_from_char_ptr(base_buffer,\n                                             exponentiate_threshold);\n        }\n\t__STL_UNWIND(RopeBase::free_string(base_buffer, exponentiate_threshold))\n\tbase_rope.tree_ptr = base_leaf;\n \tif (1 == exponent) {\n\t  result = base_rope;\n#         ifndef __GC\n\t    __stl_assert(1 == result -> tree_ptr -> refcount);\n#         endif\n\t} else {\n\t  result = power(base_rope, exponent, concat_fn());\n\t}\n\tif (0 != remainder) {\n\t  result += remainder_rope;\n\t}\n    } else {\n\tresult = remainder_rope;\n    }\n    tree_ptr = result.tree_ptr;\n    tree_ptr -> ref_nonnil();\n}\n\ntemplate<class charT, class Alloc> charT rope<charT,Alloc>::empty_c_str[1];\n\n# ifdef __STL_PTHREADS\n    template<class charT, class Alloc>\n    pthread_mutex_t rope<charT,Alloc>::swap_lock = PTHREAD_MUTEX_INITIALIZER;\n# endif\n\ntemplate<class charT, class Alloc>\nconst charT * rope<charT,Alloc>::c_str() const {\n    if (0 == tree_ptr) {\n        empty_c_str[0] = __eos((charT *)0);  // Possibly redundant,\n\t\t\t\t\t     // but probably fast.\n        return empty_c_str;\n    }\n    __GC_CONST charT * old_c_string = tree_ptr -> c_string;\n    if (0 != old_c_string) return(old_c_string);\n    size_t s = size();\n    charT * result = DataAlloc::allocate(s + 1);\n    flatten(tree_ptr, result);\n    result[s] = __eos((charT *)0);\n#   ifdef __GC\n\ttree_ptr -> c_string = result;\n#   else\n      if ((old_c_string = atomic_swap(&(tree_ptr -> c_string), result)) != 0) {\n\t// It must have been added in the interim.  Hence it had to have been\n\t// separately allocated.  Deallocate the old copy, since we just\n\t// replaced it.\n\tdestroy(old_c_string, old_c_string + s + 1);\n\tDataAlloc::deallocate(old_c_string, s + 1);\n      }\n#   endif\n    return(result);\n}\n\ntemplate<class charT, class Alloc>\nconst charT * rope<charT,Alloc>::replace_with_c_str() {\n    if (0 == tree_ptr) {\n        empty_c_str[0] = __eos((charT *)0);\n        return empty_c_str;\n    }\n    __GC_CONST charT * old_c_string = tree_ptr -> c_string;\n    if (RopeBase::leaf == tree_ptr -> tag && 0 != old_c_string) {\n\treturn(old_c_string);\n    }\n    size_t s = size();\n    charT * result = DataAlloc::allocate(rounded_up_size(s));\n    flatten(tree_ptr, result);\n    result[s] = __eos((charT *)0);\n    tree_ptr -> unref_nonnil();\n    tree_ptr = RopeLeaf_from_char_ptr(result, s);\n    return(result);\n}\n\n// Algorithm specializations.  More should be added.\n\n#ifndef _MSC_VER\n// I couldn't get this to work with VC++\ntemplate<class charT,class Alloc>\nvoid\n__rope_rotate(__rope_iterator<charT,Alloc> first,\n              __rope_iterator<charT,Alloc> middle,\n              __rope_iterator<charT,Alloc> last) {\n    __stl_assert(first.container() == middle.container()\n                 && middle.container() == last.container());\n    rope<charT,Alloc>& r(first.container());\n    rope<charT,Alloc> prefix = r.substr(0, first.index());\n    rope<charT,Alloc> suffix = r.substr(last.index(), r.size() - last.index());\n    rope<charT,Alloc> part1 = r.substr(middle.index(),\n                                       last.index() - middle.index());\n    rope<charT,Alloc> part2 = r.substr(first.index(),\n                                       middle.index() - first.index());\n    r = prefix;\n    r += part1;\n    r += part2;\n    r += suffix;\n}\n\ninline void rotate(__rope_iterator<char,__ALLOC> first,\n                   __rope_iterator<char,__ALLOC> middle,\n                   __rope_iterator<char,__ALLOC> last) {\n    __rope_rotate(first, middle, last);\n}\n\n# if 0\n// Probably not useful for several reasons:\n// - for SGIs 7.1 compiler and probably some others,\n//   this forces lots of rope<wchar_t, ...> instantiations, creating a\n//   code bloat and compile time problem.  (Fixed in 7.2.)\n// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive\n//   for unicode strings.  Unsigned short may be a better character\n//   type.\ninline void rotate(__rope_iterator<wchar_t,__ALLOC> first,\n                   __rope_iterator<wchar_t,__ALLOC> middle,\n                   __rope_iterator<wchar_t,__ALLOC> last) {\n    __rope_rotate(first, middle, last);\n}\n# endif\n#endif /* _MSC_VER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/set",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_SET\n#define __SGI_STL_SET\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <stl_set.h>\n#include <stl_multiset.h>\n\n#endif /* __SGI_STL_SET */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/set.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_SET_H\n#define __SGI_STL_SET_H\n\n#include <tree.h>\n#include <stl_set.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::set;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/slist",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_SLIST\n#define __SGI_STL_SLIST\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_slist.h>\n\n#endif /* __SGI_STL_SLIST */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/slist.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __SGI_STL_SLIST_H\n#define __SGI_STL_SLIST_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_slist.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::slist;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_SLIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stack",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_STACK\n#define __SGI_STL_STACK\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_deque.h>\n#include <stl_stack.h>\n\n#endif /* __SGI_STL_STACK */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stack.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_STACK_H\n#define __SGI_STL_STACK_H\n\n#include <vector.h>\n#include <deque.h>\n#include <heap.h>\n#include <stl_stack.h>\n#include <stl_queue.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::stack;\nusing __STD::queue;\nusing __STD::priority_queue;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_STACK_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/bastring.cc",
    "content": "// Member templates for the -*- C++ -*- string classes.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification by Takanori Adachi\n// in ANSI X3J16/94-0013R2.\n\nextern \"C++\" {\ntemplate <class charT, class traits, class Allocator>\ninline void * basic_string <charT, traits, Allocator>::Rep::\noperator new (size_t s, size_t extra)\n{\n  return Allocator::allocate(s + extra * sizeof (charT));\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline void basic_string <charT, traits, Allocator>::Rep::\noperator delete (void * ptr)\n{\n  Allocator::deallocate(ptr, sizeof(Rep) +\n\t\t\treinterpret_cast<Rep *>(ptr)->res *\n\t\t\tsizeof (charT)); \n}\n\ntemplate <class charT, class traits, class Allocator>\ninline size_t basic_string <charT, traits, Allocator>::Rep::\nfrob_size (size_t s)\n{\n  size_t i = 16;\n  while (i < s) i *= 2;\n  return i;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>::Rep *\nbasic_string <charT, traits, Allocator>::Rep::\ncreate (size_t extra)\n{\n  extra = frob_size (extra + 1);\n  Rep *p = new (extra) Rep;\n  p->res = extra;\n  p->ref = 1;\n  p->selfish = false;\n  return p;\n}\n\ntemplate <class charT, class traits, class Allocator>\ncharT * basic_string <charT, traits, Allocator>::Rep::\nclone ()\n{\n  Rep *p = Rep::create (len);\n  p->copy (0, data (), len);\n  p->len = len;\n  return p->data ();\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool basic_string <charT, traits, Allocator>::Rep::\nexcess_slop (size_t s, size_t r)\n{\n  return 2 * (s <= 16 ? 16 : s) < r;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool basic_string <charT, traits, Allocator>::\ncheck_realloc (basic_string::size_type s) const\n{\n  s += sizeof (charT);\n  rep ()->selfish = false;\n  return (rep ()->ref > 1\n\t  || s > capacity ()\n\t  || Rep::excess_slop (s, capacity ()));\n}\n\ntemplate <class charT, class traits, class Allocator>\nvoid basic_string <charT, traits, Allocator>::\nalloc (basic_string::size_type size, bool save)\n{\n  if (! check_realloc (size))\n    return;\n\n  Rep *p = Rep::create (size);\n\n  if (save)\n    {\n      p->copy (0, data (), length ());\n      p->len = length ();\n    }\n  else\n    p->len = 0;\n\n  repup (p);\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>&\nbasic_string <charT, traits, Allocator>::\nreplace (size_type pos1, size_type n1,\n\t const basic_string& str, size_type pos2, size_type n2)\n{\n  const size_t len2 = str.length ();\n\n  if (pos1 == 0 && n1 >= length () && pos2 == 0 && n2 >= len2)\n    return operator= (str);\n\n  OUTOFRANGE (pos2 > len2);\n\n  if (n2 > len2 - pos2)\n    n2 = len2 - pos2;\n\n  return replace (pos1, n1, str.data () + pos2, n2);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline void basic_string <charT, traits, Allocator>::Rep::\ncopy (size_t pos, const charT *s, size_t n)\n{\n  if (n)\n    traits::copy (data () + pos, s, n);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline void basic_string <charT, traits, Allocator>::Rep::\nmove (size_t pos, const charT *s, size_t n)\n{\n  if (n)\n    traits::move (data () + pos, s, n);\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>&\nbasic_string <charT, traits, Allocator>::\nreplace (size_type pos, size_type n1, const charT* s, size_type n2)\n{\n  const size_type len = length ();\n  OUTOFRANGE (pos > len);\n  if (n1 > len - pos)\n    n1 = len - pos;\n  LENGTHERROR (len - n1 > max_size () - n2);\n  size_t newlen = len - n1 + n2;\n\n  if (check_realloc (newlen))\n    {\n      Rep *p = Rep::create (newlen);\n      p->copy (0, data (), pos);\n      p->copy (pos + n2, data () + pos + n1, len - (pos + n1));\n      p->copy (pos, s, n2);\n      repup (p);\n    }\n  else\n    {\n      rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1));\n      rep ()->copy (pos, s, n2);\n    }\n  rep ()->len = newlen;\n\n  return *this;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline void basic_string <charT, traits, Allocator>::Rep::\nset (size_t pos, const charT c, size_t n)\n{\n  traits::set  (data () + pos, c, n);\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::\nreplace (size_type pos, size_type n1, size_type n2, charT c)\n{\n  const size_t len = length ();\n  OUTOFRANGE (pos > len);\n  if (n1 > len - pos)\n    n1 = len - pos;\n  LENGTHERROR (len - n1 > max_size () - n2);\n  size_t newlen = len - n1 + n2;\n\n  if (check_realloc (newlen))\n    {\n      Rep *p = Rep::create (newlen);\n      p->copy (0, data (), pos);\n      p->copy (pos + n2, data () + pos + n1, len - (pos + n1));\n      p->set  (pos, c, n2);\n      repup (p);\n    }\n  else\n    {\n      rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1));\n      rep ()->set  (pos, c, n2);\n    }\n  rep ()->len = newlen;\n\n  return *this;\n}\n\ntemplate <class charT, class traits, class Allocator>\nvoid basic_string <charT, traits, Allocator>::\nresize (size_type n, charT c)\n{\n  LENGTHERROR (n > max_size ());\n\n  if (n > length ())\n    append (n - length (), c);\n  else\n    erase (n);\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\ncopy (charT* s, size_type n, size_type pos) const\n{\n  OUTOFRANGE (pos > length ());\n\n  if (n > length () - pos)\n    n = length () - pos;\n\n  traits::copy (s, data () + pos, n);\n  return n;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind (const charT* s, size_type pos, size_type n) const\n{\n  size_t xpos = pos;\n  for (; xpos + n <= length (); ++xpos)\n    if (traits::eq (data () [xpos], *s)\n\t&& traits::compare (data () + xpos, s, n) == 0)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\n_find (const charT* ptr, charT c, size_type xpos, size_type len)\n{\n  for (; xpos < len; ++xpos)\n    if (traits::eq (ptr [xpos], c))\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind (charT c, size_type pos) const\n{\n  return _find (data (), c, pos, length ());\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nrfind (const charT* s, size_type pos, size_type n) const\n{\n  if (n > length ())\n    return npos;\n\n  size_t xpos = length () - n;\n  if (xpos > pos)\n    xpos = pos;\n\n  for (++xpos; xpos-- > 0; )\n    if (traits::eq (data () [xpos], *s)\n\t&& traits::compare (data () + xpos, s, n) == 0)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nrfind (charT c, size_type pos) const\n{\n  if (1 > length ())\n    return npos;\n\n  size_t xpos = length () - 1;\n  if (xpos > pos)\n    xpos = pos;\n\n  for (++xpos; xpos-- > 0; )\n    if (traits::eq (data () [xpos], c))\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_first_of (const charT* s, size_type pos, size_type n) const\n{\n  size_t xpos = pos;\n  for (; xpos < length (); ++xpos)\n    if (_find (s, data () [xpos], 0, n) != npos)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_last_of (const charT* s, size_type pos, size_type n) const\n{\n  if (length() == 0)\n    return npos;\n  size_t xpos = length () - 1;\n  if (xpos > pos)\n    xpos = pos;\n  for (++xpos; xpos-- > 0;)\n    if (_find (s, data () [xpos], 0, n) != npos)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_first_not_of (const charT* s, size_type pos, size_type n) const\n{\n  size_t xpos = pos;\n  for (; xpos < length (); ++xpos)\n    if (_find (s, data () [xpos], 0, n) == npos)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_first_not_of (charT c, size_type pos) const\n{\n  size_t xpos = pos;\n  for (; xpos < length (); ++xpos)\n    if (traits::ne (data () [xpos], c))\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_last_not_of (const charT* s, size_type pos, size_type n) const\n{\n  if (length() == 0)\n    return npos;\n  size_t xpos = length () - 1;\n  if (xpos > pos)\n    xpos = pos;\n  for (++xpos; xpos-- > 0;)\n    if (_find (s, data () [xpos], 0, n) == npos)\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::\nfind_last_not_of (charT c, size_type pos) const\n{\n  if (length() == 0)\n    return npos;\n  size_t xpos = length () - 1;\n  if (xpos > pos)\n    xpos = pos;\n  for (++xpos; xpos-- > 0;)\n    if (traits::ne (data () [xpos], c))\n      return xpos;\n  return npos;\n}\n\ntemplate <class charT, class traits, class Allocator>\nint basic_string <charT, traits, Allocator>::\ncompare (const basic_string& str, size_type pos, size_type n) const\n{\n  OUTOFRANGE (pos > length ());\n\n  size_t rlen = length () - pos;\n  if (rlen > n)\n    rlen = n;\n  if (rlen > str.length ())\n    rlen = str.length ();\n  int r = traits::compare (data () + pos, str.data (), rlen);\n  if (r != 0)\n    return r;\n  if (rlen == n)\n    return 0;\n  return (length () - pos) - str.length ();\n}\n\ntemplate <class charT, class traits, class Allocator>\nint basic_string <charT, traits, Allocator>::\ncompare (const charT* s, size_type pos, size_type n) const\n{\n  OUTOFRANGE (pos > length ());\n\n  size_t rlen = length () - pos;\n  if (rlen > n)\n    rlen = n;\n  int r = traits::compare (data () + pos, s, rlen);\n  if (r != 0)\n    return r;\n  return (length () - pos) - n;\n}\n\n#include <iostream.h>\n\ntemplate <class charT, class traits, class Allocator>\nistream &\noperator>> (istream &is, basic_string <charT, traits, Allocator> &s)\n{\n  int w = is.width (0);\n  if (is.ipfx0 ())\n    {\n      register streambuf *sb = is.rdbuf ();\n      s.resize (0);\n      while (1)\n\t{\n\t  int ch = sb->sbumpc ();\n\t  if (ch == EOF)\n\t    {\n\t      is.setstate (ios::eofbit);\n\t      break;\n\t    }\n\t  else if (traits::is_del (ch))\n\t    {\n\t      sb->sungetc ();\n\t      break;\n\t    }\n\t  s += ch;\n\t  if (--w == 1)\n\t    break;\n\t}\n    }\n\n  is.isfx ();\n  if (s.length () == 0)\n    is.setstate (ios::failbit);\n\n  return is;\n}\n\ntemplate <class charT, class traits, class Allocator>\nostream &\noperator<< (ostream &o, const basic_string <charT, traits, Allocator>& s)\n{\n  return o.write (s.data (), s.length ());\n}\n\ntemplate <class charT, class traits, class Allocator>\nistream&\ngetline (istream &is, basic_string <charT, traits, Allocator>& s, charT delim)\n{\n  if (is.ipfx1 ())\n    {\n      _IO_size_t count = 0;\n      streambuf *sb = is.rdbuf ();\n      s.resize (0);\n\n      while (1)\n\t{\n\t  int ch = sb->sbumpc ();\n\t  if (ch == EOF)\n\t    {\n\t      is.setstate (count == 0\n\t\t\t   ? (ios::failbit|ios::eofbit)\n\t\t\t   : ios::eofbit);\n\t      break;\n\t    }\n\n\t  ++count;\n\n\t  if (ch == delim)\n\t    break;\n\n\t  s += ch;\n\n\t  if (s.length () == s.npos - 1)\n\t    {\n\t      is.setstate (ios::failbit);\n\t      break;\n\t    }\n\t}\n    }\n\n  // We need to be friends with istream to do this.\n  // is._gcount = count;\n  is.isfx ();\n\n  return is;\n}\n\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>::Rep\nbasic_string<charT, traits, Allocator>::nilRep = { 0, 0, 1, false };\n\ntemplate <class charT, class traits, class Allocator>\nconst basic_string <charT, traits, Allocator>::size_type\nbasic_string <charT, traits, Allocator>::npos;\n\n} // extern \"C++\"\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/bastring.h",
    "content": "// Main templates for the -*- C++ -*- string classes.\n// Copyright (C) 1994, 1995 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification by Takanori Adachi\n// in ANSI X3J16/94-0013R2.\n\n#ifndef __BASTRING__\n#define __BASTRING__\n\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n#include <cstddef>\n#include <std/straits.h>\n\n// NOTE : This does NOT conform to the draft standard and is likely to change\n#include <alloc.h>\n\nextern \"C++\" {\nclass istream; class ostream;\n\n#include <iterator>\n\n#ifdef __STL_USE_EXCEPTIONS\n\nextern void __out_of_range (const char *);\nextern void __length_error (const char *);\n\n#define OUTOFRANGE(cond) \\\n  do { if (cond) __out_of_range (#cond); } while (0)\n#define LENGTHERROR(cond) \\\n  do { if (cond) __length_error (#cond); } while (0)\n\n#else\n\n#include <cassert>\n#define OUTOFRANGE(cond) assert (!(cond))\n#define LENGTHERROR(cond) assert (!(cond))\n\n#endif\n\ntemplate <class charT, class traits = string_char_traits<charT>,\n\t  class Allocator = alloc >\nclass basic_string\n{\nprivate:\n  struct Rep {\n    size_t len, res, ref;\n    bool selfish;\n\n    charT* data () { return reinterpret_cast<charT *>(this + 1); }\n    charT& operator[] (size_t s) { return data () [s]; }\n    charT* grab () { if (selfish) return clone (); ++ref; return data (); }\n    void release () { if (--ref == 0) delete this; }\n\n    inline static void * operator new (size_t, size_t);\n    inline static void operator delete (void *);\n    inline static Rep* create (size_t);\n    charT* clone ();\n\n    inline void copy (size_t, const charT *, size_t);\n    inline void move (size_t, const charT *, size_t);\n    inline void set  (size_t, const charT,   size_t);\n\n    inline static bool excess_slop (size_t, size_t);\n    inline static size_t frob_size (size_t);\n\n  private:\n    Rep &operator= (const Rep &);\n  };\n\npublic:\n// types:\n  typedef\t   traits\t\ttraits_type;\n  typedef typename traits::char_type\tvalue_type;\n  typedef\t   Allocator\t\tallocator_type;\n\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n  typedef charT& reference;\n  typedef const charT& const_reference;\n  typedef charT* pointer;\n  typedef const charT* const_pointer;\n  typedef pointer iterator;\n  typedef const_pointer const_iterator;\n  typedef ::reverse_iterator<iterator> reverse_iterator;\n  typedef ::reverse_iterator<const_iterator> const_reverse_iterator;\n  static const size_type npos = static_cast<size_type>(-1);\n\nprivate:\n  Rep *rep () const { return reinterpret_cast<Rep *>(dat) - 1; }\n  void repup (Rep *p) { rep ()->release (); dat = p->data (); }\n\npublic:\n  const charT* data () const\n    { return rep ()->data(); }\n  size_type length () const\n    { return rep ()->len; }\n  size_type size () const\n    { return rep ()->len; }\n  size_type capacity () const\n    { return rep ()->res; }\n  size_type max_size () const\n    { return (npos - 1)/sizeof (charT); }\t\t// XXX\n  bool empty () const\n    { return size () == 0; }\n\n// _lib.string.cons_ construct/copy/destroy:\n  basic_string& operator= (const basic_string& str)\n    {\n      if (&str != this) { rep ()->release (); dat = str.rep ()->grab (); }\n      return *this;\n    }\n\n  explicit basic_string (): dat (nilRep.grab ()) { }\n  basic_string (const basic_string& str): dat (str.rep ()->grab ()) { }\n  basic_string (const basic_string& str, size_type pos, size_type n = npos)\n    : dat (nilRep.grab ()) { assign (str, pos, n); }\n  basic_string (const charT* s, size_type n)\n    : dat (nilRep.grab ()) { assign (s, n); }\n  basic_string (const charT* s)\n    : dat (nilRep.grab ()) { assign (s); }\n  basic_string (size_type n, charT c)\n    : dat (nilRep.grab ()) { assign (n, c); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class InputIterator>\n    basic_string(InputIterator begin, InputIterator end)\n#else\n  basic_string(const_iterator begin, const_iterator end)\n#endif\n    : dat (nilRep.grab ()) { assign (begin, end); }\n\n  ~basic_string ()\n    { rep ()->release (); }\n\n  void swap (basic_string &s) { charT *d = dat; dat = s.dat; s.dat = d; }\n\n  basic_string& append (const basic_string& str, size_type pos = 0,\n\t\t\tsize_type n = npos)\n    { return replace (length (), 0, str, pos, n); }\n  basic_string& append (const charT* s, size_type n)\n    { return replace (length (), 0, s, n); }\n  basic_string& append (const charT* s)\n    { return append (s, traits::length (s)); }\n  basic_string& append (size_type n, charT c)\n    { return replace (length (), 0, n, c); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class InputIterator>\n    basic_string& append(InputIterator first, InputIterator last)\n#else\n  basic_string& append(const_iterator first, const_iterator last)\n#endif\n    { return replace (iend (), iend (), first, last); }\n\n  basic_string& assign (const basic_string& str, size_type pos = 0,\n\t\t\tsize_type n = npos)\n    { return replace (0, npos, str, pos, n); }\n  basic_string& assign (const charT* s, size_type n)\n    { return replace (0, npos, s, n); }\n  basic_string& assign (const charT* s)\n    { return assign (s, traits::length (s)); }\n  basic_string& assign (size_type n, charT c)\n    { return replace (0, npos, n, c); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class InputIterator>\n    basic_string& assign(InputIterator first, InputIterator last)\n#else\n  basic_string& assign(const_iterator first, const_iterator last)\n#endif\n    { return replace (ibegin (), iend (), first, last); }\n\n  basic_string& operator= (const charT* s)\n    { return assign (s); }\n  basic_string& operator= (charT c)\n    { return assign (1, c); }\n\n  basic_string& operator+= (const basic_string& rhs)\n    { return append (rhs); }\n  basic_string& operator+= (const charT* s)\n    { return append (s); }\n  basic_string& operator+= (charT c)\n    { return append (1, c); }\n\n  basic_string& insert (size_type pos1, const basic_string& str,\n\t\t\tsize_type pos2 = 0, size_type n = npos)\n    { return replace (pos1, 0, str, pos2, n); }\n  basic_string& insert (size_type pos, const charT* s, size_type n)\n    { return replace (pos, 0, s, n); }\n  basic_string& insert (size_type pos, const charT* s)\n    { return insert (pos, s, traits::length (s)); }\n  basic_string& insert (size_type pos, size_type n, charT c)\n    { return replace (pos, 0, n, c); }\n  iterator insert(iterator p, charT c)\n    { size_type __o = p - ibegin ();\n      insert (p - ibegin (), 1, c); selfish ();\n      return ibegin () + __o; }\n  iterator insert(iterator p, size_type n, charT c)\n    { size_type __o = p - ibegin ();\n      insert (p - ibegin (), n, c); selfish ();\n      return ibegin () + __o; }\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class InputIterator>\n    void insert(iterator p, InputIterator first, InputIterator last)\n#else\n  void insert(iterator p, const_iterator first, const_iterator last)\n#endif\n    { replace (p, p, first, last); }\n\n  basic_string& erase (size_type pos = 0, size_type n = npos)\n    { return replace (pos, n, (size_type)0, (charT)0); }\n  iterator erase(iterator p)\n    { size_type __o = p - begin();\n      replace (__o, 1, (size_type)0, (charT)0); selfish ();\n      return ibegin() + __o; }\n  iterator erase(iterator f, iterator l)\n    { size_type __o = f - ibegin();\n      replace (__o, l-f, (size_type)0, (charT)0);selfish ();\n      return ibegin() + __o; }\n\n  basic_string& replace (size_type pos1, size_type n1, const basic_string& str,\n\t\t\t size_type pos2 = 0, size_type n2 = npos);\n  basic_string& replace (size_type pos, size_type n1, const charT* s,\n\t\t\t size_type n2);\n  basic_string& replace (size_type pos, size_type n1, const charT* s)\n    { return replace (pos, n1, s, traits::length (s)); }\n  basic_string& replace (size_type pos, size_type n1, size_type n2, charT c);\n  basic_string& replace (size_type pos, size_type n, charT c)\n    { return replace (pos, n, 1, c); }\n  basic_string& replace (iterator i1, iterator i2, const basic_string& str)\n    { return replace (i1 - ibegin (), i2 - i1, str); }\n  basic_string& replace (iterator i1, iterator i2, const charT* s, size_type n)\n    { return replace (i1 - ibegin (), i2 - i1, s, n); }\n  basic_string& replace (iterator i1, iterator i2, const charT* s)\n    { return replace (i1 - ibegin (), i2 - i1, s); }\n  basic_string& replace (iterator i1, iterator i2, size_type n, charT c)\n    { return replace (i1 - ibegin (), i2 - i1, n, c); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template<class InputIterator>\n    basic_string& replace(iterator i1, iterator i2,\n\t\t\t  InputIterator j1, InputIterator j2);\n#else\n  basic_string& replace(iterator i1, iterator i2,\n\t\t\tconst_iterator j1, const_iterator j2);\n#endif\n\nprivate:\n  static charT eos () { return traits::eos (); }\n  void unique () { if (rep ()->ref > 1) alloc (length (), true); }\n  void selfish () { unique (); rep ()->selfish = true; }\n\npublic:\n  charT operator[] (size_type pos) const\n    {\n      if (pos == length ())\n\treturn eos ();\n      return data ()[pos];\n    }\n\n  reference operator[] (size_type pos)\n    { selfish (); return (*rep ())[pos]; }\n\n  reference at (size_type pos)\n    {\n      OUTOFRANGE (pos >= length ());\n      return (*this)[pos];\n    }\n  const_reference at (size_type pos) const\n    {\n      OUTOFRANGE (pos >= length ());\n      return data ()[pos];\n    }\n\nprivate:\n  void terminate () const\n    { traits::assign ((*rep ())[length ()], eos ()); }\n\npublic:\n  const charT* c_str () const\n    { if (length () == 0) return \"\"; terminate (); return data (); }\n  void resize (size_type n, charT c);\n  void resize (size_type n)\n    { resize (n, eos ()); }\n  void reserve (size_type) { }\n\n  size_type copy (charT* s, size_type n, size_type pos = 0) const;\n\n  size_type find (const basic_string& str, size_type pos = 0) const\n    { return find (str.data(), pos, str.length()); }\n  size_type find (const charT* s, size_type pos, size_type n) const;\n  size_type find (const charT* s, size_type pos = 0) const\n    { return find (s, pos, traits::length (s)); }\n  size_type find (charT c, size_type pos = 0) const;\n\n  size_type rfind (const basic_string& str, size_type pos = npos) const\n    { return rfind (str.data(), pos, str.length()); }\n  size_type rfind (const charT* s, size_type pos, size_type n) const;\n  size_type rfind (const charT* s, size_type pos = npos) const\n    { return rfind (s, pos, traits::length (s)); }\n  size_type rfind (charT c, size_type pos = npos) const;\n\n  size_type find_first_of (const basic_string& str, size_type pos = 0) const\n    { return find_first_of (str.data(), pos, str.length()); }\n  size_type find_first_of (const charT* s, size_type pos, size_type n) const;\n  size_type find_first_of (const charT* s, size_type pos = 0) const\n    { return find_first_of (s, pos, traits::length (s)); }\n  size_type find_first_of (charT c, size_type pos = 0) const\n    { return find (c, pos); }\n\n  size_type find_last_of (const basic_string& str, size_type pos = npos) const\n    { return find_last_of (str.data(), pos, str.length()); }\n  size_type find_last_of (const charT* s, size_type pos, size_type n) const;\n  size_type find_last_of (const charT* s, size_type pos = npos) const\n    { return find_last_of (s, pos, traits::length (s)); }\n  size_type find_last_of (charT c, size_type pos = npos) const\n    { return rfind (c, pos); }\n\n  size_type find_first_not_of (const basic_string& str, size_type pos = 0) const\n    { return find_first_not_of (str.data(), pos, str.length()); }\n  size_type find_first_not_of (const charT* s, size_type pos, size_type n) const;\n  size_type find_first_not_of (const charT* s, size_type pos = 0) const\n    { return find_first_not_of (s, pos, traits::length (s)); }\n  size_type find_first_not_of (charT c, size_type pos = 0) const;\n\n  size_type find_last_not_of (const basic_string& str, size_type pos = npos) const\n    { return find_last_not_of (str.data(), pos, str.length()); }\n  size_type find_last_not_of (const charT* s, size_type pos, size_type n) const;\n  size_type find_last_not_of (const charT* s, size_type pos = npos) const\n    { return find_last_not_of (s, pos, traits::length (s)); }\n  size_type find_last_not_of (charT c, size_type pos = npos) const;\n\n  basic_string substr (size_type pos = 0, size_type n = npos) const\n    { return basic_string (*this, pos, n); }\n\n  int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const;\n  // There is no 'strncmp' equivalent for charT pointers.\n  int compare (const charT* s, size_type pos, size_type n) const;\n  int compare (const charT* s, size_type pos = 0) const\n    { return compare (s, pos, traits::length (s)); }\n\n  iterator begin () { selfish (); return &(*this)[0]; }\n  iterator end () { selfish (); return &(*this)[length ()]; }\n\nprivate:\n  iterator ibegin () const { return &(*rep ())[0]; }\n  iterator iend () const { return &(*rep ())[length ()]; }\n\npublic:\n  const_iterator begin () const { return ibegin (); }\n  const_iterator end () const { return iend (); }\n\n  reverse_iterator       rbegin() { return reverse_iterator (end ()); }\n  const_reverse_iterator rbegin() const\n    { return const_reverse_iterator (end ()); }\n  reverse_iterator       rend() { return reverse_iterator (begin ()); }\n  const_reverse_iterator rend() const\n    { return const_reverse_iterator (begin ()); }\n\nprivate:\n  void alloc (size_type size, bool save);\n  static size_type _find (const charT* ptr, charT c, size_type xpos, size_type len);\n  inline bool check_realloc (size_type s) const;\n\n  static Rep nilRep;\n  charT *dat;\n};\n\n#ifdef __STL_MEMBER_TEMPLATES\ntemplate <class charT, class traits, class Allocator> template <class InputIterator>\nbasic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::\nreplace (iterator i1, iterator i2, InputIterator j1, InputIterator j2)\n#else\ntemplate <class charT, class traits, class Allocator>\nbasic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::\nreplace (iterator i1, iterator i2, const_iterator j1, const_iterator j2)\n#endif\n{\n  const size_type len = length ();\n  size_type pos = i1 - ibegin ();\n  size_type n1 = i2 - i1;\n  size_type n2 = j2 - j1;\n\n  OUTOFRANGE (pos > len);\n  if (n1 > len - pos)\n    n1 = len - pos;\n  LENGTHERROR (len - n1 > max_size () - n2);\n  size_t newlen = len - n1 + n2;\n\n  if (check_realloc (newlen))\n    {\n      Rep *p = Rep::create (newlen);\n      p->copy (0, data (), pos);\n      p->copy (pos + n2, data () + pos + n1, len - (pos + n1));\n      for (; j1 != j2; ++j1, ++pos)\n\ttraits::assign ((*p)[pos], *j1);\n      repup (p);\n    }\n  else\n    {\n      rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1));\n      for (; j1 != j2; ++j1, ++pos)\n\ttraits::assign ((*rep ())[pos], *j1);\n    }\n  rep ()->len = newlen;\n\n  return *this;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>\noperator+ (const basic_string <charT, traits, Allocator>& lhs,\n\t   const basic_string <charT, traits, Allocator>& rhs)\n{\n  basic_string <charT, traits, Allocator> str (lhs);\n  str.append (rhs);\n  return str;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>\noperator+ (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  basic_string <charT, traits, Allocator> str (lhs);\n  str.append (rhs);\n  return str;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>\noperator+ (charT lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  basic_string <charT, traits, Allocator> str (1, lhs);\n  str.append (rhs);\n  return str;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>\noperator+ (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  basic_string <charT, traits, Allocator> str (lhs);\n  str.append (rhs);\n  return str;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline basic_string <charT, traits, Allocator>\noperator+ (const basic_string <charT, traits, Allocator>& lhs, charT rhs)\n{\n  basic_string <charT, traits, Allocator> str (lhs);\n  str.append (1, rhs);\n  return str;\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator== (const basic_string <charT, traits, Allocator>& lhs,\n\t    const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) == 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator== (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) == 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator== (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) == 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator!= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) != 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator!= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) != 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator< (const basic_string <charT, traits, Allocator>& lhs,\n\t    const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) < 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator< (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) > 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator< (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) < 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator> (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) < 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator> (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) > 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator<= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) >= 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator<= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) <= 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator>= (const charT* lhs, const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (rhs.compare (lhs) <= 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator>= (const basic_string <charT, traits, Allocator>& lhs, const charT* rhs)\n{\n  return (lhs.compare (rhs) >= 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator!= (const basic_string <charT, traits, Allocator>& lhs,\n\t    const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) != 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator> (const basic_string <charT, traits, Allocator>& lhs,\n\t   const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) > 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator<= (const basic_string <charT, traits, Allocator>& lhs,\n\t    const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) <= 0);\n}\n\ntemplate <class charT, class traits, class Allocator>\ninline bool\noperator>= (const basic_string <charT, traits, Allocator>& lhs,\n\t    const basic_string <charT, traits, Allocator>& rhs)\n{\n  return (lhs.compare (rhs) >= 0);\n}\n\nclass istream; class ostream;\ntemplate <class charT, class traits, class Allocator> istream&\noperator>> (istream&, basic_string <charT, traits, Allocator>&);\ntemplate <class charT, class traits, class Allocator> ostream&\noperator<< (ostream&, const basic_string <charT, traits, Allocator>&);\ntemplate <class charT, class traits, class Allocator> istream&\ngetline (istream&, basic_string <charT, traits, Allocator>&, charT delim = '\\n');\n\n} // extern \"C++\"\n\n#include <std/bastring.cc>\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/complext.cc",
    "content": "// Member templates for the -*- C++ -*- complex number classes.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification in the 27 May 1994\n// C++ working paper, ANSI document X3J16/94-0098.\n\n#include <complex>\n\nextern \"C++\" {\ntemplate <class FLOAT> complex<FLOAT>\ncos (const complex<FLOAT>& x)\n{\n  return complex<FLOAT> (cos (real (x)) * cosh (imag (x)),\n\t\t\t   - sin (real (x)) * sinh (imag (x)));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\ncosh (const complex<FLOAT>& x)\n{\n  return complex<FLOAT> (cosh (real (x)) * cos (imag (x)),\n\t\t\t   sinh (real (x)) * sin (imag (x)));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\nexp (const complex<FLOAT>& x)\n{\n  return polar (FLOAT (exp (real (x))), imag (x));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\nlog (const complex<FLOAT>& x)\n{\n  return complex<FLOAT> (log (abs (x)), arg (x));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\npow (const complex<FLOAT>& x, const complex<FLOAT>& y)\n{\n  FLOAT logr = log (abs (x));\n  FLOAT t = arg (x);\n\n  return polar (FLOAT (exp (logr * real (y) - imag (y) * t)),\n\t\tFLOAT (imag (y) * logr + real (y) * t));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\npow (const complex<FLOAT>& x, FLOAT y)\n{\n  return exp (FLOAT (y) * log (x));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\npow (FLOAT x, const complex<FLOAT>& y)\n{\n  return exp (y * FLOAT (log (x)));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\nsin (const complex<FLOAT>& x)\n{\n  return complex<FLOAT> (sin (real (x)) * cosh (imag (x)),\n\t\t\t   cos (real (x)) * sinh (imag (x)));\n}\n\ntemplate <class FLOAT> complex<FLOAT>\nsinh (const complex<FLOAT>& x)\n{\n  return complex<FLOAT> (sinh (real (x)) * cos (imag (x)),\n\t\t\t   cosh (real (x)) * sin (imag (x)));\n}\n\n#include <iostream.h>\n\ntemplate <class FLOAT> istream&\noperator >> (istream& is, complex<FLOAT>& x)\n{\n  FLOAT re, im = 0;\n  char ch = 0;\n\n  if (is.ipfx0 ())\n    {\n      if (is.peek () == '(')\n\tis >> ch;\n      is >> re;\n      if (ch == '(')\n\t{\n\t  is >> ch;\n\t  if (ch == ',')\n\t    is >> im >> ch;\n\t}\n    }\n  is.isfx ();\n\n  if (ch != 0 && ch != ')')\n    is.setstate (ios::failbit);\n  else if (is.good ())\n    x = complex<FLOAT> (re, im);\n\n  return is;\n}\n\ntemplate <class FLOAT> ostream&\noperator << (ostream& os, const complex<FLOAT>& x)\n{\n  return os << '(' << real (x) << ',' << imag (x) << ')';\n}\n\n// The code below is adapted from f2c's libF77, and is subject to this\n// copyright:\n\n/****************************************************************\nCopyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories and Bellcore.\n\nPermission to use, copy, modify, and distribute this software\nand its documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the names of AT&T Bell Laboratories or\nBellcore or any of their entities not be used in advertising or\npublicity pertaining to distribution of the software without\nspecific, written prior permission.\n\nAT&T and Bellcore disclaim all warranties with regard to this\nsoftware, including all implied warranties of merchantability\nand fitness.  In no event shall AT&T or Bellcore be liable for\nany special, indirect or consequential damages or any damages\nwhatsoever resulting from loss of use, data or profits, whether\nin an action of contract, negligence or other tortious action,\narising out of or in connection with the use or performance of\nthis software.\n****************************************************************/\n\ntemplate <class FLOAT> complex<FLOAT>&\n__doadv (complex<FLOAT>* ths, const complex<FLOAT>& y)\n{\n  FLOAT ar = abs (y.re);\n  FLOAT ai = abs (y.im);\n  FLOAT nr, ni;\n  FLOAT t, d;\n  if (ar <= ai)\n    {\n      t = y.re / y.im;\n      d = y.im * (1 + t*t);\n      nr = (ths->re * t + ths->im) / d;\n      ni = (ths->im * t - ths->re) / d;\n    }\n  else\n    {\n      t = y.im / y.re;\n      d = y.re * (1 + t*t);\n      nr = (ths->re + ths->im * t) / d;\n      ni = (ths->im - ths->re * t) / d;\n    }\n  ths->re = nr;\n  ths->im = ni;\n  return *ths;\n}\n\ntemplate <class FLOAT> complex<FLOAT>\noperator / (const complex<FLOAT>& x, const complex<FLOAT>& y)\n{\n  FLOAT ar = abs (real (y));\n  FLOAT ai = abs (imag (y));\n  FLOAT nr, ni;\n  FLOAT t, d;\n  if (ar <= ai)\n    {\n      t = real (y) / imag (y);\n      d = imag (y) * (1 + t*t);\n      nr = (real (x) * t + imag (x)) / d;\n      ni = (imag (x) * t - real (x)) / d;\n    }\n  else\n    {\n      t = imag (y) / real (y);\n      d = real (y) * (1 + t*t);\n      nr = (real (x) + imag (x) * t) / d;\n      ni = (imag (x) - real (x) * t) / d;\n    }\n  return complex<FLOAT> (nr, ni);\n}\n\ntemplate <class FLOAT> complex<FLOAT>\noperator / (FLOAT x, const complex<FLOAT>& y)\n{\n  FLOAT ar = abs (real (y));\n  FLOAT ai = abs (imag (y));\n  FLOAT nr, ni;\n  FLOAT t, d;\n  if (ar <= ai)\n    {\n      t = real (y) / imag (y);\n      d = imag (y) * (1 + t*t);\n      nr = x * t / d;\n      ni = -x / d;\n    }\n  else\n    {\n      t = imag (y) / real (y);\n      d = real (y) * (1 + t*t);\n      nr = x / d;\n      ni = -x * t / d;\n    }\n  return complex<FLOAT> (nr, ni);\n}\n\ntemplate <class FLOAT> complex<FLOAT>\npow (const complex<FLOAT>& xin, int y)\n{\n  if (y == 0)\n    return complex<FLOAT> (1.0);\n  complex<FLOAT> r (1.0);\n  complex<FLOAT> x (xin);\n  if (y < 0)\n    {\n      y = -y;\n      x = 1/x;\n    }\n  for (;;)\n    {\n      if (y & 1)\n\tr *= x;\n      if (y >>= 1)\n\tx *= x;\n      else\n\treturn r;\n    }\n}\n\ntemplate <class FLOAT> complex<FLOAT>\nsqrt (const complex<FLOAT>& x)\n{\n  FLOAT r = abs (x);\n  FLOAT nr, ni;\n  if (r == 0.0)\n    nr = ni = r;\n  else if (real (x) > 0)\n    {\n      nr = sqrt (0.5 * (r + real (x)));\n      ni = imag (x) / nr / 2;\n    }\n  else\n    {\n      ni = sqrt (0.5 * (r - real (x)));\n      if (imag (x) < 0)\n\tni = - ni;\n      nr = imag (x) / ni / 2;\n    }\n  return complex<FLOAT> (nr, ni); \n}\n} // extern \"C++\"\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/complext.h",
    "content": "// The template and inlines for the -*- C++ -*- complex number classes.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the terms of\n// the GNU General Public License as published by the Free Software\n// Foundation; either version 2, or (at your option) any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files compiled\n// with a GNU compiler to produce an executable, this does not cause the\n// resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why the\n// executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification in the 27 May 1994\n// C++ working paper, ANSI document X3J16/94-0098.\n\n#ifndef __COMPLEXT__\n#define __COMPLEXT__\n\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n#include <cmath>\n\n#if ! defined (__GNUG__) && ! defined (__attribute__)\n#define __attribute__(foo) /* Ignore.  */\n#endif\n\nclass istream;\nclass ostream;\n\nextern \"C++\" {\ntemplate <class _FLT> class complex;\ntemplate <class _FLT> complex<_FLT>&\n  __doapl (complex<_FLT>* ths, const complex<_FLT>& r);\ntemplate <class _FLT> complex<_FLT>&\n  __doami (complex<_FLT>* ths, const complex<_FLT>& r);\ntemplate <class _FLT> complex<_FLT>&\n  __doaml (complex<_FLT>* ths, const complex<_FLT>& r);\ntemplate <class _FLT> complex<_FLT>&\n  __doadv (complex<_FLT>* ths, const complex<_FLT>& r);\n\ntemplate <class _FLT>\nclass complex\n{\npublic:\n  complex (_FLT r = 0, _FLT i = 0): re (r), im (i) { }\n  complex& operator += (const complex&);\n  complex& operator -= (const complex&);\n  complex& operator *= (const complex&);\n  complex& operator /= (const complex&);\n  _FLT real () const { return re; }\n  _FLT imag () const { return im; }\nprivate:\n  _FLT re, im;\n\n  friend complex& __doapl<> (complex *, const complex&);\n  friend complex& __doami<> (complex *, const complex&);\n  friend complex& __doaml<> (complex *, const complex&);\n  friend complex& __doadv<> (complex *, const complex&);\n};\n\n// Declare specializations.\nclass complex<float>;\nclass complex<double>;\nclass complex<long double>;\n\ntemplate <class _FLT>\ninline complex<_FLT>&\n__doapl (complex<_FLT>* ths, const complex<_FLT>& r)\n{\n  ths->re += r.re;\n  ths->im += r.im;\n  return *ths;\n}\ntemplate <class _FLT>\ninline complex<_FLT>&\ncomplex<_FLT>::operator += (const complex<_FLT>& r)\n{\n  return __doapl (this, r);\n}\n\ntemplate <class _FLT>\ninline complex<_FLT>&\n__doami (complex<_FLT>* ths, const complex<_FLT>& r)\n{\n  ths->re -= r.re;\n  ths->im -= r.im;\n  return *ths;\n}\ntemplate <class _FLT>\ninline complex<_FLT>&\ncomplex<_FLT>::operator -= (const complex<_FLT>& r)\n{\n  return __doami (this, r);\n}\n\ntemplate <class _FLT>\ninline complex<_FLT>&\n__doaml (complex<_FLT>* ths, const complex<_FLT>& r)\n{\n  _FLT f = ths->re * r.re - ths->im * r.im;\n  ths->im = ths->re * r.im + ths->im * r.re;\n  ths->re = f;\n  return *ths;\n}\ntemplate <class _FLT>\ninline complex<_FLT>&\ncomplex<_FLT>::operator *= (const complex<_FLT>& r)\n{\n  return __doaml (this, r);\n}\n\ntemplate <class _FLT>\ninline complex<_FLT>&\ncomplex<_FLT>::operator /= (const complex<_FLT>& r)\n{\n  return __doadv (this, r);\n}\n\ntemplate <class _FLT> inline _FLT\nimag (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\nimag (const complex<_FLT>& x)\n{\n  return x.imag ();\n}\n\ntemplate <class _FLT> inline _FLT\nreal (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\nreal (const complex<_FLT>& x)\n{\n  return x.real ();\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (real (x) + real (y), imag (x) + imag (y));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x, _FLT y)\n{\n  return complex<_FLT> (real (x) + y, imag (x));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (_FLT x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (_FLT x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (x + real (y), imag (y));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (real (x) - real (y), imag (x) - imag (y));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x, _FLT y)\n{\n  return complex<_FLT> (real (x) - y, imag (x));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (_FLT x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (_FLT x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (x - real (y), - imag (y));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (const complex<_FLT>& x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (real (x) * real (y) - imag (x) * imag (y),\n\t\t\t   real (x) * imag (y) + imag (x) * real (y));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (const complex<_FLT>& x, _FLT y)\n{\n  return complex<_FLT> (real (x) * y, imag (x) * y);\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (_FLT x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator * (_FLT x, const complex<_FLT>& y)\n{\n  return complex<_FLT> (x * real (y), x * imag (y));\n}\n\ntemplate <class _FLT> complex<_FLT>\noperator / (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> complex<_FLT>\noperator / (const complex<_FLT>& x, _FLT y)\n{\n  return complex<_FLT> (real (x) / y, imag (x) / y);\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator + (const complex<_FLT>& x)\n{\n  return x;\n}\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\noperator - (const complex<_FLT>& x)\n{\n  return complex<_FLT> (-real (x), -imag (x));\n}\n\ntemplate <class _FLT> inline bool\noperator == (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator == (const complex<_FLT>& x, const complex<_FLT>& y)\n{\n  return real (x) == real (y) && imag (x) == imag (y);\n}\n\ntemplate <class _FLT> inline bool\noperator == (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator == (const complex<_FLT>& x, _FLT y)\n{\n  return real (x) == y && imag (x) == 0;\n}\n\ntemplate <class _FLT> inline bool\noperator == (_FLT x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator == (_FLT x, const complex<_FLT>& y)\n{\n  return x == real (y) && imag (y) == 0;\n}\n\ntemplate <class _FLT> inline bool\noperator != (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator != (const complex<_FLT>& x, const complex<_FLT>& y)\n{\n  return real (x) != real (y) || imag (x) != imag (y);\n}\n\ntemplate <class _FLT> inline bool\noperator != (const complex<_FLT>& x, _FLT y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator != (const complex<_FLT>& x, _FLT y)\n{\n  return real (x) != y || imag (x) != 0;\n}\n\ntemplate <class _FLT> inline bool\noperator != (_FLT x, const complex<_FLT>& y) __attribute__ ((const));\n\ntemplate <class _FLT> inline bool\noperator != (_FLT x, const complex<_FLT>& y)\n{\n  return x != real (y) || imag (y) != 0;\n}\n\n// Some targets don't provide a prototype for hypot when -ansi.\nextern \"C\" double hypot (double, double) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\nabs (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\nabs (const complex<_FLT>& x)\n{\n  return hypot (real (x), imag (x));\n}\n\ntemplate <class _FLT> inline _FLT\narg (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\narg (const complex<_FLT>& x)\n{\n  return atan2 (imag (x), real (x));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\npolar (_FLT r, _FLT t) __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\npolar (_FLT r, _FLT t)\n{\n  return complex<_FLT> (r * cos (t), r * sin (t));\n}\n\ntemplate <class _FLT> inline complex<_FLT>\nconj (const complex<_FLT>& x)  __attribute__ ((const));\n\ntemplate <class _FLT> inline complex<_FLT>\nconj (const complex<_FLT>& x) \n{\n  return complex<_FLT> (real (x), -imag (x));\n}\n\ntemplate <class _FLT> inline _FLT\nnorm (const complex<_FLT>& x) __attribute__ ((const));\n\ntemplate <class _FLT> inline _FLT\nnorm (const complex<_FLT>& x)\n{\n  return real (x) * real (x) + imag (x) * imag (x);\n}\n\n// Declarations of templates in complext.ccI\n\ntemplate <class _FLT> complex<_FLT>\n  operator / (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  operator / (_FLT, const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  cos (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  cosh (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  exp (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  log (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  pow (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  pow (const complex<_FLT>&, _FLT) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  pow (const complex<_FLT>&, int) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  pow (_FLT, const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  sin (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  sinh (const complex<_FLT>&) __attribute__ ((const));\ntemplate <class _FLT> complex<_FLT>\n  sqrt (const complex<_FLT>&) __attribute__ ((const));\n\ntemplate <class _FLT> istream& operator >> (istream&, complex<_FLT>&);\ntemplate <class _FLT> ostream& operator << (ostream&, const complex<_FLT>&);\n} // extern \"C++\"\n\n// Specializations and such\n\n#include <std/fcomplex.h>\n#include <std/dcomplex.h>\n#include <std/ldcomplex.h>\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/dcomplex.h",
    "content": "// The -*- C++ -*- double_complex class.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification in the 27 May 1994\n// C++ working paper, ANSI document X3J16/94-0098.\n\n#ifndef __DCOMPLEX__\n#define __DCOMPLEX__\n\n#ifdef __GNUG__\n#pragma interface \"dcomplex\"\n#endif\n\nextern \"C++\" {\nclass complex<double>\n{\npublic:\n  complex (double r = 0, double i = 0): re (r), im (i) { }\n  complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { }\n  explicit complex (const complex<long double>& r);\n\n  complex& operator+= (const complex& r) { return __doapl (this, r); }\n  complex& operator-= (const complex& r) { return __doami (this, r); }\n  complex& operator*= (const complex& r) { return __doaml (this, r); }\n  complex& operator/= (const complex& r) { return __doadv (this, r); }\n\n  double real () const { return re; }\n  double imag () const { return im; }\nprivate:\n  double re, im;\n\n  friend complex& __doapl<> (complex *, const complex&);\n  friend complex& __doami<> (complex *, const complex&);\n  friend complex& __doaml<> (complex *, const complex&);\n  friend complex& __doadv<> (complex *, const complex&);\n\n#ifndef __STRICT_ANSI__\n  friend inline complex operator + (const complex& x, double y)\n    { return operator+<> (x, y); }\n  friend inline complex operator + (double x, const complex& y)\n    { return operator+<> (x, y); }\n  friend inline complex operator - (const complex& x, double y)\n    { return operator-<> (x, y); }\n  friend inline complex operator - (double x, const complex& y)\n    { return operator-<> (x, y); }\n  friend inline complex operator * (const complex& x, double y)\n    { return operator*<> (x, y); }\n  friend inline complex operator * (double x, const complex& y)\n    { return operator*<> (x, y); }\n  friend inline complex operator / (const complex& x, double y)\n    { return operator/<> (x, y); }\n  friend inline complex operator / (double x, const complex& y)\n    { return operator/<> (x, y); }\n  friend inline bool operator == (const complex& x, double y)\n    { return operator==<> (x, y); }\n  friend inline bool operator == (double x, const complex& y)\n    { return operator==<> (x, y); }\n  friend inline bool operator != (const complex& x, double y)\n    { return operator!=<> (x, y); }\n  friend inline bool operator != (double x, const complex& y)\n    { return operator!=<> (x, y); }\n#endif /* __STRICT_ANSI__ */\n};\n\ninline complex<float>::complex (const complex<double>& r)\n: re (r.real ()), im (r.imag ())\n{ }\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/fcomplex.h",
    "content": "// The -*- C++ -*- float_complex class.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification in the 27 May 1994\n// C++ working paper, ANSI document X3J16/94-0098.\n\n#ifndef __FCOMPLEX__\n#define __FCOMPLEX__\n\n#ifdef __GNUG__\n#pragma interface \"fcomplex\"\n#endif\n\nextern \"C++\" {\nclass complex<float>\n{\npublic:\n  complex (float r = 0, float i = 0): re (r), im (i) { }\n  explicit complex (const complex<double>& r);\n  explicit complex (const complex<long double>& r);\n\n  complex& operator+= (const complex& r) { return __doapl (this, r); }\n  complex& operator-= (const complex& r) { return __doami (this, r); }\n  complex& operator*= (const complex& r) { return __doaml (this, r); }\n  complex& operator/= (const complex& r) { return __doadv (this, r); }\n\n  float real () const { return re; }\n  float imag () const { return im; }\nprivate:\n  float re, im;\n\n  friend complex& __doapl<> (complex *, const complex&);\n  friend complex& __doami<> (complex *, const complex&);\n  friend complex& __doaml<> (complex *, const complex&);\n  friend complex& __doadv<> (complex *, const complex&);\n\n#ifndef __STRICT_ANSI__\n  friend inline complex operator + (const complex& x, float y)\n    { return operator+<> (x, y); }\n  friend inline complex operator + (float x, const complex& y)\n    { return operator+<> (x, y); }\n  friend inline complex operator - (const complex& x, float y)\n    { return operator-<> (x, y); }\n  friend inline complex operator - (float x, const complex& y)\n    { return operator-<> (x, y); }\n  friend inline complex operator * (const complex& x, float y)\n    { return operator*<> (x, y); }\n  friend inline complex operator * (float x, const complex& y)\n    { return operator*<> (x, y); }\n  friend inline complex operator / (const complex& x, float y)\n    { return operator/<> (x, y); }\n  friend inline complex operator / (float x, const complex& y)\n    { return operator/<> (x, y); }\n  friend inline bool operator == (const complex& x, float y)\n    { return operator==<> (x, y); }\n  friend inline bool operator == (float x, const complex& y)\n    { return operator==<> (x, y); }\n  friend inline bool operator != (const complex& x, float y)\n    { return operator!=<> (x, y); }\n  friend inline bool operator != (float x, const complex& y)\n    { return operator!=<> (x, y); }\n#endif /* __STRICT_ANSI__ */\n};\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/ldcomplex.h",
    "content": "// The -*- C++ -*- long_double_complex class.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification in the 27 May 1994\n// C++ working paper, ANSI document X3J16/94-0098.\n\n#ifndef __LDCOMPLEX__\n#define __LDCOMPLEX__\n\n#ifdef __GNUG__\n#pragma interface \"ldcomplex\"\n#endif\n\nextern \"C++\" {\nclass complex<long double>\n{\npublic:\n  complex (long double r = 0, long double i = 0): re (r), im (i) { }\n  complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { }\n  complex (const complex<double>& r): re (r.real ()), im (r.imag ()) { }\n\n  complex& operator+= (const complex& r) { return __doapl (this, r); }\n  complex& operator-= (const complex& r) { return __doami (this, r); }\n  complex& operator*= (const complex& r) { return __doaml (this, r); }\n  complex& operator/= (const complex& r) { return __doadv (this, r); }\n\n  long double real () const { return re; }\n  long double imag () const { return im; }\nprivate:\n  long double re, im;\n\n  friend complex& __doapl<> (complex *, const complex&);\n  friend complex& __doami<> (complex *, const complex&);\n  friend complex& __doaml<> (complex *, const complex&);\n  friend complex& __doadv<> (complex *, const complex&);\n\n#ifndef __STRICT_ANSI__\n  friend inline complex operator + (const complex& x, long double y)\n    { return operator+<> (x, y); }\n  friend inline complex operator + (long double x, const complex& y)\n    { return operator+<> (x, y); }\n  friend inline complex operator - (const complex& x, long double y)\n    { return operator-<> (x, y); }\n  friend inline complex operator - (long double x, const complex& y)\n    { return operator-<> (x, y); }\n  friend inline complex operator * (const complex& x, long double y)\n    { return operator*<> (x, y); }\n  friend inline complex operator * (long double x, const complex& y)\n    { return operator*<> (x, y); }\n  friend inline complex operator / (const complex& x, long double y)\n    { return operator/<> (x, y); }\n  friend inline complex operator / (long double x, const complex& y)\n    { return operator/<> (x, y); }\n  friend inline bool operator == (const complex& x, long double y)\n    { return operator==<> (x, y); }\n  friend inline bool operator == (long double x, const complex& y)\n    { return operator==<> (x, y); }\n  friend inline bool operator != (const complex& x, long double y)\n    { return operator!=<> (x, y); }\n  friend inline bool operator != (long double x, const complex& y)\n    { return operator!=<> (x, y); }\n#endif /* __STRICT_ANSI__ */\n};\n\ninline complex<float>::complex (const complex<long double>& r)\n: re (r.real ()), im (r.imag ())\n{ }\n\ninline complex<double>::complex (const complex<long double>& r)\n: re (r.real ()), im (r.imag ())\n{ }\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/std/straits.h",
    "content": "// Character traits template for the -*- C++ -*- string classes.\n// Copyright (C) 1994 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Jason Merrill based upon the specification by Takanori Adachi\n// in ANSI X3J16/94-0013R2.\n\n#ifndef __STRING_CHAR_TRAITS__\n#define __STRING_CHAR_TRAITS__\n\n#ifdef __GNUG__\n// For string_char_traits <char>\n#pragma interface \"std/straits.h\"\n#endif\n\n#include <cstddef>\n\nextern \"C++\" {\ntemplate <class charT>\nstruct string_char_traits {\n  typedef charT char_type; // for users to acquire the basic character type\n\n  // constraints\n\n  static void assign (char_type& c1, const char_type& c2)\n    { c1 = c2; }\n  static bool eq (const char_type& c1, const char_type& c2)\n    { return (c1 == c2); }\n  static bool ne (const char_type& c1, const char_type& c2)\n    { return !(c1 == c2); }\n  static bool lt (const char_type& c1, const char_type& c2)\n    { return (c1 < c2); }\n  static char_type eos () { return char_type(); } // the null character\n  static bool is_del(char_type a) { return 0; }\n  // characteristic function for delimiters of charT\n  \n  // speed-up functions\n\n  static int compare (const char_type* s1, const char_type* s2, size_t n)\n    {\n      size_t i;\n      for (i = 0; i < n; ++i)\n\tif (ne (s1[i], s2[i]))\n\t  return lt (s1[i], s2[i]) ? -1 : 1;\n\n      return 0;\n    }\n    \n  static size_t length (const char_type* s)\n    {\n      size_t l = 0;\n      while (ne (*s++, eos ()))\n\t++l;\n      return l;\n    }\n\n  static char_type* copy (char_type* s1, const char_type* s2, size_t n)\n    {\n      for (; n--; )\n\tassign (s1[n], s2[n]);\n      return s1;\n    }\n\n  static char_type* move (char_type* s1, const char_type* s2, size_t n)\n    {\n      char_type a[n];\n      size_t i;\n      for (i = 0; i < n; ++i)\n\tassign (a[i], s2[i]);\n      for (i = 0; i < n; ++i)\n\tassign (s1[i], a[i]);\n      return s1;\n    }\n\n  static char_type* set (char_type* s1, const char_type& c, size_t n)\n    {\n      for (; n--; )\n\tassign (s1[n], c);\n      return s1;\n    }\n};\n\nclass istream;\nclass ostream;\n#include <cctype>\n#include <cstring>\n\nstruct string_char_traits <char> {\n  typedef char char_type;\n\n  static void assign (char_type& c1, const char_type& c2)\n    { c1 = c2; }\n  static bool eq (const char_type & c1, const char_type& c2)\n    { return (c1 == c2); }\n  static bool ne (const char_type& c1, const char_type& c2)\n    { return (c1 != c2); }\n  static bool lt (const char_type& c1, const char_type& c2)\n    { return (c1 < c2); }\n  static char_type eos () { return 0; }\n  static bool is_del(char_type a) { return isspace(a); }\n\n  static int compare (const char_type* s1, const char_type* s2, size_t n)\n    { return memcmp (s1, s2, n); }\n  static size_t length (const char_type* s)\n    { return strlen (s); }\n  static char_type* copy (char_type* s1, const char_type* s2, size_t n)\n    { return (char_type*) memcpy (s1, s2, n); }\n  static char_type* move (char_type* s1, const char_type* s2, size_t n)\n    { return (char_type*) memmove (s1, s2, n); }\n  static char_type* set (char_type* s1, const char_type& c, size_t n)\n    { return (char_type*) memset (s1, c, n); }\n};\n\n#if 0\n#include <cwctype>\nstruct string_char_traits <wchar_t> {\n  typedef wchar_t char_type;\n\n  static void assign (char_type& c1, const char_type& c2)\n    { c1 = c2; }\n  static bool eq (const char_type & c1, const char_type& c2)\n    { return (c1 == c2); }\n  static bool ne (const char_type& c1, const char_type& c2)\n    { return (c1 != c2); }\n  static bool lt (const char_type& c1, const char_type& c2)\n    { return (c1 < c2); }\n  static char_type eos () { return 0; }\n  static bool is_del(char_type a) { return iswspace(a); }\n\n  static int compare (const char_type* s1, const char_type* s2, size_t n)\n    { return wmemcmp (s1, s2, n); }\n  static size_t length (const char_type* s)\n    { return wcslen (s); }\n  static char_type* copy (char_type* s1, const char_type* s2, size_t n)\n    { return wmemcpy (s1, s2, n); }\n  static char_type* set (char_type* s1, const char_type& c, size_t n)\n    { return wmemset (s1, c, n); }\n};\n#endif\n} // extern \"C++\"\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stdexcept",
    "content": "// Methods for Exception Support for -*- C++ -*-\n// Copyright (C) 1994, 1995, 1997 Free Software Foundation\n\n// This file is part of the GNU ANSI C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 2, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING.  If not, write to the Free\n// Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n// As a special exception, if you link this library with files\n// compiled with a GNU compiler to produce an executable, this does not cause\n// the resulting executable to be covered by the GNU General Public License.\n// This exception does not however invalidate any other reasons why\n// the executable file might be covered by the GNU General Public License.\n\n// Written by Mike Stump based upon the specification in the 20 September 1994\n// C++ working paper, ANSI document X3J16/94-0158.\n\n#ifndef __STDEXCEPT__\n#define __STDEXCEPT__\n\n#ifdef __GNUG__\n#pragma interface \"stdexcept\"\n#endif\n\n#include <exception>\n#include <string>\n\nextern \"C++\" {\n\n#ifdef __HONOR_STD\nnamespace std {\n#endif\n\nclass logic_error : public exception {\n  string _what;\npublic:\n  logic_error(const string& what_arg): _what (what_arg) { }\n  virtual const char* what () const { return _what.c_str (); }\n};\n\nclass domain_error : public logic_error {\npublic:\n  domain_error (const string& what_arg): logic_error (what_arg) { }\n};\n\nclass invalid_argument : public logic_error {\npublic:\n  invalid_argument (const string& what_arg): logic_error (what_arg) { }\n};\n\nclass length_error : public logic_error {\npublic:\n  length_error (const string& what_arg): logic_error (what_arg) { }\n};\n\nclass out_of_range : public logic_error {\npublic:\n  out_of_range (const string& what_arg): logic_error (what_arg) { }\n};\n\nclass runtime_error : public exception {\n  string _what;\npublic:\n  runtime_error(const string& what_arg): _what (what_arg) { }\n  virtual const char* what () const { return _what.c_str (); }\nprotected:\n  runtime_error(): exception () { }\n};\n\nclass range_error : public runtime_error {\npublic:\n  range_error (const string& what_arg): runtime_error (what_arg) { }\n};\n\nclass overflow_error : public runtime_error {\npublic:\n  overflow_error (const string& what_arg): runtime_error (what_arg) { }\n};\n\nclass underflow_error : public runtime_error {\npublic:\n  underflow_error (const string& what_arg): runtime_error (what_arg) { }\n};\n\n#ifdef __HONOR_STD\n} // namespace std\n#endif\n \n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stdiostream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* Written by Per Bothner (bothner@cygnus.com). */\n\n#ifndef _STDIOSTREAM_H\n#define _STDIOSTREAM_H\n\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n#include <iostream.h>\n#include <stdio.h>\n\nextern \"C++\" {\nclass stdiobuf : public filebuf {\n  protected:\n    FILE *_file;\n  public:\n    FILE* stdiofile() const { return _file; }\n    stdiobuf(FILE *);\n    ~stdiobuf();\n    int buffered () const { return _flags & _IO_UNBUFFERED ? 0 : 1; }\n    void buffered (int);\n    virtual streamsize sys_read(char*, streamsize);\n    virtual streampos sys_seek(streamoff, _seek_dir);\n    virtual streamsize sys_write(const char*, streamsize);\n    virtual int sys_close();\n    virtual int sync();\n    virtual int overflow(int c = EOF);\n    streamsize xsputn(const char* s, streamsize n);\n};\n\nclass istdiostream : public istream\n{\nprivate:\n  stdiobuf _file;\npublic:\n  istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }\n  stdiobuf* rdbuf()/* const */ { return &_file; }\n  int buffered () const { return _file.buffered (); }\n  void buffered (int _i) { _file.buffered (_i); }\n};\n\nclass ostdiostream : public ostream\n{\nprivate:\n  stdiobuf _file;\npublic:\n  ostdiostream (FILE* __f) : ostream(), _file(__f) { init(&_file); }\n  stdiobuf* rdbuf() /* const */ { return &_file; }\n  int buffered () const { return _file.buffered (); }\n  void buffered (int _i) { _file.buffered (_i); }\n};\n} // extern \"C++\"\n\n#endif /* !_STDIOSTREAM_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl.h",
    "content": "// -*- C++ -*- compatibility header.\n// This file is part of the GNU ANSI C++ Library.\n\n#include <algorithm>\n#include <deque>\n#include <functional>\n#include <iterator>\n#include <list>\n#include <map>\n#include <memory>\n#include <numeric>\n#include <set>\n#include <stack>\n#include <utility>\n#include <vector>\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_algo.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ALGO_H\n#define __SGI_STL_INTERNAL_ALGO_H\n\n#include <stl_heap.h>\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1209\n#endif\n\ntemplate <class T>\ninline const T& __median(const T& a, const T& b, const T& c) {\n  if (a < b)\n    if (b < c)\n      return b;\n    else if (a < c)\n      return c;\n    else\n      return a;\n  else if (a < c)\n    return a;\n  else if (b < c)\n    return c;\n  else\n    return b;\n}\n\ntemplate <class T, class Compare>\ninline const T& __median(const T& a, const T& b, const T& c, Compare comp) {\n  if (comp(a, b))\n    if (comp(b, c))\n      return b;\n    else if (comp(a, c))\n      return c;\n    else\n      return a;\n  else if (comp(a, c))\n    return a;\n  else if (comp(b, c))\n    return c;\n  else\n    return b;\n}\n\ntemplate <class InputIterator, class Function>\nFunction for_each(InputIterator first, InputIterator last, Function f) {\n  for ( ; first != last; ++first)\n    f(*first);\n  return f;\n}\n\ntemplate <class InputIterator, class T>\nInputIterator find(InputIterator first, InputIterator last, const T& value) {\n  while (first != last && *first != value) ++first;\n  return first;\n}\n\ntemplate <class InputIterator, class Predicate>\nInputIterator find_if(InputIterator first, InputIterator last,\n                      Predicate pred) {\n  while (first != last && !pred(*first)) ++first;\n  return first;\n}\n\ntemplate <class ForwardIterator>\nForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last) {\n  if (first == last) return last;\n  ForwardIterator next = first;\n  while(++next != last) {\n    if (*first == *next) return first;\n    first = next;\n  }\n  return last;\n}\n\ntemplate <class ForwardIterator, class BinaryPredicate>\nForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last,\n                              BinaryPredicate binary_pred) {\n  if (first == last) return last;\n  ForwardIterator next = first;\n  while(++next != last) {\n    if (binary_pred(*first, *next)) return first;\n    first = next;\n  }\n  return last;\n}\n\ntemplate <class InputIterator, class T, class Size>\nvoid count(InputIterator first, InputIterator last, const T& value,\n           Size& n) {\n  for ( ; first != last; ++first)\n    if (*first == value)\n      ++n;\n}\n\ntemplate <class InputIterator, class Predicate, class Size>\nvoid count_if(InputIterator first, InputIterator last, Predicate pred,\n              Size& n) {\n  for ( ; first != last; ++first)\n    if (pred(*first))\n      ++n;\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class InputIterator, class T>\ntypename iterator_traits<InputIterator>::difference_type\ncount(InputIterator first, InputIterator last, const T& value) {\n  typename iterator_traits<InputIterator>::difference_type n = 0;\n  for ( ; first != last; ++first)\n    if (*first == value)\n      ++n;\n  return n;\n}\n\ntemplate <class InputIterator, class Predicate>\ntypename iterator_traits<InputIterator>::difference_type\ncount_if(InputIterator first, InputIterator last, Predicate pred) {\n  typename iterator_traits<InputIterator>::difference_type n = 0;\n  for ( ; first != last; ++first)\n    if (pred(*first))\n      ++n;\n  return n;\n}\n\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class ForwardIterator1, class ForwardIterator2, class Distance1,\n          class Distance2>\nForwardIterator1 __search(ForwardIterator1 first1, ForwardIterator1 last1,\n                          ForwardIterator2 first2, ForwardIterator2 last2,\n                          Distance1*, Distance2*) {\n  Distance1 d1 = 0;\n  distance(first1, last1, d1);\n  Distance2 d2 = 0;\n  distance(first2, last2, d2);\n\n  if (d1 < d2) return last1;\n\n  ForwardIterator1 current1 = first1;\n  ForwardIterator2 current2 = first2;\n\n  while (current2 != last2) \n    if (*current1 == *current2) {\n      ++current1;\n      ++current2;\n    }\n    else {\n      if (d1 == d2)\n        return last1;\n      else {\n        current1 = ++first1;\n        current2 = first2;\n        --d1;\n      }\n    }\n  return first1;\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2>\ninline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1,\n                               ForwardIterator2 first2, ForwardIterator2 last2)\n{\n  return __search(first1, last1, first2, last2, distance_type(first1),\n                  distance_type(first2));\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2,\n          class BinaryPredicate, class Distance1, class Distance2>\nForwardIterator1 __search(ForwardIterator1 first1, ForwardIterator1 last1,\n                          ForwardIterator2 first2, ForwardIterator2 last2,\n                          BinaryPredicate binary_pred, Distance1*, Distance2*) {\n  Distance1 d1 = 0;\n  distance(first1, last1, d1);\n  Distance2 d2 = 0;\n  distance(first2, last2, d2);\n\n  if (d1 < d2) return last1;\n\n  ForwardIterator1 current1 = first1;\n  ForwardIterator2 current2 = first2;\n\n  while (current2 != last2)\n    if (binary_pred(*current1, *current2)) {\n      ++current1;\n      ++current2;\n    }\n    else {\n      if (d1 == d2)\n        return last1;\n      else {\n        current1 = ++first1;\n        current2 = first2;\n        --d1;\n      }\n    }\n  return first1;\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2,\n          class BinaryPredicate>\ninline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1,\n                               ForwardIterator2 first2, ForwardIterator2 last2,\n                               BinaryPredicate binary_pred) {\n  return __search(first1, last1, first2, last2, binary_pred,\n                  distance_type(first1), distance_type(first2));\n}\n\ntemplate <class ForwardIterator, class Integer, class T>\nForwardIterator search_n(ForwardIterator first, ForwardIterator last,\n                         Integer count, const T& value) {\n  if (count <= 0)\n    return first;\n  else {\n    first = find(first, last, value);\n    while (first != last) {\n      Integer n = count - 1;\n      ForwardIterator i = first;\n      ++i;\n      while (i != last && n != 0 && *i == value) {\n        ++i;\n        --n;\n      }\n      if (n == 0)\n        return first;\n      else\n        first = find(i, last, value);\n    }\n    return last;\n  }\n}\n\ntemplate <class ForwardIterator, class Integer, class T, class BinaryPredicate>\nForwardIterator search_n(ForwardIterator first, ForwardIterator last,\n                         Integer count, const T& value,\n                         BinaryPredicate binary_pred) {\n  if (count <= 0)\n    return first;\n  else {\n    while (first != last) {\n      if (binary_pred(*first, value)) break;\n      ++first;\n    }\n    while (first != last) {\n      Integer n = count - 1;\n      ForwardIterator i = first;\n      ++i;\n      while (i != last && n != 0 && binary_pred(*i, value)) {\n        ++i;\n        --n;\n      }\n      if (n == 0)\n        return first;\n      else {\n        while (i != last) {\n          if (binary_pred(*i, value)) break;\n          ++i;\n        }\n        first = i;\n      }\n    }\n    return last;\n  }\n} \n\ntemplate <class ForwardIterator1, class ForwardIterator2>\nForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1,\n                             ForwardIterator2 first2) {\n  for ( ; first1 != last1; ++first1, ++first2)\n    iter_swap(first1, first2);\n  return first2;\n}\n\ntemplate <class InputIterator, class OutputIterator, class UnaryOperation>\nOutputIterator transform(InputIterator first, InputIterator last,\n                         OutputIterator result, UnaryOperation op) {\n  for ( ; first != last; ++first, ++result)\n    *result = op(*first);\n  return result;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator,\n          class BinaryOperation>\nOutputIterator transform(InputIterator1 first1, InputIterator1 last1,\n                         InputIterator2 first2, OutputIterator result,\n                         BinaryOperation binary_op) {\n  for ( ; first1 != last1; ++first1, ++first2, ++result)\n    *result = binary_op(*first1, *first2);\n  return result;\n}\n\ntemplate <class ForwardIterator, class T>\nvoid replace(ForwardIterator first, ForwardIterator last, const T& old_value,\n             const T& new_value) {\n  for ( ; first != last; ++first)\n    if (*first == old_value) *first = new_value;\n}\n\ntemplate <class ForwardIterator, class Predicate, class T>\nvoid replace_if(ForwardIterator first, ForwardIterator last, Predicate pred,\n                const T& new_value) {\n  for ( ; first != last; ++first)\n    if (pred(*first)) *first = new_value;\n}\n\ntemplate <class InputIterator, class OutputIterator, class T>\nOutputIterator replace_copy(InputIterator first, InputIterator last,\n                            OutputIterator result, const T& old_value,\n                            const T& new_value) {\n  for ( ; first != last; ++first, ++result)\n    *result = *first == old_value ? new_value : *first;\n  return result;\n}\n\ntemplate <class Iterator, class OutputIterator, class Predicate, class T>\nOutputIterator replace_copy_if(Iterator first, Iterator last,\n                               OutputIterator result, Predicate pred,\n                               const T& new_value) {\n  for ( ; first != last; ++first, ++result)\n    *result = pred(*first) ? new_value : *first;\n  return result;\n}\n\ntemplate <class ForwardIterator, class Generator>\nvoid generate(ForwardIterator first, ForwardIterator last, Generator gen) {\n  for ( ; first != last; ++first)\n    *first = gen();\n}\n\ntemplate <class OutputIterator, class Size, class Generator>\nOutputIterator generate_n(OutputIterator first, Size n, Generator gen) {\n  for ( ; n > 0; --n, ++first)\n    *first = gen();\n  return first;\n}\n\ntemplate <class InputIterator, class OutputIterator, class T>\nOutputIterator remove_copy(InputIterator first, InputIterator last,\n                           OutputIterator result, const T& value) {\n  for ( ; first != last; ++first)\n    if (*first != value) {\n      *result = *first;\n      ++result;\n    }\n  return result;\n}\n\ntemplate <class InputIterator, class OutputIterator, class Predicate>\nOutputIterator remove_copy_if(InputIterator first, InputIterator last,\n                              OutputIterator result, Predicate pred) {\n  for ( ; first != last; ++first)\n    if (!pred(*first)) {\n      *result = *first;\n      ++result;\n    }\n  return result;\n}\n\ntemplate <class ForwardIterator, class T>\nForwardIterator remove(ForwardIterator first, ForwardIterator last,\n                       const T& value) {\n  first = find(first, last, value);\n  ForwardIterator next = first;\n  return first == last ? first : remove_copy(++next, last, first, value);\n}\n\ntemplate <class ForwardIterator, class Predicate>\nForwardIterator remove_if(ForwardIterator first, ForwardIterator last,\n                          Predicate pred) {\n  first = find_if(first, last, pred);\n  ForwardIterator next = first;\n  return first == last ? first : remove_copy_if(++next, last, first, pred);\n}\n\ntemplate <class InputIterator, class ForwardIterator>\nForwardIterator __unique_copy(InputIterator first, InputIterator last,\n                              ForwardIterator result, forward_iterator_tag) {\n  *result = *first;\n  while (++first != last)\n    if (*result != *first) *++result = *first;\n  return ++result;\n}\n\n\ntemplate <class InputIterator, class OutputIterator, class T>\nOutputIterator __unique_copy(InputIterator first, InputIterator last,\n                             OutputIterator result, T*) {\n  T value = *first;\n  *result = value;\n  while (++first != last)\n    if (value != *first) {\n      value = *first;\n      *++result = value;\n    }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator>\ninline OutputIterator __unique_copy(InputIterator first, InputIterator last,\n                                    OutputIterator result, \n                                    output_iterator_tag) {\n  return __unique_copy(first, last, result, value_type(first));\n}\n\ntemplate <class InputIterator, class OutputIterator>\ninline OutputIterator unique_copy(InputIterator first, InputIterator last,\n                                  OutputIterator result) {\n  if (first == last) return result;\n  return __unique_copy(first, last, result, iterator_category(result));\n}\ntemplate <class InputIterator, class ForwardIterator, class BinaryPredicate>\nForwardIterator __unique_copy(InputIterator first, InputIterator last,\n                              ForwardIterator result, \n                              BinaryPredicate binary_pred,\n                              forward_iterator_tag) {\n  *result = *first;\n  while (++first != last)\n    if (!binary_pred(*result, *first)) *++result = *first;\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator, class BinaryPredicate,\n          class T>\nOutputIterator __unique_copy(InputIterator first, InputIterator last,\n                             OutputIterator result,\n                             BinaryPredicate binary_pred, T*) {\n  T value = *first;\n  *result = value;\n  while (++first != last)\n    if (!binary_pred(value, *first)) {\n      value = *first;\n      *++result = value;\n    }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator, class BinaryPredicate>\ninline OutputIterator __unique_copy(InputIterator first, InputIterator last,\n                                    OutputIterator result,\n                                    BinaryPredicate binary_pred,\n                                    output_iterator_tag) {\n  return __unique_copy(first, last, result, binary_pred, value_type(first));\n}\n\ntemplate <class InputIterator, class OutputIterator, class BinaryPredicate>\ninline OutputIterator unique_copy(InputIterator first, InputIterator last,\n                                  OutputIterator result,\n                                  BinaryPredicate binary_pred) {\n  if (first == last) return result;\n  return __unique_copy(first, last, result, binary_pred,\n                       iterator_category(result));\n}\n\ntemplate <class ForwardIterator>\nForwardIterator unique(ForwardIterator first, ForwardIterator last) {\n  first = adjacent_find(first, last);\n  return unique_copy(first, last, first);\n}\n\ntemplate <class ForwardIterator, class BinaryPredicate>\nForwardIterator unique(ForwardIterator first, ForwardIterator last,\n                       BinaryPredicate binary_pred) {\n  first = adjacent_find(first, last, binary_pred);\n  return unique_copy(first, last, first, binary_pred);\n}\n\ntemplate <class BidirectionalIterator>\nvoid __reverse(BidirectionalIterator first, BidirectionalIterator last, \n               bidirectional_iterator_tag) {\n  while (true)\n    if (first == last || first == --last)\n      return;\n    else\n      iter_swap(first++, last);\n}\n\ntemplate <class RandomAccessIterator>\nvoid __reverse(RandomAccessIterator first, RandomAccessIterator last,\n               random_access_iterator_tag) {\n  while (first < last) iter_swap(first++, --last);\n}\n\ntemplate <class BidirectionalIterator>\ninline void reverse(BidirectionalIterator first, BidirectionalIterator last) {\n  __reverse(first, last, iterator_category(first));\n}\n\ntemplate <class BidirectionalIterator, class OutputIterator>\nOutputIterator reverse_copy(BidirectionalIterator first,\n                            BidirectionalIterator last,\n                            OutputIterator result) {\n  while (first != last) {\n    --last;\n    *result = *last;\n    ++result;\n  }\n  return result;\n}\n\ntemplate <class ForwardIterator, class Distance>\nvoid __rotate(ForwardIterator first, ForwardIterator middle,\n              ForwardIterator last, Distance*, forward_iterator_tag) {\n  for (ForwardIterator i = middle; ;) {\n    iter_swap(first, i);\n    ++first;\n    ++i;\n    if (first == middle) {\n      if (i == last) return;\n      middle = i;\n    }\n    else if (i == last)\n      i = middle;\n  }\n}\n\ntemplate <class BidirectionalIterator, class Distance>\nvoid __rotate(BidirectionalIterator first, BidirectionalIterator middle,\n              BidirectionalIterator last, Distance*,\n              bidirectional_iterator_tag) {\n  reverse(first, middle);\n  reverse(middle, last);\n  reverse(first, last);\n}\n\ntemplate <class EuclideanRingElement>\nEuclideanRingElement __gcd(EuclideanRingElement m, EuclideanRingElement n)\n{\n  while (n != 0) {\n    EuclideanRingElement t = m % n;\n    m = n;\n    n = t;\n  }\n  return m;\n}\n\ntemplate <class RandomAccessIterator, class Distance, class T>\nvoid __rotate_cycle(RandomAccessIterator first, RandomAccessIterator last,\n                    RandomAccessIterator initial, Distance shift, T*) {\n  T value = *initial;\n  RandomAccessIterator ptr1 = initial;\n  RandomAccessIterator ptr2 = ptr1 + shift;\n  while (ptr2 != initial) {\n    *ptr1 = *ptr2;\n    ptr1 = ptr2;\n    if (last - ptr2 > shift)\n      ptr2 += shift;\n    else\n      ptr2 = first + (shift - (last - ptr2));\n  }\n  *ptr1 = value;\n}\n\ntemplate <class RandomAccessIterator, class Distance>\nvoid __rotate(RandomAccessIterator first, RandomAccessIterator middle,\n              RandomAccessIterator last, Distance*,\n              random_access_iterator_tag) {\n  Distance n = __gcd(last - first, middle - first);\n  while (n--)\n    __rotate_cycle(first, last, first + n, middle - first,\n                   value_type(first));\n}\n\ntemplate <class ForwardIterator>\ninline void rotate(ForwardIterator first, ForwardIterator middle,\n                   ForwardIterator last) {\n  if (first == middle || middle == last) return;\n  __rotate(first, middle, last, distance_type(first),\n           iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class OutputIterator>\nOutputIterator rotate_copy(ForwardIterator first, ForwardIterator middle,\n                           ForwardIterator last, OutputIterator result) {\n  return copy(first, middle, copy(middle, last, result));\n}\n\ntemplate <class RandomAccessIterator, class Distance>\nvoid __random_shuffle(RandomAccessIterator first, RandomAccessIterator last,\n                      Distance*) {\n  if (first == last) return;\n  for (RandomAccessIterator i = first + 1; i != last; ++i) \n#ifdef __STL_NO_DRAND48\n    iter_swap(i, first + Distance(rand() % ((i - first) + 1)));\n#else\n  iter_swap(i, first + Distance(lrand48() % ((i - first) + 1)));\n#endif\n}\n\ntemplate <class RandomAccessIterator>\ninline void random_shuffle(RandomAccessIterator first,\n                           RandomAccessIterator last) {\n  __random_shuffle(first, last, distance_type(first));\n}\n\ntemplate <class RandomAccessIterator, class RandomNumberGenerator>\nvoid random_shuffle(RandomAccessIterator first, RandomAccessIterator last,\n                    RandomNumberGenerator& rand) {\n  if (first == last) return;\n  for (RandomAccessIterator i = first + 1; i != last; ++i)\n    iter_swap(i, first + rand((i - first) + 1));\n}\n\ntemplate <class ForwardIterator, class OutputIterator, class Distance>\nOutputIterator random_sample_n(ForwardIterator first, ForwardIterator last,\n                               OutputIterator out, const Distance n)\n{\n  Distance remaining = 0;\n  distance(first, last, remaining);\n  Distance m = min(n, remaining);\n\n  while (m > 0) {\n#ifdef __STL_NO_DRAND48\n    if (rand() % remaining < m) {\n#else\n    if (lrand48() % remaining < m) {\n#endif\n      *out = *first;\n      ++out;\n      --m;\n    }\n\n    --remaining;\n    ++first;\n  }\n  return out;\n}\n\ntemplate <class ForwardIterator, class OutputIterator, class Distance,\n          class RandomNumberGenerator>\nOutputIterator random_sample_n(ForwardIterator first, ForwardIterator last,\n                               OutputIterator out, const Distance n,\n                               RandomNumberGenerator& rand)\n{\n  Distance remaining = 0;\n  distance(first, last, remaining);\n  Distance m = min(n, remaining);\n\n  while (m > 0) {\n    if (rand(remaining) < m) {\n      *out = *first;\n      ++out;\n      --m;\n    }\n\n    --remaining;\n    ++first;\n  }\n  return out;\n}\n\ntemplate <class InputIterator, class RandomAccessIterator, class Distance>\nRandomAccessIterator __random_sample(InputIterator first, InputIterator last,\n                                     RandomAccessIterator out,\n                                     const Distance n)\n{\n  Distance m = 0;\n  Distance t = n;\n  for ( ; first != last && m < n; ++m, ++first) \n    out[m] = *first;\n\n  while (first != last) {\n    ++t;\n#ifdef __STL_NO_DRAND48\n    Distance M = rand() % t;\n#else\n    Distance M = lrand48() % t;\n#endif\n    if (M < n)\n      out[M] = *first;\n    ++first;\n  }\n\n  return out + m;\n}\n\ntemplate <class InputIterator, class RandomAccessIterator,\n          class RandomNumberGenerator, class Distance>\nRandomAccessIterator __random_sample(InputIterator first, InputIterator last,\n                                     RandomAccessIterator out,\n                                     RandomNumberGenerator& rand,\n                                     const Distance n)\n{\n  Distance m = 0;\n  Distance t = n;\n  for ( ; first != last && m < n; ++m, ++first)\n    out[m] = *first;\n\n  while (first != last) {\n    ++t;\n    Distance M = rand(t);\n    if (M < n)\n      out[M] = *first;\n    ++first;\n  }\n\n  return out + m;\n}\n\ntemplate <class InputIterator, class RandomAccessIterator>\ninline RandomAccessIterator\nrandom_sample(InputIterator first, InputIterator last,\n              RandomAccessIterator out_first, RandomAccessIterator out_last) \n{\n  return __random_sample(first, last, out_first, out_last - out_first);\n}\n\ntemplate <class InputIterator, class RandomAccessIterator, \n          class RandomNumberGenerator>\ninline RandomAccessIterator\nrandom_sample(InputIterator first, InputIterator last,\n              RandomAccessIterator out_first, RandomAccessIterator out_last,\n              RandomNumberGenerator& rand) \n{\n  return __random_sample(first, last, out_first, rand, out_last - out_first);\n}\n\n\n\ntemplate <class BidirectionalIterator, class Predicate>\nBidirectionalIterator partition(BidirectionalIterator first,\n                                BidirectionalIterator last, Predicate pred) {\n  while (true) {\n    while (true)\n      if (first == last)\n        return first;\n      else if (pred(*first))\n        ++first;\n      else\n        break;\n    --last;\n    while (true)\n      if (first == last)\n        return first;\n      else if (!pred(*last))\n        --last;\n      else\n        break;\n    iter_swap(first, last);\n    ++first;\n  }\n}\n\ntemplate <class ForwardIterator, class Predicate, class Distance>\nForwardIterator __inplace_stable_partition(ForwardIterator first,\n                                           ForwardIterator last,\n                                           Predicate pred, Distance len) {\n  if (len == 1) return pred(*first) ? last : first;\n  ForwardIterator middle = first;\n  advance(middle, len / 2);\n  ForwardIterator \n    first_cut = __inplace_stable_partition(first, middle, pred, len / 2);\n  ForwardIterator \n    second_cut = __inplace_stable_partition(middle, last, pred,\n                                            len - len / 2);\n  rotate(first_cut, middle, second_cut);\n  len = 0;\n  distance(middle, second_cut, len);\n  advance(first_cut, len);\n  return first_cut;\n}\n\ntemplate <class ForwardIterator, class Pointer, class Predicate, \n          class Distance>\nForwardIterator __stable_partition_adaptive(ForwardIterator first,\n                                            ForwardIterator last,\n                                            Predicate pred, Distance len,\n                                            Pointer buffer,\n                                            Distance buffer_size) {\n  if (len <= buffer_size) {\n    ForwardIterator result1 = first;\n    Pointer result2 = buffer;\n    for ( ; first != last ; ++first)\n      if (pred(*first)) {\n        *result1 = *first;\n        ++result1;\n      }\n      else {\n        *result2 = *first;\n        ++result2;\n      }\n    copy(buffer, result2, result1);\n    return result1;\n  }\n  else {\n    ForwardIterator middle = first;\n    advance(middle, len / 2);\n    ForwardIterator first_cut =\n      __stable_partition_adaptive(first, middle, pred, len / 2,\n                                  buffer, buffer_size);\n    ForwardIterator second_cut =\n      __stable_partition_adaptive(middle, last, pred, len - len / 2,\n                                  buffer, buffer_size);\n\n    rotate(first_cut, middle, second_cut);\n    len = 0;\n    distance(middle, second_cut, len);\n    advance(first_cut, len);\n    return first_cut;\n  }\n}\n\ntemplate <class ForwardIterator, class Predicate, class T, class Distance>\ninline ForwardIterator __stable_partition_aux(ForwardIterator first,\n                                              ForwardIterator last, \n                                              Predicate pred, T*, Distance*) {\n  temporary_buffer<ForwardIterator, T> buf(first, last);\n  if (buf.size() > 0)\n    return __stable_partition_adaptive(first, last, pred,\n                                       Distance(buf.requested_size()),\n                                       buf.begin(), buf.size());\n  else\n    return __inplace_stable_partition(first, last, pred, \n                                      Distance(buf.requested_size()));\n}\n\ntemplate <class ForwardIterator, class Predicate>\ninline ForwardIterator stable_partition(ForwardIterator first,\n                                        ForwardIterator last, \n                                        Predicate pred) {\n  if (first == last)\n    return first;\n  else\n    return __stable_partition_aux(first, last, pred,\n                                  value_type(first), distance_type(first));\n}\n\ntemplate <class RandomAccessIterator, class T>\nRandomAccessIterator __unguarded_partition(RandomAccessIterator first, \n                                           RandomAccessIterator last, \n                                           T pivot) {\n  while (true) {\n    while (*first < pivot) ++first;\n    --last;\n    while (pivot < *last) --last;\n    if (!(first < last)) return first;\n    iter_swap(first, last);\n    ++first;\n  }\n}    \n\ntemplate <class RandomAccessIterator, class T, class Compare>\nRandomAccessIterator __unguarded_partition(RandomAccessIterator first, \n                                           RandomAccessIterator last, \n                                           T pivot, Compare comp) {\n  while (1) {\n    while (comp(*first, pivot)) ++first;\n    --last;\n    while (comp(pivot, *last)) --last;\n    if (!(first < last)) return first;\n    iter_swap(first, last);\n    ++first;\n  }\n}\n\nconst int __stl_threshold = 16;\n\n\ntemplate <class RandomAccessIterator, class T>\nvoid __unguarded_linear_insert(RandomAccessIterator last, T value) {\n  RandomAccessIterator next = last;\n  --next;\n  while (value < *next) {\n    *last = *next;\n    last = next;\n    --next;\n  }\n  *last = value;\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\nvoid __unguarded_linear_insert(RandomAccessIterator last, T value, \n                               Compare comp) {\n  RandomAccessIterator next = last;\n  --next;  \n  while (comp(value , *next)) {\n    *last = *next;\n    last = next;\n    --next;\n  }\n  *last = value;\n}\n\ntemplate <class RandomAccessIterator, class T>\ninline void __linear_insert(RandomAccessIterator first, \n                            RandomAccessIterator last, T*) {\n  T value = *last;\n  if (value < *first) {\n    copy_backward(first, last, last + 1);\n    *first = value;\n  }\n  else\n    __unguarded_linear_insert(last, value);\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\ninline void __linear_insert(RandomAccessIterator first, \n                            RandomAccessIterator last, T*, Compare comp) {\n  T value = *last;\n  if (comp(value, *first)) {\n    copy_backward(first, last, last + 1);\n    *first = value;\n  }\n  else\n    __unguarded_linear_insert(last, value, comp);\n}\n\ntemplate <class RandomAccessIterator>\nvoid __insertion_sort(RandomAccessIterator first, RandomAccessIterator last) {\n  if (first == last) return; \n  for (RandomAccessIterator i = first + 1; i != last; ++i)\n    __linear_insert(first, i, value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Compare>\nvoid __insertion_sort(RandomAccessIterator first,\n                      RandomAccessIterator last, Compare comp) {\n  if (first == last) return;\n  for (RandomAccessIterator i = first + 1; i != last; ++i)\n    __linear_insert(first, i, value_type(first), comp);\n}\n\ntemplate <class RandomAccessIterator, class T>\nvoid __unguarded_insertion_sort_aux(RandomAccessIterator first, \n                                    RandomAccessIterator last, T*) {\n  for (RandomAccessIterator i = first; i != last; ++i)\n    __unguarded_linear_insert(i, T(*i));\n}\n\ntemplate <class RandomAccessIterator>\ninline void __unguarded_insertion_sort(RandomAccessIterator first, \n                                RandomAccessIterator last) {\n  __unguarded_insertion_sort_aux(first, last, value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\nvoid __unguarded_insertion_sort_aux(RandomAccessIterator first, \n                                    RandomAccessIterator last,\n                                    T*, Compare comp) {\n  for (RandomAccessIterator i = first; i != last; ++i)\n    __unguarded_linear_insert(i, T(*i), comp);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void __unguarded_insertion_sort(RandomAccessIterator first, \n                                       RandomAccessIterator last,\n                                       Compare comp) {\n  __unguarded_insertion_sort_aux(first, last, value_type(first), comp);\n}\n\ntemplate <class RandomAccessIterator>\nvoid __final_insertion_sort(RandomAccessIterator first, \n                            RandomAccessIterator last) {\n  if (last - first > __stl_threshold) {\n    __insertion_sort(first, first + __stl_threshold);\n    __unguarded_insertion_sort(first + __stl_threshold, last);\n  }\n  else\n    __insertion_sort(first, last);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\nvoid __final_insertion_sort(RandomAccessIterator first, \n                            RandomAccessIterator last, Compare comp) {\n  if (last - first > __stl_threshold) {\n    __insertion_sort(first, first + __stl_threshold, comp);\n    __unguarded_insertion_sort(first + __stl_threshold, last, comp);\n  }\n  else\n    __insertion_sort(first, last, comp);\n}\n\ntemplate <class Size>\ninline Size __lg(Size n) {\n  Size k;\n  for (k = 0; n > 1; n >>= 1) ++k;\n  return k;\n}\n\ntemplate <class RandomAccessIterator, class T, class Size>\nvoid __introsort_loop(RandomAccessIterator first,\n                      RandomAccessIterator last, T*,\n                      Size depth_limit) {\n  while (last - first > __stl_threshold) {\n    if (depth_limit == 0) {\n      partial_sort(first, last, last);\n      return;\n    }\n    --depth_limit;\n    RandomAccessIterator cut = __unguarded_partition\n      (first, last, T(__median(*first, *(first + (last - first)/2),\n                               *(last - 1))));\n    __introsort_loop(cut, last, value_type(first), depth_limit);\n    last = cut;\n  }\n}\n\ntemplate <class RandomAccessIterator, class T, class Size, class Compare>\nvoid __introsort_loop(RandomAccessIterator first,\n                      RandomAccessIterator last, T*,\n                      Size depth_limit, Compare comp) {\n  while (last - first > __stl_threshold) {\n    if (depth_limit == 0) {\n      partial_sort(first, last, last, comp);\n      return;\n    }\n    --depth_limit;\n    RandomAccessIterator cut = __unguarded_partition\n      (first, last, T(__median(*first, *(first + (last - first)/2),\n                               *(last - 1), comp)), comp);\n    __introsort_loop(cut, last, value_type(first), depth_limit, comp);\n    last = cut;\n  }\n}\n\ntemplate <class RandomAccessIterator>\ninline void sort(RandomAccessIterator first, RandomAccessIterator last) {\n  if (first != last) {\n    __introsort_loop(first, last, value_type(first), __lg(last - first) * 2);\n    __final_insertion_sort(first, last);\n  }\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void sort(RandomAccessIterator first, RandomAccessIterator last,\n                 Compare comp) {\n  if (first != last) {\n    __introsort_loop(first, last, value_type(first), __lg(last - first) * 2,\n                     comp);\n    __final_insertion_sort(first, last, comp);\n  }\n}\n\n\ntemplate <class RandomAccessIterator>\nvoid __inplace_stable_sort(RandomAccessIterator first,\n                           RandomAccessIterator last) {\n  if (last - first < 15) {\n    __insertion_sort(first, last);\n    return;\n  }\n  RandomAccessIterator middle = first + (last - first) / 2;\n  __inplace_stable_sort(first, middle);\n  __inplace_stable_sort(middle, last);\n  __merge_without_buffer(first, middle, last, middle - first, last - middle);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\nvoid __inplace_stable_sort(RandomAccessIterator first,\n                           RandomAccessIterator last, Compare comp) {\n  if (last - first < 15) {\n    __insertion_sort(first, last, comp);\n    return;\n  }\n  RandomAccessIterator middle = first + (last - first) / 2;\n  __inplace_stable_sort(first, middle, comp);\n  __inplace_stable_sort(middle, last, comp);\n  __merge_without_buffer(first, middle, last, middle - first,\n                         last - middle, comp);\n}\n\ntemplate <class RandomAccessIterator1, class RandomAccessIterator2,\n          class Distance>\nvoid __merge_sort_loop(RandomAccessIterator1 first,\n                       RandomAccessIterator1 last, \n                       RandomAccessIterator2 result, Distance step_size) {\n  Distance two_step = 2 * step_size;\n\n  while (last - first >= two_step) {\n    result = merge(first, first + step_size,\n                   first + step_size, first + two_step, result);\n    first += two_step;\n  }\n\n  step_size = min(Distance(last - first), step_size);\n  merge(first, first + step_size, first + step_size, last, result);\n}\n\ntemplate <class RandomAccessIterator1, class RandomAccessIterator2,\n          class Distance, class Compare>\nvoid __merge_sort_loop(RandomAccessIterator1 first,\n                       RandomAccessIterator1 last, \n                       RandomAccessIterator2 result, Distance step_size,\n                       Compare comp) {\n  Distance two_step = 2 * step_size;\n\n  while (last - first >= two_step) {\n    result = merge(first, first + step_size,\n                   first + step_size, first + two_step, result, comp);\n    first += two_step;\n  }\n  step_size = min(Distance(last - first), step_size);\n\n  merge(first, first + step_size, first + step_size, last, result, comp);\n}\n\nconst int __stl_chunk_size = 7;\n        \ntemplate <class RandomAccessIterator, class Distance>\nvoid __chunk_insertion_sort(RandomAccessIterator first, \n                            RandomAccessIterator last, Distance chunk_size) {\n  while (last - first >= chunk_size) {\n    __insertion_sort(first, first + chunk_size);\n    first += chunk_size;\n  }\n  __insertion_sort(first, last);\n}\n\ntemplate <class RandomAccessIterator, class Distance, class Compare>\nvoid __chunk_insertion_sort(RandomAccessIterator first, \n                            RandomAccessIterator last,\n                            Distance chunk_size, Compare comp) {\n  while (last - first >= chunk_size) {\n    __insertion_sort(first, first + chunk_size, comp);\n    first += chunk_size;\n  }\n  __insertion_sort(first, last, comp);\n}\n\ntemplate <class RandomAccessIterator, class Pointer, class Distance>\nvoid __merge_sort_with_buffer(RandomAccessIterator first, \n                              RandomAccessIterator last,\n                              Pointer buffer, Distance*) {\n  Distance len = last - first;\n  Pointer buffer_last = buffer + len;\n\n  Distance step_size = __stl_chunk_size;\n  __chunk_insertion_sort(first, last, step_size);\n\n  while (step_size < len) {\n    __merge_sort_loop(first, last, buffer, step_size);\n    step_size *= 2;\n    __merge_sort_loop(buffer, buffer_last, first, step_size);\n    step_size *= 2;\n  }\n}\n\ntemplate <class RandomAccessIterator, class Pointer, class Distance,\n          class Compare>\nvoid __merge_sort_with_buffer(RandomAccessIterator first, \n                              RandomAccessIterator last, Pointer buffer,\n                              Distance*, Compare comp) {\n  Distance len = last - first;\n  Pointer buffer_last = buffer + len;\n\n  Distance step_size = __stl_chunk_size;\n  __chunk_insertion_sort(first, last, step_size, comp);\n\n  while (step_size < len) {\n    __merge_sort_loop(first, last, buffer, step_size, comp);\n    step_size *= 2;\n    __merge_sort_loop(buffer, buffer_last, first, step_size, comp);\n    step_size *= 2;\n  }\n}\n\ntemplate <class RandomAccessIterator, class Pointer, class Distance>\nvoid __stable_sort_adaptive(RandomAccessIterator first, \n                            RandomAccessIterator last, Pointer buffer,\n                            Distance buffer_size) {\n  Distance len = (last - first + 1) / 2;\n  RandomAccessIterator middle = first + len;\n  if (len > buffer_size) {\n    __stable_sort_adaptive(first, middle, buffer, buffer_size);\n    __stable_sort_adaptive(middle, last, buffer, buffer_size);\n  } else {\n    __merge_sort_with_buffer(first, middle, buffer, (Distance*)0);\n    __merge_sort_with_buffer(middle, last, buffer, (Distance*)0);\n  }\n  __merge_adaptive(first, middle, last, Distance(middle - first), \n                   Distance(last - middle), buffer, buffer_size);\n}\n\ntemplate <class RandomAccessIterator, class Pointer, class Distance, \n          class Compare>\nvoid __stable_sort_adaptive(RandomAccessIterator first, \n                            RandomAccessIterator last, Pointer buffer,\n                            Distance buffer_size, Compare comp) {\n  Distance len = (last - first + 1) / 2;\n  RandomAccessIterator middle = first + len;\n  if (len > buffer_size) {\n    __stable_sort_adaptive(first, middle, buffer, buffer_size, \n                           comp);\n    __stable_sort_adaptive(middle, last, buffer, buffer_size, \n                           comp);\n  } else {\n    __merge_sort_with_buffer(first, middle, buffer, (Distance*)0, comp);\n    __merge_sort_with_buffer(middle, last, buffer, (Distance*)0, comp);\n  }\n  __merge_adaptive(first, middle, last, Distance(middle - first), \n                   Distance(last - middle), buffer, buffer_size,\n                   comp);\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\ninline void __stable_sort_aux(RandomAccessIterator first,\n                              RandomAccessIterator last, T*, Distance*) {\n  temporary_buffer<RandomAccessIterator, T> buf(first, last);\n  if (buf.begin() == 0)\n    __inplace_stable_sort(first, last);\n  else \n    __stable_sort_adaptive(first, last, buf.begin(), Distance(buf.size()));\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance, class Compare>\ninline void __stable_sort_aux(RandomAccessIterator first,\n                              RandomAccessIterator last, T*, Distance*,\n                              Compare comp) {\n  temporary_buffer<RandomAccessIterator, T> buf(first, last);\n  if (buf.begin() == 0)\n    __inplace_stable_sort(first, last, comp);\n  else \n    __stable_sort_adaptive(first, last, buf.begin(), Distance(buf.size()),\n                           comp);\n}\n\ntemplate <class RandomAccessIterator>\ninline void stable_sort(RandomAccessIterator first,\n                        RandomAccessIterator last) {\n  __stable_sort_aux(first, last, value_type(first), distance_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void stable_sort(RandomAccessIterator first,\n                        RandomAccessIterator last, Compare comp) {\n  __stable_sort_aux(first, last, value_type(first), distance_type(first), \n                    comp);\n}\n\ntemplate <class RandomAccessIterator, class T>\nvoid __partial_sort(RandomAccessIterator first, RandomAccessIterator middle,\n                    RandomAccessIterator last, T*) {\n  make_heap(first, middle);\n  for (RandomAccessIterator i = middle; i < last; ++i)\n    if (*i < *first) \n      __pop_heap(first, middle, i, T(*i), distance_type(first));\n  sort_heap(first, middle);\n}\n\ntemplate <class RandomAccessIterator>\ninline void partial_sort(RandomAccessIterator first,\n                         RandomAccessIterator middle,\n                         RandomAccessIterator last) {\n  __partial_sort(first, middle, last, value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\nvoid __partial_sort(RandomAccessIterator first, RandomAccessIterator middle,\n                    RandomAccessIterator last, T*, Compare comp) {\n  make_heap(first, middle, comp);\n  for (RandomAccessIterator i = middle; i < last; ++i)\n    if (comp(*i, *first))\n      __pop_heap(first, middle, i, T(*i), comp, distance_type(first));\n  sort_heap(first, middle, comp);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void partial_sort(RandomAccessIterator first,\n                         RandomAccessIterator middle,\n                         RandomAccessIterator last, Compare comp) {\n  __partial_sort(first, middle, last, value_type(first), comp);\n}\n\ntemplate <class InputIterator, class RandomAccessIterator, class Distance,\n          class T>\nRandomAccessIterator __partial_sort_copy(InputIterator first,\n                                         InputIterator last,\n                                         RandomAccessIterator result_first,\n                                         RandomAccessIterator result_last, \n                                         Distance*, T*) {\n  if (result_first == result_last) return result_last;\n  RandomAccessIterator result_real_last = result_first;\n  while(first != last && result_real_last != result_last) {\n    *result_real_last = *first;\n    ++result_real_last;\n    ++first;\n  }\n  make_heap(result_first, result_real_last);\n  while (first != last) {\n    if (*first < *result_first) \n      __adjust_heap(result_first, Distance(0),\n                    Distance(result_real_last - result_first), T(*first));\n    ++first;\n  }\n  sort_heap(result_first, result_real_last);\n  return result_real_last;\n}\n\ntemplate <class InputIterator, class RandomAccessIterator>\ninline RandomAccessIterator\npartial_sort_copy(InputIterator first, InputIterator last,\n                  RandomAccessIterator result_first,\n                  RandomAccessIterator result_last) {\n  return __partial_sort_copy(first, last, result_first, result_last, \n                             distance_type(result_first), value_type(first));\n}\n\ntemplate <class InputIterator, class RandomAccessIterator, class Compare,\n          class Distance, class T>\nRandomAccessIterator __partial_sort_copy(InputIterator first,\n                                         InputIterator last,\n                                         RandomAccessIterator result_first,\n                                         RandomAccessIterator result_last,\n                                         Compare comp, Distance*, T*) {\n  if (result_first == result_last) return result_last;\n  RandomAccessIterator result_real_last = result_first;\n  while(first != last && result_real_last != result_last) {\n    *result_real_last = *first;\n    ++result_real_last;\n    ++first;\n  }\n  make_heap(result_first, result_real_last, comp);\n  while (first != last) {\n    if (comp(*first, *result_first))\n      __adjust_heap(result_first, Distance(0),\n                    Distance(result_real_last - result_first), T(*first),\n                    comp);\n    ++first;\n  }\n  sort_heap(result_first, result_real_last, comp);\n  return result_real_last;\n}\n\ntemplate <class InputIterator, class RandomAccessIterator, class Compare>\ninline RandomAccessIterator\npartial_sort_copy(InputIterator first, InputIterator last,\n                  RandomAccessIterator result_first,\n                  RandomAccessIterator result_last, Compare comp) {\n  return __partial_sort_copy(first, last, result_first, result_last, comp,\n                             distance_type(result_first), value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class T>\nvoid __nth_element(RandomAccessIterator first, RandomAccessIterator nth,\n                   RandomAccessIterator last, T*) {\n  while (last - first > 3) {\n    RandomAccessIterator cut = __unguarded_partition\n      (first, last, T(__median(*first, *(first + (last - first)/2),\n                               *(last - 1))));\n    if (cut <= nth)\n      first = cut;\n    else \n      last = cut;\n  }\n  __insertion_sort(first, last);\n}\n\ntemplate <class RandomAccessIterator>\ninline void nth_element(RandomAccessIterator first, RandomAccessIterator nth,\n                        RandomAccessIterator last) {\n  __nth_element(first, nth, last, value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\nvoid __nth_element(RandomAccessIterator first, RandomAccessIterator nth,\n                   RandomAccessIterator last, T*, Compare comp) {\n  while (last - first > 3) {\n    RandomAccessIterator cut = __unguarded_partition\n      (first, last, T(__median(*first, *(first + (last - first)/2), \n                               *(last - 1), comp)), comp);\n    if (cut <= nth)\n      first = cut;\n    else \n      last = cut;\n  }\n  __insertion_sort(first, last, comp);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void nth_element(RandomAccessIterator first, RandomAccessIterator nth,\n                 RandomAccessIterator last, Compare comp) {\n  __nth_element(first, nth, last, value_type(first), comp);\n}\n\ntemplate <class ForwardIterator, class T, class Distance>\nForwardIterator __lower_bound(ForwardIterator first, ForwardIterator last,\n                              const T& value, Distance*,\n                              forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (*middle < value) {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n    else\n      len = half;\n  }\n  return first;\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\nRandomAccessIterator __lower_bound(RandomAccessIterator first,\n                                   RandomAccessIterator last, const T& value,\n                                   Distance*, random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (*middle < value) {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n    else\n      len = half;\n  }\n  return first;\n}\n\ntemplate <class ForwardIterator, class T>\ninline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last,\n                                   const T& value) {\n  return __lower_bound(first, last, value, distance_type(first),\n                       iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T, class Compare, class Distance>\nForwardIterator __lower_bound(ForwardIterator first, ForwardIterator last,\n                              const T& value, Compare comp, Distance*,\n                              forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (comp(*middle, value)) {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n    else\n      len = half;\n  }\n  return first;\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare, class Distance>\nRandomAccessIterator __lower_bound(RandomAccessIterator first,\n                                   RandomAccessIterator last,\n                                   const T& value, Compare comp, Distance*,\n                                   random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (comp(*middle, value)) {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n    else\n      len = half;\n  }\n  return first;\n}\n\ntemplate <class ForwardIterator, class T, class Compare>\ninline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last,\n                                   const T& value, Compare comp) {\n  return __lower_bound(first, last, value, comp, distance_type(first),\n                       iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T, class Distance>\nForwardIterator __upper_bound(ForwardIterator first, ForwardIterator last,\n                              const T& value, Distance*,\n                              forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (value < *middle)\n      len = half;\n    else {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n  }\n  return first;\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\nRandomAccessIterator __upper_bound(RandomAccessIterator first,\n                                   RandomAccessIterator last, const T& value,\n                                   Distance*, random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (value < *middle)\n      len = half;\n    else {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n  }\n  return first;\n}\n\ntemplate <class ForwardIterator, class T>\ninline ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last,\n                                   const T& value) {\n  return __upper_bound(first, last, value, distance_type(first),\n                       iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T, class Compare, class Distance>\nForwardIterator __upper_bound(ForwardIterator first, ForwardIterator last,\n                              const T& value, Compare comp, Distance*,\n                              forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (comp(value, *middle))\n      len = half;\n    else {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n  }\n  return first;\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare, class Distance>\nRandomAccessIterator __upper_bound(RandomAccessIterator first,\n                                   RandomAccessIterator last,\n                                   const T& value, Compare comp, Distance*,\n                                   random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (comp(value, *middle))\n      len = half;\n    else {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n  }\n  return first;\n}\n\ntemplate <class ForwardIterator, class T, class Compare>\ninline ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last,\n                                   const T& value, Compare comp) {\n  return __upper_bound(first, last, value, comp, distance_type(first),\n                       iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T, class Distance>\npair<ForwardIterator, ForwardIterator>\n__equal_range(ForwardIterator first, ForwardIterator last, const T& value,\n              Distance*, forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle, left, right;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (*middle < value) {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n    else if (value < *middle)\n      len = half;\n    else {\n      left = lower_bound(first, middle, value);\n      advance(first, len);\n      right = upper_bound(++middle, first, value);\n      return pair<ForwardIterator, ForwardIterator>(left, right);\n    }\n  }\n  return pair<ForwardIterator, ForwardIterator>(first, first);\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\npair<RandomAccessIterator, RandomAccessIterator>\n__equal_range(RandomAccessIterator first, RandomAccessIterator last,\n              const T& value, Distance*, random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle, left, right;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (*middle < value) {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n    else if (value < *middle)\n      len = half;\n    else {\n      left = lower_bound(first, middle, value);\n      right = upper_bound(++middle, first + len, value);\n      return pair<RandomAccessIterator, RandomAccessIterator>(left,\n                                                              right);\n    }\n  }\n  return pair<RandomAccessIterator, RandomAccessIterator>(first, first);\n}\n\ntemplate <class ForwardIterator, class T>\ninline pair<ForwardIterator, ForwardIterator>\nequal_range(ForwardIterator first, ForwardIterator last, const T& value) {\n  return __equal_range(first, last, value, distance_type(first),\n                       iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T, class Compare, class Distance>\npair<ForwardIterator, ForwardIterator>\n__equal_range(ForwardIterator first, ForwardIterator last, const T& value,\n              Compare comp, Distance*, forward_iterator_tag) {\n  Distance len = 0;\n  distance(first, last, len);\n  Distance half;\n  ForwardIterator middle, left, right;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first;\n    advance(middle, half);\n    if (comp(*middle, value)) {\n      first = middle;\n      ++first;\n      len = len - half - 1;\n    }\n    else if (comp(value, *middle))\n      len = half;\n    else {\n      left = lower_bound(first, middle, value, comp);\n      advance(first, len);\n      right = upper_bound(++middle, first, value, comp);\n      return pair<ForwardIterator, ForwardIterator>(left, right);\n    }\n  }\n  return pair<ForwardIterator, ForwardIterator>(first, first);\n}           \n\ntemplate <class RandomAccessIterator, class T, class Compare, class Distance>\npair<RandomAccessIterator, RandomAccessIterator>\n__equal_range(RandomAccessIterator first, RandomAccessIterator last,\n              const T& value, Compare comp, Distance*,\n              random_access_iterator_tag) {\n  Distance len = last - first;\n  Distance half;\n  RandomAccessIterator middle, left, right;\n\n  while (len > 0) {\n    half = len >> 1;\n    middle = first + half;\n    if (comp(*middle, value)) {\n      first = middle + 1;\n      len = len - half - 1;\n    }\n    else if (comp(value, *middle))\n      len = half;\n    else {\n      left = lower_bound(first, middle, value, comp);\n      right = upper_bound(++middle, first + len, value, comp);\n      return pair<RandomAccessIterator, RandomAccessIterator>(left,\n                                                              right);\n    }\n  }\n  return pair<RandomAccessIterator, RandomAccessIterator>(first, first);\n}           \n\ntemplate <class ForwardIterator, class T, class Compare>\ninline pair<ForwardIterator, ForwardIterator>\nequal_range(ForwardIterator first, ForwardIterator last, const T& value,\n            Compare comp) {\n  return __equal_range(first, last, value, comp, distance_type(first),\n                       iterator_category(first));\n}    \n\ntemplate <class ForwardIterator, class T>\nbool binary_search(ForwardIterator first, ForwardIterator last,\n                   const T& value) {\n  ForwardIterator i = lower_bound(first, last, value);\n  return i != last && !(value < *i);\n}\n\ntemplate <class ForwardIterator, class T, class Compare>\nbool binary_search(ForwardIterator first, ForwardIterator last, const T& value,\n                   Compare comp) {\n  ForwardIterator i = lower_bound(first, last, value, comp);\n  return i != last && !comp(value, *i);\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator>\nOutputIterator merge(InputIterator1 first1, InputIterator1 last1,\n                     InputIterator2 first2, InputIterator2 last2,\n                     OutputIterator result) {\n  while (first1 != last1 && first2 != last2) {\n    if (*first2 < *first1) {\n      *result = *first2;\n      ++first2;\n    }\n    else {\n      *result = *first1;\n      ++first1;\n    }\n    ++result;\n  }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator,\n          class Compare>\nOutputIterator merge(InputIterator1 first1, InputIterator1 last1,\n                     InputIterator2 first2, InputIterator2 last2,\n                     OutputIterator result, Compare comp) {\n  while (first1 != last1 && first2 != last2) {\n    if (comp(*first2, *first1)) {\n      *result = *first2;\n      ++first2;\n    }\n    else {\n      *result = *first1;\n      ++first1;\n    }\n    ++result;\n  }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class BidirectionalIterator, class Distance>\nvoid __merge_without_buffer(BidirectionalIterator first,\n                            BidirectionalIterator middle,\n                            BidirectionalIterator last,\n                            Distance len1, Distance len2) {\n  if (len1 == 0 || len2 == 0) return;\n  if (len1 + len2 == 2) {\n    if (*middle < *first) iter_swap(first, middle);\n    return;\n  }\n  BidirectionalIterator first_cut = first;\n  BidirectionalIterator second_cut = middle;\n  Distance len11 = 0;\n  Distance len22 = 0;\n  if (len1 > len2) {\n    len11 = len1 / 2;\n    advance(first_cut, len11);\n    second_cut = lower_bound(middle, last, *first_cut);\n    distance(middle, second_cut, len22);\n  }\n  else {\n    len22 = len2 / 2;\n    advance(second_cut, len22);\n    first_cut = upper_bound(first, middle, *second_cut);\n    distance(first, first_cut, len11);\n  }\n  rotate(first_cut, middle, second_cut);\n  BidirectionalIterator new_middle = first_cut;\n  advance(new_middle, len22);\n  __merge_without_buffer(first, first_cut, new_middle, len11, len22);\n  __merge_without_buffer(new_middle, second_cut, last, len1 - len11,\n                         len2 - len22);\n}\n\ntemplate <class BidirectionalIterator, class Distance, class Compare>\nvoid __merge_without_buffer(BidirectionalIterator first,\n                            BidirectionalIterator middle,\n                            BidirectionalIterator last,\n                            Distance len1, Distance len2, Compare comp) {\n  if (len1 == 0 || len2 == 0) return;\n  if (len1 + len2 == 2) {\n    if (comp(*middle, *first)) iter_swap(first, middle);\n    return;\n  }\n  BidirectionalIterator first_cut = first;\n  BidirectionalIterator second_cut = middle;\n  Distance len11 = 0;\n  Distance len22 = 0;\n  if (len1 > len2) {\n    len11 = len1 / 2;\n    advance(first_cut, len11);\n    second_cut = lower_bound(middle, last, *first_cut, comp);\n    distance(middle, second_cut, len22);\n  }\n  else {\n    len22 = len2 / 2;\n    advance(second_cut, len22);\n    first_cut = upper_bound(first, middle, *second_cut, comp);\n    distance(first, first_cut, len11);\n  }\n  rotate(first_cut, middle, second_cut);\n  BidirectionalIterator new_middle = first_cut;\n  advance(new_middle, len22);\n  __merge_without_buffer(first, first_cut, new_middle, len11, len22, comp);\n  __merge_without_buffer(new_middle, second_cut, last, len1 - len11,\n                         len2 - len22, comp);\n}\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2,\n          class Distance>\nBidirectionalIterator1 __rotate_adaptive(BidirectionalIterator1 first,\n                                         BidirectionalIterator1 middle,\n                                         BidirectionalIterator1 last,\n                                         Distance len1, Distance len2,\n                                         BidirectionalIterator2 buffer,\n                                         Distance buffer_size) {\n  BidirectionalIterator2 buffer_end;\n  if (len1 > len2 && len2 <= buffer_size) {\n    buffer_end = copy(middle, last, buffer);\n    copy_backward(first, middle, last);\n    return copy(buffer, buffer_end, first);\n  } else if (len1 <= buffer_size) {\n    buffer_end = copy(first, middle, buffer);\n    copy(middle, last, first);\n    return copy_backward(buffer, buffer_end, last);\n  } else  {\n    rotate(first, middle, last);\n    advance(first, len2);\n    return first;\n  }\n}\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2,\n          class BidirectionalIterator3>\nBidirectionalIterator3 __merge_backward(BidirectionalIterator1 first1,\n                                        BidirectionalIterator1 last1,\n                                        BidirectionalIterator2 first2,\n                                        BidirectionalIterator2 last2,\n                                        BidirectionalIterator3 result) {\n  if (first1 == last1) return copy_backward(first2, last2, result);\n  if (first2 == last2) return copy_backward(first1, last1, result);\n  --last1;\n  --last2;\n  while (true) {\n    if (*last2 < *last1) {\n      *--result = *last1;\n      if (first1 == last1) return copy_backward(first2, ++last2, result);\n      --last1;\n    }\n    else {\n      *--result = *last2;\n      if (first2 == last2) return copy_backward(first1, ++last1, result);\n      --last2;\n    }\n  }\n}\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2,\n          class BidirectionalIterator3, class Compare>\nBidirectionalIterator3 __merge_backward(BidirectionalIterator1 first1,\n                                        BidirectionalIterator1 last1,\n                                        BidirectionalIterator2 first2,\n                                        BidirectionalIterator2 last2,\n                                        BidirectionalIterator3 result,\n                                        Compare comp) {\n  if (first1 == last1) return copy_backward(first2, last2, result);\n  if (first2 == last2) return copy_backward(first1, last1, result);\n  --last1;\n  --last2;\n  while (true) {\n    if (comp(*last2, *last1)) {\n      *--result = *last1;\n      if (first1 == last1) return copy_backward(first2, ++last2, result);\n      --last1;\n    }\n    else {\n      *--result = *last2;\n      if (first2 == last2) return copy_backward(first1, ++last1, result);\n      --last2;\n    }\n  }\n}\n\ntemplate <class BidirectionalIterator, class Distance, class Pointer>\nvoid __merge_adaptive(BidirectionalIterator first, \n                      BidirectionalIterator middle, \n                      BidirectionalIterator last, Distance len1, Distance len2,\n                      Pointer buffer, Distance buffer_size) {\n  if (len1 <= len2 && len1 <= buffer_size) {\n    Pointer end_buffer = copy(first, middle, buffer);\n    merge(buffer, end_buffer, middle, last, first);\n  }\n  else if (len2 <= buffer_size) {\n    Pointer end_buffer = copy(middle, last, buffer);\n    __merge_backward(first, middle, buffer, end_buffer, last);\n  }\n  else {\n    BidirectionalIterator first_cut = first;\n    BidirectionalIterator second_cut = middle;\n    Distance len11 = 0;\n    Distance len22 = 0;\n    if (len1 > len2) {\n      len11 = len1 / 2;\n      advance(first_cut, len11);\n      second_cut = lower_bound(middle, last, *first_cut);\n      distance(middle, second_cut, len22);   \n    }\n    else {\n      len22 = len2 / 2;\n      advance(second_cut, len22);\n      first_cut = upper_bound(first, middle, *second_cut);\n      distance(first, first_cut, len11);\n    }\n    BidirectionalIterator new_middle =\n      __rotate_adaptive(first_cut, middle, second_cut, len1 - len11,\n                        len22, buffer, buffer_size);\n    __merge_adaptive(first, first_cut, new_middle, len11, len22, buffer,\n                     buffer_size);\n    __merge_adaptive(new_middle, second_cut, last, len1 - len11,\n                     len2 - len22, buffer, buffer_size);\n  }\n}\n\ntemplate <class BidirectionalIterator, class Distance, class Pointer,\n          class Compare>\nvoid __merge_adaptive(BidirectionalIterator first, \n                      BidirectionalIterator middle, \n                      BidirectionalIterator last, Distance len1, Distance len2,\n                      Pointer buffer, Distance buffer_size, Compare comp) {\n  if (len1 <= len2 && len1 <= buffer_size) {\n    Pointer end_buffer = copy(first, middle, buffer);\n    merge(buffer, end_buffer, middle, last, first, comp);\n  }\n  else if (len2 <= buffer_size) {\n    Pointer end_buffer = copy(middle, last, buffer);\n    __merge_backward(first, middle, buffer, end_buffer, last, comp);\n  }\n  else {\n    BidirectionalIterator first_cut = first;\n    BidirectionalIterator second_cut = middle;\n    Distance len11 = 0;\n    Distance len22 = 0;\n    if (len1 > len2) {\n      len11 = len1 / 2;\n      advance(first_cut, len11);\n      second_cut = lower_bound(middle, last, *first_cut, comp);\n      distance(middle, second_cut, len22);   \n    }\n    else {\n      len22 = len2 / 2;\n      advance(second_cut, len22);\n      first_cut = upper_bound(first, middle, *second_cut, comp);\n      distance(first, first_cut, len11);\n    }\n    BidirectionalIterator new_middle =\n      __rotate_adaptive(first_cut, middle, second_cut, len1 - len11,\n                        len22, buffer, buffer_size);\n    __merge_adaptive(first, first_cut, new_middle, len11, len22, buffer,\n                     buffer_size, comp);\n    __merge_adaptive(new_middle, second_cut, last, len1 - len11,\n                     len2 - len22, buffer, buffer_size, comp);\n  }\n}\n\ntemplate <class BidirectionalIterator, class T, class Distance>\ninline void __inplace_merge_aux(BidirectionalIterator first,\n                                BidirectionalIterator middle,\n                                BidirectionalIterator last, T*, Distance*) {\n  Distance len1 = 0;\n  distance(first, middle, len1);\n  Distance len2 = 0;\n  distance(middle, last, len2);\n\n  temporary_buffer<BidirectionalIterator, T> buf(first, last);\n  if (buf.begin() == 0)\n    __merge_without_buffer(first, middle, last, len1, len2);\n  else\n    __merge_adaptive(first, middle, last, len1, len2,\n                     buf.begin(), Distance(buf.size()));\n}\n\ntemplate <class BidirectionalIterator, class T, class Distance, class Compare>\ninline void __inplace_merge_aux(BidirectionalIterator first,\n                                BidirectionalIterator middle,\n                                BidirectionalIterator last, T*, Distance*,\n                                Compare comp) {\n  Distance len1 = 0;\n  distance(first, middle, len1);\n  Distance len2 = 0;\n  distance(middle, last, len2);\n\n  temporary_buffer<BidirectionalIterator, T> buf(first, last);\n  if (buf.begin() == 0)\n    __merge_without_buffer(first, middle, last, len1, len2, comp);\n  else\n    __merge_adaptive(first, middle, last, len1, len2,\n                     buf.begin(), Distance(buf.size()),\n                     comp);\n}\n\ntemplate <class BidirectionalIterator>\ninline void inplace_merge(BidirectionalIterator first,\n                          BidirectionalIterator middle,\n                          BidirectionalIterator last) {\n  if (first == middle || middle == last) return;\n  __inplace_merge_aux(first, middle, last, value_type(first),\n                      distance_type(first));\n}\n\ntemplate <class BidirectionalIterator, class Compare>\ninline void inplace_merge(BidirectionalIterator first,\n                          BidirectionalIterator middle,\n                          BidirectionalIterator last, Compare comp) {\n  if (first == middle || middle == last) return;\n  __inplace_merge_aux(first, middle, last, value_type(first),\n                      distance_type(first), comp);\n}\n\ntemplate <class InputIterator1, class InputIterator2>\nbool includes(InputIterator1 first1, InputIterator1 last1,\n              InputIterator2 first2, InputIterator2 last2) {\n  while (first1 != last1 && first2 != last2)\n    if (*first2 < *first1)\n      return false;\n    else if(*first1 < *first2) \n      ++first1;\n    else\n      ++first1, ++first2;\n\n  return first2 == last2;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class Compare>\nbool includes(InputIterator1 first1, InputIterator1 last1,\n              InputIterator2 first2, InputIterator2 last2, Compare comp) {\n  while (first1 != last1 && first2 != last2)\n    if (comp(*first2, *first1))\n      return false;\n    else if(comp(*first1, *first2)) \n      ++first1;\n    else\n      ++first1, ++first2;\n\n  return first2 == last2;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator>\nOutputIterator set_union(InputIterator1 first1, InputIterator1 last1,\n                         InputIterator2 first2, InputIterator2 last2,\n                         OutputIterator result) {\n  while (first1 != last1 && first2 != last2) {\n    if (*first1 < *first2) {\n      *result = *first1;\n      ++first1;\n    }\n    else if (*first2 < *first1) {\n      *result = *first2;\n      ++first2;\n    }\n    else {\n      *result = *first1;\n      ++first1;\n      ++first2;\n    }\n    ++result;\n  }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator,\n          class Compare>\nOutputIterator set_union(InputIterator1 first1, InputIterator1 last1,\n                         InputIterator2 first2, InputIterator2 last2,\n                         OutputIterator result, Compare comp) {\n  while (first1 != last1 && first2 != last2) {\n    if (comp(*first1, *first2)) {\n      *result = *first1;\n      ++first1;\n    }\n    else if (comp(*first2, *first1)) {\n      *result = *first2;\n      ++first2;\n    }\n    else {\n      *result = *first1;\n      ++first1;\n      ++first2;\n    }\n    ++result;\n  }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator>\nOutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1,\n                                InputIterator2 first2, InputIterator2 last2,\n                                OutputIterator result) {\n  while (first1 != last1 && first2 != last2) \n    if (*first1 < *first2) \n      ++first1;\n    else if (*first2 < *first1) \n      ++first2;\n    else {\n      *result = *first1;\n      ++first1;\n      ++first2;\n      ++result;\n    }\n  return result;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator,\n          class Compare>\nOutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1,\n                                InputIterator2 first2, InputIterator2 last2,\n                                OutputIterator result, Compare comp) {\n  while (first1 != last1 && first2 != last2)\n    if (comp(*first1, *first2))\n      ++first1;\n    else if (comp(*first2, *first1))\n      ++first2;\n    else {\n      *result = *first1;\n      ++first1;\n      ++first2;\n      ++result;\n    }\n  return result;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator>\nOutputIterator set_difference(InputIterator1 first1, InputIterator1 last1,\n                              InputIterator2 first2, InputIterator2 last2,\n                              OutputIterator result) {\n  while (first1 != last1 && first2 != last2)\n    if (*first1 < *first2) {\n      *result = *first1;\n      ++first1;\n      ++result;\n    }\n    else if (*first2 < *first1)\n      ++first2;\n    else {\n      ++first1;\n      ++first2;\n    }\n  return copy(first1, last1, result);\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator, \n          class Compare>\nOutputIterator set_difference(InputIterator1 first1, InputIterator1 last1,\n                              InputIterator2 first2, InputIterator2 last2, \n                              OutputIterator result, Compare comp) {\n  while (first1 != last1 && first2 != last2)\n    if (comp(*first1, *first2)) {\n      *result = *first1;\n      ++first1;\n      ++result;\n    }\n    else if (comp(*first2, *first1))\n      ++first2;\n    else {\n      ++first1;\n      ++first2;\n    }\n  return copy(first1, last1, result);\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator>\nOutputIterator set_symmetric_difference(InputIterator1 first1,\n                                        InputIterator1 last1,\n                                        InputIterator2 first2,\n                                        InputIterator2 last2,\n                                        OutputIterator result) {\n  while (first1 != last1 && first2 != last2)\n    if (*first1 < *first2) {\n      *result = *first1;\n      ++first1;\n      ++result;\n    }\n    else if (*first2 < *first1) {\n      *result = *first2;\n      ++first2;\n      ++result;\n    }\n    else {\n      ++first1;\n      ++first2;\n    }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class InputIterator1, class InputIterator2, class OutputIterator,\n          class Compare>\nOutputIterator set_symmetric_difference(InputIterator1 first1,\n                                        InputIterator1 last1,\n                                        InputIterator2 first2,\n                                        InputIterator2 last2,\n                                        OutputIterator result, Compare comp) {\n  while (first1 != last1 && first2 != last2)\n    if (comp(*first1, *first2)) {\n      *result = *first1;\n      ++first1;\n      ++result;\n    }\n    else if (comp(*first2, *first1)) {\n      *result = *first2;\n      ++first2;\n      ++result;\n    }\n    else {\n      ++first1;\n      ++first2;\n    }\n  return copy(first2, last2, copy(first1, last1, result));\n}\n\ntemplate <class ForwardIterator>\nForwardIterator max_element(ForwardIterator first, ForwardIterator last) {\n  if (first == last) return first;\n  ForwardIterator result = first;\n  while (++first != last) \n    if (*result < *first) result = first;\n  return result;\n}\n\ntemplate <class ForwardIterator, class Compare>\nForwardIterator max_element(ForwardIterator first, ForwardIterator last,\n                            Compare comp) {\n  if (first == last) return first;\n  ForwardIterator result = first;\n  while (++first != last) \n    if (comp(*result, *first)) result = first;\n  return result;\n}\n\ntemplate <class ForwardIterator>\nForwardIterator min_element(ForwardIterator first, ForwardIterator last) {\n  if (first == last) return first;\n  ForwardIterator result = first;\n  while (++first != last) \n    if (*first < *result) result = first;\n  return result;\n}\n\ntemplate <class ForwardIterator, class Compare>\nForwardIterator min_element(ForwardIterator first, ForwardIterator last,\n                            Compare comp) {\n  if (first == last) return first;\n  ForwardIterator result = first;\n  while (++first != last) \n    if (comp(*first, *result)) result = first;\n  return result;\n}\n\ntemplate <class BidirectionalIterator>\nbool next_permutation(BidirectionalIterator first,\n                      BidirectionalIterator last) {\n  if (first == last) return false;\n  BidirectionalIterator i = first;\n  ++i;\n  if (i == last) return false;\n  i = last;\n  --i;\n\n  for(;;) {\n    BidirectionalIterator ii = i;\n    --i;\n    if (*i < *ii) {\n      BidirectionalIterator j = last;\n      while (!(*i < *--j));\n      iter_swap(i, j);\n      reverse(ii, last);\n      return true;\n    }\n    if (i == first) {\n      reverse(first, last);\n      return false;\n    }\n  }\n}\n\ntemplate <class BidirectionalIterator, class Compare>\nbool next_permutation(BidirectionalIterator first, BidirectionalIterator last,\n                      Compare comp) {\n  if (first == last) return false;\n  BidirectionalIterator i = first;\n  ++i;\n  if (i == last) return false;\n  i = last;\n  --i;\n\n  for(;;) {\n    BidirectionalIterator ii = i;\n    --i;\n    if (comp(*i, *ii)) {\n      BidirectionalIterator j = last;\n      while (!comp(*i, *--j));\n      iter_swap(i, j);\n      reverse(ii, last);\n      return true;\n    }\n    if (i == first) {\n      reverse(first, last);\n      return false;\n    }\n  }\n}\n\ntemplate <class BidirectionalIterator>\nbool prev_permutation(BidirectionalIterator first,\n                      BidirectionalIterator last) {\n  if (first == last) return false;\n  BidirectionalIterator i = first;\n  ++i;\n  if (i == last) return false;\n  i = last;\n  --i;\n\n  for(;;) {\n    BidirectionalIterator ii = i;\n    --i;\n    if (*ii < *i) {\n      BidirectionalIterator j = last;\n      while (!(*--j < *i));\n      iter_swap(i, j);\n      reverse(ii, last);\n      return true;\n    }\n    if (i == first) {\n      reverse(first, last);\n      return false;\n    }\n  }\n}\n\ntemplate <class BidirectionalIterator, class Compare>\nbool prev_permutation(BidirectionalIterator first, BidirectionalIterator last,\n                      Compare comp) {\n  if (first == last) return false;\n  BidirectionalIterator i = first;\n  ++i;\n  if (i == last) return false;\n  i = last;\n  --i;\n\n  for(;;) {\n    BidirectionalIterator ii = i;\n    --i;\n    if (comp(*ii, *i)) {\n      BidirectionalIterator j = last;\n      while (!comp(*--j, *i));\n      iter_swap(i, j);\n      reverse(ii, last);\n      return true;\n    }\n    if (i == first) {\n      reverse(first, last);\n      return false;\n    }\n  }\n}\n\ntemplate <class InputIterator, class ForwardIterator>\nInputIterator find_first_of(InputIterator first1, InputIterator last1,\n                            ForwardIterator first2, ForwardIterator last2)\n{\n  for ( ; first1 != last1; ++first1) \n    for (ForwardIterator iter = first2; iter != last2; ++iter)\n      if (*first1 == *iter)\n        return first1;\n  return last1;\n}\n\ntemplate <class InputIterator, class ForwardIterator, class BinaryPredicate>\nInputIterator find_first_of(InputIterator first1, InputIterator last1,\n                            ForwardIterator first2, ForwardIterator last2,\n                            BinaryPredicate comp)\n{\n  for ( ; first1 != last1; ++first1) \n    for (ForwardIterator iter = first2; iter != last2; ++iter)\n      if (comp(*first1, *iter))\n        return first1;\n  return last1;\n}\n\n\n// Search [first2, last2) as a subsequence in [first1, last1).\n\n// find_end for forward iterators. \ntemplate <class ForwardIterator1, class ForwardIterator2>\nForwardIterator1 __find_end(ForwardIterator1 first1, ForwardIterator1 last1,\n                            ForwardIterator2 first2, ForwardIterator2 last2,\n                            forward_iterator_tag, forward_iterator_tag)\n{\n  if (first2 == last2)\n    return last1;\n  else {\n    ForwardIterator1 result = last1;\n    while (1) {\n      ForwardIterator1 new_result = search(first1, last1, first2, last2);\n      if (new_result == last1)\n        return result;\n      else {\n        result = new_result;\n        first1 = new_result;\n        ++first1;\n      }\n    }\n  }\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2,\n          class BinaryPredicate>\nForwardIterator1 __find_end(ForwardIterator1 first1, ForwardIterator1 last1,\n                            ForwardIterator2 first2, ForwardIterator2 last2,\n                            forward_iterator_tag, forward_iterator_tag,\n                            BinaryPredicate comp)\n{\n  if (first2 == last2)\n    return last1;\n  else {\n    ForwardIterator1 result = last1;\n    while (1) {\n      ForwardIterator1 new_result = search(first1, last1, first2, last2, comp);\n      if (new_result == last1)\n        return result;\n      else {\n        result = new_result;\n        first1 = new_result;\n        ++first1;\n      }\n    }\n  }\n}\n\n// find_end for bidirectional iterators.  Requires partial specialization.\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2>\nBidirectionalIterator1\n__find_end(BidirectionalIterator1 first1, BidirectionalIterator1 last1,\n           BidirectionalIterator2 first2, BidirectionalIterator2 last2,\n           bidirectional_iterator_tag, bidirectional_iterator_tag)\n{\n  typedef reverse_iterator<BidirectionalIterator1> reviter1;\n  typedef reverse_iterator<BidirectionalIterator2> reviter2;\n\n  reviter1 rlast1(first1);\n  reviter2 rlast2(first2);\n  reviter1 rresult = search(reviter1(last1), rlast1, reviter2(last2), rlast2);\n\n  if (rresult == rlast1)\n    return last1;\n  else {\n    BidirectionalIterator1 result = rresult.base();\n    advance(result, -distance(first2, last2));\n    return result;\n  }\n}\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2,\n          class BinaryPredicate>\nBidirectionalIterator1\n__find_end(BidirectionalIterator1 first1, BidirectionalIterator1 last1,\n           BidirectionalIterator2 first2, BidirectionalIterator2 last2,\n           bidirectional_iterator_tag, bidirectional_iterator_tag, \n           BinaryPredicate comp)\n{\n  typedef reverse_iterator<BidirectionalIterator1> reviter1;\n  typedef reverse_iterator<BidirectionalIterator2> reviter2;\n\n  reviter1 rlast1(first1);\n  reviter2 rlast2(first2);\n  reviter1 rresult = search(reviter1(last1), rlast1, reviter2(last2), rlast2,\n                            comp);\n\n  if (rresult == rlast1)\n    return last1;\n  else {\n    BidirectionalIterator1 result = rresult.base();\n    advance(result, -distance(first2, last2));\n    return result;\n  }\n}\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Dispatching functions.\n\ntemplate <class ForwardIterator1, class ForwardIterator2>\ninline ForwardIterator1 \nfind_end(ForwardIterator1 first1, ForwardIterator1 last1, \n         ForwardIterator2 first2, ForwardIterator2 last2)\n{\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef typename iterator_traits<ForwardIterator1>::iterator_category\n          category1;\n  typedef typename iterator_traits<ForwardIterator2>::iterator_category\n          category2;\n  return __find_end(first1, last1, first2, last2, category1(), category2());\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  return __find_end(first1, last1, first2, last2,\n                    forward_iterator_tag(), forward_iterator_tag());\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2, \n          class BinaryPredicate>\ninline ForwardIterator1 \nfind_end(ForwardIterator1 first1, ForwardIterator1 last1, \n         ForwardIterator2 first2, ForwardIterator2 last2,\n         BinaryPredicate comp)\n{\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef typename iterator_traits<ForwardIterator1>::iterator_category\n          category1;\n  typedef typename iterator_traits<ForwardIterator2>::iterator_category\n          category2;\n  return __find_end(first1, last1, first2, last2, category1(), category2(),\n                    comp);\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  return __find_end(first1, last1, first2, last2,\n                    forward_iterator_tag(), forward_iterator_tag(),\n                    comp);\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n}\n\ntemplate <class RandomAccessIterator, class Distance>\nbool __is_heap(RandomAccessIterator first, RandomAccessIterator last,\n               Distance*)\n{\n  const Distance n = last - first;\n\n  Distance parent = 0;\n  for (Distance child = 1; child < n; ++child) {\n    if (first[parent] < first[child]) \n      return false;\n    if ((child & 1) == 0)\n      ++parent;\n  }\n  return true;\n}\n\ntemplate <class RandomAccessIterator>\ninline bool is_heap(RandomAccessIterator first, RandomAccessIterator last)\n{\n  return __is_heap(first, last, distance_type(first));\n}\n\n\ntemplate <class RandomAccessIterator, class Distance, class StrictWeakOrdering>\nbool __is_heap(RandomAccessIterator first, RandomAccessIterator last,\n               StrictWeakOrdering comp,\n               Distance*)\n{\n  const Distance n = last - first;\n\n  Distance parent = 0;\n  for (Distance child = 1; child < n; ++child) {\n    if (comp(first[parent], first[child]))\n      return false;\n    if ((child & 1) == 0)\n      ++parent;\n  }\n  return true;\n}\n\ntemplate <class RandomAccessIterator, class StrictWeakOrdering>\ninline bool is_heap(RandomAccessIterator first, RandomAccessIterator last,\n                    StrictWeakOrdering comp)\n{\n  return __is_heap(first, last, comp, distance_type(first));\n}\n\n\ntemplate <class ForwardIterator>\nbool is_sorted(ForwardIterator first, ForwardIterator last)\n{\n  if (first == last)\n    return true;\n\n  ForwardIterator next = first;\n  for (++next; next != last; first = next, ++next) {\n    if (*next < *first)\n      return false;\n  }\n\n  return true;\n}\n\ntemplate <class ForwardIterator, class StrictWeakOrdering>\nbool is_sorted(ForwardIterator first, ForwardIterator last,\n               StrictWeakOrdering comp)\n{\n  if (first == last)\n    return true;\n\n  ForwardIterator next = first;\n  for (++next; next != last; first = next, ++next) {\n    if (comp(*next, *first))\n      return false;\n  }\n\n  return true;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1209\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ALGO_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_algobase.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n\n#ifndef __SGI_STL_INTERNAL_ALGOBASE_H\n#define __SGI_STL_INTERNAL_ALGOBASE_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#include <stl_relops.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#include <stl_pair.h>\n#endif\n#ifndef __TYPE_TRAITS_H_\n#include <type_traits.h>\n#endif\n\n#include <string.h>\n#include <limits.h>\n#include <stdlib.h>\n#include <stddef.h>\n#include <new.h>\n#include <iostream.h>\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#include <stl_iterator.h>\n#endif\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class ForwardIterator1, class ForwardIterator2, class T>\ninline void __iter_swap(ForwardIterator1 a, ForwardIterator2 b, T*) {\n  T tmp = *a;\n  *a = *b;\n  *b = tmp;\n}\n\ntemplate <class ForwardIterator1, class ForwardIterator2>\ninline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) {\n  __iter_swap(a, b, value_type(a));\n}\n\ntemplate <class T>\ninline void swap(T& a, T& b) {\n  T tmp = a;\n  a = b;\n  b = tmp;\n}\n\n#ifndef __BORLANDC__\n\n#undef min\n#undef max\n\ntemplate <class T>\ninline const T& min(const T& a, const T& b) {\n  return b < a ? b : a;\n}\n\ntemplate <class T>\ninline const T& max(const T& a, const T& b) {\n  return  a < b ? b : a;\n}\n\n#endif /* __BORLANDC__ */\n\ntemplate <class T, class Compare>\ninline const T& min(const T& a, const T& b, Compare comp) {\n  return comp(b, a) ? b : a;\n}\n\ntemplate <class T, class Compare>\ninline const T& max(const T& a, const T& b, Compare comp) {\n  return comp(a, b) ? b : a;\n}\n\ntemplate <class InputIterator, class OutputIterator>\ninline OutputIterator __copy(InputIterator first, InputIterator last,\n                             OutputIterator result, input_iterator_tag)\n{\n  for ( ; first != last; ++result, ++first)\n    *result = *first;\n  return result;\n}\n\ntemplate <class RandomAccessIterator, class OutputIterator, class Distance>\ninline OutputIterator\n__copy_d(RandomAccessIterator first, RandomAccessIterator last,\n         OutputIterator result, Distance*)\n{\n  for (Distance n = last - first; n > 0; --n, ++result, ++first) \n    *result = *first;\n  return result;\n}\n\ntemplate <class RandomAccessIterator, class OutputIterator>\ninline OutputIterator \n__copy(RandomAccessIterator first, RandomAccessIterator last,\n       OutputIterator result, random_access_iterator_tag)\n{\n  return __copy_d(first, last, result, distance_type(first));\n}\n\ntemplate <class InputIterator, class OutputIterator>\nstruct __copy_dispatch\n{\n  OutputIterator operator()(InputIterator first, InputIterator last,\n                            OutputIterator result) {\n    return __copy(first, last, result, iterator_category(first));\n  }\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION \n\ntemplate <class T>\ninline T* __copy_t(const T* first, const T* last, T* result, __true_type) {\n  memmove(result, first, sizeof(T) * (last - first));\n  return result + (last - first);\n}\n\ntemplate <class T>\ninline T* __copy_t(const T* first, const T* last, T* result, __false_type) {\n  return __copy_d(first, last, result, (ptrdiff_t*) 0);\n}\n\ntemplate <class T>\nstruct __copy_dispatch<T*, T*>\n{\n  T* operator()(T* first, T* last, T* result) {\n    typedef typename __type_traits<T>::has_trivial_assignment_operator t; \n    return __copy_t(first, last, result, t());\n  }\n};\n\ntemplate <class T>\nstruct __copy_dispatch<const T*, T*>\n{\n  T* operator()(const T* first, const T* last, T* result) {\n    typedef typename __type_traits<T>::has_trivial_assignment_operator t; \n    return __copy_t(first, last, result, t());\n  }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class InputIterator, class OutputIterator>\ninline OutputIterator copy(InputIterator first, InputIterator last,\n                           OutputIterator result)\n{\n  return __copy_dispatch<InputIterator,OutputIterator>()(first, last, result);\n}\n\ninline char* copy(const char* first, const char* last, char* result) {\n  memmove(result, first, last - first);\n  return result + (last - first);\n}\n\ninline wchar_t* copy(const wchar_t* first, const wchar_t* last,\n                     wchar_t* result) {\n  memmove(result, first, sizeof(wchar_t) * (last - first));\n  return result + (last - first);\n}\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2>\ninline BidirectionalIterator2 __copy_backward(BidirectionalIterator1 first, \n                                              BidirectionalIterator1 last, \n                                              BidirectionalIterator2 result) {\n  while (first != last) *--result = *--last;\n  return result;\n}\n\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2>\nstruct __copy_backward_dispatch\n{\n  BidirectionalIterator2 operator()(BidirectionalIterator1 first, \n                                    BidirectionalIterator1 last, \n                                    BidirectionalIterator2 result) {\n    return __copy_backward(first, last, result);\n  }\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION \n\ntemplate <class T>\ninline T* __copy_backward_t(const T* first, const T* last, T* result,\n                            __true_type) {\n  const ptrdiff_t N = last - first;\n  memmove(result - N, first, sizeof(T) * N);\n  return result - N;\n}\n\ntemplate <class T>\ninline T* __copy_backward_t(const T* first, const T* last, T* result,\n                            __false_type) {\n  return __copy_backward(first, last, result);\n}\n\ntemplate <class T>\nstruct __copy_backward_dispatch<T*, T*>\n{\n  T* operator()(T* first, T* last, T* result) {\n    typedef typename __type_traits<T>::has_trivial_assignment_operator t; \n    return __copy_backward_t(first, last, result, t());\n  }\n};\n\ntemplate <class T>\nstruct __copy_backward_dispatch<const T*, T*>\n{\n  T* operator()(const T* first, const T* last, T* result) {\n    typedef typename __type_traits<T>::has_trivial_assignment_operator t; \n    return __copy_backward_t(first, last, result, t());\n  }\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class BidirectionalIterator1, class BidirectionalIterator2>\ninline BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, \n                                            BidirectionalIterator1 last, \n                                            BidirectionalIterator2 result) {\n  return __copy_backward_dispatch<BidirectionalIterator1, \n                                  BidirectionalIterator2>()(first, last, \n                                                            result);\n}\n\ntemplate <class InputIterator, class Size, class OutputIterator>\npair<InputIterator, OutputIterator> __copy_n(InputIterator first, Size count,\n                                             OutputIterator result,\n                                             input_iterator_tag) {\n  for ( ; count > 0; --count, ++first, ++result)\n    *result = *first;\n  return pair<InputIterator, OutputIterator>(first, result);\n}\n\ntemplate <class RandomAccessIterator, class Size, class OutputIterator>\ninline pair<RandomAccessIterator, OutputIterator>\n__copy_n(RandomAccessIterator first, Size count,\n         OutputIterator result,\n         random_access_iterator_tag) {\n  RandomAccessIterator last = first + count;\n  return pair<RandomAccessIterator, OutputIterator>(last,\n                                                    copy(first, last, result));\n}\n\ntemplate <class InputIterator, class Size, class OutputIterator>\ninline pair<InputIterator, OutputIterator>\ncopy_n(InputIterator first, Size count,\n       OutputIterator result) {\n  return __copy_n(first, count, result, iterator_category(first));\n}\n\ntemplate <class ForwardIterator, class T>\nvoid fill(ForwardIterator first, ForwardIterator last, const T& value) {\n  for ( ; first != last; ++first)\n    *first = value;\n}\n\ntemplate <class OutputIterator, class Size, class T>\nOutputIterator fill_n(OutputIterator first, Size n, const T& value) {\n  for ( ; n > 0; --n, ++first)\n    *first = value;\n  return first;\n}\n\ntemplate <class InputIterator1, class InputIterator2>\npair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,\n\t\t\t\t\t      InputIterator1 last1,\n\t\t\t\t\t      InputIterator2 first2) {\n  while (first1 != last1 && *first1 == *first2) {\n    ++first1;\n    ++first2;\n  }\n  return pair<InputIterator1, InputIterator2>(first1, first2);\n}\n\ntemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>\npair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1,\n\t\t\t\t\t      InputIterator1 last1,\n\t\t\t\t\t      InputIterator2 first2,\n\t\t\t\t\t      BinaryPredicate binary_pred) {\n  while (first1 != last1 && binary_pred(*first1, *first2)) {\n    ++first1;\n    ++first2;\n  }\n  return pair<InputIterator1, InputIterator2>(first1, first2);\n}\n\ntemplate <class InputIterator1, class InputIterator2>\ninline bool equal(InputIterator1 first1, InputIterator1 last1,\n\t\t  InputIterator2 first2) {\n  for ( ; first1 != last1; ++first1, ++first2)\n    if (*first1 != *first2)\n      return false;\n  return true;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class BinaryPredicate>\ninline bool equal(InputIterator1 first1, InputIterator1 last1,\n\t\t  InputIterator2 first2, BinaryPredicate binary_pred) {\n  for ( ; first1 != last1; ++first1, ++first2)\n    if (!binary_pred(*first1, *first2))\n      return false;\n  return true;\n}\n\ntemplate <class InputIterator1, class InputIterator2>\nbool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,\n\t\t\t     InputIterator2 first2, InputIterator2 last2) {\n  for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) {\n    if (*first1 < *first2)\n      return true;\n    if (*first2 < *first1)\n      return false;\n  }\n  return first1 == last1 && first2 != last2;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class Compare>\nbool lexicographical_compare(InputIterator1 first1, InputIterator1 last1,\n\t\t\t     InputIterator2 first2, InputIterator2 last2,\n\t\t\t     Compare comp) {\n  for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) {\n    if (comp(*first1, *first2))\n      return true;\n    if (comp(*first2, *first1))\n      return false;\n  }\n  return first1 == last1 && first2 != last2;\n}\n\ninline bool \nlexicographical_compare(const unsigned char* first1,\n                        const unsigned char* last1,\n                        const unsigned char* first2,\n                        const unsigned char* last2)\n{\n  const size_t len1 = last1 - first1;\n  const size_t len2 = last2 - first2;\n  const int result = memcmp(first1, first2, min(len1, len2));\n  return result != 0 ? result < 0 : len1 < len2;\n}\n\ninline bool lexicographical_compare(const char* first1, const char* last1,\n                                    const char* first2, const char* last2)\n{\n#if CHAR_MAX == SCHAR_MAX\n  return lexicographical_compare((const signed char*) first1,\n                                 (const signed char*) last1,\n                                 (const signed char*) first2,\n                                 (const signed char*) last2);\n#else\n  return lexicographical_compare((const unsigned char*) first1,\n                                 (const unsigned char*) last1,\n                                 (const unsigned char*) first2,\n                                 (const unsigned char*) last2);\n#endif\n}\n\ntemplate <class InputIterator1, class InputIterator2>\nint lexicographical_compare_3way(InputIterator1 first1, InputIterator1 last1,\n                                 InputIterator2 first2, InputIterator2 last2)\n{\n  while (first1 != last1 && first2 != last2) {\n    if (*first1 < *first2) return -1;\n    if (*first2 < *first1) return 1;\n    ++first1; ++first2;\n  }\n  if (first2 == last2) {\n    return !(first1 == last1);\n  } else {\n    return -1;\n  }\n}\n\ninline int\nlexicographical_compare_3way(const unsigned char* first1,\n                             const unsigned char* last1,\n                             const unsigned char* first2,\n                             const unsigned char* last2)\n{\n  const ptrdiff_t len1 = last1 - first1;\n  const ptrdiff_t len2 = last2 - first2;\n  const int result = memcmp(first1, first2, min(len1, len2));\n  return result != 0 ? result : (len1 == len2 ? 0 : (len1 < len2 ? -1 : 1));\n}\n\ninline int lexicographical_compare_3way(const char* first1, const char* last1,\n                                        const char* first2, const char* last2)\n{\n#if CHAR_MAX == SCHAR_MAX\n  return lexicographical_compare_3way(\n\t\t\t\t(const signed char*) first1,\n                                (const signed char*) last1,\n                                (const signed char*) first2,\n                                (const signed char*) last2);\n#else\n  return lexicographical_compare_3way((const unsigned char*) first1,\n                                      (const unsigned char*) last1,\n                                      (const unsigned char*) first2,\n                                      (const unsigned char*) last2);\n#endif\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_alloc.h",
    "content": "/*\n * Copyright (c) 1996-1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ALLOC_H\n#define __SGI_STL_INTERNAL_ALLOC_H\n\n#ifdef __SUNPRO_CC\n#  define __PRIVATE public\n   // Extra access restrictions prevent us from really making some things\n   // private.\n#else\n#  define __PRIVATE private\n#endif\n\n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\n#  define __USE_MALLOC\n#endif\n\n\n// This implements some standard node allocators.  These are\n// NOT the same as the allocators in the C++ draft standard or in\n// in the original STL.  They do not encapsulate different pointer\n// types; indeed we assume that there is only one pointer type.\n// The allocation primitives are intended to allocate individual objects,\n// not larger arenas as with the original STL allocators.\n\n#if 0\n#   include <new>\n#   define __THROW_BAD_ALLOC throw bad_alloc\n#elif !defined(__THROW_BAD_ALLOC)\n#   include <iostream.h>\n#   define __THROW_BAD_ALLOC cerr << \"out of memory\" << endl; exit(1)\n#endif\n\n#ifndef __ALLOC\n#   define __ALLOC alloc\n#endif\n#ifdef __STL_WIN32THREADS\n#   include <windows.h>\n#endif\n\n#include <stddef.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#ifndef __RESTRICT\n#  define __RESTRICT\n#endif\n\n#if !defined(__STL_PTHREADS) && !defined(_NOTHREADS) \\\n && !defined(__STL_SGI_THREADS) && !defined(__STL_WIN32THREADS)\n#   define _NOTHREADS\n#endif\n\n# ifdef __STL_PTHREADS\n    // POSIX Threads\n    // This is dubious, since this is likely to be a high contention\n    // lock.   Performance may not be adequate.\n#   include <pthread.h>\n#   define __NODE_ALLOCATOR_LOCK \\\n        if (threads) pthread_mutex_lock(&__node_allocator_lock)\n#   define __NODE_ALLOCATOR_UNLOCK \\\n        if (threads) pthread_mutex_unlock(&__node_allocator_lock)\n#   define __NODE_ALLOCATOR_THREADS true\n#   define __VOLATILE volatile  // Needed at -O3 on SGI\n# endif\n# ifdef __STL_WIN32THREADS\n    // The lock needs to be initialized by constructing an allocator\n    // objects of the right type.  We do that here explicitly for alloc.\n#   define __NODE_ALLOCATOR_LOCK \\\n        EnterCriticalSection(&__node_allocator_lock)\n#   define __NODE_ALLOCATOR_UNLOCK \\\n        LeaveCriticalSection(&__node_allocator_lock)\n#   define __NODE_ALLOCATOR_THREADS true\n#   define __VOLATILE volatile  // may not be needed\n# endif /* WIN32THREADS */\n# ifdef __STL_SGI_THREADS\n    // This should work without threads, with sproc threads, or with\n    // pthreads.  It is suboptimal in all cases.\n    // It is unlikely to even compile on nonSGI machines.\n\n    extern \"C\" {\n      extern int __us_rsthread_malloc;\n    }\n\t// The above is copied from malloc.h.  Including <malloc.h>\n\t// would be cleaner but fails with certain levels of standard\n\t// conformance.\n#   define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \\\n                { __lock(&__node_allocator_lock); }\n#   define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \\\n                { __unlock(&__node_allocator_lock); }\n#   define __NODE_ALLOCATOR_THREADS true\n#   define __VOLATILE volatile  // Needed at -O3 on SGI\n# endif\n# ifdef _NOTHREADS\n//  Thread-unsafe\n#   define __NODE_ALLOCATOR_LOCK\n#   define __NODE_ALLOCATOR_UNLOCK\n#   define __NODE_ALLOCATOR_THREADS false\n#   define __VOLATILE\n# endif\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// Malloc-based allocator.  Typically slower than default alloc below.\n// Typically thread-safe and more storage efficient.\n#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG\n# ifdef __DECLARE_GLOBALS_HERE\n    void (* __malloc_alloc_oom_handler)() = 0;\n    // g++ 2.7.2 does not handle static template data members.\n# else\n    extern void (* __malloc_alloc_oom_handler)();\n# endif\n#endif\n\ntemplate <int inst>\nclass __malloc_alloc_template {\n\nprivate:\n\nstatic void *oom_malloc(size_t);\n\nstatic void *oom_realloc(void *, size_t);\n\n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG\n    static void (* __malloc_alloc_oom_handler)();\n#endif\n\npublic:\n\nstatic void * allocate(size_t n)\n{\n    void *result = malloc(n);\n    if (0 == result) result = oom_malloc(n);\n    return result;\n}\n\nstatic void deallocate(void *p, size_t /* n */)\n{\n    free(p);\n}\n\nstatic void * reallocate(void *p, size_t /* old_sz */, size_t new_sz)\n{\n    void * result = realloc(p, new_sz);\n    if (0 == result) result = oom_realloc(p, new_sz);\n    return result;\n}\n\nstatic void (* set_malloc_handler(void (*f)()))()\n{\n    void (* old)() = __malloc_alloc_oom_handler;\n    __malloc_alloc_oom_handler = f;\n    return(old);\n}\n\n};\n\n// malloc_alloc out-of-memory handling\n\n#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG\ntemplate <int inst>\nvoid (* __malloc_alloc_template<inst>::__malloc_alloc_oom_handler)() = 0;\n#endif\n\ntemplate <int inst>\nvoid * __malloc_alloc_template<inst>::oom_malloc(size_t n)\n{\n    void (* my_malloc_handler)();\n    void *result;\n\n    for (;;) {\n        my_malloc_handler = __malloc_alloc_oom_handler;\n        if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; }\n        (*my_malloc_handler)();\n        result = malloc(n);\n        if (result) return(result);\n    }\n}\n\ntemplate <int inst>\nvoid * __malloc_alloc_template<inst>::oom_realloc(void *p, size_t n)\n{\n    void (* my_malloc_handler)();\n    void *result;\n\n    for (;;) {\n        my_malloc_handler = __malloc_alloc_oom_handler;\n        if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; }\n        (*my_malloc_handler)();\n        result = realloc(p, n);\n        if (result) return(result);\n    }\n}\n\ntypedef __malloc_alloc_template<0> malloc_alloc;\n\ntemplate<class T, class Alloc>\nclass simple_alloc {\n\npublic:\n    static T *allocate(size_t n)\n                { return 0 == n? 0 : (T*) Alloc::allocate(n * sizeof (T)); }\n    static T *allocate(void)\n                { return (T*) Alloc::allocate(sizeof (T)); }\n    static void deallocate(T *p, size_t n)\n                { if (0 != n) Alloc::deallocate(p, n * sizeof (T)); }\n    static void deallocate(T *p)\n                { Alloc::deallocate(p, sizeof (T)); }\n};\n\n// Allocator adaptor to check size arguments for debugging.\n// Reports errors using assert.  Checking can be disabled with\n// NDEBUG, but it's far better to just use the underlying allocator\n// instead when no checking is desired.\n// There is some evidence that this can confuse Purify.\ntemplate <class Alloc>\nclass debug_alloc {\n\nprivate:\n\nenum {extra = 8};       // Size of space used to store size.  Note\n                        // that this must be large enough to preserve\n                        // alignment.\n\npublic:\n\nstatic void * allocate(size_t n)\n{\n    char *result = (char *)Alloc::allocate(n + extra);\n    *(size_t *)result = n;\n    return result + extra;\n}\n\nstatic void deallocate(void *p, size_t n)\n{\n    char * real_p = (char *)p - extra;\n    assert(*(size_t *)real_p == n);\n    Alloc::deallocate(real_p, n + extra);\n}\n\nstatic void * reallocate(void *p, size_t old_sz, size_t new_sz)\n{\n    char * real_p = (char *)p - extra;\n    assert(*(size_t *)real_p == old_sz);\n    char * result = (char *)\n                  Alloc::reallocate(real_p, old_sz + extra, new_sz + extra);\n    *(size_t *)result = new_sz;\n    return result + extra;\n}\n\n\n};\n\n\n# ifdef __USE_MALLOC\n\ntypedef malloc_alloc alloc;\ntypedef malloc_alloc single_client_alloc;\n\n# else\n\n\n// Default node allocator.\n// With a reasonable compiler, this should be roughly as fast as the\n// original STL class-specific allocators, but with less fragmentation.\n// Default_alloc_template parameters are experimental and MAY\n// DISAPPEAR in the future.  Clients should just use alloc for now.\n//\n// Important implementation properties:\n// 1. If the client request an object of size > __MAX_BYTES, the resulting\n//    object will be obtained directly from malloc.\n// 2. In all other cases, we allocate an object of size exactly\n//    ROUND_UP(requested_size).  Thus the client has enough size\n//    information that we can return the object to the proper free list\n//    without permanently losing part of the object.\n//\n\n// The first template parameter specifies whether more than one thread\n// may use this allocator.  It is safe to allocate an object from\n// one instance of a default_alloc and deallocate it with another\n// one.  This effectively transfers its ownership to the second one.\n// This may have undesirable effects on reference locality.\n// The second parameter is unreferenced and serves only to allow the\n// creation of multiple default_alloc instances.\n// Node that containers built on different allocator instances have\n// different types, limiting the utility of this approach.\n#ifdef __SUNPRO_CC\n// breaks if we make these template class members:\n  enum {__ALIGN = 8};\n  enum {__MAX_BYTES = 128};\n  enum {__NFREELISTS = __MAX_BYTES/__ALIGN};\n#endif\n\ntemplate <bool threads, int inst>\nclass __default_alloc_template {\n\nprivate:\n  // Really we should use static const int x = N\n  // instead of enum { x = N }, but few compilers accept the former.\n# ifndef __SUNPRO_CC\n    enum {__ALIGN = 8};\n    enum {__MAX_BYTES = 128};\n    enum {__NFREELISTS = __MAX_BYTES/__ALIGN};\n# endif\n  static size_t ROUND_UP(size_t bytes) {\n        return (((bytes) + __ALIGN-1) & ~(__ALIGN - 1));\n  }\n__PRIVATE:\n  union obj {\n        union obj * free_list_link;\n        char client_data[1];    /* The client sees this.        */\n  };\nprivate:\n# ifdef __SUNPRO_CC\n    static obj * __VOLATILE free_list[]; \n        // Specifying a size results in duplicate def for 4.1\n# else\n    static obj * __VOLATILE free_list[__NFREELISTS]; \n# endif\n  static  size_t FREELIST_INDEX(size_t bytes) {\n        return (((bytes) + __ALIGN-1)/__ALIGN - 1);\n  }\n\n  // Returns an object of size n, and optionally adds to size n free list.\n  static void *refill(size_t n);\n  // Allocates a chunk for nobjs of size \"size\".  nobjs may be reduced\n  // if it is inconvenient to allocate the requested number.\n  static char *chunk_alloc(size_t size, int &nobjs);\n\n  // Chunk allocation state.\n  static char *start_free;\n  static char *end_free;\n  static size_t heap_size;\n\n# ifdef __STL_SGI_THREADS\n    static volatile unsigned long __node_allocator_lock;\n    static void __lock(volatile unsigned long *); \n    static inline void __unlock(volatile unsigned long *);\n# endif\n\n# ifdef __STL_PTHREADS\n    static pthread_mutex_t __node_allocator_lock;\n# endif\n\n# ifdef __STL_WIN32THREADS\n    static CRITICAL_SECTION __node_allocator_lock;\n    static bool __node_allocator_lock_initialized;\n\n  public:\n    __default_alloc_template() {\n\t// This assumes the first constructor is called before threads\n\t// are started.\n        if (!__node_allocator_lock_initialized) {\n            InitializeCriticalSection(&__node_allocator_lock);\n            __node_allocator_lock_initialized = true;\n        }\n    }\n  private:\n# endif\n\n    class lock {\n        public:\n            lock() { __NODE_ALLOCATOR_LOCK; }\n            ~lock() { __NODE_ALLOCATOR_UNLOCK; }\n    };\n    friend class lock;\n\npublic:\n\n  /* n must be > 0      */\n  static void * allocate(size_t n)\n  {\n    obj * __VOLATILE * my_free_list;\n    obj * __RESTRICT result;\n\n    if (n > (size_t) __MAX_BYTES) {\n        return(malloc_alloc::allocate(n));\n    }\n    my_free_list = free_list + FREELIST_INDEX(n);\n    // Acquire the lock here with a constructor call.\n    // This ensures that it is released in exit or during stack\n    // unwinding.\n#       ifndef _NOTHREADS\n        /*REFERENCED*/\n        lock lock_instance;\n#       endif\n    result = *my_free_list;\n    if (result == 0) {\n        void *r = refill(ROUND_UP(n));\n        return r;\n    }\n    *my_free_list = result -> free_list_link;\n    return (result);\n  };\n\n  /* p may not be 0 */\n  static void deallocate(void *p, size_t n)\n  {\n    obj *q = (obj *)p;\n    obj * __VOLATILE * my_free_list;\n\n    if (n > (size_t) __MAX_BYTES) {\n        malloc_alloc::deallocate(p, n);\n        return;\n    }\n    my_free_list = free_list + FREELIST_INDEX(n);\n    // acquire lock\n#       ifndef _NOTHREADS\n        /*REFERENCED*/\n        lock lock_instance;\n#       endif /* _NOTHREADS */\n    q -> free_list_link = *my_free_list;\n    *my_free_list = q;\n    // lock is released here\n  }\n\n  static void * reallocate(void *p, size_t old_sz, size_t new_sz);\n\n} ;\n\ntypedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;\ntypedef __default_alloc_template<false, 0> single_client_alloc;\n\n\n\n/* We allocate memory in large chunks in order to avoid fragmenting     */\n/* the malloc heap too much.                                            */\n/* We assume that size is properly aligned.                             */\n/* We hold the allocation lock.                                         */\ntemplate <bool threads, int inst>\nchar*\n__default_alloc_template<threads, inst>::chunk_alloc(size_t size, int& nobjs)\n{\n    char * result;\n    size_t total_bytes = size * nobjs;\n    size_t bytes_left = end_free - start_free;\n\n    if (bytes_left >= total_bytes) {\n        result = start_free;\n        start_free += total_bytes;\n        return(result);\n    } else if (bytes_left >= size) {\n        nobjs = bytes_left/size;\n        total_bytes = size * nobjs;\n        result = start_free;\n        start_free += total_bytes;\n        return(result);\n    } else {\n        size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4);\n        // Try to make use of the left-over piece.\n        if (bytes_left > 0) {\n            obj * __VOLATILE * my_free_list =\n                        free_list + FREELIST_INDEX(bytes_left);\n\n            ((obj *)start_free) -> free_list_link = *my_free_list;\n            *my_free_list = (obj *)start_free;\n        }\n        start_free = (char *)malloc(bytes_to_get);\n        if (0 == start_free) {\n            int i;\n            obj * __VOLATILE * my_free_list, *p;\n            // Try to make do with what we have.  That can't\n            // hurt.  We do not try smaller requests, since that tends\n            // to result in disaster on multi-process machines.\n            for (i = size; i <= __MAX_BYTES; i += __ALIGN) {\n                my_free_list = free_list + FREELIST_INDEX(i);\n                p = *my_free_list;\n                if (0 != p) {\n                    *my_free_list = p -> free_list_link;\n                    start_free = (char *)p;\n                    end_free = start_free + i;\n                    return(chunk_alloc(size, nobjs));\n                    // Any leftover piece will eventually make it to the\n                    // right free list.\n                }\n            }\n\t    end_free = 0;\t// In case of exception.\n            start_free = (char *)malloc_alloc::allocate(bytes_to_get);\n            // This should either throw an\n            // exception or remedy the situation.  Thus we assume it\n            // succeeded.\n        }\n        heap_size += bytes_to_get;\n        end_free = start_free + bytes_to_get;\n        return(chunk_alloc(size, nobjs));\n    }\n}\n\n\n/* Returns an object of size n, and optionally adds to size n free list.*/\n/* We assume that n is properly aligned.                                */\n/* We hold the allocation lock.                                         */\ntemplate <bool threads, int inst>\nvoid* __default_alloc_template<threads, inst>::refill(size_t n)\n{\n    int nobjs = 20;\n    char * chunk = chunk_alloc(n, nobjs);\n    obj * __VOLATILE * my_free_list;\n    obj * result;\n    obj * current_obj, * next_obj;\n    int i;\n\n    if (1 == nobjs) return(chunk);\n    my_free_list = free_list + FREELIST_INDEX(n);\n\n    /* Build free list in chunk */\n      result = (obj *)chunk;\n      *my_free_list = next_obj = (obj *)(chunk + n);\n      for (i = 1; ; i++) {\n        current_obj = next_obj;\n        next_obj = (obj *)((char *)next_obj + n);\n        if (nobjs - 1 == i) {\n            current_obj -> free_list_link = 0;\n            break;\n        } else {\n            current_obj -> free_list_link = next_obj;\n        }\n      }\n    return(result);\n}\n\ntemplate <bool threads, int inst>\nvoid*\n__default_alloc_template<threads, inst>::reallocate(void *p,\n                                                    size_t old_sz,\n                                                    size_t new_sz)\n{\n    void * result;\n    size_t copy_sz;\n\n    if (old_sz > (size_t) __MAX_BYTES && new_sz > (size_t) __MAX_BYTES) {\n        return(realloc(p, new_sz));\n    }\n    if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p);\n    result = allocate(new_sz);\n    copy_sz = new_sz > old_sz? old_sz : new_sz;\n    memcpy(result, p, copy_sz);\n    deallocate(p, old_sz);\n    return(result);\n}\n\n#ifdef __STL_PTHREADS\n    template <bool threads, int inst>\n    pthread_mutex_t\n    __default_alloc_template<threads, inst>::__node_allocator_lock\n        = PTHREAD_MUTEX_INITIALIZER;\n#endif\n\n#ifdef __STL_WIN32THREADS\n    template <bool threads, int inst> CRITICAL_SECTION\n    __default_alloc_template<threads, inst>::__node_allocator_lock;\n\n    template <bool threads, int inst> bool\n    __default_alloc_template<threads, inst>::__node_allocator_lock_initialized\n\t= false;\n#endif\n\n#ifdef __STL_SGI_THREADS\n__STL_END_NAMESPACE\n#include <mutex.h>\n#include <time.h>\n__STL_BEGIN_NAMESPACE\n// Somewhat generic lock implementations.  We need only test-and-set\n// and some way to sleep.  These should work with both SGI pthreads\n// and sproc threads.  They may be useful on other systems.\ntemplate <bool threads, int inst>\nvolatile unsigned long\n__default_alloc_template<threads, inst>::__node_allocator_lock = 0;\n\n#if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) || defined(__GNUC__)\n#   define __test_and_set(l,v) test_and_set(l,v)\n#endif\n\ntemplate <bool threads, int inst>\nvoid \n__default_alloc_template<threads, inst>::__lock(volatile unsigned long *lock)\n{\n    const unsigned low_spin_max = 30;  // spin cycles if we suspect uniprocessor\n    const unsigned high_spin_max = 1000; // spin cycles for multiprocessor\n    static unsigned spin_max = low_spin_max;\n    unsigned my_spin_max;\n    static unsigned last_spins = 0;\n    unsigned my_last_spins;\n    static struct timespec ts = {0, 1000};\n    unsigned junk;\n#   define __ALLOC_PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk\n    int i;\n\n    if (!__test_and_set((unsigned long *)lock, 1)) {\n        return;\n    }\n    my_spin_max = spin_max;\n    my_last_spins = last_spins;\n    for (i = 0; i < my_spin_max; i++) {\n        if (i < my_last_spins/2 || *lock) {\n            __ALLOC_PAUSE;\n            continue;\n        }\n        if (!__test_and_set((unsigned long *)lock, 1)) {\n            // got it!\n            // Spinning worked.  Thus we're probably not being scheduled\n            // against the other process with which we were contending.\n            // Thus it makes sense to spin longer the next time.\n            last_spins = i;\n            spin_max = high_spin_max;\n            return;\n        }\n    }\n    // We are probably being scheduled against the other process.  Sleep.\n    spin_max = low_spin_max;\n    for (;;) {\n        if (!__test_and_set((unsigned long *)lock, 1)) {\n            return;\n        }\n        nanosleep(&ts, 0);\n    }\n}\n\ntemplate <bool threads, int inst>\ninline void\n__default_alloc_template<threads, inst>::__unlock(volatile unsigned long *lock)\n{\n#   if defined(__GNUC__) && __mips >= 3\n        asm(\"sync\");\n        *lock = 0;\n#   elif __mips >= 3 && (defined (_ABIN32) || defined(_ABI64))\n        __lock_release(lock);\n#   else \n        *lock = 0;\n        // This is not sufficient on many multiprocessors, since\n        // writes to protected variables and the lock may be reordered.\n#   endif\n}\n#endif\n\ntemplate <bool threads, int inst>\nchar *__default_alloc_template<threads, inst>::start_free = 0;\n\ntemplate <bool threads, int inst>\nchar *__default_alloc_template<threads, inst>::end_free = 0;\n\ntemplate <bool threads, int inst>\nsize_t __default_alloc_template<threads, inst>::heap_size = 0;\n\ntemplate <bool threads, int inst>\n__default_alloc_template<threads, inst>::obj * __VOLATILE\n__default_alloc_template<threads, inst> ::free_list[\n# ifdef __SUNPRO_CC\n    __NFREELISTS\n# else\n    __default_alloc_template<threads, inst>::__NFREELISTS\n# endif\n] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };\n// The 16 zeros are necessary to make version 4.1 of the SunPro\n// compiler happy.  Otherwise it appears to allocate too little\n// space for the array.\n\n# ifdef __STL_WIN32THREADS\n  // Create one to get critical section initialized.\n  // We do this onece per file, but only the first constructor\n  // does anything.\n  static alloc __node_allocator_dummy_instance;\n# endif\n\n#endif /* ! __USE_MALLOC */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#undef __PRIVATE\n\n#endif /* __SGI_STL_INTERNAL_ALLOC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_bvector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_BVECTOR_H\n#define __SGI_STL_INTERNAL_BVECTOR_H\n\n__STL_BEGIN_NAMESPACE \n\nstatic const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\nstruct __bit_reference {\n  unsigned int* p;\n  unsigned int mask;\n  __bit_reference(unsigned int* x, unsigned int y) : p(x), mask(y) {}\n\npublic:\n  __bit_reference() : p(0), mask(0) {}\n  operator bool() const { return !(!(*p & mask)); }\n  __bit_reference& operator=(bool x) {\n    if (x)      \n      *p |= mask;\n    else \n      *p &= ~mask;\n    return *this;\n  }\n  __bit_reference& operator=(const __bit_reference& x) { return *this = bool(x); }\n  bool operator==(const __bit_reference& x) const {\n    return bool(*this) == bool(x);\n  }\n  bool operator<(const __bit_reference& x) const {\n    return bool(*this) < bool(x);\n  }\n  void flip() { *p ^= mask; }\n};\n\ninline void swap(__bit_reference x, __bit_reference y) {\n  bool tmp = x;\n  x = y;\n  y = tmp;\n}\n\nstruct __bit_iterator : public random_access_iterator<bool, ptrdiff_t> {\n  typedef __bit_reference  reference;\n  typedef __bit_reference* pointer;\n  typedef __bit_iterator iterator;\n\n  unsigned int* p;\n  unsigned int offset;\n  void bump_up() {\n    if (offset++ == __WORD_BIT - 1) {\n      offset = 0;\n      ++p;\n    }\n  }\n  void bump_down() {\n    if (offset-- == 0) {\n      offset = __WORD_BIT - 1;\n      --p;\n    }\n  }\n\n  __bit_iterator() : p(0), offset(0) {}\n  __bit_iterator(unsigned int* x, unsigned int y) : p(x), offset(y) {}\n  reference operator*() const { return reference(p, 1U << offset); }\n  iterator& operator++() {\n    bump_up();\n    return *this;\n  }\n  iterator operator++(int) {\n    iterator tmp = *this;\n    bump_up();\n    return tmp;\n  }\n  iterator& operator--() {\n    bump_down();\n    return *this;\n  }\n  iterator operator--(int) {\n    iterator tmp = *this;\n    bump_down();\n    return tmp;\n  }\n  iterator& operator+=(difference_type i) {\n    difference_type n = i + offset;\n    p += n / __WORD_BIT;\n    n = n % __WORD_BIT;\n    if (n < 0) {\n      offset = (unsigned int) n + __WORD_BIT;\n      --p;\n    } else\n      offset = (unsigned int) n;\n    return *this;\n  }\n  iterator& operator-=(difference_type i) {\n    *this += -i;\n    return *this;\n  }\n  iterator operator+(difference_type i) const {\n    iterator tmp = *this;\n    return tmp += i;\n  }\n  iterator operator-(difference_type i) const {\n    iterator tmp = *this;\n    return tmp -= i;\n  }\n  difference_type operator-(iterator x) const {\n    return __WORD_BIT * (p - x.p) + offset - x.offset;\n  }\n  reference operator[](difference_type i) { return *(*this + i); }\n  bool operator==(const iterator& x) const {\n    return p == x.p && offset == x.offset;\n  }\n  bool operator!=(const iterator& x) const {\n    return p != x.p || offset != x.offset;\n  }\n  bool operator<(iterator x) const {\n    return p < x.p || (p == x.p && offset < x.offset);\n  }\n};\n\nstruct __bit_const_iterator\n  : public random_access_iterator<bool, ptrdiff_t>\n{\n  typedef bool                 reference;\n  typedef bool                 const_reference;\n  typedef const bool*          pointer;\n  typedef __bit_const_iterator const_iterator;\n\n  unsigned int* p;\n  unsigned int offset;\n  void bump_up() {\n    if (offset++ == __WORD_BIT - 1) {\n      offset = 0;\n      ++p;\n    }\n  }\n  void bump_down() {\n    if (offset-- == 0) {\n      offset = __WORD_BIT - 1;\n      --p;\n    }\n  }\n\n  __bit_const_iterator() : p(0), offset(0) {}\n  __bit_const_iterator(unsigned int* x, unsigned int y) : p(x), offset(y) {}\n  __bit_const_iterator(const __bit_iterator& x) : p(x.p), offset(x.offset) {}\n  const_reference operator*() const {\n    return __bit_reference(p, 1U << offset);\n  }\n  const_iterator& operator++() {\n    bump_up();\n    return *this;\n  }\n  const_iterator operator++(int) {\n    const_iterator tmp = *this;\n    bump_up();\n    return tmp;\n  }\n  const_iterator& operator--() {\n    bump_down();\n    return *this;\n  }\n  const_iterator operator--(int) {\n    const_iterator tmp = *this;\n    bump_down();\n    return tmp;\n  }\n  const_iterator& operator+=(difference_type i) {\n    difference_type n = i + offset;\n    p += n / __WORD_BIT;\n    n = n % __WORD_BIT;\n    if (n < 0) {\n      offset = (unsigned int) n + __WORD_BIT;\n      --p;\n    } else\n      offset = (unsigned int) n;\n    return *this;\n  }\n  const_iterator& operator-=(difference_type i) {\n    *this += -i;\n    return *this;\n  }\n  const_iterator operator+(difference_type i) const {\n    const_iterator tmp = *this;\n    return tmp += i;\n  }\n  const_iterator operator-(difference_type i) const {\n    const_iterator tmp = *this;\n    return tmp -= i;\n  }\n  difference_type operator-(const_iterator x) const {\n    return __WORD_BIT * (p - x.p) + offset - x.offset;\n  }\n  const_reference operator[](difference_type i) { \n    return *(*this + i); \n  }\n  bool operator==(const const_iterator& x) const {\n    return p == x.p && offset == x.offset;\n  }\n  bool operator!=(const const_iterator& x) const {\n    return p != x.p || offset != x.offset;\n  }\n  bool operator<(const_iterator x) const {\n    return p < x.p || (p == x.p && offset < x.offset);\n  }\n};\n\n// The next few lines are confusing.  What we're doing is declaring a\n//  partial specialization of vector<T, Alloc> if we have the necessary\n//  compiler support.  Otherwise, we define a class bit_vector which uses\n//  the default allocator.  In either case, we typedef \"data_allocator\" \n//  appropriately.\n\n#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NEED_BOOL)\n#define __SGI_STL_VECBOOL_TEMPLATE\n#define __BVECTOR vector\n#else\n#undef __SGI_STL_VECBOOL_TEMPLATE\n#define __BVECTOR bit_vector\n#endif\n\n#      ifdef __SGI_STL_VECBOOL_TEMPLATE\n       __STL_END_NAMESPACE\n#      include <stl_vector.h>\n       __STL_BEGIN_NAMESPACE\ntemplate<class Alloc> class vector<bool, Alloc>\n#      else /* __SGI_STL_VECBOOL_TEMPLATE */\nclass bit_vector\n#      endif /* __SGI_STL_VECBOOL_TEMPLATE */\n{\n#      ifdef __SGI_STL_VECBOOL_TEMPLATE\n  typedef simple_alloc<unsigned int, Alloc> data_allocator;\n#      else /* __SGI_STL_VECBOOL_TEMPLATE */\n  typedef simple_alloc<unsigned int, alloc> data_allocator;  \n#      endif /* __SGI_STL_VECBOOL_TEMPLATE */\npublic:\n  typedef bool value_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type; \n  typedef __bit_reference reference;\n  typedef bool const_reference;\n  typedef __bit_reference* pointer;\n  typedef const bool* const_pointer;\n\n  typedef __bit_iterator                iterator;\n  typedef __bit_const_iterator          const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type> const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:\n  iterator start;\n  iterator finish;\n  unsigned int* end_of_storage;\n  unsigned int* bit_alloc(size_type n) {\n    return data_allocator::allocate((n + __WORD_BIT - 1)/__WORD_BIT);\n  }\n  void deallocate() {\n    if (start.p)\n      data_allocator::deallocate(start.p, end_of_storage - start.p);\n  }\n  void initialize(size_type n) {\n    unsigned int* q = bit_alloc(n);\n    end_of_storage = q + (n + __WORD_BIT - 1)/__WORD_BIT;\n    start = iterator(q, 0);\n    finish = start + difference_type(n);\n  }\n  void insert_aux(iterator position, bool x) {\n    if (finish.p != end_of_storage) {\n      copy_backward(position, finish, finish + 1);\n      *position = x;\n      ++finish;\n    }\n    else {\n      size_type len = size() ? 2 * size() : __WORD_BIT;\n      unsigned int* q = bit_alloc(len);\n      iterator i = copy(begin(), position, iterator(q, 0));\n      *i++ = x;\n      finish = copy(position, end(), i);\n      deallocate();\n      end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT;\n      start = iterator(q, 0);\n    }\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void initialize_range(InputIterator first, InputIterator last,\n                        input_iterator_tag) {\n    start = iterator();\n    finish = iterator();\n    end_of_storage = 0;\n    for ( ; first != last; ++first) \n      push_back(*first);\n  }\n\n  template <class ForwardIterator>\n  void initialize_range(ForwardIterator first, ForwardIterator last,\n                        forward_iterator_tag) {\n    size_type n = 0;\n    distance(first, last, n);\n    initialize(n);\n    copy(first, last, start);\n  }\n\n  template <class InputIterator>\n  void insert_range(iterator pos,\n                    InputIterator first, InputIterator last,\n                    input_iterator_tag) {\n    for ( ; first != last; ++first) {\n      pos = insert(pos, *first);\n      ++pos;\n    }\n  }\n\n  template <class ForwardIterator>\n  void insert_range(iterator position,\n                    ForwardIterator first, ForwardIterator last,\n                    forward_iterator_tag) {\n    if (first != last) {\n      size_type n = 0;\n      distance(first, last, n);\n      if (capacity() - size() >= n) {\n        copy_backward(position, end(), finish + difference_type(n));\n        copy(first, last, position);\n        finish += difference_type(n);\n      }\n      else {\n        size_type len = size() + max(size(), n);\n        unsigned int* q = bit_alloc(len);\n        iterator i = copy(begin(), position, iterator(q, 0));\n        i = copy(first, last, i);\n        finish = copy(position, end(), i);\n        deallocate();\n        end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT;\n        start = iterator(q, 0);\n      }\n    }\n  }      \n\n#endif /* __STL_MEMBER_TEMPLATES */\n\npublic:\n  iterator begin() { return start; }\n  const_iterator begin() const { return start; }\n  iterator end() { return finish; }\n  const_iterator end() const { return finish; }\n\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin()); \n  }\n\n  size_type size() const { return size_type(end() - begin()); }\n  size_type max_size() const { return size_type(-1); }\n  size_type capacity() const {\n    return size_type(const_iterator(end_of_storage, 0) - begin());\n  }\n  bool empty() const { return begin() == end(); }\n  reference operator[](size_type n) {\n    return *(begin() + difference_type(n));\n  }\n  const_reference operator[](size_type n) const {\n    return *(begin() + difference_type(n));\n  }\n  __BVECTOR() : start(iterator()), finish(iterator()), end_of_storage(0) {}\n  __BVECTOR(size_type n, bool value) {\n    initialize(n);\n    fill(start.p, end_of_storage, value ? ~0 : 0);\n  }\n  __BVECTOR(int n, bool value) {\n    initialize(n);\n    fill(start.p, end_of_storage, value ? ~0 : 0);\n  }\n  __BVECTOR(long n, bool value) {\n    initialize(n);\n    fill(start.p, end_of_storage, value ? ~0 : 0);\n  }\n  explicit __BVECTOR(size_type n) {\n    initialize(n);\n    fill(start.p, end_of_storage, 0);\n  }\n  __BVECTOR(const __BVECTOR& x) {\n    initialize(x.size());\n    copy(x.begin(), x.end(), start);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  __BVECTOR(InputIterator first, InputIterator last) {\n    initialize_range(first, last, iterator_category(first));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  __BVECTOR(const_iterator first, const_iterator last) {\n    size_type n = 0;\n    distance(first, last, n);\n    initialize(n);\n    copy(first, last, start);\n  }\n  __BVECTOR(const bool* first, const bool* last) {\n    size_type n = 0;\n    distance(first, last, n);\n    initialize(n);\n    copy(first, last, start);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  ~__BVECTOR() { deallocate(); }\n  __BVECTOR& operator=(const __BVECTOR& x) {\n    if (&x == this) return *this;\n    if (x.size() > capacity()) {\n      deallocate();\n      initialize(x.size());\n    }\n    copy(x.begin(), x.end(), begin());\n    finish = begin() + difference_type(x.size());\n    return *this;\n  }\n  void reserve(size_type n) {\n    if (capacity() < n) {\n      unsigned int* q = bit_alloc(n);\n      finish = copy(begin(), end(), iterator(q, 0));\n      deallocate();\n      start = iterator(q, 0);\n      end_of_storage = q + (n + __WORD_BIT - 1)/__WORD_BIT;\n    }\n  }\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(end() - 1); }\n  const_reference back() const { return *(end() - 1); }\n  void push_back(bool x) {\n    if (finish.p != end_of_storage)\n      *finish++ = x;\n    else\n      insert_aux(end(), x);\n  }\n  void swap(__BVECTOR& x) {\n    __STD::swap(start, x.start);\n    __STD::swap(finish, x.finish);\n    __STD::swap(end_of_storage, x.end_of_storage);\n  }\n  iterator insert(iterator position, bool x = bool()) {\n    difference_type n = position - begin();\n    if (finish.p != end_of_storage && position == end())\n      *finish++ = x;\n    else\n      insert_aux(position, x);\n    return begin() + n;\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator> void insert(iterator position,\n                                             InputIterator first,\n                                             InputIterator last) {\n    insert_range(position, first, last, iterator_category(first));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator position, const_iterator first, \n              const_iterator last) {\n    if (first == last) return;\n    size_type n = 0;\n    distance(first, last, n);\n    if (capacity() - size() >= n) {\n      copy_backward(position, end(), finish + n);\n      copy(first, last, position);\n      finish += n;\n    }\n    else {\n      size_type len = size() + max(size(), n);\n      unsigned int* q = bit_alloc(len);\n      iterator i = copy(begin(), position, iterator(q, 0));\n      i = copy(first, last, i);\n      finish = copy(position, end(), i);\n      deallocate();\n      end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT;\n      start = iterator(q, 0);\n    }\n  }\n\n  void insert(iterator position, const bool* first, const bool* last) {\n    if (first == last) return;\n    size_type n = 0;\n    distance(first, last, n);\n    if (capacity() - size() >= n) {\n      copy_backward(position, end(), finish + n);\n      copy(first, last, position);\n      finish += n;\n    }\n    else {\n      size_type len = size() + max(size(), n);\n      unsigned int* q = bit_alloc(len);\n      iterator i = copy(begin(), position, iterator(q, 0));\n      i = copy(first, last, i);\n      finish = copy(position, end(), i);\n      deallocate();\n      end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT;\n      start = iterator(q, 0);\n    }\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  \n  void insert(iterator position, size_type n, bool x) {\n    if (n == 0) return;\n    if (capacity() - size() >= n) {\n      copy_backward(position, end(), finish + difference_type(n));\n      fill(position, position + difference_type(n), x);\n      finish += difference_type(n);\n    }\n    else {\n      size_type len = size() + max(size(), n);\n      unsigned int* q = bit_alloc(len);\n      iterator i = copy(begin(), position, iterator(q, 0));\n      fill_n(i, n, x);\n      finish = copy(position, end(), i + difference_type(n));\n      deallocate();\n      end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT;\n      start = iterator(q, 0);\n    }\n  }\n\n  void insert(iterator pos, int n, bool x)  { insert(pos, (size_type)n, x); }\n  void insert(iterator pos, long n, bool x) { insert(pos, (size_type)n, x); }\n\n  void pop_back() { --finish; }\n  iterator erase(iterator position) {\n    if (position + 1 != end())\n      copy(position + 1, end(), position);\n    --finish;\n    return position;\n  }\n  iterator erase(iterator first, iterator last) {\n    finish = copy(last, end(), first);\n    return first;\n  }\n  void resize(size_type new_size, bool x = bool()) {\n    if (new_size < size()) \n      erase(begin() + difference_type(new_size), end());\n    else\n      insert(end(), new_size - size(), x);\n  }\n  void clear() { erase(begin(), end()); }\n};\n\n#ifdef __SGI_STL_VECBOOL_TEMPLATE\n\ntypedef vector<bool, alloc> bit_vector;\n\n#else /* __SGI_STL_VECBOOL_TEMPLATE */\n\ninline bool operator==(const bit_vector& x, const bit_vector& y) {\n  return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());\n}\n\ninline bool operator<(const bit_vector& x, const bit_vector& y) {\n  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());\n}\n\n#endif /* __SGI_STL_VECBOOL_TEMPLATE */\n\n#undef __SGI_STL_VECBOOL_TEMPLATE\n#undef __BVECTOR\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_BVECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_config.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n#ifndef __STL_CONFIG_H\n# define __STL_CONFIG_H\n\n// What this file does.\n//  (1)  Defines bool, true, and false if the compiler doesn't do so already.\n//  (2)  Defines __STL_NO_DRAND48 if the compiler's standard library does\n//       not support the drand48() function.\n//  (3)  Defines __STL_STATIC_TEMPLATE_MEMBER_BUG if the compiler can't \n//       handle static members of template classes.\n//  (4)  Defines 'typename' as a null macro if the compiler does not support\n//       the typename keyword.\n//  (5)  Defines __STL_CLASS_PARTIAL_SPECIALIZATION if the compiler \n//       supports partial specialization of class templates.\n//  (6)  Defines __STL_FUNCTION_TMPL_PARTIAL_ORDER if the compiler supports\n//       partial ordering of function templates (a.k.a partial specialization\n//       of function templates.\n//  (7)  Defines __STL_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler\n//       supports calling a function template by providing its template\n//       arguments explicitly.\n//  (8)  Defines __STL_MEMBER_TEMPLATES if the compiler supports\n//       template members of classes.\n//  (9)  Defines 'explicit' as a null macro if the compiler does not support\n//       the explicit keyword.    \n//  (10) Defines __STL_LIMITED_DEFAULT_TEMPLATES if the compiler is\n//       unable to handle default template parameters that depend on\n//       previous template parameters.\n//  (11) Defines __STL_NON_TYPE_TMPL_PARAM_BUG if the compiler has \n//       trouble performing function template argument deduction for\n//       non-type template parameters.\n//  (12) Defines __SGI_STL_NO_ARROW_OPERATOR if the compiler is unable\n//       to support the -> operator for iterators.\n//  (13) Defines __STL_USE_EXCEPTIONS if the compiler (in the current\n//       compilation mode) supports exceptions.\n//  (14) Define __STL_USE_NAMESPACES if we're putting the STL into a \n//       namespace.  \n//  (15) Defines __STL_SGI_THREADS if this is being compiled on an SGI\n//       compiler, and if the user hasn't selected pthreads or no threads\n//       instead.\n//  (16) Defines __STL_WIN32THREADS if this is being compiled on a \n//       WIN32 compiler in multithreaded mode.\n//  (17) Define namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)\n//       apropriately.\n//  (18) Define exception-related macros (__STL_TRY, __STL_UNWIND, etc.)\n//       appropriately.\n//  (19) Defines __stl_assert either as a test or as a null macro,\n//       depending on whether or not __STL_ASSERTIONS is defined.\n\n#ifdef _PTHREADS\n#   define __STL_PTHREADS\n#endif\n\n# if defined(__sgi) && !defined(__GNUC__)\n#   if !defined(_BOOL)\n#     define __STL_NEED_BOOL\n#   endif\n#   if !defined(_TYPENAME_IS_KEYWORD)\n#     define __STL_NEED_TYPENAME\n#   endif\n#   ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   endif\n#   ifdef _MEMBER_TEMPLATES\n#     define __STL_MEMBER_TEMPLATES\n#   endif\n#   if !defined(_EXPLICIT_IS_KEYWORD)\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)\n#     define __STL_USE_NAMESPACES\n#   endif \n#   if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)\n#     define __STL_SGI_THREADS\n#   endif\n# endif\n\n# ifdef __GNUC__\n#   include <_G_config.h>\n#   if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)\n#     define __STL_STATIC_TEMPLATE_MEMBER_BUG\n#     define __STL_NEED_TYPENAME\n#     define __STL_NEED_EXPLICIT\n#   else\n#     define __STL_CLASS_PARTIAL_SPECIALIZATION\n#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER\n#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#     define __STL_MEMBER_TEMPLATES\n#   endif\n    /* glibc pre 2.0 is very buggy. We have to disable thread for it.\n       It should be upgraded to glibc 2.0 or later. */\n#   if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)\n#     define __STL_PTHREADS\n#   endif\n#   ifdef __EXCEPTIONS\n#     define __STL_USE_EXCEPTIONS\n#   endif\n# endif\n\n# if defined(__SUNPRO_CC) \n#   define __STL_NEED_BOOL\n#   define __STL_NEED_TYPENAME\n#   define __STL_NEED_EXPLICIT\n#   define __STL_USE_EXCEPTIONS\n# endif\n\n# if defined(__COMO__)\n#   define __STL_MEMBER_TEMPLATES\n#   define __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_USE_EXCEPTIONS\n#   define __STL_USE_NAMESPACES\n# endif\n\n# if defined(_MSC_VER)\n#   if _MSC_VER > 1000\n#     include <yvals.h>\n#   else\n#     define __STL_NEED_BOOL\n#   endif\n#   define __STL_NO_DRAND48\n#   define __STL_NEED_TYPENAME\n#   if _MSC_VER < 1100\n#     define __STL_NEED_EXPLICIT\n#   endif\n#   define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef _MT\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n# if defined(__BORLANDC__)\n#   define __STL_NO_DRAND48\n#   define __STL_NEED_TYPENAME\n#   define __STL_LIMITED_DEFAULT_TEMPLATES\n#   define __SGI_STL_NO_ARROW_OPERATOR\n#   define __STL_NON_TYPE_TMPL_PARAM_BUG\n#   ifdef _CPPUNWIND\n#     define __STL_USE_EXCEPTIONS\n#   endif\n#   ifdef __MT__\n#     define __STL_WIN32THREADS\n#   endif\n# endif\n\n\n# if defined(__STL_NEED_BOOL)\n    typedef int bool;\n#   define true 1\n#   define false 0\n# endif\n\n# ifdef __STL_NEED_TYPENAME\n#   define typename\n# endif\n\n# ifdef __STL_NEED_EXPLICIT\n#   define explicit\n# endif\n\n# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS\n#   define __STL_NULL_TMPL_ARGS <>\n# else\n#   define __STL_NULL_TMPL_ARGS\n# endif\n\n# ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n#   define __STL_TEMPLATE_NULL template<>\n# else\n#   define __STL_TEMPLATE_NULL\n# endif\n\n// __STL_NO_NAMESPACES is a hook so that users can disable namespaces\n// without having to edit library headers.\n# if defined(__STL_USE_NAMESPACES) && !defined(__STL_NO_NAMESPACES)\n#   define __STD std\n#   define __STL_BEGIN_NAMESPACE namespace std {\n#   define __STL_END_NAMESPACE }\n#   define  __STL_USE_NAMESPACE_FOR_RELOPS\n#   define __STL_BEGIN_RELOPS_NAMESPACE namespace std {\n#   define __STL_END_RELOPS_NAMESPACE }\n#   define __STD_RELOPS std\n# else\n#   define __STD \n#   define __STL_BEGIN_NAMESPACE \n#   define __STL_END_NAMESPACE \n#   undef  __STL_USE_NAMESPACE_FOR_RELOPS\n#   define __STL_BEGIN_RELOPS_NAMESPACE \n#   define __STL_END_RELOPS_NAMESPACE \n#   define __STD_RELOPS \n# endif\n\n# ifdef __STL_USE_EXCEPTIONS\n#   define __STL_TRY try\n#   define __STL_CATCH_ALL catch(...)\n#   define __STL_RETHROW throw\n#   define __STL_NOTHROW throw()\n#   define __STL_UNWIND(action) catch(...) { action; throw; }\n# else\n#   define __STL_TRY \n#   define __STL_CATCH_ALL if (false)\n#   define __STL_RETHROW \n#   define __STL_NOTHROW \n#   define __STL_UNWIND(action) \n# endif\n\n#ifdef __STL_ASSERTIONS\n# include <stdio.h>\n# define __stl_assert(expr) \\\n    if (!(expr)) { fprintf(stderr, \"%s:%d STL assertion failure: %s\\n\", \\\n\t\t\t  __FILE__, __LINE__, # expr); abort(); }\n#else\n# define __stl_assert(expr)\n#endif\n\n#endif /* __STL_CONFIG_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_construct.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#define __SGI_STL_INTERNAL_CONSTRUCT_H\n\n#include <new.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class T>\ninline void destroy(T* pointer) {\n    pointer->~T();\n}\n\ntemplate <class T1, class T2>\ninline void construct(T1* p, const T2& value) {\n  new (p) T1(value);\n}\n\ntemplate <class ForwardIterator>\ninline void\n__destroy_aux(ForwardIterator first, ForwardIterator last, __false_type) {\n  for ( ; first < last; ++first)\n    destroy(&*first);\n}\n\ntemplate <class ForwardIterator> \ninline void __destroy_aux(ForwardIterator, ForwardIterator, __true_type) {}\n\ntemplate <class ForwardIterator, class T>\ninline void __destroy(ForwardIterator first, ForwardIterator last, T*) {\n  typedef typename __type_traits<T>::has_trivial_destructor trivial_destructor;\n  __destroy_aux(first, last, trivial_destructor());\n}\n\ntemplate <class ForwardIterator>\ninline void destroy(ForwardIterator first, ForwardIterator last) {\n  __destroy(first, last, value_type(first));\n}\n\ninline void destroy(char*, char*) {}\ninline void destroy(wchar_t*, wchar_t*) {}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_deque.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_DEQUE_H\n#define __SGI_STL_INTERNAL_DEQUE_H\n\n/* Class invariants:\n *  For any nonsingular iterator i:\n *    i.node is the address of an element in the map array.  The\n *      contents of i.node is a pointer to the beginning of a node.\n *    i.first == *(i.node) \n *    i.last  == i.first + node_size\n *    i.cur is a pointer in the range [i.first, i.last).  NOTE:\n *      the implication of this is that i.cur is always a dereferenceable\n *      pointer, even if i is a past-the-end iterator.\n *  Start and Finish are always nonsingular iterators.  NOTE: this means\n *    that an empty deque must have one node, and that a deque\n *    with N elements, where N is the buffer size, must have two nodes.\n *  For every node other than start.node and finish.node, every element\n *    in the node is an initialized object.  If start.node == finish.node,\n *    then [start.cur, finish.cur) are initialized objects, and\n *    the elements outside that range are uninitialized storage.  Otherwise,\n *    [start.cur, start.last) and [finish.first, finish.cur) are initialized\n *    objects, and [start.first, start.cur) and [finish.cur, finish.last)\n *    are uninitialized storage.\n *  [map, map + map_size) is a valid, non-empty range.  \n *  [start.node, finish.node] is a valid range contained within \n *    [map, map + map_size).  \n *  A pointer in the range [map, map + map_size) points to an allocated\n *    node if and only if the pointer is in the range [start.node, finish.node].\n */\n\n\n/*\n * In previous versions of deque, node_size was fixed by the \n * implementation.  In this version, however, users can select\n * the node size.  Deque has three template parameters; the third,\n * a number of type size_t, is the number of elements per node.\n * If the third template parameter is 0 (which is the default), \n * then deque will use a default node size.\n *\n * The only reason for using an alternate node size is if your application\n * requires a different performance tradeoff than the default.  If,\n * for example, your program contains many deques each of which contains\n * only a few elements, then you might want to save memory (possibly\n * by sacrificing some speed) by using smaller nodes.\n *\n * Unfortunately, some compilers have trouble with non-type template \n * parameters; stl_config.h defines __STL_NON_TYPE_TMPL_PARAM_BUG if\n * that is the case.  If your compiler is one of them, then you will\n * not be able to use alternate node sizes; you will have to use the\n * default value.\n */\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// Note: this function is simply a kludge to work around several compilers'\n//  bugs in handling constant expressions.\ninline size_t __deque_buf_size(size_t n, size_t sz)\n{\n  return n != 0 ? n : (sz < 512 ? size_t(512 / sz) : size_t(1));\n}\n\n#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG\ntemplate <class T, class Ref, class Ptr, size_t BufSiz>\nstruct __deque_iterator {\n  typedef __deque_iterator<T, T&, T*, BufSiz>             iterator;\n  typedef __deque_iterator<T, const T&, const T*, BufSiz> const_iterator;\n  static size_t buffer_size() {return __deque_buf_size(BufSiz, sizeof(T)); }\n#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */\ntemplate <class T, class Ref, class Ptr>\nstruct __deque_iterator {\n  typedef __deque_iterator<T, T&, T*>             iterator;\n  typedef __deque_iterator<T, const T&, const T*> const_iterator;\n  static size_t buffer_size() {return __deque_buf_size(0, sizeof(T)); }\n#endif\n\n  typedef random_access_iterator_tag iterator_category;\n  typedef T value_type;\n  typedef Ptr pointer;\n  typedef Ref reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n  typedef T** map_pointer;\n\n  typedef __deque_iterator self;\n\n  T* cur;\n  T* first;\n  T* last;\n  map_pointer node;\n\n  __deque_iterator(T* x, map_pointer y) \n    : cur(x), first(*y), last(*y + buffer_size()), node(y) {}\n  __deque_iterator() : cur(0), first(0), last(0), node(0) {}\n  __deque_iterator(const iterator& x)\n    : cur(x.cur), first(x.first), last(x.last), node(x.node) {}\n\n  reference operator*() const { return *cur; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  difference_type operator-(const self& x) const {\n    return difference_type(buffer_size()) * (node - x.node - 1) +\n      (cur - first) + (x.last - x.cur);\n  }\n\n  self& operator++() {\n    ++cur;\n    if (cur == last) {\n      set_node(node + 1);\n      cur = first;\n    }\n    return *this; \n  }\n  self operator++(int)  {\n    self tmp = *this;\n    ++*this;\n    return tmp;\n  }\n\n  self& operator--() {\n    if (cur == first) {\n      set_node(node - 1);\n      cur = last;\n    }\n    --cur;\n    return *this;\n  }\n  self operator--(int) {\n    self tmp = *this;\n    --*this;\n    return tmp;\n  }\n\n  self& operator+=(difference_type n) {\n    difference_type offset = n + (cur - first);\n    if (offset >= 0 && offset < difference_type(buffer_size()))\n      cur += n;\n    else {\n      difference_type node_offset =\n        offset > 0 ? offset / difference_type(buffer_size())\n                   : -difference_type((-offset - 1) / buffer_size()) - 1;\n      set_node(node + node_offset);\n      cur = first + (offset - node_offset * difference_type(buffer_size()));\n    }\n    return *this;\n  }\n\n  self operator+(difference_type n) const {\n    self tmp = *this;\n    return tmp += n;\n  }\n\n  self& operator-=(difference_type n) { return *this += -n; }\n \n  self operator-(difference_type n) const {\n    self tmp = *this;\n    return tmp -= n;\n  }\n\n  reference operator[](difference_type n) const { return *(*this + n); }\n\n  bool operator==(const self& x) const { return cur == x.cur; }\n  bool operator!=(const self& x) const { return !(*this == x); }\n  bool operator<(const self& x) const {\n    return (node == x.node) ? (cur < x.cur) : (node < x.node);\n  }\n\n  void set_node(map_pointer new_node) {\n    node = new_node;\n    first = *new_node;\n    last = first + difference_type(buffer_size());\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\n#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG\n\ntemplate <class T, class Ref, class Ptr, size_t BufSiz>\ninline random_access_iterator_tag\niterator_category(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {\n  return random_access_iterator_tag();\n}\n\ntemplate <class T, class Ref, class Ptr, size_t BufSiz>\ninline T* value_type(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {\n  return 0;\n}\n\ntemplate <class T, class Ref, class Ptr, size_t BufSiz>\ninline ptrdiff_t* distance_type(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {\n  return 0;\n}\n\n#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n\ntemplate <class T, class Ref, class Ptr>\ninline random_access_iterator_tag\niterator_category(const __deque_iterator<T, Ref, Ptr>&) {\n  return random_access_iterator_tag();\n}\n\ntemplate <class T, class Ref, class Ptr>\ninline T* value_type(const __deque_iterator<T, Ref, Ptr>&) { return 0; }\n\ntemplate <class T, class Ref, class Ptr>\ninline ptrdiff_t* distance_type(const __deque_iterator<T, Ref, Ptr>&) {\n  return 0;\n}\n\n#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// See __deque_buf_size().  The only reason that the default value is 0\n//  is as a workaround for bugs in the way that some compilers handle\n//  constant expressions.\ntemplate <class T, class Alloc = alloc, size_t BufSiz = 0> \nclass deque {\npublic:                         // Basic types\n  typedef T value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\npublic:                         // Iterators\n#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG\n  typedef __deque_iterator<T, T&, T*, BufSiz>              iterator;\n  typedef __deque_iterator<T, const T&, const T&, BufSiz>  const_iterator;\n#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n  typedef __deque_iterator<T, T&, T*>                      iterator;\n  typedef __deque_iterator<T, const T&, const T*>          const_iterator;\n#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type>  \n          const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator; \n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:                      // Internal typedefs\n  typedef pointer* map_pointer;\n  typedef simple_alloc<value_type, Alloc> data_allocator;\n  typedef simple_alloc<pointer, Alloc> map_allocator;\n\n  static size_type buffer_size() {\n    return __deque_buf_size(BufSiz, sizeof(value_type));\n  }\n  static size_type initial_map_size() { return 8; }\n\nprotected:                      // Data members\n  iterator start;\n  iterator finish;\n\n  map_pointer map;\n  size_type map_size;\n\npublic:                         // Basic accessors\n  iterator begin() { return start; }\n  iterator end() { return finish; }\n  const_iterator begin() const { return start; }\n  const_iterator end() const { return finish; }\n\n  reverse_iterator rbegin() { return reverse_iterator(finish); }\n  reverse_iterator rend() { return reverse_iterator(start); }\n  const_reverse_iterator rbegin() const {\n    return const_reverse_iterator(finish);\n  }\n  const_reverse_iterator rend() const {\n    return const_reverse_iterator(start);\n  }\n\n  reference operator[](size_type n) { return start[difference_type(n)]; }\n  const_reference operator[](size_type n) const {\n    return start[difference_type(n)];\n  }\n\n  reference front() { return *start; }\n  reference back() {\n    iterator tmp = finish;\n    --tmp;\n    return *tmp;\n  }\n  const_reference front() const { return *start; }\n  const_reference back() const {\n    const_iterator tmp = finish;\n    --tmp;\n    return *tmp;\n  }\n\n  size_type size() const { return finish - start;; }\n  size_type max_size() const { return size_type(-1); }\n  bool empty() const { return finish == start; }\n\npublic:                         // Constructor, destructor.\n  deque()\n    : start(), finish(), map(0), map_size(0)\n  {\n    create_map_and_nodes(0);\n  }\n\n  deque(const deque& x)\n    : start(), finish(), map(0), map_size(0)\n  {\n    create_map_and_nodes(x.size());\n    __STL_TRY {\n      uninitialized_copy(x.begin(), x.end(), start);\n    }\n    __STL_UNWIND(destroy_map_and_nodes());\n  }\n\n  deque(size_type n, const value_type& value)\n    : start(), finish(), map(0), map_size(0)\n  {\n    fill_initialize(n, value);\n  }\n\n  deque(int n, const value_type& value)\n    : start(), finish(), map(0), map_size(0)\n  {\n    fill_initialize(n, value);\n  }\n \n  deque(long n, const value_type& value)\n    : start(), finish(), map(0), map_size(0)\n  {\n    fill_initialize(n, value);\n  }\n\n  explicit deque(size_type n)\n    : start(), finish(), map(0), map_size(0)\n  {\n    fill_initialize(n, value_type());\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n\n  template <class InputIterator>\n  deque(InputIterator first, InputIterator last)\n    : start(), finish(), map(0), map_size(0)\n  {\n    range_initialize(first, last, iterator_category(first));\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  deque(const value_type* first, const value_type* last)\n    : start(), finish(), map(0), map_size(0)\n  {\n    create_map_and_nodes(last - first);\n    __STL_TRY {\n      uninitialized_copy(first, last, start);\n    }\n    __STL_UNWIND(destroy_map_and_nodes());\n  }\n\n  deque(const_iterator first, const_iterator last)\n    : start(), finish(), map(0), map_size(0)\n  {\n    create_map_and_nodes(last - first);\n    __STL_TRY {\n      uninitialized_copy(first, last, start);\n    }\n    __STL_UNWIND(destroy_map_and_nodes());\n  }\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  ~deque() {\n    destroy(start, finish);\n    destroy_map_and_nodes();\n  }\n\n  deque& operator= (const deque& x) {\n    const size_type len = size();\n    if (&x != this) {\n      if (len >= x.size())\n        erase(copy(x.begin(), x.end(), start), finish);\n      else {\n        const_iterator mid = x.begin() + difference_type(len);\n        copy(x.begin(), mid, start);\n        insert(finish, mid, x.end());\n      }\n    }\n    return *this;\n  }        \n\n  void swap(deque& x) {\n    __STD::swap(start, x.start);\n    __STD::swap(finish, x.finish);\n    __STD::swap(map, x.map);\n    __STD::swap(map_size, x.map_size);\n  }\n\npublic:                         // push_* and pop_*\n  \n  void push_back(const value_type& t) {\n    if (finish.cur != finish.last - 1) {\n      construct(finish.cur, t);\n      ++finish.cur;\n    }\n    else\n      push_back_aux(t);\n  }\n\n  void push_front(const value_type& t) {\n    if (start.cur != start.first) {\n      construct(start.cur - 1, t);\n      --start.cur;\n    }\n    else\n      push_front_aux(t);\n  }\n\n  void pop_back() {\n    if (finish.cur != finish.first) {\n      --finish.cur;\n      destroy(finish.cur);\n    }\n    else\n      pop_back_aux();\n  }\n\n  void pop_front() {\n    if (start.cur != start.last - 1) {\n      destroy(start.cur);\n      ++start.cur;\n    }\n    else \n      pop_front_aux();\n  }\n\npublic:                         // Insert\n\n  iterator insert(iterator position, const value_type& x) {\n    if (position.cur == start.cur) {\n      push_front(x);\n      return start;\n    }\n    else if (position.cur == finish.cur) {\n      push_back(x);\n      iterator tmp = finish;\n      --tmp;\n      return tmp;\n    }\n    else {\n      return insert_aux(position, x);\n    }\n  }\n\n  iterator insert(iterator position) { return insert(position, value_type()); }\n\n  void insert(iterator pos, size_type n, const value_type& x); \n\n  void insert(iterator pos, int n, const value_type& x) {\n    insert(pos, (size_type) n, x);\n  }\n  void insert(iterator pos, long n, const value_type& x) {\n    insert(pos, (size_type) n, x);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class InputIterator>\n  void insert(iterator pos, InputIterator first, InputIterator last) {\n    insert(pos, first, last, iterator_category(first));\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n\n  void insert(iterator pos, const value_type* first, const value_type* last);\n  void insert(iterator pos, const_iterator first, const_iterator last);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void resize(size_type new_size, const value_type& x) {\n    const size_type len = size();\n    if (new_size < len) \n      erase(start + new_size, finish);\n    else\n      insert(finish, new_size - len, x);\n  }\n\n  void resize(size_type new_size) { resize(new_size, value_type()); }\n\npublic:                         // Erase\n  iterator erase(iterator pos) {\n    iterator next = pos;\n    ++next;\n    difference_type index = pos - start;\n    if (index < (size() >> 1)) {\n      copy_backward(start, pos, next);\n      pop_front();\n    }\n    else {\n      copy(next, finish, pos);\n      pop_back();\n    }\n    return start + index;\n  }\n\n  iterator erase(iterator first, iterator last);\n  void clear(); \n\nprotected:                        // Internal construction/destruction\n\n  void create_map_and_nodes(size_type num_elements);\n  void destroy_map_and_nodes();\n  void fill_initialize(size_type n, const value_type& value);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class InputIterator>\n  void range_initialize(InputIterator first, InputIterator last,\n                        input_iterator_tag);\n\n  template <class ForwardIterator>\n  void range_initialize(ForwardIterator first, ForwardIterator last,\n                        forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprotected:                        // Internal push_* and pop_*\n\n  void push_back_aux(const value_type& t);\n  void push_front_aux(const value_type& t);\n  void pop_back_aux();\n  void pop_front_aux();\n\nprotected:                        // Internal insert functions\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class InputIterator>\n  void insert(iterator pos, InputIterator first, InputIterator last,\n              input_iterator_tag);\n\n  template <class ForwardIterator>\n  void insert(iterator pos, ForwardIterator first, ForwardIterator last,\n              forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator insert_aux(iterator pos, const value_type& x);\n  void insert_aux(iterator pos, size_type n, const value_type& x);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\n  template <class ForwardIterator>\n  void insert_aux(iterator pos, ForwardIterator first, ForwardIterator last,\n                  size_type n);\n\n#else /* __STL_MEMBER_TEMPLATES */\n  \n  void insert_aux(iterator pos,\n                  const value_type* first, const value_type* last,\n                  size_type n);\n\n  void insert_aux(iterator pos, const_iterator first, const_iterator last,\n                  size_type n);\n \n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator reserve_elements_at_front(size_type n) {\n    size_type vacancies = start.cur - start.first;\n    if (n > vacancies) \n      new_elements_at_front(n - vacancies);\n    return start - difference_type(n);\n  }\n\n  iterator reserve_elements_at_back(size_type n) {\n    size_type vacancies = (finish.last - finish.cur) - 1;\n    if (n > vacancies)\n      new_elements_at_back(n - vacancies);\n    return finish + difference_type(n);\n  }\n\n  void new_elements_at_front(size_type new_elements);\n  void new_elements_at_back(size_type new_elements);\n\n  void destroy_nodes_at_front(iterator before_start);\n  void destroy_nodes_at_back(iterator after_finish);\n\nprotected:                      // Allocation of map and nodes\n\n  // Makes sure the map has space for new nodes.  Does not actually\n  //  add the nodes.  Can invalidate map pointers.  (And consequently, \n  //  deque iterators.)\n\n  void reserve_map_at_back (size_type nodes_to_add = 1) {\n    if (nodes_to_add + 1 > map_size - (finish.node - map))\n      reallocate_map(nodes_to_add, false);\n  }\n\n  void reserve_map_at_front (size_type nodes_to_add = 1) {\n    if (nodes_to_add > start.node - map)\n      reallocate_map(nodes_to_add, true);\n  }\n\n  void reallocate_map(size_type nodes_to_add, bool add_at_front);\n\n  pointer allocate_node() { return data_allocator::allocate(buffer_size()); }\n  void deallocate_node(pointer n) {\n    data_allocator::deallocate(n, buffer_size());\n  }\n\n#ifdef __STL_NON_TYPE_TMPL_PARAM_BUG\npublic:\n  bool operator==(const deque<T, Alloc, 0>& x) const {\n    return size() == x.size() && equal(begin(), end(), x.begin());\n  }\n  bool operator!=(const deque<T, Alloc, 0>& x) const {\n    return size() != x.size() || !equal(begin(), end(), x.begin());\n  }\n  bool operator<(const deque<T, Alloc, 0>& x) const {\n    return lexicographical_compare(begin(), end(), x.begin(), x.end());\n  }\n#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n};\n\n// Non-inline member functions\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert(iterator pos,\n                                      size_type n, const value_type& x) {\n  if (pos.cur == start.cur) {\n    iterator new_start = reserve_elements_at_front(n);\n    uninitialized_fill(new_start, start, x);\n    start = new_start;\n  }\n  else if (pos.cur == finish.cur) {\n    iterator new_finish = reserve_elements_at_back(n);\n    uninitialized_fill(finish, new_finish, x);\n    finish = new_finish;\n  }\n  else \n    insert_aux(pos, n, x);\n}\n\n#ifndef __STL_MEMBER_TEMPLATES  \n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert(iterator pos,\n                                      const value_type* first,\n                                      const value_type* last) {\n  size_type n = last - first;\n  if (pos.cur == start.cur) {\n    iterator new_start = reserve_elements_at_front(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, new_start);\n      start = new_start;\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else if (pos.cur == finish.cur) {\n    iterator new_finish = reserve_elements_at_back(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, finish);\n      finish = new_finish;\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n  else\n    insert_aux(pos, first, last, n);\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert(iterator pos,\n                                      const_iterator first,\n                                      const_iterator last)\n{\n  size_type n = last - first;\n  if (pos.cur == start.cur) {\n    iterator new_start = reserve_elements_at_front(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, new_start);\n      start = new_start;\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else if (pos.cur == finish.cur) {\n    iterator new_finish = reserve_elements_at_back(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, finish);\n      finish = new_finish;\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n  else\n    insert_aux(pos, first, last, n);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc, size_t BufSize>\ndeque<T, Alloc, BufSize>::iterator \ndeque<T, Alloc, BufSize>::erase(iterator first, iterator last) {\n  if (first == start && last == finish) {\n    clear();\n    return finish;\n  }\n  else {\n    difference_type n = last - first;\n    difference_type elems_before = first - start;\n    if (elems_before < (size() - n) / 2) {\n      copy_backward(start, first, last);\n      iterator new_start = start + n;\n      destroy(start, new_start);\n      for (map_pointer cur = start.node; cur < new_start.node; ++cur)\n        data_allocator::deallocate(*cur, buffer_size());\n      start = new_start;\n    }\n    else {\n      copy(last, finish, first);\n      iterator new_finish = finish - n;\n      destroy(new_finish, finish);\n      for (map_pointer cur = new_finish.node + 1; cur <= finish.node; ++cur)\n        data_allocator::deallocate(*cur, buffer_size());\n      finish = new_finish;\n    }\n    return start + elems_before;\n  }\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::clear() {\n  for (map_pointer node = start.node + 1; node < finish.node; ++node) {\n    destroy(*node, *node + buffer_size());\n    data_allocator::deallocate(*node, buffer_size());\n  }\n\n  if (start.node != finish.node) {\n    destroy(start.cur, start.last);\n    destroy(finish.first, finish.cur);\n    data_allocator::deallocate(finish.first, buffer_size());\n  }\n  else\n    destroy(start.cur, finish.cur);\n\n  finish = start;\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::create_map_and_nodes(size_type num_elements) {\n  size_type num_nodes = num_elements / buffer_size() + 1;\n\n  map_size = max(initial_map_size(), num_nodes + 2);\n  map = map_allocator::allocate(map_size);\n\n  map_pointer nstart = map + (map_size - num_nodes) / 2;\n  map_pointer nfinish = nstart + num_nodes - 1;\n    \n  map_pointer cur;\n  __STL_TRY {\n    for (cur = nstart; cur <= nfinish; ++cur)\n      *cur = allocate_node();\n  }\n#     ifdef  __STL_USE_EXCEPTIONS \n  catch(...) {\n    for (map_pointer n = nstart; n < cur; ++n)\n      deallocate_node(*n);\n    map_allocator::deallocate(map, map_size);\n    throw;\n  }\n#     endif /* __STL_USE_EXCEPTIONS */\n\n  start.set_node(nstart);\n  finish.set_node(nfinish);\n  start.cur = start.first;\n  finish.cur = finish.first + num_elements % buffer_size();\n}\n\n// This is only used as a cleanup function in catch clauses.\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::destroy_map_and_nodes() {\n  for (map_pointer cur = start.node; cur <= finish.node; ++cur)\n    deallocate_node(*cur);\n  map_allocator::deallocate(map, map_size);\n}\n  \n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::fill_initialize(size_type n,\n                                               const value_type& value) {\n  create_map_and_nodes(n);\n  map_pointer cur;\n  __STL_TRY {\n    for (cur = start.node; cur < finish.node; ++cur)\n      uninitialized_fill(*cur, *cur + buffer_size(), value);\n    uninitialized_fill(finish.first, finish.cur, value);\n  }\n#       ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    for (map_pointer n = start.node; n < cur; ++n)\n      destroy(*n, *n + buffer_size());\n    destroy_map_and_nodes();\n    throw;\n  }\n#       endif /* __STL_USE_EXCEPTIONS */\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class T, class Alloc, size_t BufSize>\ntemplate <class InputIterator>\nvoid deque<T, Alloc, BufSize>::range_initialize(InputIterator first,\n                                                InputIterator last,\n                                                input_iterator_tag) {\n  create_map_and_nodes(0);\n  for ( ; first != last; ++first)\n    push_back(*first);\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\ntemplate <class ForwardIterator>\nvoid deque<T, Alloc, BufSize>::range_initialize(ForwardIterator first,\n                                                ForwardIterator last,\n                                                forward_iterator_tag) {\n  size_type n = 0;\n  distance(first, last, n);\n  create_map_and_nodes(n);\n  __STL_TRY {\n    uninitialized_copy(first, last, start);\n  }\n  __STL_UNWIND(destroy_map_and_nodes());\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n// Called only if finish.cur == finish.last - 1.\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::push_back_aux(const value_type& t) {\n  value_type t_copy = t;\n  reserve_map_at_back();\n  *(finish.node + 1) = allocate_node();\n  __STL_TRY {\n    construct(finish.cur, t_copy);\n    finish.set_node(finish.node + 1);\n    finish.cur = finish.first;\n  }\n  __STL_UNWIND(deallocate_node(*(finish.node + 1)));\n}\n\n// Called only if start.cur == start.first.\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::push_front_aux(const value_type& t) {\n  value_type t_copy = t;\n  reserve_map_at_front();\n  *(start.node - 1) = allocate_node();\n  __STL_TRY {\n    start.set_node(start.node - 1);\n    start.cur = start.last - 1;\n    construct(start.cur, t_copy);\n  }\n#     ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    start.set_node(start.node + 1);\n    start.cur = start.first;\n    deallocate_node(*(start.node - 1));\n    throw;\n  }\n#     endif /* __STL_USE_EXCEPTIONS */\n} \n\n// Called only if finish.cur == finish.first.\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>:: pop_back_aux() {\n  deallocate_node(finish.first);\n  finish.set_node(finish.node - 1);\n  finish.cur = finish.last - 1;\n  destroy(finish.cur);\n}\n\n// Called only if start.cur == start.last - 1.  Note that if the deque\n//  has at least one element (a necessary precondition for this member\n//  function), and if start.cur == start.last, then the deque must have\n//  at least two nodes.\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::pop_front_aux() {\n  destroy(start.cur);\n  deallocate_node(start.first);\n  start.set_node(start.node + 1);\n  start.cur = start.first;\n}      \n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class T, class Alloc, size_t BufSize>\ntemplate <class InputIterator>\nvoid deque<T, Alloc, BufSize>::insert(iterator pos,\n                                      InputIterator first, InputIterator last,\n                                      input_iterator_tag) {\n  copy(first, last, inserter(*this, pos));\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\ntemplate <class ForwardIterator>\nvoid deque<T, Alloc, BufSize>::insert(iterator pos,\n                                      ForwardIterator first,\n                                      ForwardIterator last,\n                                      forward_iterator_tag) {\n  size_type n = 0;\n  distance(first, last, n);\n  if (pos.cur == start.cur) {\n    iterator new_start = reserve_elements_at_front(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, new_start);\n      start = new_start;\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else if (pos.cur == finish.cur) {\n    iterator new_finish = reserve_elements_at_back(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, finish);\n      finish = new_finish;\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n  else\n    insert_aux(pos, first, last, n);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc, size_t BufSize>\ntypename deque<T, Alloc, BufSize>::iterator\ndeque<T, Alloc, BufSize>::insert_aux(iterator pos, const value_type& x) {\n  difference_type index = pos - start;\n  value_type x_copy = x;\n  if (index < size() / 2) {\n    push_front(front());\n    iterator front1 = start;\n    ++front1;\n    iterator front2 = front1;\n    ++front2;\n    pos = start + index;\n    iterator pos1 = pos;\n    ++pos1;\n    copy(front2, pos1, front1);\n  }\n  else {\n    push_back(back());\n    iterator back1 = finish;\n    --back1;\n    iterator back2 = back1;\n    --back2;\n    pos = start + index;\n    copy_backward(pos, back2, back1);\n  }\n  *pos = x_copy;\n  return pos;\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert_aux(iterator pos,\n                                          size_type n, const value_type& x) {\n  const difference_type elems_before = pos - start;\n  size_type length = size();\n  value_type x_copy = x;\n  if (elems_before < length / 2) {\n    iterator new_start = reserve_elements_at_front(n);\n    iterator old_start = start;\n    pos = start + elems_before;\n    __STL_TRY {\n      if (elems_before >= difference_type(n)) {\n        iterator start_n = start + difference_type(n);\n        uninitialized_copy(start, start_n, new_start);\n        start = new_start;\n        copy(start_n, pos, old_start);\n        fill(pos - difference_type(n), pos, x_copy);\n      }\n      else {\n        __uninitialized_copy_fill(start, pos, new_start, start, x_copy);\n        start = new_start;\n        fill(old_start, pos, x_copy);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else {\n    iterator new_finish = reserve_elements_at_back(n);\n    iterator old_finish = finish;\n    const difference_type elems_after = difference_type(length) - elems_before;\n    pos = finish - elems_after;\n    __STL_TRY {\n      if (elems_after > difference_type(n)) {\n        iterator finish_n = finish - difference_type(n);\n        uninitialized_copy(finish_n, finish, finish);\n        finish = new_finish;\n        copy_backward(pos, finish_n, old_finish);\n        fill(pos, pos + difference_type(n), x_copy);\n      }\n      else {\n        __uninitialized_fill_copy(finish, pos + difference_type(n),\n                                  x_copy,\n                                  pos, finish);\n        finish = new_finish;\n        fill(pos, old_finish, x_copy);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class T, class Alloc, size_t BufSize>\ntemplate <class ForwardIterator>\nvoid deque<T, Alloc, BufSize>::insert_aux(iterator pos,\n                                          ForwardIterator first,\n                                          ForwardIterator last,\n                                          size_type n)\n{\n  const difference_type elems_before = pos - start;\n  size_type length = size();\n  if (elems_before < length / 2) {\n    iterator new_start = reserve_elements_at_front(n);\n    iterator old_start = start;\n    pos = start + elems_before;\n    __STL_TRY {\n      if (elems_before >= difference_type(n)) {\n        iterator start_n = start + difference_type(n); \n        uninitialized_copy(start, start_n, new_start);\n        start = new_start;\n        copy(start_n, pos, old_start);\n        copy(first, last, pos - difference_type(n));\n      }\n      else {\n        ForwardIterator mid = first;\n        advance(mid, difference_type(n) - elems_before);\n        __uninitialized_copy_copy(start, pos, first, mid, new_start);\n        start = new_start;\n        copy(mid, last, old_start);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else {\n    iterator new_finish = reserve_elements_at_back(n);\n    iterator old_finish = finish;\n    const difference_type elems_after = difference_type(length) - elems_before;\n    pos = finish - elems_after;\n    __STL_TRY {\n      if (elems_after > difference_type(n)) {\n        iterator finish_n = finish - difference_type(n);\n        uninitialized_copy(finish_n, finish, finish);\n        finish = new_finish;\n        copy_backward(pos, finish_n, old_finish);\n        copy(first, last, pos);\n      }\n      else {\n        ForwardIterator mid = first;\n        advance(mid, elems_after);\n        __uninitialized_copy_copy(mid, last, pos, finish, finish);\n        finish = new_finish;\n        copy(first, mid, pos);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert_aux(iterator pos,\n                                          const value_type* first,\n                                          const value_type* last,\n                                          size_type n)\n{\n  const difference_type elems_before = pos - start;\n  size_type length = size();\n  if (elems_before < length / 2) {\n    iterator new_start = reserve_elements_at_front(n);\n    iterator old_start = start;\n    pos = start + elems_before;\n    __STL_TRY {\n      if (elems_before >= difference_type(n)) {\n        iterator start_n = start + difference_type(n);\n        uninitialized_copy(start, start_n, new_start);\n        start = new_start;\n        copy(start_n, pos, old_start);\n        copy(first, last, pos - difference_type(n));\n      }\n      else {\n        const value_type* mid = first + (difference_type(n) - elems_before);\n        __uninitialized_copy_copy(start, pos, first, mid, new_start);\n        start = new_start;\n        copy(mid, last, old_start);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else {\n    iterator new_finish = reserve_elements_at_back(n);\n    iterator old_finish = finish;\n    const difference_type elems_after = difference_type(length) - elems_before;\n    pos = finish - elems_after;\n    __STL_TRY {\n      if (elems_after > difference_type(n)) {\n        iterator finish_n = finish - difference_type(n);\n        uninitialized_copy(finish_n, finish, finish);\n        finish = new_finish;\n        copy_backward(pos, finish_n, old_finish);\n        copy(first, last, pos);\n      }\n      else {\n        const value_type* mid = first + elems_after;\n        __uninitialized_copy_copy(mid, last, pos, finish, finish);\n        finish = new_finish;\n        copy(first, mid, pos);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::insert_aux(iterator pos,\n                                          const_iterator first,\n                                          const_iterator last,\n                                          size_type n)\n{\n  const difference_type elems_before = pos - start;\n  size_type length = size();\n  if (elems_before < length / 2) {\n    iterator new_start = reserve_elements_at_front(n);\n    iterator old_start = start;\n    pos = start + elems_before;\n    __STL_TRY {\n      if (elems_before >= n) {\n        iterator start_n = start + n;\n        uninitialized_copy(start, start_n, new_start);\n        start = new_start;\n        copy(start_n, pos, old_start);\n        copy(first, last, pos - difference_type(n));\n      }\n      else {\n        const_iterator mid = first + (n - elems_before);\n        __uninitialized_copy_copy(start, pos, first, mid, new_start);\n        start = new_start;\n        copy(mid, last, old_start);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_front(new_start));\n  }\n  else {\n    iterator new_finish = reserve_elements_at_back(n);\n    iterator old_finish = finish;\n    const difference_type elems_after = length - elems_before;\n    pos = finish - elems_after;\n    __STL_TRY {\n      if (elems_after > n) {\n        iterator finish_n = finish - difference_type(n);\n        uninitialized_copy(finish_n, finish, finish);\n        finish = new_finish;\n        copy_backward(pos, finish_n, old_finish);\n        copy(first, last, pos);\n      }\n      else {\n        const_iterator mid = first + elems_after;\n        __uninitialized_copy_copy(mid, last, pos, finish, finish);\n        finish = new_finish;\n        copy(first, mid, pos);\n      }\n    }\n    __STL_UNWIND(destroy_nodes_at_back(new_finish));\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::new_elements_at_front(size_type new_elements) {\n  size_type new_nodes = (new_elements + buffer_size() - 1) / buffer_size();\n  reserve_map_at_front(new_nodes);\n  size_type i;\n  __STL_TRY {\n    for (i = 1; i <= new_nodes; ++i)\n      *(start.node - i) = allocate_node();\n  }\n#       ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    for (size_type j = 1; j < i; ++j)\n      deallocate_node(*(start.node - j));      \n    throw;\n  }\n#       endif /* __STL_USE_EXCEPTIONS */\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::new_elements_at_back(size_type new_elements) {\n  size_type new_nodes = (new_elements + buffer_size() - 1) / buffer_size();\n  reserve_map_at_back(new_nodes);\n  size_type i;\n  __STL_TRY {\n    for (i = 1; i <= new_nodes; ++i)\n      *(finish.node + i) = allocate_node();\n  }\n#       ifdef __STL_USE_EXCEPTIONS\n  catch(...) {\n    for (size_type j = 1; j < i; ++j)\n      deallocate_node(*(finish.node + j));      \n    throw;\n  }\n#       endif /* __STL_USE_EXCEPTIONS */\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::destroy_nodes_at_front(iterator before_start) {\n  for (map_pointer n = before_start.node; n < start.node; ++n)\n    deallocate_node(*n);\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::destroy_nodes_at_back(iterator after_finish) {\n  for (map_pointer n = after_finish.node; n > finish.node; --n)\n    deallocate_node(*n);\n}\n\ntemplate <class T, class Alloc, size_t BufSize>\nvoid deque<T, Alloc, BufSize>::reallocate_map(size_type nodes_to_add,\n                                              bool add_at_front) {\n  size_type old_num_nodes = finish.node - start.node + 1;\n  size_type new_num_nodes = old_num_nodes + nodes_to_add;\n\n  map_pointer new_nstart;\n  if (map_size > 2 * new_num_nodes) {\n    new_nstart = map + (map_size - new_num_nodes) / 2 \n                     + (add_at_front ? nodes_to_add : 0);\n    if (new_nstart < start.node)\n      copy(start.node, finish.node + 1, new_nstart);\n    else\n      copy_backward(start.node, finish.node + 1, new_nstart + old_num_nodes);\n  }\n  else {\n    size_type new_map_size = map_size + max(map_size, nodes_to_add) + 2;\n\n    map_pointer new_map = map_allocator::allocate(new_map_size);\n    new_nstart = new_map + (new_map_size - new_num_nodes) / 2\n                         + (add_at_front ? nodes_to_add : 0);\n    copy(start.node, finish.node + 1, new_nstart);\n    map_allocator::deallocate(map, map_size);\n\n    map = new_map;\n    map_size = new_map_size;\n  }\n\n  start.set_node(new_nstart);\n  finish.set_node(new_nstart + old_num_nodes - 1);\n}\n\n\n// Nonmember functions.\n\n#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG\n\ntemplate <class T, class Alloc, size_t BufSiz>\nbool operator==(const deque<T, Alloc, BufSiz>& x,\n                const deque<T, Alloc, BufSiz>& y) {\n  return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());\n}\n\ntemplate <class T, class Alloc, size_t BufSiz>\nbool operator<(const deque<T, Alloc, BufSiz>& x,\n               const deque<T, Alloc, BufSiz>& y) {\n  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());\n}\n\n#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */\n\n#if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \\\n    !defined(__STL_NON_TYPE_TMPL_PARAM_BUG)\n\ntemplate <class T, class Alloc, size_t BufSiz>\ninline void swap(deque<T, Alloc, BufSiz>& x, deque<T, Alloc, BufSiz>& y) {\n  x.swap(y);\n}\n\n#endif\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n          \n__STL_END_NAMESPACE \n  \n#endif /* __SGI_STL_INTERNAL_DEQUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_function.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_FUNCTION_H\n#define __SGI_STL_INTERNAL_FUNCTION_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class Arg, class Result>\nstruct unary_function {\n    typedef Arg argument_type;\n    typedef Result result_type;\n};\n\ntemplate <class Arg1, class Arg2, class Result>\nstruct binary_function {\n    typedef Arg1 first_argument_type;\n    typedef Arg2 second_argument_type;\n    typedef Result result_type;\n};      \n\ntemplate <class T>\nstruct plus : public binary_function<T, T, T> {\n    T operator()(const T& x, const T& y) const { return x + y; }\n};\n\ntemplate <class T>\nstruct minus : public binary_function<T, T, T> {\n    T operator()(const T& x, const T& y) const { return x - y; }\n};\n\ntemplate <class T>\nstruct multiplies : public binary_function<T, T, T> {\n    T operator()(const T& x, const T& y) const { return x * y; }\n};\n\ntemplate <class T>\nstruct divides : public binary_function<T, T, T> {\n    T operator()(const T& x, const T& y) const { return x / y; }\n};\n\ntemplate <class T> inline T identity_element(plus<T>) { return T(0); }\n\ntemplate <class T> inline T identity_element(multiplies<T>) { return T(1); }\n\ntemplate <class T>\nstruct modulus : public binary_function<T, T, T> {\n    T operator()(const T& x, const T& y) const { return x % y; }\n};\n\ntemplate <class T>\nstruct negate : public unary_function<T, T> {\n    T operator()(const T& x) const { return -x; }\n};\n\ntemplate <class T>\nstruct equal_to : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x == y; }\n};\n\ntemplate <class T>\nstruct not_equal_to : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x != y; }\n};\n\ntemplate <class T>\nstruct greater : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x > y; }\n};\n\ntemplate <class T>\nstruct less : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x < y; }\n};\n\ntemplate <class T>\nstruct greater_equal : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x >= y; }\n};\n\ntemplate <class T>\nstruct less_equal : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x <= y; }\n};\n\ntemplate <class T>\nstruct logical_and : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x && y; }\n};\n\ntemplate <class T>\nstruct logical_or : public binary_function<T, T, bool> {\n    bool operator()(const T& x, const T& y) const { return x || y; }\n};\n\ntemplate <class T>\nstruct logical_not : public unary_function<T, bool> {\n    bool operator()(const T& x) const { return !x; }\n};\n\ntemplate <class Predicate>\nclass unary_negate\n  : public unary_function<typename Predicate::argument_type, bool> {\nprotected:\n  Predicate pred;\npublic:\n  explicit unary_negate(const Predicate& x) : pred(x) {}\n  bool operator()(const typename Predicate::argument_type& x) const {\n    return !pred(x);\n  }\n};\n\ntemplate <class Predicate>\ninline unary_negate<Predicate> not1(const Predicate& pred) {\n  return unary_negate<Predicate>(pred);\n}\n\ntemplate <class Predicate> \nclass binary_negate \n  : public binary_function<typename Predicate::first_argument_type,\n                           typename Predicate::second_argument_type,\n                           bool> {\nprotected:\n  Predicate pred;\npublic:\n  explicit binary_negate(const Predicate& x) : pred(x) {}\n  bool operator()(const typename Predicate::first_argument_type& x, \n                  const typename Predicate::second_argument_type& y) const {\n    return !pred(x, y); \n  }\n};\n\ntemplate <class Predicate>\ninline binary_negate<Predicate> not2(const Predicate& pred) {\n  return binary_negate<Predicate>(pred);\n}\n\ntemplate <class Operation> \nclass binder1st\n  : public unary_function<typename Operation::second_argument_type,\n                          typename Operation::result_type> {\nprotected:\n  Operation op;\n  typename Operation::first_argument_type value;\npublic:\n  binder1st(const Operation& x,\n            const typename Operation::first_argument_type& y)\n      : op(x), value(y) {}\n  typename Operation::result_type\n  operator()(const typename Operation::second_argument_type& x) const {\n    return op(value, x); \n  }\n};\n\ntemplate <class Operation, class T>\ninline binder1st<Operation> bind1st(const Operation& op, const T& x) {\n  typedef typename Operation::first_argument_type arg1_type;\n  return binder1st<Operation>(op, arg1_type(x));\n}\n\ntemplate <class Operation> \nclass binder2nd\n  : public unary_function<typename Operation::first_argument_type,\n                          typename Operation::result_type> {\nprotected:\n  Operation op;\n  typename Operation::second_argument_type value;\npublic:\n  binder2nd(const Operation& x,\n            const typename Operation::second_argument_type& y) \n      : op(x), value(y) {}\n  typename Operation::result_type\n  operator()(const typename Operation::first_argument_type& x) const {\n    return op(x, value); \n  }\n};\n\ntemplate <class Operation, class T>\ninline binder2nd<Operation> bind2nd(const Operation& op, const T& x) {\n  typedef typename Operation::second_argument_type arg2_type;\n  return binder2nd<Operation>(op, arg2_type(x));\n}\n\ntemplate <class Operation1, class Operation2>\nclass unary_compose : public unary_function<typename Operation2::argument_type,\n                                            typename Operation1::result_type> {\nprotected:\n  Operation1 op1;\n  Operation2 op2;\npublic:\n  unary_compose(const Operation1& x, const Operation2& y) : op1(x), op2(y) {}\n  typename Operation1::result_type\n  operator()(const typename Operation2::argument_type& x) const {\n    return op1(op2(x));\n  }\n};\n\ntemplate <class Operation1, class Operation2>\ninline unary_compose<Operation1, Operation2> compose1(const Operation1& op1, \n                                                      const Operation2& op2) {\n  return unary_compose<Operation1, Operation2>(op1, op2);\n}\n\ntemplate <class Operation1, class Operation2, class Operation3>\nclass binary_compose\n  : public unary_function<typename Operation2::argument_type,\n                          typename Operation1::result_type> {\nprotected:\n  Operation1 op1;\n  Operation2 op2;\n  Operation3 op3;\npublic:\n  binary_compose(const Operation1& x, const Operation2& y, \n                 const Operation3& z) : op1(x), op2(y), op3(z) { }\n  typename Operation1::result_type\n  operator()(const typename Operation2::argument_type& x) const {\n    return op1(op2(x), op3(x));\n  }\n};\n\ntemplate <class Operation1, class Operation2, class Operation3>\ninline binary_compose<Operation1, Operation2, Operation3> \ncompose2(const Operation1& op1, const Operation2& op2, const Operation3& op3) {\n  return binary_compose<Operation1, Operation2, Operation3>(op1, op2, op3);\n}\n\ntemplate <class Arg, class Result>\nclass pointer_to_unary_function : public unary_function<Arg, Result> {\nprotected:\n  Result (*ptr)(Arg);\npublic:\n  pointer_to_unary_function() {}\n  explicit pointer_to_unary_function(Result (*x)(Arg)) : ptr(x) {}\n  Result operator()(Arg x) const { return ptr(x); }\n};\n\ntemplate <class Arg, class Result>\ninline pointer_to_unary_function<Arg, Result> ptr_fun(Result (*x)(Arg)) {\n  return pointer_to_unary_function<Arg, Result>(x);\n}\n\ntemplate <class Arg1, class Arg2, class Result>\nclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> {\nprotected:\n    Result (*ptr)(Arg1, Arg2);\npublic:\n    pointer_to_binary_function() {}\n    explicit pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr(x) {}\n    Result operator()(Arg1 x, Arg2 y) const { return ptr(x, y); }\n};\n\ntemplate <class Arg1, class Arg2, class Result>\ninline pointer_to_binary_function<Arg1, Arg2, Result> \nptr_fun(Result (*x)(Arg1, Arg2)) {\n  return pointer_to_binary_function<Arg1, Arg2, Result>(x);\n}\n\ntemplate <class T>\nstruct identity : public unary_function<T, T> {\n  const T& operator()(const T& x) const { return x; }\n};\n\ntemplate <class Pair>\nstruct select1st : public unary_function<Pair, typename Pair::first_type> {\n  const typename Pair::first_type& operator()(const Pair& x) const\n  {\n    return x.first;\n  }\n};\n\ntemplate <class Pair>\nstruct select2nd : public unary_function<Pair, typename Pair::second_type> {\n  const typename Pair::second_type& operator()(const Pair& x) const\n  {\n    return x.second;\n  }\n};\n\ntemplate <class Arg1, class Arg2>\nstruct project1st : public binary_function<Arg1, Arg2, Arg1> {\n  Arg1 operator()(const Arg1& x, const Arg2&) const { return x; }\n};\n\ntemplate <class Arg1, class Arg2>\nstruct project2nd : public binary_function<Arg1, Arg2, Arg2> {\n  Arg2 operator()(const Arg1&, const Arg2& y) const { return y; }\n};\n\ntemplate <class Result>\nstruct constant_void_fun\n{\n  typedef Result result_type;\n  result_type val;\n  constant_void_fun(const result_type& v) : val(v) {}\n  const result_type& operator()() const { return val; }\n};  \n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Result, class Argument = Result>\n#else\ntemplate <class Result, class Argument>\n#endif\nstruct constant_unary_fun : public unary_function<Argument, Result> {\n  Result val;\n  constant_unary_fun(const Result& v) : val(v) {}\n  const Result& operator()(const Argument&) const { return val; }\n};\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Result, class Arg1 = Result, class Arg2 = Arg1>\n#else\ntemplate <class Result, class Arg1, class Arg2>\n#endif\nstruct constant_binary_fun : public binary_function<Arg1, Arg2, Result> {\n  Result val;\n  constant_binary_fun(const Result& v) : val(v) {}\n  const Result& operator()(const Arg1&, const Arg2&) const {\n    return val;\n  }\n};\n\ntemplate <class Result>\ninline constant_void_fun<Result> constant0(const Result& val)\n{\n  return constant_void_fun<Result>(val);\n}\n\ntemplate <class Result>\ninline constant_unary_fun<Result,Result> constant1(const Result& val)\n{\n  return constant_unary_fun<Result,Result>(val);\n}\n\ntemplate <class Result>\ninline constant_binary_fun<Result,Result,Result> constant2(const Result& val)\n{\n  return constant_binary_fun<Result,Result,Result>(val);\n}\n\n// Note: this code assumes that int is 32 bits.\nclass subtractive_rng : public unary_function<unsigned int, unsigned int> {\nprivate:\n  unsigned int table[55];\n  size_t index1;\n  size_t index2;\npublic:\n  unsigned int operator()(unsigned int limit) {\n    index1 = (index1 + 1) % 55;\n    index2 = (index2 + 1) % 55;\n    table[index1] = table[index1] - table[index2];\n    return table[index1] % limit;\n  }\n\n  void initialize(unsigned int seed)\n  {\n    unsigned int k = 1;\n    table[54] = seed;\n    size_t i;\n    for (i = 0; i < 54; i++) {\n        size_t ii = (21 * (i + 1) % 55) - 1;\n        table[ii] = k;\n        k = seed - k;\n        seed = table[ii];\n    }\n    for (int loop = 0; loop < 4; loop++) {\n        for (i = 0; i < 55; i++)\n            table[i] = table[i] - table[(1 + i + 30) % 55];\n    }\n    index1 = 0;\n    index2 = 31;\n  }\n\n  subtractive_rng(unsigned int seed) { initialize(seed); }\n  subtractive_rng() { initialize(161803398u); }\n};\n\n\n// Adaptor function objects: pointers to member functions.\n\n// There are a total of 16 = 2^4 function objects in this family.\n//  (1) Member functions taking no arguments vs member functions taking\n//       one argument.\n//  (2) Call through pointer vs call through reference.\n//  (3) Member function with void return type vs member function with\n//      non-void return type.\n//  (4) Const vs non-const member function.\n\n// Note that choice (4) is not present in the 8/97 draft C++ standard, \n//  which only allows these adaptors to be used with non-const functions.\n//  This is likely to be recified before the standard becomes final.\n// Note also that choice (3) is nothing more than a workaround: according\n//  to the draft, compilers should handle void and non-void the same way.\n//  This feature is not yet widely implemented, though.  You can only use\n//  member functions returning void if your compiler supports partial\n//  specialization.\n\n// All of this complexity is in the function objects themselves.  You can\n//  ignore it by using the helper function mem_fun, mem_fun_ref,\n//  mem_fun1, and mem_fun1_ref, which create whichever type of adaptor\n//  is appropriate.\n\n\ntemplate <class S, class T>\nclass mem_fun_t : public unary_function<T*, S> {\npublic:\n  explicit mem_fun_t(S (T::*pf)()) : f(pf) {}\n  S operator()(T* p) const { return (p->*f)(); }\nprivate:\n  S (T::*f)();\n};\n\ntemplate <class S, class T>\nclass const_mem_fun_t : public unary_function<const T*, S> {\npublic:\n  explicit const_mem_fun_t(S (T::*pf)() const) : f(pf) {}\n  S operator()(const T* p) const { return (p->*f)(); }\nprivate:\n  S (T::*f)() const;\n};\n\n\ntemplate <class S, class T>\nclass mem_fun_ref_t : public unary_function<T, S> {\npublic:\n  explicit mem_fun_ref_t(S (T::*pf)()) : f(pf) {}\n  S operator()(T& r) const { return (r.*f)(); }\nprivate:\n  S (T::*f)();\n};\n\ntemplate <class S, class T>\nclass const_mem_fun_ref_t : public unary_function<T, S> {\npublic:\n  explicit const_mem_fun_ref_t(S (T::*pf)() const) : f(pf) {}\n  S operator()(const T& r) const { return (r.*f)(); }\nprivate:\n  S (T::*f)() const;\n};\n\ntemplate <class S, class T, class A>\nclass mem_fun1_t : public binary_function<T*, A, S> {\npublic:\n  explicit mem_fun1_t(S (T::*pf)(A)) : f(pf) {}\n  S operator()(T* p, A x) const { return (p->*f)(x); }\nprivate:\n  S (T::*f)(A);\n};\n\ntemplate <class S, class T, class A>\nclass const_mem_fun1_t : public binary_function<const T*, A, S> {\npublic:\n  explicit const_mem_fun1_t(S (T::*pf)(A) const) : f(pf) {}\n  S operator()(const T* p, A x) const { return (p->*f)(x); }\nprivate:\n  S (T::*f)(A) const;\n};\n\ntemplate <class S, class T, class A>\nclass mem_fun1_ref_t : public binary_function<T, A, S> {\npublic:\n  explicit mem_fun1_ref_t(S (T::*pf)(A)) : f(pf) {}\n  S operator()(T& r, A x) const { return (r.*f)(x); }\nprivate:\n  S (T::*f)(A);\n};\n\ntemplate <class S, class T, class A>\nclass const_mem_fun1_ref_t : public binary_function<T, A, S> {\npublic:\n  explicit const_mem_fun1_ref_t(S (T::*pf)(A) const) : f(pf) {}\n  S operator()(const T& r, A x) const { return (r.*f)(x); }\nprivate:\n  S (T::*f)(A) const;\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class T>\nclass mem_fun_t<void, T> : public unary_function<T*, void> {\npublic:\n  explicit mem_fun_t(void (T::*pf)()) : f(pf) {}\n  void operator()(T* p) const { (p->*f)(); }\nprivate:\n  void (T::*f)();\n};\n\ntemplate <class T>\nclass const_mem_fun_t<void, T> : public unary_function<const T*, void> {\npublic:\n  explicit const_mem_fun_t(void (T::*pf)() const) : f(pf) {}\n  void operator()(const T* p) const { (p->*f)(); }\nprivate:\n  void (T::*f)() const;\n};\n\ntemplate <class T>\nclass mem_fun_ref_t<void, T> : public unary_function<T, void> {\npublic:\n  explicit mem_fun_ref_t(void (T::*pf)()) : f(pf) {}\n  void operator()(T& r) const { (r.*f)(); }\nprivate:\n  void (T::*f)();\n};\n\ntemplate <class T>\nclass const_mem_fun_ref_t<void, T> : public unary_function<T, void> {\npublic:\n  explicit const_mem_fun_ref_t(void (T::*pf)() const) : f(pf) {}\n  void operator()(const T& r) const { (r.*f)(); }\nprivate:\n  void (T::*f)() const;\n};\n\ntemplate <class T, class A>\nclass mem_fun1_t<void, T, A> : public binary_function<T*, A, void> {\npublic:\n  explicit mem_fun1_t(void (T::*pf)(A)) : f(pf) {}\n  void operator()(T* p, A x) const { (p->*f)(x); }\nprivate:\n  void (T::*f)(A);\n};\n\ntemplate <class T, class A>\nclass const_mem_fun1_t<void, T, A> : public binary_function<const T*, A, void> {\npublic:\n  explicit const_mem_fun1_t(void (T::*pf)(A) const) : f(pf) {}\n  void operator()(const T* p, A x) const { (p->*f)(x); }\nprivate:\n  void (T::*f)(A) const;\n};\n\ntemplate <class T, class A>\nclass mem_fun1_ref_t<void, T, A> : public binary_function<T, A, void> {\npublic:\n  explicit mem_fun1_ref_t(void (T::*pf)(A)) : f(pf) {}\n  void operator()(T& r, A x) const { (r.*f)(x); }\nprivate:\n  void (T::*f)(A);\n};\n\ntemplate <class T, class A>\nclass const_mem_fun1_ref_t<void, T, A> : public binary_function<T, A, void> {\npublic:\n  explicit const_mem_fun1_ref_t(void (T::*pf)(A) const) : f(pf) {}\n  void operator()(const T& r, A x) const { (r.*f)(x); }\nprivate:\n  void (T::*f)(A) const;\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// Mem_fun adaptor helper functions.  There are only four:\n//  mem_fun, mem_fun_ref, mem_fun1, mem_fun1_ref.\n\ntemplate <class S, class T>\ninline mem_fun_t<S,T> mem_fun(S (T::*f)()) { \n  return mem_fun_t<S,T>(f);\n}\n\ntemplate <class S, class T>\ninline const_mem_fun_t<S,T> mem_fun(S (T::*f)() const) {\n  return const_mem_fun_t<S,T>(f);\n}\n\ntemplate <class S, class T>\ninline mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()) { \n  return mem_fun_ref_t<S,T>(f);\n}\n\ntemplate <class S, class T>\ninline const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const) {\n  return const_mem_fun_ref_t<S,T>(f);\n}\n\ntemplate <class S, class T, class A>\ninline mem_fun1_t<S,T,A> mem_fun1(S (T::*f)(A)) { \n  return mem_fun1_t<S,T,A>(f);\n}\n\ntemplate <class S, class T, class A>\ninline const_mem_fun1_t<S,T,A> mem_fun1(S (T::*f)(A) const) {\n  return const_mem_fun1_t<S,T,A>(f);\n}\n\ntemplate <class S, class T, class A>\ninline mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A)) { \n  return mem_fun1_ref_t<S,T,A>(f);\n}\n\ntemplate <class S, class T, class A>\ninline const_mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A) const) {\n  return const_mem_fun1_ref_t<S,T,A>(f);\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_FUNCTION_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_hash_fun.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_HASH_FUN_H\n#define __SGI_STL_HASH_FUN_H\n\n#include <stddef.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class Key> struct hash { };\n\ninline size_t __stl_hash_string(const char* s)\n{\n  unsigned long h = 0; \n  for ( ; *s; ++s)\n    h = 5*h + *s;\n  \n  return size_t(h);\n}\n\n__STL_TEMPLATE_NULL struct hash<char*>\n{\n  size_t operator()(const char* s) const { return __stl_hash_string(s); }\n};\n\n__STL_TEMPLATE_NULL struct hash<const char*>\n{\n  size_t operator()(const char* s) const { return __stl_hash_string(s); }\n};\n\n__STL_TEMPLATE_NULL struct hash<char> {\n  size_t operator()(char x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned char> {\n  size_t operator()(unsigned char x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<signed char> {\n  size_t operator()(unsigned char x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<short> {\n  size_t operator()(short x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned short> {\n  size_t operator()(unsigned short x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<int> {\n  size_t operator()(int x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned int> {\n  size_t operator()(unsigned int x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<long> {\n  size_t operator()(long x) const { return x; }\n};\n__STL_TEMPLATE_NULL struct hash<unsigned long> {\n  size_t operator()(unsigned long x) const { return x; }\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_HASH_FUN_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_hash_map.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASH_MAP_H\n#define __SGI_STL_INTERNAL_HASH_MAP_H\n\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class T, class HashFcn = hash<Key>,\n          class EqualKey = equal_to<Key>,\n          class Alloc = alloc>\n#else\ntemplate <class Key, class T, class HashFcn, class EqualKey, \n          class Alloc = alloc>\n#endif\nclass hash_map\n{\nprivate:\n  typedef hashtable<pair<const Key, T>, Key, HashFcn,\n                    select1st<pair<const Key, T> >, EqualKey, Alloc> ht;\n  ht rep;\n\npublic:\n  typedef typename ht::key_type key_type;\n  typedef T data_type;\n  typedef T mapped_type;\n  typedef typename ht::value_type value_type;\n  typedef typename ht::hasher hasher;\n  typedef typename ht::key_equal key_equal;\n\n  typedef typename ht::size_type size_type;\n  typedef typename ht::difference_type difference_type;\n  typedef typename ht::pointer pointer;\n  typedef typename ht::const_pointer const_pointer;\n  typedef typename ht::reference reference;\n  typedef typename ht::const_reference const_reference;\n\n  typedef typename ht::iterator iterator;\n  typedef typename ht::const_iterator const_iterator;\n\n  hasher hash_funct() const { return rep.hash_funct(); }\n  key_equal key_eq() const { return rep.key_eq(); }\n\npublic:\n  hash_map() : rep(100, hasher(), key_equal()) {}\n  explicit hash_map(size_type n) : rep(n, hasher(), key_equal()) {}\n  hash_map(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}\n  hash_map(size_type n, const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  hash_map(InputIterator f, InputIterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_map(InputIterator f, InputIterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_map(InputIterator f, InputIterator l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_map(InputIterator f, InputIterator l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n\n#else\n  hash_map(const value_type* f, const value_type* l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const value_type* f, const value_type* l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const value_type* f, const value_type* l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const value_type* f, const value_type* l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n\n  hash_map(const_iterator f, const_iterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const_iterator f, const_iterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const_iterator f, const_iterator l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  hash_map(const_iterator f, const_iterator l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return rep.size(); }\n  size_type max_size() const { return rep.max_size(); }\n  bool empty() const { return rep.empty(); }\n  void swap(hash_map& hs) { rep.swap(hs.rep); }\n  friend bool\n  operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);\n\n  iterator begin() { return rep.begin(); }\n  iterator end() { return rep.end(); }\n  const_iterator begin() const { return rep.begin(); }\n  const_iterator end() const { return rep.end(); }\n\npublic:\n  pair<iterator, bool> insert(const value_type& obj)\n    { return rep.insert_unique(obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); }\n#else\n  void insert(const value_type* f, const value_type* l) {\n    rep.insert_unique(f,l);\n  }\n  void insert(const_iterator f, const_iterator l) { rep.insert_unique(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  pair<iterator, bool> insert_noresize(const value_type& obj)\n    { return rep.insert_unique_noresize(obj); }    \n\n  iterator find(const key_type& key) { return rep.find(key); }\n  const_iterator find(const key_type& key) const { return rep.find(key); }\n\n  T& operator[](const key_type& key) {\n    return rep.find_or_insert(value_type(key, T())).second;\n  }\n\n  size_type count(const key_type& key) const { return rep.count(key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& key)\n    { return rep.equal_range(key); }\n  pair<const_iterator, const_iterator> equal_range(const key_type& key) const\n    { return rep.equal_range(key); }\n\n  size_type erase(const key_type& key) {return rep.erase(key); }\n  void erase(iterator it) { rep.erase(it); }\n  void erase(iterator f, iterator l) { rep.erase(f, l); }\n  void clear() { rep.clear(); }\n\npublic:\n  void resize(size_type hint) { rep.resize(hint); }\n  size_type bucket_count() const { return rep.bucket_count(); }\n  size_type max_bucket_count() const { return rep.max_bucket_count(); }\n  size_type elems_in_bucket(size_type n) const\n    { return rep.elems_in_bucket(n); }\n};\n\ntemplate <class Key, class T, class HashFcn, class EqualKey, class Alloc>\ninline bool operator==(const hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm1,\n                       const hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm2)\n{\n  return hm1.rep == hm2.rep;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class T, class HashFcn, class EqualKey, class Alloc>\ninline void swap(hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm1,\n                 hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm2)\n{\n  hm1.swap(hm2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class T, class HashFcn = hash<Key>,\n          class EqualKey = equal_to<Key>,\n          class Alloc = alloc>\n#else\ntemplate <class Key, class T, class HashFcn, class EqualKey,\n          class Alloc = alloc>\n#endif\nclass hash_multimap\n{\nprivate:\n  typedef hashtable<pair<const Key, T>, Key, HashFcn,\n                    select1st<pair<const Key, T> >, EqualKey, Alloc> ht;\n  ht rep;\n\npublic:\n  typedef typename ht::key_type key_type;\n  typedef T data_type;\n  typedef T mapped_type;\n  typedef typename ht::value_type value_type;\n  typedef typename ht::hasher hasher;\n  typedef typename ht::key_equal key_equal;\n\n  typedef typename ht::size_type size_type;\n  typedef typename ht::difference_type difference_type;\n  typedef typename ht::pointer pointer;\n  typedef typename ht::const_pointer const_pointer;\n  typedef typename ht::reference reference;\n  typedef typename ht::const_reference const_reference;\n\n  typedef typename ht::iterator iterator;\n  typedef typename ht::const_iterator const_iterator;\n\n  hasher hash_funct() const { return rep.hash_funct(); }\n  key_equal key_eq() const { return rep.key_eq(); }\n\npublic:\n  hash_multimap() : rep(100, hasher(), key_equal()) {}\n  explicit hash_multimap(size_type n) : rep(n, hasher(), key_equal()) {}\n  hash_multimap(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}\n  hash_multimap(size_type n, const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  hash_multimap(InputIterator f, InputIterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multimap(InputIterator f, InputIterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multimap(InputIterator f, InputIterator l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multimap(InputIterator f, InputIterator l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n\n#else\n  hash_multimap(const value_type* f, const value_type* l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const value_type* f, const value_type* l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const value_type* f, const value_type* l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const value_type* f, const value_type* l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n\n  hash_multimap(const_iterator f, const_iterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const_iterator f, const_iterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const_iterator f, const_iterator l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  hash_multimap(const_iterator f, const_iterator l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return rep.size(); }\n  size_type max_size() const { return rep.max_size(); }\n  bool empty() const { return rep.empty(); }\n  void swap(hash_multimap& hs) { rep.swap(hs.rep); }\n  friend bool\n  operator== __STL_NULL_TMPL_ARGS (const hash_multimap&, const hash_multimap&);\n\n  iterator begin() { return rep.begin(); }\n  iterator end() { return rep.end(); }\n  const_iterator begin() const { return rep.begin(); }\n  const_iterator end() const { return rep.end(); }\n\npublic:\n  iterator insert(const value_type& obj) { return rep.insert_equal(obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); }\n#else\n  void insert(const value_type* f, const value_type* l) {\n    rep.insert_equal(f,l);\n  }\n  void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  iterator insert_noresize(const value_type& obj)\n    { return rep.insert_equal_noresize(obj); }    \n\n  iterator find(const key_type& key) { return rep.find(key); }\n  const_iterator find(const key_type& key) const { return rep.find(key); }\n\n  size_type count(const key_type& key) const { return rep.count(key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& key)\n    { return rep.equal_range(key); }\n  pair<const_iterator, const_iterator> equal_range(const key_type& key) const\n    { return rep.equal_range(key); }\n\n  size_type erase(const key_type& key) {return rep.erase(key); }\n  void erase(iterator it) { rep.erase(it); }\n  void erase(iterator f, iterator l) { rep.erase(f, l); }\n  void clear() { rep.clear(); }\n\npublic:\n  void resize(size_type hint) { rep.resize(hint); }\n  size_type bucket_count() const { return rep.bucket_count(); }\n  size_type max_bucket_count() const { return rep.max_bucket_count(); }\n  size_type elems_in_bucket(size_type n) const\n    { return rep.elems_in_bucket(n); }\n};\n\ntemplate <class Key, class T, class HF, class EqKey, class Alloc>\ninline bool operator==(const hash_multimap<Key, T, HF, EqKey, Alloc>& hm1,\n                       const hash_multimap<Key, T, HF, EqKey, Alloc>& hm2)\n{\n  return hm1.rep == hm2.rep;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class T, class HashFcn, class EqualKey, class Alloc>\ninline void swap(hash_multimap<Key, T, HashFcn, EqualKey, Alloc>& hm1,\n                 hash_multimap<Key, T, HashFcn, EqualKey, Alloc>& hm2)\n{\n  hm1.swap(hm2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASH_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_hash_set.h",
    "content": "/*\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASH_SET_H\n#define __SGI_STL_INTERNAL_HASH_SET_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Value, class HashFcn = hash<Value>,\n          class EqualKey = equal_to<Value>,\n          class Alloc = alloc>\n#else\ntemplate <class Value, class HashFcn, class EqualKey, class Alloc = alloc>\n#endif\nclass hash_set\n{\nprivate:\n  typedef hashtable<Value, Value, HashFcn, identity<Value>, \n                    EqualKey, Alloc> ht;\n  ht rep;\n\npublic:\n  typedef typename ht::key_type key_type;\n  typedef typename ht::value_type value_type;\n  typedef typename ht::hasher hasher;\n  typedef typename ht::key_equal key_equal;\n\n  typedef typename ht::size_type size_type;\n  typedef typename ht::difference_type difference_type;\n  typedef typename ht::const_pointer pointer;\n  typedef typename ht::const_pointer const_pointer;\n  typedef typename ht::const_reference reference;\n  typedef typename ht::const_reference const_reference;\n\n  typedef typename ht::const_iterator iterator;\n  typedef typename ht::const_iterator const_iterator;\n\n  hasher hash_funct() const { return rep.hash_funct(); }\n  key_equal key_eq() const { return rep.key_eq(); }\n\npublic:\n  hash_set() : rep(100, hasher(), key_equal()) {}\n  explicit hash_set(size_type n) : rep(n, hasher(), key_equal()) {}\n  hash_set(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}\n  hash_set(size_type n, const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  hash_set(InputIterator f, InputIterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_set(InputIterator f, InputIterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_set(InputIterator f, InputIterator l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  template <class InputIterator>\n  hash_set(InputIterator f, InputIterator l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n#else\n\n  hash_set(const value_type* f, const value_type* l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const value_type* f, const value_type* l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const value_type* f, const value_type* l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const value_type* f, const value_type* l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n\n  hash_set(const_iterator f, const_iterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const_iterator f, const_iterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const_iterator f, const_iterator l, size_type n,\n           const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }\n  hash_set(const_iterator f, const_iterator l, size_type n,\n           const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_unique(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return rep.size(); }\n  size_type max_size() const { return rep.max_size(); }\n  bool empty() const { return rep.empty(); }\n  void swap(hash_set& hs) { rep.swap(hs.rep); }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const hash_set&,\n                                               const hash_set&);\n\n  iterator begin() const { return rep.begin(); }\n  iterator end() const { return rep.end(); }\n\npublic:\n  pair<iterator, bool> insert(const value_type& obj)\n    {\n      pair<typename ht::iterator, bool> p = rep.insert_unique(obj);\n      return pair<iterator, bool>(p.first, p.second);\n    }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); }\n#else\n  void insert(const value_type* f, const value_type* l) {\n    rep.insert_unique(f,l);\n  }\n  void insert(const_iterator f, const_iterator l) {rep.insert_unique(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  pair<iterator, bool> insert_noresize(const value_type& obj)\n  {\n    pair<typename ht::iterator, bool> p = rep.insert_unique_noresize(obj);\n    return pair<iterator, bool>(p.first, p.second);\n  }\n\n  iterator find(const key_type& key) const { return rep.find(key); }\n\n  size_type count(const key_type& key) const { return rep.count(key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& key) const\n    { return rep.equal_range(key); }\n\n  size_type erase(const key_type& key) {return rep.erase(key); }\n  void erase(iterator it) { rep.erase(it); }\n  void erase(iterator f, iterator l) { rep.erase(f, l); }\n  void clear() { rep.clear(); }\n\npublic:\n  void resize(size_type hint) { rep.resize(hint); }\n  size_type bucket_count() const { return rep.bucket_count(); }\n  size_type max_bucket_count() const { return rep.max_bucket_count(); }\n  size_type elems_in_bucket(size_type n) const\n    { return rep.elems_in_bucket(n); }\n};\n\ntemplate <class Value, class HashFcn, class EqualKey, class Alloc>\ninline bool operator==(const hash_set<Value, HashFcn, EqualKey, Alloc>& hs1,\n                       const hash_set<Value, HashFcn, EqualKey, Alloc>& hs2)\n{\n  return hs1.rep == hs2.rep;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Val, class HashFcn, class EqualKey, class Alloc>\ninline void swap(hash_set<Val, HashFcn, EqualKey, Alloc>& hs1,\n                 hash_set<Val, HashFcn, EqualKey, Alloc>& hs2) {\n  hs1.swap(hs2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Value, class HashFcn = hash<Value>,\n          class EqualKey = equal_to<Value>,\n          class Alloc = alloc>\n#else\ntemplate <class Value, class HashFcn, class EqualKey, class Alloc = alloc>\n#endif\nclass hash_multiset\n{\nprivate:\n  typedef hashtable<Value, Value, HashFcn, identity<Value>, \n                    EqualKey, Alloc> ht;\n  ht rep;\n\npublic:\n  typedef typename ht::key_type key_type;\n  typedef typename ht::value_type value_type;\n  typedef typename ht::hasher hasher;\n  typedef typename ht::key_equal key_equal;\n\n  typedef typename ht::size_type size_type;\n  typedef typename ht::difference_type difference_type;\n  typedef typename ht::const_pointer pointer;\n  typedef typename ht::const_pointer const_pointer;\n  typedef typename ht::const_reference reference;\n  typedef typename ht::const_reference const_reference;\n\n  typedef typename ht::const_iterator iterator;\n  typedef typename ht::const_iterator const_iterator;\n\n  hasher hash_funct() const { return rep.hash_funct(); }\n  key_equal key_eq() const { return rep.key_eq(); }\n\npublic:\n  hash_multiset() : rep(100, hasher(), key_equal()) {}\n  explicit hash_multiset(size_type n) : rep(n, hasher(), key_equal()) {}\n  hash_multiset(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}\n  hash_multiset(size_type n, const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  hash_multiset(InputIterator f, InputIterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multiset(InputIterator f, InputIterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multiset(InputIterator f, InputIterator l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  template <class InputIterator>\n  hash_multiset(InputIterator f, InputIterator l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n#else\n\n  hash_multiset(const value_type* f, const value_type* l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const value_type* f, const value_type* l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const value_type* f, const value_type* l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const value_type* f, const value_type* l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n\n  hash_multiset(const_iterator f, const_iterator l)\n    : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const_iterator f, const_iterator l, size_type n)\n    : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const_iterator f, const_iterator l, size_type n,\n                const hasher& hf)\n    : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }\n  hash_multiset(const_iterator f, const_iterator l, size_type n,\n                const hasher& hf, const key_equal& eql)\n    : rep(n, hf, eql) { rep.insert_equal(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n\npublic:\n  size_type size() const { return rep.size(); }\n  size_type max_size() const { return rep.max_size(); }\n  bool empty() const { return rep.empty(); }\n  void swap(hash_multiset& hs) { rep.swap(hs.rep); }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,\n                                               const hash_multiset&);\n\n  iterator begin() const { return rep.begin(); }\n  iterator end() const { return rep.end(); }\n\npublic:\n  iterator insert(const value_type& obj) { return rep.insert_equal(obj); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); }\n#else\n  void insert(const value_type* f, const value_type* l) {\n    rep.insert_equal(f,l);\n  }\n  void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); }\n#endif /*__STL_MEMBER_TEMPLATES */\n  iterator insert_noresize(const value_type& obj)\n    { return rep.insert_equal_noresize(obj); }    \n\n  iterator find(const key_type& key) const { return rep.find(key); }\n\n  size_type count(const key_type& key) const { return rep.count(key); }\n  \n  pair<iterator, iterator> equal_range(const key_type& key) const\n    { return rep.equal_range(key); }\n\n  size_type erase(const key_type& key) {return rep.erase(key); }\n  void erase(iterator it) { rep.erase(it); }\n  void erase(iterator f, iterator l) { rep.erase(f, l); }\n  void clear() { rep.clear(); }\n\npublic:\n  void resize(size_type hint) { rep.resize(hint); }\n  size_type bucket_count() const { return rep.bucket_count(); }\n  size_type max_bucket_count() const { return rep.max_bucket_count(); }\n  size_type elems_in_bucket(size_type n) const\n    { return rep.elems_in_bucket(n); }\n};\n\ntemplate <class Val, class HashFcn, class EqualKey, class Alloc>\ninline bool operator==(const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,\n                       const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)\n{\n  return hs1.rep == hs2.rep;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Val, class HashFcn, class EqualKey, class Alloc>\ninline void swap(hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,\n                 hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)\n{\n  hs1.swap(hs2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASH_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_hashtable.h",
    "content": "/*\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HASHTABLE_H\n#define __SGI_STL_INTERNAL_HASHTABLE_H\n\n// Hashtable class, used to implement the hashed associative containers\n// hash_set, hash_map, hash_multiset, and hash_multimap.\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_tempbuf.h>\n#include <stl_algo.h>\n#include <stl_uninitialized.h>\n#include <stl_function.h>\n#include <stl_vector.h>\n#include <stl_hash_fun.h>\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class Value>\nstruct __hashtable_node\n{\n  __hashtable_node* next;\n  Value val;\n};  \n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey, class Alloc = alloc>\nclass hashtable;\n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey, class Alloc>\nstruct __hashtable_iterator;\n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey, class Alloc>\nstruct __hashtable_const_iterator;\n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey, class Alloc>\nstruct __hashtable_iterator {\n  typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>\n          hashtable;\n  typedef __hashtable_iterator<Value, Key, HashFcn, \n                               ExtractKey, EqualKey, Alloc>\n          iterator;\n  typedef __hashtable_const_iterator<Value, Key, HashFcn, \n                                     ExtractKey, EqualKey, Alloc>\n          const_iterator;\n  typedef __hashtable_node<Value> node;\n\n  typedef forward_iterator_tag iterator_category;\n  typedef Value value_type;\n  typedef ptrdiff_t difference_type;\n  typedef size_t size_type;\n  typedef Value& reference;\n  typedef Value* pointer;\n\n  node* cur;\n  hashtable* ht;\n\n  __hashtable_iterator(node* n, hashtable* tab) : cur(n), ht(tab) {}\n  __hashtable_iterator() {}\n  reference operator*() const { return cur->val; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  iterator& operator++();\n  iterator operator++(int);\n  bool operator==(const iterator& it) const { return cur == it.cur; }\n  bool operator!=(const iterator& it) const { return cur != it.cur; }\n};\n\n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey, class Alloc>\nstruct __hashtable_const_iterator {\n  typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>\n          hashtable;\n  typedef __hashtable_iterator<Value, Key, HashFcn, \n                               ExtractKey, EqualKey, Alloc>\n          iterator;\n  typedef __hashtable_const_iterator<Value, Key, HashFcn, \n                                     ExtractKey, EqualKey, Alloc>\n          const_iterator;\n  typedef __hashtable_node<Value> node;\n\n  typedef forward_iterator_tag iterator_category;\n  typedef Value value_type;\n  typedef ptrdiff_t difference_type;\n  typedef size_t size_type;\n  typedef const Value& reference;\n  typedef const Value* pointer;\n\n  const node* cur;\n  const hashtable* ht;\n\n  __hashtable_const_iterator(const node* n, const hashtable* tab)\n    : cur(n), ht(tab) {}\n  __hashtable_const_iterator() {}\n  __hashtable_const_iterator(const iterator& it) : cur(it.cur), ht(it.ht) {}\n  reference operator*() const { return cur->val; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  const_iterator& operator++();\n  const_iterator operator++(int);\n  bool operator==(const const_iterator& it) const { return cur == it.cur; }\n  bool operator!=(const const_iterator& it) const { return cur != it.cur; }\n};\n\n// Note: assumes long is at least 32 bits.\nstatic const int __stl_num_primes = 28;\nstatic const unsigned long __stl_prime_list[__stl_num_primes] =\n{\n  53,         97,           193,         389,       769,\n  1543,       3079,         6151,        12289,     24593,\n  49157,      98317,        196613,      393241,    786433,\n  1572869,    3145739,      6291469,     12582917,  25165843,\n  50331653,   100663319,    201326611,   402653189, 805306457, \n  1610612741, 3221225473ul, 4294967291ul\n};\n\ninline unsigned long __stl_next_prime(unsigned long n)\n{\n  const unsigned long* first = __stl_prime_list;\n  const unsigned long* last = __stl_prime_list + __stl_num_primes;\n  const unsigned long* pos = lower_bound(first, last, n);\n  return pos == last ? *(last - 1) : *pos;\n}\n\n\ntemplate <class Value, class Key, class HashFcn,\n          class ExtractKey, class EqualKey,\n          class Alloc>\nclass hashtable {\npublic:\n  typedef Key key_type;\n  typedef Value value_type;\n  typedef HashFcn hasher;\n  typedef EqualKey key_equal;\n\n  typedef size_t            size_type;\n  typedef ptrdiff_t         difference_type;\n  typedef value_type*       pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type&       reference;\n  typedef const value_type& const_reference;\n\n  hasher hash_funct() const { return hash; }\n  key_equal key_eq() const { return equals; }\n\nprivate:\n  hasher hash;\n  key_equal equals;\n  ExtractKey get_key;\n\n  typedef __hashtable_node<Value> node;\n  typedef simple_alloc<node, Alloc> node_allocator;\n\n  vector<node*,Alloc> buckets;\n  size_type num_elements;\n\npublic:\n  typedef __hashtable_iterator<Value, Key, HashFcn, ExtractKey, EqualKey, \n                               Alloc>\n  iterator;\n\n  typedef __hashtable_const_iterator<Value, Key, HashFcn, ExtractKey, EqualKey,\n                                     Alloc>\n  const_iterator;\n\n  friend struct\n  __hashtable_iterator<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>;\n  friend struct\n  __hashtable_const_iterator<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>;\n\npublic:\n  hashtable(size_type n,\n            const HashFcn&    hf,\n            const EqualKey&   eql,\n            const ExtractKey& ext)\n    : hash(hf), equals(eql), get_key(ext), num_elements(0)\n  {\n    initialize_buckets(n);\n  }\n\n  hashtable(size_type n,\n            const HashFcn&    hf,\n            const EqualKey&   eql)\n    : hash(hf), equals(eql), get_key(ExtractKey()), num_elements(0)\n  {\n    initialize_buckets(n);\n  }\n\n  hashtable(const hashtable& ht)\n    : hash(ht.hash), equals(ht.equals), get_key(ht.get_key), num_elements(0)\n  {\n    copy_from(ht);\n  }\n\n  hashtable& operator= (const hashtable& ht)\n  {\n    if (&ht != this) {\n      clear();\n      hash = ht.hash;\n      equals = ht.equals;\n      get_key = ht.get_key;\n      copy_from(ht);\n    }\n    return *this;\n  }\n\n  ~hashtable() { clear(); }\n\n  size_type size() const { return num_elements; }\n  size_type max_size() const { return size_type(-1); }\n  bool empty() const { return size() == 0; }\n\n  void swap(hashtable& ht)\n  {\n    __STD::swap(hash, ht.hash);\n    __STD::swap(equals, ht.equals);\n    __STD::swap(get_key, ht.get_key);\n    buckets.swap(ht.buckets);\n    __STD::swap(num_elements, ht.num_elements);\n  }\n\n  iterator begin()\n  { \n    for (size_type n = 0; n < buckets.size(); ++n)\n      if (buckets[n])\n        return iterator(buckets[n], this);\n    return end();\n  }\n\n  iterator end() { return iterator(0, this); }\n\n  const_iterator begin() const\n  {\n    for (size_type n = 0; n < buckets.size(); ++n)\n      if (buckets[n])\n        return const_iterator(buckets[n], this);\n    return end();\n  }\n\n  const_iterator end() const { return const_iterator(0, this); }\n\n  friend bool\n  operator== __STL_NULL_TMPL_ARGS (const hashtable&, const hashtable&);\n\npublic:\n\n  size_type bucket_count() const { return buckets.size(); }\n\n  size_type max_bucket_count() const\n    { return __stl_prime_list[__stl_num_primes - 1]; } \n\n  size_type elems_in_bucket(size_type bucket) const\n  {\n    size_type result = 0;\n    for (node* cur = buckets[bucket]; cur; cur = cur->next)\n      result += 1;\n    return result;\n  }\n\n  pair<iterator, bool> insert_unique(const value_type& obj)\n  {\n    resize(num_elements + 1);\n    return insert_unique_noresize(obj);\n  }\n\n  iterator insert_equal(const value_type& obj)\n  {\n    resize(num_elements + 1);\n    return insert_equal_noresize(obj);\n  }\n\n  pair<iterator, bool> insert_unique_noresize(const value_type& obj);\n  iterator insert_equal_noresize(const value_type& obj);\n \n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert_unique(InputIterator f, InputIterator l)\n  {\n    insert_unique(f, l, iterator_category(f));\n  }\n\n  template <class InputIterator>\n  void insert_equal(InputIterator f, InputIterator l)\n  {\n    insert_equal(f, l, iterator_category(f));\n  }\n\n  template <class InputIterator>\n  void insert_unique(InputIterator f, InputIterator l,\n                     input_iterator_tag)\n  {\n    for ( ; f != l; ++f)\n      insert_unique(*f);\n  }\n\n  template <class InputIterator>\n  void insert_equal(InputIterator f, InputIterator l,\n                    input_iterator_tag)\n  {\n    for ( ; f != l; ++f)\n      insert_equal(*f);\n  }\n\n  template <class ForwardIterator>\n  void insert_unique(ForwardIterator f, ForwardIterator l,\n                     forward_iterator_tag)\n  {\n    size_type n = 0;\n    distance(f, l, n);\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_unique_noresize(*f);\n  }\n\n  template <class ForwardIterator>\n  void insert_equal(ForwardIterator f, ForwardIterator l,\n                    forward_iterator_tag)\n  {\n    size_type n = 0;\n    distance(f, l, n);\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_equal_noresize(*f);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert_unique(const value_type* f, const value_type* l)\n  {\n    size_type n = l - f;\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_unique_noresize(*f);\n  }\n\n  void insert_equal(const value_type* f, const value_type* l)\n  {\n    size_type n = l - f;\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_equal_noresize(*f);\n  }\n\n  void insert_unique(const_iterator f, const_iterator l)\n  {\n    size_type n = 0;\n    distance(f, l, n);\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_unique_noresize(*f);\n  }\n\n  void insert_equal(const_iterator f, const_iterator l)\n  {\n    size_type n = 0;\n    distance(f, l, n);\n    resize(num_elements + n);\n    for ( ; n > 0; --n, ++f)\n      insert_equal_noresize(*f);\n  }\n#endif /*__STL_MEMBER_TEMPLATES */\n\n  reference find_or_insert(const value_type& obj);\n\n  iterator find(const key_type& key) \n  {\n    size_type n = bkt_num_key(key);\n    node* first;\n    for ( first = buckets[n];\n          first && !equals(get_key(first->val), key);\n          first = first->next)\n      {}\n    return iterator(first, this);\n  } \n\n  const_iterator find(const key_type& key) const\n  {\n    size_type n = bkt_num_key(key);\n    const node* first;\n    for ( first = buckets[n];\n          first && !equals(get_key(first->val), key);\n          first = first->next)\n      {}\n    return const_iterator(first, this);\n  } \n\n  size_type count(const key_type& key) const\n  {\n    const size_type n = bkt_num_key(key);\n    size_type result = 0;\n\n    for (const node* cur = buckets[n]; cur; cur = cur->next)\n      if (equals(get_key(cur->val), key))\n        ++result;\n    return result;\n  }\n\n  pair<iterator, iterator> equal_range(const key_type& key);\n  pair<const_iterator, const_iterator> equal_range(const key_type& key) const;\n\n  size_type erase(const key_type& key);\n  void erase(const iterator& it);\n  void erase(iterator first, iterator last);\n\n  void erase(const const_iterator& it);\n  void erase(const_iterator first, const_iterator last);\n\n  void resize(size_type num_elements_hint);\n  void clear();\n\nprivate:\n  size_type next_size(size_type n) const { return __stl_next_prime(n); }\n\n  void initialize_buckets(size_type n)\n  {\n    const size_type n_buckets = next_size(n);\n    buckets.reserve(n_buckets);\n    buckets.insert(buckets.end(), n_buckets, (node*) 0);\n    num_elements = 0;\n  }\n\n  size_type bkt_num_key(const key_type& key) const\n  {\n    return bkt_num_key(key, buckets.size());\n  }\n\n  size_type bkt_num(const value_type& obj) const\n  {\n    return bkt_num_key(get_key(obj));\n  }\n\n  size_type bkt_num_key(const key_type& key, size_t n) const\n  {\n    return hash(key) % n;\n  }\n\n  size_type bkt_num(const value_type& obj, size_t n) const\n  {\n    return bkt_num_key(get_key(obj), n);\n  }\n\n  node* new_node(const value_type& obj)\n  {\n    node* n = node_allocator::allocate();\n    n->next = 0;\n    __STL_TRY {\n      construct(&n->val, obj);\n      return n;\n    }\n    __STL_UNWIND(node_allocator::deallocate(n));\n  }\n  \n  void delete_node(node* n)\n  {\n    destroy(&n->val);\n    node_allocator::deallocate(n);\n  }\n\n  void erase_bucket(const size_type n, node* first, node* last);\n  void erase_bucket(const size_type n, node* last);\n\n  void copy_from(const hashtable& ht);\n\n};\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class A>\n__hashtable_iterator<V, K, HF, ExK, EqK, A>&\n__hashtable_iterator<V, K, HF, ExK, EqK, A>::operator++()\n{\n  const node* old = cur;\n  cur = cur->next;\n  if (!cur) {\n    size_type bucket = ht->bkt_num(old->val);\n    while (!cur && ++bucket < ht->buckets.size())\n      cur = ht->buckets[bucket];\n  }\n  return *this;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class A>\ninline __hashtable_iterator<V, K, HF, ExK, EqK, A>\n__hashtable_iterator<V, K, HF, ExK, EqK, A>::operator++(int)\n{\n  iterator tmp = *this;\n  ++*this;\n  return tmp;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class A>\n__hashtable_const_iterator<V, K, HF, ExK, EqK, A>&\n__hashtable_const_iterator<V, K, HF, ExK, EqK, A>::operator++()\n{\n  const node* old = cur;\n  cur = cur->next;\n  if (!cur) {\n    size_type bucket = ht->bkt_num(old->val);\n    while (!cur && ++bucket < ht->buckets.size())\n      cur = ht->buckets[bucket];\n  }\n  return *this;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class A>\ninline __hashtable_const_iterator<V, K, HF, ExK, EqK, A>\n__hashtable_const_iterator<V, K, HF, ExK, EqK, A>::operator++(int)\n{\n  const_iterator tmp = *this;\n  ++*this;\n  return tmp;\n}\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline forward_iterator_tag\niterator_category(const __hashtable_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return forward_iterator_tag();\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline V* value_type(const __hashtable_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return (V*) 0;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline hashtable<V, K, HF, ExK, EqK, All>::difference_type*\ndistance_type(const __hashtable_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return (hashtable<V, K, HF, ExK, EqK, All>::difference_type*) 0;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline forward_iterator_tag\niterator_category(const __hashtable_const_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return forward_iterator_tag();\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline V* \nvalue_type(const __hashtable_const_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return (V*) 0;\n}\n\ntemplate <class V, class K, class HF, class ExK, class EqK, class All>\ninline hashtable<V, K, HF, ExK, EqK, All>::difference_type*\ndistance_type(const __hashtable_const_iterator<V, K, HF, ExK, EqK, All>&)\n{\n  return (hashtable<V, K, HF, ExK, EqK, All>::difference_type*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nbool operator==(const hashtable<V, K, HF, Ex, Eq, A>& ht1,\n                const hashtable<V, K, HF, Ex, Eq, A>& ht2)\n{\n  typedef typename hashtable<V, K, HF, Ex, Eq, A>::node node;\n  if (ht1.buckets.size() != ht2.buckets.size())\n    return false;\n  for (int n = 0; n < ht1.buckets.size(); ++n) {\n    node* cur1 = ht1.buckets[n];\n    node* cur2 = ht2.buckets[n];\n    for ( ; cur1 && cur2 && cur1->val == cur2->val;\n          cur1 = cur1->next, cur2 = cur2->next)\n      {}\n    if (cur1 || cur2)\n      return false;\n  }\n  return true;\n}  \n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Val, class Key, class HF, class Extract, class EqKey, class A>\ninline void swap(hashtable<Val, Key, HF, Extract, EqKey, A>& ht1,\n                 hashtable<Val, Key, HF, Extract, EqKey, A>& ht2) {\n  ht1.swap(ht2);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\npair<typename hashtable<V, K, HF, Ex, Eq, A>::iterator, bool> \nhashtable<V, K, HF, Ex, Eq, A>::insert_unique_noresize(const value_type& obj)\n{\n  const size_type n = bkt_num(obj);\n  node* first = buckets[n];\n\n  for (node* cur = first; cur; cur = cur->next) \n    if (equals(get_key(cur->val), get_key(obj)))\n      return pair<iterator, bool>(iterator(cur, this), false);\n\n  node* tmp = new_node(obj);\n  tmp->next = first;\n  buckets[n] = tmp;\n  ++num_elements;\n  return pair<iterator, bool>(iterator(tmp, this), true);\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\ntypename hashtable<V, K, HF, Ex, Eq, A>::iterator \nhashtable<V, K, HF, Ex, Eq, A>::insert_equal_noresize(const value_type& obj)\n{\n  const size_type n = bkt_num(obj);\n  node* first = buckets[n];\n\n  for (node* cur = first; cur; cur = cur->next) \n    if (equals(get_key(cur->val), get_key(obj))) {\n      node* tmp = new_node(obj);\n      tmp->next = cur->next;\n      cur->next = tmp;\n      ++num_elements;\n      return iterator(tmp, this);\n    }\n\n  node* tmp = new_node(obj);\n  tmp->next = first;\n  buckets[n] = tmp;\n  ++num_elements;\n  return iterator(tmp, this);\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\ntypename hashtable<V, K, HF, Ex, Eq, A>::reference \nhashtable<V, K, HF, Ex, Eq, A>::find_or_insert(const value_type& obj)\n{\n  resize(num_elements + 1);\n\n  size_type n = bkt_num(obj);\n  node* first = buckets[n];\n\n  for (node* cur = first; cur; cur = cur->next)\n    if (equals(get_key(cur->val), get_key(obj)))\n      return cur->val;\n\n  node* tmp = new_node(obj);\n  tmp->next = first;\n  buckets[n] = tmp;\n  ++num_elements;\n  return tmp->val;\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\npair<typename hashtable<V, K, HF, Ex, Eq, A>::iterator,\n     typename hashtable<V, K, HF, Ex, Eq, A>::iterator> \nhashtable<V, K, HF, Ex, Eq, A>::equal_range(const key_type& key)\n{\n  typedef pair<iterator, iterator> pii;\n  const size_type n = bkt_num_key(key);\n\n  for (node* first = buckets[n]; first; first = first->next) {\n    if (equals(get_key(first->val), key)) {\n      for (node* cur = first->next; cur; cur = cur->next)\n        if (!equals(get_key(cur->val), key))\n          return pii(iterator(first, this), iterator(cur, this));\n      for (size_type m = n + 1; m < buckets.size(); ++m)\n        if (buckets[m])\n          return pii(iterator(first, this),\n                     iterator(buckets[m], this));\n      return pii(iterator(first, this), end());\n    }\n  }\n  return pii(end(), end());\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\npair<typename hashtable<V, K, HF, Ex, Eq, A>::const_iterator, \n     typename hashtable<V, K, HF, Ex, Eq, A>::const_iterator> \nhashtable<V, K, HF, Ex, Eq, A>::equal_range(const key_type& key) const\n{\n  typedef pair<const_iterator, const_iterator> pii;\n  const size_type n = bkt_num_key(key);\n\n  for (const node* first = buckets[n] ; first; first = first->next) {\n    if (equals(get_key(first->val), key)) {\n      for (const node* cur = first->next; cur; cur = cur->next)\n        if (!equals(get_key(cur->val), key))\n          return pii(const_iterator(first, this),\n                     const_iterator(cur, this));\n      for (size_type m = n + 1; m < buckets.size(); ++m)\n        if (buckets[m])\n          return pii(const_iterator(first, this),\n                     const_iterator(buckets[m], this));\n      return pii(const_iterator(first, this), end());\n    }\n  }\n  return pii(end(), end());\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\ntypename hashtable<V, K, HF, Ex, Eq, A>::size_type \nhashtable<V, K, HF, Ex, Eq, A>::erase(const key_type& key)\n{\n  const size_type n = bkt_num_key(key);\n  node* first = buckets[n];\n  size_type erased = 0;\n\n  if (first) {\n    node* cur = first;\n    node* next = cur->next;\n    while (next) {\n      if (equals(get_key(next->val), key)) {\n        cur->next = next->next;\n        delete_node(next);\n        next = cur->next;\n        ++erased;\n        --num_elements;\n      }\n      else {\n        cur = next;\n        next = cur->next;\n      }\n    }\n    if (equals(get_key(first->val), key)) {\n      buckets[n] = first->next;\n      delete_node(first);\n      ++erased;\n      --num_elements;\n    }\n  }\n  return erased;\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::erase(const iterator& it)\n{\n  if (node* const p = it.cur) {\n    const size_type n = bkt_num(p->val);\n    node* cur = buckets[n];\n\n    if (cur == p) {\n      buckets[n] = cur->next;\n      delete_node(cur);\n      --num_elements;\n    }\n    else {\n      node* next = cur->next;\n      while (next) {\n        if (next == p) {\n          cur->next = next->next;\n          delete_node(next);\n          --num_elements;\n          break;\n        }\n        else {\n          cur = next;\n          next = cur->next;\n        }\n      }\n    }\n  }\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::erase(iterator first, iterator last)\n{\n  size_type f_bucket = first.cur ? bkt_num(first.cur->val) : buckets.size();\n  size_type l_bucket = last.cur ? bkt_num(last.cur->val) : buckets.size();\n\n  if (first.cur == last.cur)\n    return;\n  else if (f_bucket == l_bucket)\n    erase_bucket(f_bucket, first.cur, last.cur);\n  else {\n    erase_bucket(f_bucket, first.cur, 0);\n    for (size_type n = f_bucket + 1; n < l_bucket; ++n)\n      erase_bucket(n, 0);\n    if (l_bucket != buckets.size())\n      erase_bucket(l_bucket, last.cur);\n  }\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\ninline void\nhashtable<V, K, HF, Ex, Eq, A>::erase(const_iterator first,\n                                      const_iterator last)\n{\n  erase(iterator(const_cast<node*>(first.cur),\n                 const_cast<hashtable*>(first.ht)),\n        iterator(const_cast<node*>(last.cur),\n                 const_cast<hashtable*>(last.ht)));\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\ninline void\nhashtable<V, K, HF, Ex, Eq, A>::erase(const const_iterator& it)\n{\n  erase(iterator(const_cast<node*>(it.cur),\n                 const_cast<hashtable*>(it.ht)));\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::resize(size_type num_elements_hint)\n{\n  const size_type old_n = buckets.size();\n  if (num_elements_hint > old_n) {\n    const size_type n = next_size(num_elements_hint);\n    if (n > old_n) {\n      vector<node*, A> tmp(n, (node*) 0);\n      __STL_TRY {\n        for (size_type bucket = 0; bucket < old_n; ++bucket) {\n          node* first = buckets[bucket];\n          while (first) {\n            size_type new_bucket = bkt_num(first->val, n);\n            buckets[bucket] = first->next;\n            first->next = tmp[new_bucket];\n            tmp[new_bucket] = first;\n            first = buckets[bucket];          \n          }\n        }\n        buckets.swap(tmp);\n      }\n#         ifdef __STL_USE_EXCEPTIONS\n      catch(...) {\n        for (size_type bucket = 0; bucket < tmp.size(); ++bucket) {\n          while (tmp[bucket]) {\n            node* next = tmp[bucket]->next;\n            delete_node(tmp[bucket]);\n            tmp[bucket] = next;\n          }\n        }\n        throw;\n      }\n#         endif /* __STL_USE_EXCEPTIONS */\n    }\n  }\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, \n                                                  node* first, node* last)\n{\n  node* cur = buckets[n];\n  if (cur == first)\n    erase_bucket(n, last);\n  else {\n    node* next;\n    for (next = cur->next; next != first; cur = next, next = cur->next)\n      ;\n    while (next) {\n      cur->next = next->next;\n      delete_node(next);\n      next = cur->next;\n      --num_elements;\n    }\n  }\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid \nhashtable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* last)\n{\n  node* cur = buckets[n];\n  while (cur != last) {\n    node* next = cur->next;\n    delete_node(cur);\n    cur = next;\n    buckets[n] = cur;\n    --num_elements;\n  }\n}\n\ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::clear()\n{\n  for (size_type i = 0; i < buckets.size(); ++i) {\n    node* cur = buckets[i];\n    while (cur != 0) {\n      node* next = cur->next;\n      delete_node(cur);\n      cur = next;\n    }\n    buckets[i] = 0;\n  }\n  num_elements = 0;\n}\n\n    \ntemplate <class V, class K, class HF, class Ex, class Eq, class A>\nvoid hashtable<V, K, HF, Ex, Eq, A>::copy_from(const hashtable& ht)\n{\n  buckets.clear();\n  buckets.reserve(ht.buckets.size());\n  buckets.insert(buckets.end(), ht.buckets.size(), (node*) 0);\n  __STL_TRY {\n    for (size_type i = 0; i < ht.buckets.size(); ++i) {\n      if (const node* cur = ht.buckets[i]) {\n        node* copy = new_node(cur->val);\n        buckets[i] = copy;\n\n        for (node* next = cur->next; next; cur = next, next = cur->next) {\n          copy->next = new_node(next->val);\n          copy = copy->next;\n        }\n      }\n    }\n    num_elements = ht.num_elements;\n  }\n  __STL_UNWIND(clear());\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HASHTABLE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_heap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_HEAP_H\n#define __SGI_STL_INTERNAL_HEAP_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1209\n#endif\n\ntemplate <class RandomAccessIterator, class Distance, class T>\nvoid __push_heap(RandomAccessIterator first, Distance holeIndex,\n                 Distance topIndex, T value) {\n  Distance parent = (holeIndex - 1) / 2;\n  while (holeIndex > topIndex && *(first + parent) < value) {\n    *(first + holeIndex) = *(first + parent);\n    holeIndex = parent;\n    parent = (holeIndex - 1) / 2;\n  }    \n  *(first + holeIndex) = value;\n}\n\ntemplate <class RandomAccessIterator, class Distance, class T>\ninline void __push_heap_aux(RandomAccessIterator first,\n                            RandomAccessIterator last, Distance*, T*) {\n  __push_heap(first, Distance((last - first) - 1), Distance(0), \n              T(*(last - 1)));\n}\n\ntemplate <class RandomAccessIterator>\ninline void push_heap(RandomAccessIterator first, RandomAccessIterator last) {\n  __push_heap_aux(first, last, distance_type(first), value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Distance, class T, class Compare>\nvoid __push_heap(RandomAccessIterator first, Distance holeIndex,\n                 Distance topIndex, T value, Compare comp) {\n  Distance parent = (holeIndex - 1) / 2;\n  while (holeIndex > topIndex && comp(*(first + parent), value)) {\n    *(first + holeIndex) = *(first + parent);\n    holeIndex = parent;\n    parent = (holeIndex - 1) / 2;\n  }\n  *(first + holeIndex) = value;\n}\n\ntemplate <class RandomAccessIterator, class Compare, class Distance, class T>\ninline void __push_heap_aux(RandomAccessIterator first,\n                            RandomAccessIterator last, Compare comp,\n                            Distance*, T*) {\n  __push_heap(first, Distance((last - first) - 1), Distance(0), \n              T(*(last - 1)), comp);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void push_heap(RandomAccessIterator first, RandomAccessIterator last,\n                      Compare comp) {\n  __push_heap_aux(first, last, comp, distance_type(first), value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Distance, class T>\nvoid __adjust_heap(RandomAccessIterator first, Distance holeIndex,\n                   Distance len, T value) {\n  Distance topIndex = holeIndex;\n  Distance secondChild = 2 * holeIndex + 2;\n  while (secondChild < len) {\n    if (*(first + secondChild) < *(first + (secondChild - 1)))\n      secondChild--;\n    *(first + holeIndex) = *(first + secondChild);\n    holeIndex = secondChild;\n    secondChild = 2 * (secondChild + 1);\n  }\n  if (secondChild == len) {\n    *(first + holeIndex) = *(first + (secondChild - 1));\n    holeIndex = secondChild - 1;\n  }\n  __push_heap(first, holeIndex, topIndex, value);\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\ninline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last,\n                       RandomAccessIterator result, T value, Distance*) {\n  *result = *first;\n  __adjust_heap(first, Distance(0), Distance(last - first), value);\n}\n\ntemplate <class RandomAccessIterator, class T>\ninline void __pop_heap_aux(RandomAccessIterator first,\n                           RandomAccessIterator last, T*) {\n  __pop_heap(first, last - 1, last - 1, T(*(last - 1)), distance_type(first));\n}\n\ntemplate <class RandomAccessIterator>\ninline void pop_heap(RandomAccessIterator first, RandomAccessIterator last) {\n  __pop_heap_aux(first, last, value_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Distance, class T, class Compare>\nvoid __adjust_heap(RandomAccessIterator first, Distance holeIndex,\n                   Distance len, T value, Compare comp) {\n  Distance topIndex = holeIndex;\n  Distance secondChild = 2 * holeIndex + 2;\n  while (secondChild < len) {\n    if (comp(*(first + secondChild), *(first + (secondChild - 1))))\n      secondChild--;\n    *(first + holeIndex) = *(first + secondChild);\n    holeIndex = secondChild;\n    secondChild = 2 * (secondChild + 1);\n  }\n  if (secondChild == len) {\n    *(first + holeIndex) = *(first + (secondChild - 1));\n    holeIndex = secondChild - 1;\n  }\n  __push_heap(first, holeIndex, topIndex, value, comp);\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare, class Distance>\ninline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last,\n                       RandomAccessIterator result, T value, Compare comp,\n                       Distance*) {\n  *result = *first;\n  __adjust_heap(first, Distance(0), Distance(last - first), value, comp);\n}\n\ntemplate <class RandomAccessIterator, class T, class Compare>\ninline void __pop_heap_aux(RandomAccessIterator first,\n                           RandomAccessIterator last, T*, Compare comp) {\n  __pop_heap(first, last - 1, last - 1, T(*(last - 1)), comp,\n             distance_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void pop_heap(RandomAccessIterator first, RandomAccessIterator last,\n                     Compare comp) {\n    __pop_heap_aux(first, last, value_type(first), comp);\n}\n\ntemplate <class RandomAccessIterator, class T, class Distance>\nvoid __make_heap(RandomAccessIterator first, RandomAccessIterator last, T*,\n                 Distance*) {\n  if (last - first < 2) return;\n  Distance len = last - first;\n  Distance parent = (len - 2)/2;\n    \n  while (true) {\n    __adjust_heap(first, parent, len, T(*(first + parent)));\n    if (parent == 0) return;\n    parent--;\n  }\n}\n\ntemplate <class RandomAccessIterator>\ninline void make_heap(RandomAccessIterator first, RandomAccessIterator last) {\n  __make_heap(first, last, value_type(first), distance_type(first));\n}\n\ntemplate <class RandomAccessIterator, class Compare, class T, class Distance>\nvoid __make_heap(RandomAccessIterator first, RandomAccessIterator last,\n                 Compare comp, T*, Distance*) {\n  if (last - first < 2) return;\n  Distance len = last - first;\n  Distance parent = (len - 2)/2;\n    \n  while (true) {\n    __adjust_heap(first, parent, len, T(*(first + parent)), comp);\n    if (parent == 0) return;\n    parent--;\n  }\n}\n\ntemplate <class RandomAccessIterator, class Compare>\ninline void make_heap(RandomAccessIterator first, RandomAccessIterator last,\n                      Compare comp) {\n  __make_heap(first, last, comp, value_type(first), distance_type(first));\n}\n\ntemplate <class RandomAccessIterator>\nvoid sort_heap(RandomAccessIterator first, RandomAccessIterator last) {\n  while (last - first > 1) pop_heap(first, last--);\n}\n\ntemplate <class RandomAccessIterator, class Compare>\nvoid sort_heap(RandomAccessIterator first, RandomAccessIterator last,\n               Compare comp) {\n  while (last - first > 1) pop_heap(first, last--, comp);\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1209\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_HEAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_iterator.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ITERATOR_H\n#define __SGI_STL_INTERNAL_ITERATOR_H\n\n__STL_BEGIN_NAMESPACE\n\nstruct input_iterator_tag {};\nstruct output_iterator_tag {};\nstruct forward_iterator_tag : public input_iterator_tag {};\nstruct bidirectional_iterator_tag : public forward_iterator_tag {};\nstruct random_access_iterator_tag : public bidirectional_iterator_tag {};\n\ntemplate <class T, class Distance> struct input_iterator {\n  typedef input_iterator_tag iterator_category;\n  typedef T                  value_type;\n  typedef Distance           difference_type;\n  typedef T*                 pointer;\n  typedef T&                 reference;\n};\n\nstruct output_iterator {\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n};\n\ntemplate <class T, class Distance> struct forward_iterator {\n  typedef forward_iterator_tag iterator_category;\n  typedef T                    value_type;\n  typedef Distance             difference_type;\n  typedef T*                   pointer;\n  typedef T&                   reference;\n};\n\n\ntemplate <class T, class Distance> struct bidirectional_iterator {\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef Distance                   difference_type;\n  typedef T*                         pointer;\n  typedef T&                         reference;\n};\n\ntemplate <class T, class Distance> struct random_access_iterator {\n  typedef random_access_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef Distance                   difference_type;\n  typedef T*                         pointer;\n  typedef T&                         reference;\n};\n\n#ifdef __STL_USE_NAMESPACES\ntemplate <class Category, class T, class Distance = ptrdiff_t,\n          class Pointer = T*, class Reference = T&>\nstruct iterator {\n  typedef Category  iterator_category;\n  typedef T         value_type;\n  typedef Distance  difference_type;\n  typedef Pointer   pointer;\n  typedef Reference reference;\n};\n#endif /* __STL_USE_NAMESPACES */\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class Iterator>\nstruct iterator_traits {\n  typedef typename Iterator::iterator_category iterator_category;\n  typedef typename Iterator::value_type        value_type;\n  typedef typename Iterator::difference_type   difference_type;\n  typedef typename Iterator::pointer           pointer;\n  typedef typename Iterator::reference         reference;\n};\n\ntemplate <class T>\nstruct iterator_traits<T*> {\n  typedef random_access_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef ptrdiff_t                  difference_type;\n  typedef T*                         pointer;\n  typedef T&                         reference;\n};\n\ntemplate <class T>\nstruct iterator_traits<const T*> {\n  typedef random_access_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef ptrdiff_t                  difference_type;\n  typedef const T*                   pointer;\n  typedef const T&                   reference;\n};\n\ntemplate <class Iterator>\ninline typename iterator_traits<Iterator>::iterator_category\niterator_category(const Iterator&) {\n  typedef typename iterator_traits<Iterator>::iterator_category category;\n  return category();\n}\n\ntemplate <class Iterator>\ninline typename iterator_traits<Iterator>::difference_type*\ndistance_type(const Iterator&) {\n  return static_cast<typename iterator_traits<Iterator>::difference_type*>(0);\n}\n\ntemplate <class Iterator>\ninline typename iterator_traits<Iterator>::value_type*\nvalue_type(const Iterator&) {\n  return static_cast<typename iterator_traits<Iterator>::value_type*>(0);\n}\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class T, class Distance> \ninline input_iterator_tag \niterator_category(const input_iterator<T, Distance>&) {\n  return input_iterator_tag();\n}\n\ninline output_iterator_tag iterator_category(const output_iterator&) {\n  return output_iterator_tag();\n}\n\ntemplate <class T, class Distance> \ninline forward_iterator_tag\niterator_category(const forward_iterator<T, Distance>&) {\n  return forward_iterator_tag();\n}\n\ntemplate <class T, class Distance> \ninline bidirectional_iterator_tag\niterator_category(const bidirectional_iterator<T, Distance>&) {\n  return bidirectional_iterator_tag();\n}\n\ntemplate <class T, class Distance> \ninline random_access_iterator_tag\niterator_category(const random_access_iterator<T, Distance>&) {\n  return random_access_iterator_tag();\n}\n\ntemplate <class T>\ninline random_access_iterator_tag iterator_category(const T*) {\n  return random_access_iterator_tag();\n}\n\ntemplate <class T, class Distance> \ninline T* value_type(const input_iterator<T, Distance>&) {\n  return (T*)(0); \n}\n\ntemplate <class T, class Distance> \ninline T* value_type(const forward_iterator<T, Distance>&) {\n  return (T*)(0);\n}\n\ntemplate <class T, class Distance> \ninline T* value_type(const bidirectional_iterator<T, Distance>&) {\n  return (T*)(0);\n}\n\ntemplate <class T, class Distance> \ninline T* value_type(const random_access_iterator<T, Distance>&) {\n  return (T*)(0);\n}\n\ntemplate <class T>\ninline T* value_type(const T*) { return (T*)(0); }\n\ntemplate <class T, class Distance> \ninline Distance* distance_type(const input_iterator<T, Distance>&) {\n  return (Distance*)(0);\n}\n\ntemplate <class T, class Distance> \ninline Distance* distance_type(const forward_iterator<T, Distance>&) {\n  return (Distance*)(0);\n}\n\ntemplate <class T, class Distance> \ninline Distance* \ndistance_type(const bidirectional_iterator<T, Distance>&) {\n  return (Distance*)(0);\n}\n\ntemplate <class T, class Distance> \ninline Distance* \ndistance_type(const random_access_iterator<T, Distance>&) {\n  return (Distance*)(0);\n}\n\ntemplate <class T>\ninline ptrdiff_t* distance_type(const T*) { return (ptrdiff_t*)(0); }\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class InputIterator, class Distance>\ninline void __distance(InputIterator first, InputIterator last, Distance& n, \n                       input_iterator_tag) {\n  while (first != last) { ++first; ++n; }\n}\n\ntemplate <class RandomAccessIterator, class Distance>\ninline void __distance(RandomAccessIterator first, RandomAccessIterator last, \n                       Distance& n, random_access_iterator_tag) {\n  n += last - first;\n}\n\ntemplate <class InputIterator, class Distance>\ninline void distance(InputIterator first, InputIterator last, Distance& n) {\n  __distance(first, last, n, iterator_category(first));\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class InputIterator>\ninline iterator_traits<InputIterator>::difference_type\n__distance(InputIterator first, InputIterator last, input_iterator_tag) {\n  iterator_traits<InputIterator>::difference_type n = 0;\n  while (first != last) {\n    ++first; ++n;\n  }\n  return n;\n}\n\ntemplate <class RandomAccessIterator>\ninline iterator_traits<RandomAccessIterator>::difference_type\n__distance(RandomAccessIterator first, RandomAccessIterator last,\n           random_access_iterator_tag) {\n  return last - first;\n}\n\ntemplate <class InputIterator>\ninline iterator_traits<InputIterator>::difference_type\ndistance(InputIterator first, InputIterator last) {\n  typedef typename iterator_traits<InputIterator>::iterator_category category;\n  return __distance(first, last, category());\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class InputIterator, class Distance>\ninline void __advance(InputIterator& i, Distance n, input_iterator_tag) {\n  while (n--) ++i;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1183\n#endif\n\ntemplate <class BidirectionalIterator, class Distance>\ninline void __advance(BidirectionalIterator& i, Distance n, \n                      bidirectional_iterator_tag) {\n  if (n >= 0)\n    while (n--) ++i;\n  else\n    while (n++) --i;\n}\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1183\n#endif\n\ntemplate <class RandomAccessIterator, class Distance>\ninline void __advance(RandomAccessIterator& i, Distance n, \n                      random_access_iterator_tag) {\n  i += n;\n}\n\ntemplate <class InputIterator, class Distance>\ninline void advance(InputIterator& i, Distance n) {\n  __advance(i, n, iterator_category(i));\n}\n\ntemplate <class Container>\nclass back_insert_iterator {\nprotected:\n  Container* container;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit back_insert_iterator(Container& x) : container(&x) {}\n  back_insert_iterator<Container>&\n  operator=(const typename Container::value_type& value) { \n    container->push_back(value);\n    return *this;\n  }\n  back_insert_iterator<Container>& operator*() { return *this; }\n  back_insert_iterator<Container>& operator++() { return *this; }\n  back_insert_iterator<Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class Container>\ninline output_iterator_tag\niterator_category(const back_insert_iterator<Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class Container>\ninline back_insert_iterator<Container> back_inserter(Container& x) {\n  return back_insert_iterator<Container>(x);\n}\n\ntemplate <class Container>\nclass front_insert_iterator {\nprotected:\n  Container* container;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit front_insert_iterator(Container& x) : container(&x) {}\n  front_insert_iterator<Container>&\n  operator=(const typename Container::value_type& value) { \n    container->push_front(value);\n    return *this;\n  }\n  front_insert_iterator<Container>& operator*() { return *this; }\n  front_insert_iterator<Container>& operator++() { return *this; }\n  front_insert_iterator<Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class Container>\ninline output_iterator_tag\niterator_category(const front_insert_iterator<Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class Container>\ninline front_insert_iterator<Container> front_inserter(Container& x) {\n  return front_insert_iterator<Container>(x);\n}\n\ntemplate <class Container>\nclass insert_iterator {\nprotected:\n  Container* container;\n  typename Container::iterator iter;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  insert_iterator(Container& x, typename Container::iterator i) \n    : container(&x), iter(i) {}\n  insert_iterator<Container>&\n  operator=(const typename Container::value_type& value) { \n    iter = container->insert(iter, value);\n    ++iter;\n    return *this;\n  }\n  insert_iterator<Container>& operator*() { return *this; }\n  insert_iterator<Container>& operator++() { return *this; }\n  insert_iterator<Container>& operator++(int) { return *this; }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class Container>\ninline output_iterator_tag\niterator_category(const insert_iterator<Container>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class Container, class Iterator>\ninline insert_iterator<Container> inserter(Container& x, Iterator i) {\n  typedef typename Container::iterator iter;\n  return insert_iterator<Container>(x, iter(i));\n}\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class BidirectionalIterator, class T, class Reference = T&, \n          class Distance = ptrdiff_t> \n#else\ntemplate <class BidirectionalIterator, class T, class Reference, \n          class Distance> \n#endif\nclass reverse_bidirectional_iterator {\n  typedef reverse_bidirectional_iterator<BidirectionalIterator, T, Reference,\n                                         Distance> self;\nprotected:\n  BidirectionalIterator current;\npublic:\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef Distance                   difference_type;\n  typedef T*                         pointer;\n  typedef Reference                  reference;\n\n  reverse_bidirectional_iterator() {}\n  explicit reverse_bidirectional_iterator(BidirectionalIterator x)\n    : current(x) {}\n  BidirectionalIterator base() const { return current; }\n  Reference operator*() const {\n    BidirectionalIterator tmp = current;\n    return *--tmp;\n  }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  self& operator++() {\n    --current;\n    return *this;\n  }\n  self operator++(int) {\n    self tmp = *this;\n    --current;\n    return tmp;\n  }\n  self& operator--() {\n    ++current;\n    return *this;\n  }\n  self operator--(int) {\n    self tmp = *this;\n    ++current;\n    return tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class BidirectionalIterator, class T, class Reference, \n          class Distance>\ninline bidirectional_iterator_tag\niterator_category(const reverse_bidirectional_iterator<BidirectionalIterator,\n                                                       T,\n                                                       Reference, Distance>&) {\n  return bidirectional_iterator_tag();\n}\n\ntemplate <class BidirectionalIterator, class T, class Reference, \n          class Distance>\ninline T*\nvalue_type(const reverse_bidirectional_iterator<BidirectionalIterator, T,\n                                               Reference, Distance>&) {\n  return (T*) 0;\n}\n\ntemplate <class BidirectionalIterator, class T, class Reference, \n          class Distance>\ninline Distance*\ndistance_type(const reverse_bidirectional_iterator<BidirectionalIterator, T,\n                                                  Reference, Distance>&) {\n  return (Distance*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class BidirectionalIterator, class T, class Reference,\n          class Distance>\ninline bool operator==(\n    const reverse_bidirectional_iterator<BidirectionalIterator, T, Reference,\n                                         Distance>& x, \n    const reverse_bidirectional_iterator<BidirectionalIterator, T, Reference,\n                                         Distance>& y) {\n  return x.base() == y.base();\n}\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\n// This is the new version of reverse_iterator, as defined in the\n//  draft C++ standard.  It relies on the iterator_traits template,\n//  which in turn relies on partial specialization.  The class\n//  reverse_bidirectional_iterator is no longer part of the draft\n//  standard, but it is retained for backward compatibility.\n\ntemplate <class Iterator>\nclass reverse_iterator \n{\nprotected:\n  Iterator current;\npublic:\n  typedef typename iterator_traits<Iterator>::iterator_category\n          iterator_category;\n  typedef typename iterator_traits<Iterator>::value_type\n          value_type;\n  typedef typename iterator_traits<Iterator>::difference_type\n          difference_type;\n  typedef typename iterator_traits<Iterator>::pointer\n          pointer;\n  typedef typename iterator_traits<Iterator>::reference\n          reference;\n\n  typedef Iterator iterator_type;\n  typedef reverse_iterator<Iterator> self;\n\npublic:\n  reverse_iterator() {}\n  explicit reverse_iterator(iterator_type x) : current(x) {}\n\n  reverse_iterator(const self& x) : current(x.current) {}\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class Iter>\n  reverse_iterator(const reverse_iterator<Iter>& x) : current(x.current) {}\n#endif /* __STL_MEMBER_TEMPLATES */\n    \n  iterator_type base() const { return current; }\n  reference operator*() const {\n    Iterator tmp = current;\n    return *--tmp;\n  }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  self& operator++() {\n    --current;\n    return *this;\n  }\n  self operator++(int) {\n    self tmp = *this;\n    --current;\n    return tmp;\n  }\n  self& operator--() {\n    ++current;\n    return *this;\n  }\n  self operator--(int) {\n    self tmp = *this;\n    ++current;\n    return tmp;\n  }\n\n  self operator+(difference_type n) const {\n    return self(current - n);\n  }\n  self& operator+=(difference_type n) {\n    current -= n;\n    return *this;\n  }\n  self operator-(difference_type n) const {\n    return self(current + n);\n  }\n  self& operator-=(difference_type n) {\n    current += n;\n    return *this;\n  }\n  reference operator[](difference_type n) const { return *(*this + n); }  \n}; \n \ntemplate <class Iterator>\ninline bool operator==(const reverse_iterator<Iterator>& x, \n                       const reverse_iterator<Iterator>& y) {\n  return x.base() == y.base();\n}\n\ntemplate <class Iterator>\ninline bool operator<(const reverse_iterator<Iterator>& x, \n                      const reverse_iterator<Iterator>& y) {\n  return y.base() < x.base();\n}\n\ntemplate <class Iterator>\ninline typename reverse_iterator<Iterator>::difference_type\noperator-(const reverse_iterator<Iterator>& x, \n          const reverse_iterator<Iterator>& y) {\n  return y.base() - x.base();\n}\n\ntemplate <class Iterator>\ninline reverse_iterator<Iterator> \noperator+(reverse_iterator<Iterator>::difference_type n,\n          const reverse_iterator<Iterator>& x) {\n  return reverse_iterator<Iterator>(x.base() - n);\n}\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n// This is the old version of reverse_iterator, as found in the original\n//  HP STL.  It does not use partial specialization.\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class RandomAccessIterator, class T, class Reference = T&,\n          class Distance = ptrdiff_t> \n#else\ntemplate <class RandomAccessIterator, class T, class Reference,\n          class Distance> \n#endif\nclass reverse_iterator {\n  typedef reverse_iterator<RandomAccessIterator, T, Reference, Distance>\n        self;\nprotected:\n  RandomAccessIterator current;\npublic:\n  typedef random_access_iterator_tag iterator_category;\n  typedef T                          value_type;\n  typedef Distance                   difference_type;\n  typedef T*                         pointer;\n  typedef Reference                  reference;\n\n  reverse_iterator() {}\n  explicit reverse_iterator(RandomAccessIterator x) : current(x) {}\n  RandomAccessIterator base() const { return current; }\n  Reference operator*() const { return *(current - 1); }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  self& operator++() {\n    --current;\n    return *this;\n  }\n  self operator++(int) {\n    self tmp = *this;\n    --current;\n    return tmp;\n  }\n  self& operator--() {\n    ++current;\n    return *this;\n  }\n  self operator--(int) {\n    self tmp = *this;\n    ++current;\n    return tmp;\n  }\n  self operator+(Distance n) const {\n    return self(current - n);\n  }\n  self& operator+=(Distance n) {\n    current -= n;\n    return *this;\n  }\n  self operator-(Distance n) const {\n    return self(current + n);\n  }\n  self& operator-=(Distance n) {\n    current += n;\n    return *this;\n  }\n  Reference operator[](Distance n) const { return *(*this + n); }\n};\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline random_access_iterator_tag\niterator_category(const reverse_iterator<RandomAccessIterator, T,\n                                         Reference, Distance>&) {\n  return random_access_iterator_tag();\n}\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline T* value_type(const reverse_iterator<RandomAccessIterator, T,\n                                            Reference, Distance>&) {\n  return (T*) 0;\n}\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline Distance* distance_type(const reverse_iterator<RandomAccessIterator, T,\n                                                      Reference, Distance>&) {\n  return (Distance*) 0;\n}\n\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline bool operator==(const reverse_iterator<RandomAccessIterator, T,\n                                              Reference, Distance>& x, \n                       const reverse_iterator<RandomAccessIterator, T,\n                                              Reference, Distance>& y) {\n  return x.base() == y.base();\n}\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline bool operator<(const reverse_iterator<RandomAccessIterator, T,\n                                             Reference, Distance>& x, \n                      const reverse_iterator<RandomAccessIterator, T,\n                                             Reference, Distance>& y) {\n  return y.base() < x.base();\n}\n\ntemplate <class RandomAccessIterator, class T, class Reference, class Distance>\ninline Distance operator-(const reverse_iterator<RandomAccessIterator, T,\n                                                 Reference, Distance>& x, \n                          const reverse_iterator<RandomAccessIterator, T,\n                                                 Reference, Distance>& y) {\n  return y.base() - x.base();\n}\n\ntemplate <class RandomAccessIter, class T, class Ref, class Dist>\ninline reverse_iterator<RandomAccessIter, T, Ref, Dist> \noperator+(Dist n, const reverse_iterator<RandomAccessIter, T, Ref, Dist>& x) {\n  return reverse_iterator<RandomAccessIter, T, Ref, Dist>(x.base() - n);\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class T, class Distance = ptrdiff_t> \nclass istream_iterator {\n  friend bool\n  operator== __STL_NULL_TMPL_ARGS (const istream_iterator<T, Distance>& x,\n                                   const istream_iterator<T, Distance>& y);\nprotected:\n  istream* stream;\n  T value;\n  bool end_marker;\n  void read() {\n    end_marker = (*stream) ? true : false;\n    if (end_marker) *stream >> value;\n    end_marker = (*stream) ? true : false;\n  }\npublic:\n  typedef input_iterator_tag iterator_category;\n  typedef T                  value_type;\n  typedef Distance           difference_type;\n  typedef const T*           pointer;\n  typedef const T&           reference;\n\n  istream_iterator() : stream(&cin), end_marker(false) {}\n  istream_iterator(istream& s) : stream(&s) { read(); }\n  reference operator*() const { return value; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n  istream_iterator<T, Distance>& operator++() { \n    read(); \n    return *this;\n  }\n  istream_iterator<T, Distance> operator++(int)  {\n    istream_iterator<T, Distance> tmp = *this;\n    read();\n    return tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class T, class Distance>\ninline input_iterator_tag \niterator_category(const istream_iterator<T, Distance>&) {\n  return input_iterator_tag();\n}\n\ntemplate <class T, class Distance>\ninline T* value_type(const istream_iterator<T, Distance>&) { return (T*) 0; }\n\ntemplate <class T, class Distance>\ninline Distance* distance_type(const istream_iterator<T, Distance>&) {\n  return (Distance*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class T, class Distance>\ninline bool operator==(const istream_iterator<T, Distance>& x,\n                       const istream_iterator<T, Distance>& y) {\n  return x.stream == y.stream && x.end_marker == y.end_marker ||\n         x.end_marker == false && y.end_marker == false;\n}\n\ntemplate <class T>\nclass ostream_iterator {\nprotected:\n  ostream* stream;\n  const char* string;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  ostream_iterator(ostream& s) : stream(&s), string(0) {}\n  ostream_iterator(ostream& s, const char* c) : stream(&s), string(c)  {}\n  ostream_iterator<T>& operator=(const T& value) { \n    *stream << value;\n    if (string) *stream << string;\n    return *this;\n  }\n  ostream_iterator<T>& operator*() { return *this; }\n  ostream_iterator<T>& operator++() { return *this; } \n  ostream_iterator<T>& operator++(int) { return *this; } \n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class T>\ninline output_iterator_tag \niterator_category(const ostream_iterator<T>&) {\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_ITERATOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_list.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_LIST_H\n#define __SGI_STL_INTERNAL_LIST_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\ntemplate <class T>\nstruct __list_node {\n  typedef void* void_pointer;\n  void_pointer next;\n  void_pointer prev;\n  T data;\n};\n\ntemplate<class T, class Ref, class Ptr>\nstruct __list_iterator {\n  typedef __list_iterator<T, T&, T*>             iterator;\n  typedef __list_iterator<T, const T&, const T*> const_iterator;\n  typedef __list_iterator<T, Ref, Ptr>           self;\n\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef T value_type;\n  typedef Ptr pointer;\n  typedef Ref reference;\n  typedef __list_node<T>* link_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  link_type node;\n\n  __list_iterator(link_type x) : node(x) {}\n  __list_iterator() {}\n  __list_iterator(const iterator& x) : node(x.node) {}\n\n  bool operator==(const self& x) const { return node == x.node; }\n  bool operator!=(const self& x) const { return node != x.node; }\n  reference operator*() const { return (*node).data; }\n\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  self& operator++() { \n    node = (link_type)((*node).next);\n    return *this;\n  }\n  self operator++(int) { \n    self tmp = *this;\n    ++*this;\n    return tmp;\n  }\n  self& operator--() { \n    node = (link_type)((*node).prev);\n    return *this;\n  }\n  self operator--(int) { \n    self tmp = *this;\n    --*this;\n    return tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class T, class Ref, class Ptr>\ninline bidirectional_iterator_tag\niterator_category(const __list_iterator<T, Ref, Ptr>&) {\n  return bidirectional_iterator_tag();\n}\n\ntemplate <class T, class Ref, class Ptr>\ninline T*\nvalue_type(const __list_iterator<T, Ref, Ptr>&) {\n  return 0;\n}\n\ntemplate <class T, class Ref, class Ptr>\ninline ptrdiff_t*\ndistance_type(const __list_iterator<T, Ref, Ptr>&) {\n  return 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ntemplate <class T, class Alloc = alloc>\nclass list {\nprotected:\n  typedef void* void_pointer;\n  typedef __list_node<T> list_node;\n  typedef simple_alloc<list_node, Alloc> list_node_allocator;\npublic:      \n  typedef T value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef list_node* link_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\npublic:\n  typedef __list_iterator<T, T&, T*>             iterator;\n  typedef __list_iterator<T, const T&, const T*> const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_bidirectional_iterator<const_iterator, value_type,\n  const_reference, difference_type>\n  const_reverse_iterator;\n  typedef reverse_bidirectional_iterator<iterator, value_type, reference,\n  difference_type>\n  reverse_iterator; \n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nprotected:\n  link_type get_node() { return list_node_allocator::allocate(); }\n  void put_node(link_type p) { list_node_allocator::deallocate(p); }\n\n  link_type create_node(const T& x) {\n    link_type p = get_node();\n    __STL_TRY {\n      construct(&p->data, x);\n    }\n    __STL_UNWIND(put_node(p));\n    return p;\n  }\n  void destroy_node(link_type p) {\n    destroy(&p->data);\n    put_node(p);\n  }\n\nprotected:\n  void empty_initialize() { \n    node = get_node();\n    node->next = node;\n    node->prev = node;\n  }\n\n  void fill_initialize(size_type n, const T& value) {\n    empty_initialize();\n    __STL_TRY {\n      insert(begin(), n, value);\n    }\n    __STL_UNWIND(clear(); put_node(node));\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void range_initialize(InputIterator first, InputIterator last) {\n    empty_initialize();\n    __STL_TRY {\n      insert(begin(), first, last);\n    }\n    __STL_UNWIND(clear(); put_node(node));\n  }\n#else  /* __STL_MEMBER_TEMPLATES */\n  void range_initialize(const T* first, const T* last) {\n    empty_initialize();\n    __STL_TRY {\n      insert(begin(), first, last);\n    }\n    __STL_UNWIND(clear(); put_node(node));\n  }\n  void range_initialize(const_iterator first, const_iterator last) {\n    empty_initialize();\n    __STL_TRY {\n      insert(begin(), first, last);\n    }\n    __STL_UNWIND(clear(); put_node(node));\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprotected:\n  link_type node;\n\npublic:\n  list() { empty_initialize(); }\n\n  iterator begin() { return (link_type)((*node).next); }\n  const_iterator begin() const { return (link_type)((*node).next); }\n  iterator end() { return node; }\n  const_iterator end() const { return node; }\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin());\n  } \n  bool empty() const { return node->next == node; }\n  size_type size() const {\n    size_type result = 0;\n    distance(begin(), end(), result);\n    return result;\n  }\n  size_type max_size() const { return size_type(-1); }\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(--end()); }\n  const_reference back() const { return *(--end()); }\n  void swap(list<T, Alloc>& x) { __STD::swap(node, x.node); }\n  iterator insert(iterator position, const T& x) {\n    link_type tmp = create_node(x);\n    tmp->next = position.node;\n    tmp->prev = position.node->prev;\n    (link_type(position.node->prev))->next = tmp;\n    position.node->prev = tmp;\n    return tmp;\n  }\n  iterator insert(iterator position) { return insert(position, T()); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(iterator position, InputIterator first, InputIterator last);\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator position, const T* first, const T* last);\n  void insert(iterator position,\n              const_iterator first, const_iterator last);\n#endif /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator pos, size_type n, const T& x);\n  void insert(iterator pos, int n, const T& x) {\n    insert(pos, (size_type)n, x);\n  }\n  void insert(iterator pos, long n, const T& x) {\n    insert(pos, (size_type)n, x);\n  }\n\n  void push_front(const T& x) { insert(begin(), x); }\n  void push_back(const T& x) { insert(end(), x); }\n  iterator erase(iterator position) {\n    link_type next_node = link_type(position.node->next);\n    link_type prev_node = link_type(position.node->prev);\n    prev_node->next = next_node;\n    next_node->prev = prev_node;\n    destroy_node(position.node);\n    return iterator(next_node);\n  }\n  iterator erase(iterator first, iterator last);\n  void resize(size_type new_size, const T& x);\n  void resize(size_type new_size) { resize(new_size, T()); }\n  void clear();\n\n  void pop_front() { erase(begin()); }\n  void pop_back() { \n    iterator tmp = end();\n    erase(--tmp);\n  }\n  list(size_type n, const T& value) { fill_initialize(n, value); }\n  list(int n, const T& value) { fill_initialize(n, value); }\n  list(long n, const T& value) { fill_initialize(n, value); }\n  explicit list(size_type n) { fill_initialize(n, T()); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  list(InputIterator first, InputIterator last) {\n    range_initialize(first, last);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  list(const T* first, const T* last) { range_initialize(first, last); }\n  list(const_iterator first, const_iterator last) {\n    range_initialize(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  list(const list<T, Alloc>& x) {\n    range_initialize(x.begin(), x.end());\n  }\n  ~list() {\n    clear();\n    put_node(node);\n  }\n  list<T, Alloc>& operator=(const list<T, Alloc>& x);\n\nprotected:\n  void transfer(iterator position, iterator first, iterator last) {\n    if (position != last) {\n      (*(link_type((*last.node).prev))).next = position.node;\n      (*(link_type((*first.node).prev))).next = last.node;\n      (*(link_type((*position.node).prev))).next = first.node;  \n      link_type tmp = link_type((*position.node).prev);\n      (*position.node).prev = (*last.node).prev;\n      (*last.node).prev = (*first.node).prev; \n      (*first.node).prev = tmp;\n    }\n  }\n\npublic:\n  void splice(iterator position, list& x) {\n    if (!x.empty()) \n      transfer(position, x.begin(), x.end());\n  }\n  void splice(iterator position, list&, iterator i) {\n    iterator j = i;\n    ++j;\n    if (position == i || position == j) return;\n    transfer(position, i, j);\n  }\n  void splice(iterator position, list&, iterator first, iterator last) {\n    if (first != last) \n      transfer(position, first, last);\n  }\n  void remove(const T& value);\n  void unique();\n  void merge(list& x);\n  void reverse();\n  void sort();\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class Predicate> void remove_if(Predicate);\n  template <class BinaryPredicate> void unique(BinaryPredicate);\n  template <class StrictWeakOrdering> void merge(list&, StrictWeakOrdering);\n  template <class StrictWeakOrdering> void sort(StrictWeakOrdering);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  friend bool operator== __STL_NULL_TMPL_ARGS (const list& x, const list& y);\n};\n\ntemplate <class T, class Alloc>\ninline bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y) {\n  typedef typename list<T,Alloc>::link_type link_type;\n  link_type e1 = x.node;\n  link_type e2 = y.node;\n  link_type n1 = (link_type) e1->next;\n  link_type n2 = (link_type) e2->next;\n  for ( ; n1 != e1 && n2 != e2 ;\n          n1 = (link_type) n1->next, n2 = (link_type) n2->next)\n    if (n1->data != n2->data)\n      return false;\n  return n1 == e1 && n2 == e2;\n}\n\ntemplate <class T, class Alloc>\ninline bool operator<(const list<T, Alloc>& x, const list<T, Alloc>& y) {\n  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class T, class Alloc>\ninline void swap(list<T, Alloc>& x, list<T, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class T, class Alloc> template <class InputIterator>\nvoid list<T, Alloc>::insert(iterator position,\n                            InputIterator first, InputIterator last) {\n  for ( ; first != last; ++first)\n    insert(position, *first);\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::insert(iterator position, const T* first, const T* last) {\n  for ( ; first != last; ++first)\n    insert(position, *first);\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::insert(iterator position,\n                            const_iterator first, const_iterator last) {\n  for ( ; first != last; ++first)\n    insert(position, *first);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::insert(iterator position, size_type n, const T& x) {\n  for ( ; n > 0; --n)\n    insert(position, x);\n}\n\ntemplate <class T, class Alloc>\nlist<T,Alloc>::iterator list<T, Alloc>::erase(iterator first, iterator last) {\n  while (first != last) erase(first++);\n  return last;\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::resize(size_type new_size, const T& x)\n{\n  iterator i = begin();\n  size_type len = 0;\n  for ( ; i != end() && len < new_size; ++i, ++len)\n    ;\n  if (len == new_size)\n    erase(i, end());\n  else                          // i == end()\n    insert(end(), new_size - len, x);\n}\n\ntemplate <class T, class Alloc> \nvoid list<T, Alloc>::clear()\n{\n  link_type cur = (link_type) node->next;\n  while (cur != node) {\n    link_type tmp = cur;\n    cur = (link_type) cur->next;\n    destroy_node(tmp);\n  }\n  node->next = node;\n  node->prev = node;\n}\n\ntemplate <class T, class Alloc>\nlist<T, Alloc>& list<T, Alloc>::operator=(const list<T, Alloc>& x) {\n  if (this != &x) {\n    iterator first1 = begin();\n    iterator last1 = end();\n    const_iterator first2 = x.begin();\n    const_iterator last2 = x.end();\n    while (first1 != last1 && first2 != last2) *first1++ = *first2++;\n    if (first2 == last2)\n      erase(first1, last1);\n    else\n      insert(last1, first2, last2);\n  }\n  return *this;\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::remove(const T& value) {\n  iterator first = begin();\n  iterator last = end();\n  while (first != last) {\n    iterator next = first;\n    ++next;\n    if (*first == value) erase(first);\n    first = next;\n  }\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::unique() {\n  iterator first = begin();\n  iterator last = end();\n  if (first == last) return;\n  iterator next = first;\n  while (++next != last) {\n    if (*first == *next)\n      erase(next);\n    else\n      first = next;\n    next = first;\n  }\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::merge(list<T, Alloc>& x) {\n  iterator first1 = begin();\n  iterator last1 = end();\n  iterator first2 = x.begin();\n  iterator last2 = x.end();\n  while (first1 != last1 && first2 != last2)\n    if (*first2 < *first1) {\n      iterator next = first2;\n      transfer(first1, first2, ++next);\n      first2 = next;\n    }\n    else\n      ++first1;\n  if (first2 != last2) transfer(last1, first2, last2);\n}\n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::reverse() {\n  if (node->next == node || link_type(node->next)->next == node) return;\n  iterator first = begin();\n  ++first;\n  while (first != end()) {\n    iterator old = first;\n    ++first;\n    transfer(begin(), old, first);\n  }\n}    \n\ntemplate <class T, class Alloc>\nvoid list<T, Alloc>::sort() {\n  if (node->next == node || link_type(node->next)->next == node) return;\n  list<T, Alloc> carry;\n  list<T, Alloc> counter[64];\n  int fill = 0;\n  while (!empty()) {\n    carry.splice(carry.begin(), *this, begin());\n    int i = 0;\n    while(i < fill && !counter[i].empty()) {\n      counter[i].merge(carry);\n      carry.swap(counter[i++]);\n    }\n    carry.swap(counter[i]);         \n    if (i == fill) ++fill;\n  } \n\n  for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1]);\n  swap(counter[fill-1]);\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class T, class Alloc> template <class Predicate>\nvoid list<T, Alloc>::remove_if(Predicate pred) {\n  iterator first = begin();\n  iterator last = end();\n  while (first != last) {\n    iterator next = first;\n    ++next;\n    if (pred(*first)) erase(first);\n    first = next;\n  }\n}\n\ntemplate <class T, class Alloc> template <class BinaryPredicate>\nvoid list<T, Alloc>::unique(BinaryPredicate binary_pred) {\n  iterator first = begin();\n  iterator last = end();\n  if (first == last) return;\n  iterator next = first;\n  while (++next != last) {\n    if (binary_pred(*first, *next))\n      erase(next);\n    else\n      first = next;\n    next = first;\n  }\n}\n\ntemplate <class T, class Alloc> template <class StrictWeakOrdering>\nvoid list<T, Alloc>::merge(list<T, Alloc>& x, StrictWeakOrdering comp) {\n  iterator first1 = begin();\n  iterator last1 = end();\n  iterator first2 = x.begin();\n  iterator last2 = x.end();\n  while (first1 != last1 && first2 != last2)\n    if (comp(*first2, *first1)) {\n      iterator next = first2;\n      transfer(first1, first2, ++next);\n      first2 = next;\n    }\n    else\n      ++first1;\n  if (first2 != last2) transfer(last1, first2, last2);\n}\n\ntemplate <class T, class Alloc> template <class StrictWeakOrdering>\nvoid list<T, Alloc>::sort(StrictWeakOrdering comp) {\n  if (node->next == node || link_type(node->next)->next == node) return;\n  list<T, Alloc> carry;\n  list<T, Alloc> counter[64];\n  int fill = 0;\n  while (!empty()) {\n    carry.splice(carry.begin(), *this, begin());\n    int i = 0;\n    while(i < fill && !counter[i].empty()) {\n      counter[i].merge(carry, comp);\n      carry.swap(counter[i++]);\n    }\n    carry.swap(counter[i]);         \n    if (i == fill) ++fill;\n  } \n\n  for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1], comp);\n  swap(counter[fill-1]);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_LIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_map.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MAP_H\n#define __SGI_STL_INTERNAL_MAP_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class T, class Compare = less<Key>, class Alloc = alloc>\n#else\ntemplate <class Key, class T, class Compare, class Alloc = alloc>\n#endif\nclass map {\npublic:\n\n// typedefs:\n\n  typedef Key key_type;\n  typedef T data_type;\n  typedef T mapped_type;\n  typedef pair<const Key, T> value_type;\n  typedef Compare key_compare;\n    \n  class value_compare\n    : public binary_function<value_type, value_type, bool> {\n  friend class map<Key, T, Compare, Alloc>;\n  protected :\n    Compare comp;\n    value_compare(Compare c) : comp(c) {}\n  public:\n    bool operator()(const value_type& x, const value_type& y) const {\n      return comp(x.first, y.first);\n    }\n  };\n\nprivate:\n  typedef rb_tree<key_type, value_type, \n                  select1st<value_type>, key_compare, Alloc> rep_type;\n  rep_type t;  // red-black tree representing map\npublic:\n  typedef typename rep_type::pointer pointer;\n  typedef typename rep_type::const_pointer const_pointer;\n  typedef typename rep_type::reference reference;\n  typedef typename rep_type::const_reference const_reference;\n  typedef typename rep_type::iterator iterator;\n  typedef typename rep_type::const_iterator const_iterator;\n  typedef typename rep_type::reverse_iterator reverse_iterator;\n  typedef typename rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename rep_type::size_type size_type;\n  typedef typename rep_type::difference_type difference_type;\n\n  // allocation/deallocation\n\n  map() : t(Compare()) {}\n  explicit map(const Compare& comp) : t(comp) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  map(InputIterator first, InputIterator last)\n    : t(Compare()) { t.insert_unique(first, last); }\n\n  template <class InputIterator>\n  map(InputIterator first, InputIterator last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n#else\n  map(const value_type* first, const value_type* last)\n    : t(Compare()) { t.insert_unique(first, last); }\n  map(const value_type* first, const value_type* last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n\n  map(const_iterator first, const_iterator last)\n    : t(Compare()) { t.insert_unique(first, last); }\n  map(const_iterator first, const_iterator last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  map(const map<Key, T, Compare, Alloc>& x) : t(x.t) {}\n  map<Key, T, Compare, Alloc>& operator=(const map<Key, T, Compare, Alloc>& x)\n  {\n    t = x.t;\n    return *this; \n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return t.key_comp(); }\n  value_compare value_comp() const { return value_compare(t.key_comp()); }\n  iterator begin() { return t.begin(); }\n  const_iterator begin() const { return t.begin(); }\n  iterator end() { return t.end(); }\n  const_iterator end() const { return t.end(); }\n  reverse_iterator rbegin() { return t.rbegin(); }\n  const_reverse_iterator rbegin() const { return t.rbegin(); }\n  reverse_iterator rend() { return t.rend(); }\n  const_reverse_iterator rend() const { return t.rend(); }\n  bool empty() const { return t.empty(); }\n  size_type size() const { return t.size(); }\n  size_type max_size() const { return t.max_size(); }\n  T& operator[](const key_type& k) {\n    return (*((insert(value_type(k, T()))).first)).second;\n  }\n  void swap(map<Key, T, Compare, Alloc>& x) { t.swap(x.t); }\n\n  // insert/erase\n\n  pair<iterator,bool> insert(const value_type& x) { return t.insert_unique(x); }\n  iterator insert(iterator position, const value_type& x) {\n    return t.insert_unique(position, x);\n  }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator first, InputIterator last) {\n    t.insert_unique(first, last);\n  }\n#else\n  void insert(const value_type* first, const value_type* last) {\n    t.insert_unique(first, last);\n  }\n  void insert(const_iterator first, const_iterator last) {\n    t.insert_unique(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void erase(iterator position) { t.erase(position); }\n  size_type erase(const key_type& x) { return t.erase(x); }\n  void erase(iterator first, iterator last) { t.erase(first, last); }\n  void clear() { t.clear(); }\n\n  // map operations:\n\n  iterator find(const key_type& x) { return t.find(x); }\n  const_iterator find(const key_type& x) const { return t.find(x); }\n  size_type count(const key_type& x) const { return t.count(x); }\n  iterator lower_bound(const key_type& x) {return t.lower_bound(x); }\n  const_iterator lower_bound(const key_type& x) const {\n    return t.lower_bound(x); \n  }\n  iterator upper_bound(const key_type& x) {return t.upper_bound(x); }\n  const_iterator upper_bound(const key_type& x) const {\n    return t.upper_bound(x); \n  }\n  \n  pair<iterator,iterator> equal_range(const key_type& x) {\n    return t.equal_range(x);\n  }\n  pair<const_iterator,const_iterator> equal_range(const key_type& x) const {\n    return t.equal_range(x);\n  }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const map&, const map&);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const map&, const map&);\n};\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline bool operator==(const map<Key, T, Compare, Alloc>& x, \n                       const map<Key, T, Compare, Alloc>& y) {\n  return x.t == y.t;\n}\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline bool operator<(const map<Key, T, Compare, Alloc>& x, \n                      const map<Key, T, Compare, Alloc>& y) {\n  return x.t < y.t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline void swap(map<Key, T, Compare, Alloc>& x, \n                 map<Key, T, Compare, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_multimap.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MULTIMAP_H\n#define __SGI_STL_INTERNAL_MULTIMAP_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class T, class Compare = less<Key>, class Alloc = alloc>\n#else\ntemplate <class Key, class T, class Compare, class Alloc = alloc>\n#endif\nclass multimap {\npublic:\n\n// typedefs:\n\n  typedef Key key_type;\n  typedef T data_type;\n  typedef T mapped_type;\n  typedef pair<const Key, T> value_type;\n  typedef Compare key_compare;\n\n  class value_compare : public binary_function<value_type, value_type, bool> {\n  friend class multimap<Key, T, Compare, Alloc>;\n  protected:\n    Compare comp;\n    value_compare(Compare c) : comp(c) {}\n  public:\n    bool operator()(const value_type& x, const value_type& y) const {\n      return comp(x.first, y.first);\n    }\n  };\n\nprivate:\n  typedef rb_tree<key_type, value_type, \n                  select1st<value_type>, key_compare, Alloc> rep_type;\n  rep_type t;  // red-black tree representing multimap\npublic:\n  typedef typename rep_type::pointer pointer;\n  typedef typename rep_type::const_pointer const_pointer;\n  typedef typename rep_type::reference reference;\n  typedef typename rep_type::const_reference const_reference;\n  typedef typename rep_type::iterator iterator;\n  typedef typename rep_type::const_iterator const_iterator; \n  typedef typename rep_type::reverse_iterator reverse_iterator;\n  typedef typename rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename rep_type::size_type size_type;\n  typedef typename rep_type::difference_type difference_type;\n\n// allocation/deallocation\n\n  multimap() : t(Compare()) { }\n  explicit multimap(const Compare& comp) : t(comp) { }\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class InputIterator>\n  multimap(InputIterator first, InputIterator last)\n    : t(Compare()) { t.insert_equal(first, last); }\n\n  template <class InputIterator>\n  multimap(InputIterator first, InputIterator last, const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n#else\n  multimap(const value_type* first, const value_type* last)\n    : t(Compare()) { t.insert_equal(first, last); }\n  multimap(const value_type* first, const value_type* last,\n           const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n\n  multimap(const_iterator first, const_iterator last)\n    : t(Compare()) { t.insert_equal(first, last); }\n  multimap(const_iterator first, const_iterator last, const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  multimap(const multimap<Key, T, Compare, Alloc>& x) : t(x.t) { }\n  multimap<Key, T, Compare, Alloc>&\n  operator=(const multimap<Key, T, Compare, Alloc>& x) {\n    t = x.t;\n    return *this; \n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return t.key_comp(); }\n  value_compare value_comp() const { return value_compare(t.key_comp()); }\n  iterator begin() { return t.begin(); }\n  const_iterator begin() const { return t.begin(); }\n  iterator end() { return t.end(); }\n  const_iterator end() const { return t.end(); }\n  reverse_iterator rbegin() { return t.rbegin(); }\n  const_reverse_iterator rbegin() const { return t.rbegin(); }\n  reverse_iterator rend() { return t.rend(); }\n  const_reverse_iterator rend() const { return t.rend(); }\n  bool empty() const { return t.empty(); }\n  size_type size() const { return t.size(); }\n  size_type max_size() const { return t.max_size(); }\n  void swap(multimap<Key, T, Compare, Alloc>& x) { t.swap(x.t); }\n\n  // insert/erase\n\n  iterator insert(const value_type& x) { return t.insert_equal(x); }\n  iterator insert(iterator position, const value_type& x) {\n    return t.insert_equal(position, x);\n  }\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class InputIterator>\n  void insert(InputIterator first, InputIterator last) {\n    t.insert_equal(first, last);\n  }\n#else\n  void insert(const value_type* first, const value_type* last) {\n    t.insert_equal(first, last);\n  }\n  void insert(const_iterator first, const_iterator last) {\n    t.insert_equal(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator position) { t.erase(position); }\n  size_type erase(const key_type& x) { return t.erase(x); }\n  void erase(iterator first, iterator last) { t.erase(first, last); }\n  void clear() { t.clear(); }\n\n  // multimap operations:\n\n  iterator find(const key_type& x) { return t.find(x); }\n  const_iterator find(const key_type& x) const { return t.find(x); }\n  size_type count(const key_type& x) const { return t.count(x); }\n  iterator lower_bound(const key_type& x) {return t.lower_bound(x); }\n  const_iterator lower_bound(const key_type& x) const {\n    return t.lower_bound(x); \n  }\n  iterator upper_bound(const key_type& x) {return t.upper_bound(x); }\n  const_iterator upper_bound(const key_type& x) const {\n    return t.upper_bound(x); \n  }\n   pair<iterator,iterator> equal_range(const key_type& x) {\n    return t.equal_range(x);\n  }\n  pair<const_iterator,const_iterator> equal_range(const key_type& x) const {\n    return t.equal_range(x);\n  }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const multimap&,\n                                               const multimap&);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const multimap&,\n                                              const multimap&);\n};\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline bool operator==(const multimap<Key, T, Compare, Alloc>& x, \n                       const multimap<Key, T, Compare, Alloc>& y) {\n  return x.t == y.t;\n}\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline bool operator<(const multimap<Key, T, Compare, Alloc>& x, \n                      const multimap<Key, T, Compare, Alloc>& y) {\n  return x.t < y.t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class T, class Compare, class Alloc>\ninline void swap(multimap<Key, T, Compare, Alloc>& x, \n                 multimap<Key, T, Compare, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_multiset.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_MULTISET_H\n#define __SGI_STL_INTERNAL_MULTISET_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class Compare = less<Key>, class Alloc = alloc>\n#else\ntemplate <class Key, class Compare, class Alloc = alloc>\n#endif\nclass multiset {\npublic:\n  // typedefs:\n\n  typedef Key key_type;\n  typedef Key value_type;\n  typedef Compare key_compare;\n  typedef Compare value_compare;\nprivate:\n  typedef rb_tree<key_type, value_type, \n                  identity<value_type>, key_compare, Alloc> rep_type;\n  rep_type t;  // red-black tree representing multiset\npublic:\n  typedef typename rep_type::const_pointer pointer;\n  typedef typename rep_type::const_pointer const_pointer;\n  typedef typename rep_type::const_reference reference;\n  typedef typename rep_type::const_reference const_reference;\n  typedef typename rep_type::const_iterator iterator;\n  typedef typename rep_type::const_iterator const_iterator;\n  typedef typename rep_type::const_reverse_iterator reverse_iterator;\n  typedef typename rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename rep_type::size_type size_type;\n  typedef typename rep_type::difference_type difference_type;\n\n  // allocation/deallocation\n\n  multiset() : t(Compare()) {}\n  explicit multiset(const Compare& comp) : t(comp) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  multiset(InputIterator first, InputIterator last)\n    : t(Compare()) { t.insert_equal(first, last); }\n  template <class InputIterator>\n  multiset(InputIterator first, InputIterator last, const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n#else\n  multiset(const value_type* first, const value_type* last)\n    : t(Compare()) { t.insert_equal(first, last); }\n  multiset(const value_type* first, const value_type* last,\n           const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n\n  multiset(const_iterator first, const_iterator last)\n    : t(Compare()) { t.insert_equal(first, last); }\n  multiset(const_iterator first, const_iterator last, const Compare& comp)\n    : t(comp) { t.insert_equal(first, last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  multiset(const multiset<Key, Compare, Alloc>& x) : t(x.t) {}\n  multiset<Key, Compare, Alloc>&\n  operator=(const multiset<Key, Compare, Alloc>& x) {\n    t = x.t; \n    return *this;\n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return t.key_comp(); }\n  value_compare value_comp() const { return t.key_comp(); }\n  iterator begin() const { return t.begin(); }\n  iterator end() const { return t.end(); }\n  reverse_iterator rbegin() const { return t.rbegin(); } \n  reverse_iterator rend() const { return t.rend(); }\n  bool empty() const { return t.empty(); }\n  size_type size() const { return t.size(); }\n  size_type max_size() const { return t.max_size(); }\n  void swap(multiset<Key, Compare, Alloc>& x) { t.swap(x.t); }\n\n  // insert/erase\n  iterator insert(const value_type& x) { \n    return t.insert_equal(x);\n  }\n  iterator insert(iterator position, const value_type& x) {\n    typedef typename rep_type::iterator rep_iterator;\n    return t.insert_equal((rep_iterator&)position, x);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class InputIterator>\n  void insert(InputIterator first, InputIterator last) {\n    t.insert_equal(first, last);\n  }\n#else\n  void insert(const value_type* first, const value_type* last) {\n    t.insert_equal(first, last);\n  }\n  void insert(const_iterator first, const_iterator last) {\n    t.insert_equal(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator position) { \n    typedef typename rep_type::iterator rep_iterator;\n    t.erase((rep_iterator&)position); \n  }\n  size_type erase(const key_type& x) { \n    return t.erase(x); \n  }\n  void erase(iterator first, iterator last) { \n    typedef typename rep_type::iterator rep_iterator;\n    t.erase((rep_iterator&)first, (rep_iterator&)last); \n  }\n  void clear() { t.clear(); }\n\n  // multiset operations:\n\n  iterator find(const key_type& x) const { return t.find(x); }\n  size_type count(const key_type& x) const { return t.count(x); }\n  iterator lower_bound(const key_type& x) const {\n    return t.lower_bound(x);\n  }\n  iterator upper_bound(const key_type& x) const {\n    return t.upper_bound(x); \n  }\n  pair<iterator,iterator> equal_range(const key_type& x) const {\n    return t.equal_range(x);\n  }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const multiset&,\n                                               const multiset&);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const multiset&,\n                                              const multiset&);\n};\n\ntemplate <class Key, class Compare, class Alloc>\ninline bool operator==(const multiset<Key, Compare, Alloc>& x, \n                       const multiset<Key, Compare, Alloc>& y) {\n  return x.t == y.t;\n}\n\ntemplate <class Key, class Compare, class Alloc>\ninline bool operator<(const multiset<Key, Compare, Alloc>& x, \n                      const multiset<Key, Compare, Alloc>& y) {\n  return x.t < y.t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class Compare, class Alloc>\ninline void swap(multiset<Key, Compare, Alloc>& x, \n                 multiset<Key, Compare, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_MULTISET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_numeric.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n\n#ifndef __SGI_STL_INTERNAL_NUMERIC_H\n#define __SGI_STL_INTERNAL_NUMERIC_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class InputIterator, class T>\nT accumulate(InputIterator first, InputIterator last, T init) {\n  for ( ; first != last; ++first)\n    init = init + *first;\n  return init;\n}\n\ntemplate <class InputIterator, class T, class BinaryOperation>\nT accumulate(InputIterator first, InputIterator last, T init,\n             BinaryOperation binary_op) {\n  for ( ; first != last; ++first)\n    init = binary_op(init, *first);\n  return init;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class T>\nT inner_product(InputIterator1 first1, InputIterator1 last1,\n                InputIterator2 first2, T init) {\n  for ( ; first1 != last1; ++first1, ++first2)\n    init = init + (*first1 * *first2);\n  return init;\n}\n\ntemplate <class InputIterator1, class InputIterator2, class T,\n          class BinaryOperation1, class BinaryOperation2>\nT inner_product(InputIterator1 first1, InputIterator1 last1,\n                InputIterator2 first2, T init, BinaryOperation1 binary_op1,\n                BinaryOperation2 binary_op2) {\n  for ( ; first1 != last1; ++first1, ++first2)\n    init = binary_op1(init, binary_op2(*first1, *first2));\n  return init;\n}\n\ntemplate <class InputIterator, class OutputIterator, class T>\nOutputIterator __partial_sum(InputIterator first, InputIterator last,\n                             OutputIterator result, T*) {\n  T value = *first;\n  while (++first != last) {\n    value = value + *first;\n    *++result = value;\n  }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator>\nOutputIterator partial_sum(InputIterator first, InputIterator last,\n                           OutputIterator result) {\n  if (first == last) return result;\n  *result = *first;\n  return __partial_sum(first, last, result, value_type(first));\n}\n\ntemplate <class InputIterator, class OutputIterator, class T,\n          class BinaryOperation>\nOutputIterator __partial_sum(InputIterator first, InputIterator last,\n                             OutputIterator result, T*,\n                             BinaryOperation binary_op) {\n  T value = *first;\n  while (++first != last) {\n    value = binary_op(value, *first);\n    *++result = value;\n  }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator, class BinaryOperation>\nOutputIterator partial_sum(InputIterator first, InputIterator last,\n                           OutputIterator result, BinaryOperation binary_op) {\n  if (first == last) return result;\n  *result = *first;\n  return __partial_sum(first, last, result, value_type(first), binary_op);\n}\n\ntemplate <class InputIterator, class OutputIterator, class T>\nOutputIterator __adjacent_difference(InputIterator first, InputIterator last, \n                                     OutputIterator result, T*) {\n  T value = *first;\n  while (++first != last) {\n    T tmp = *first;\n    *++result = tmp - value;\n    value = tmp;\n  }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator>\nOutputIterator adjacent_difference(InputIterator first, InputIterator last, \n                                   OutputIterator result) {\n  if (first == last) return result;\n  *result = *first;\n  return __adjacent_difference(first, last, result, value_type(first));\n}\n\ntemplate <class InputIterator, class OutputIterator, class T, \n          class BinaryOperation>\nOutputIterator __adjacent_difference(InputIterator first, InputIterator last, \n                                     OutputIterator result, T*,\n                                     BinaryOperation binary_op) {\n  T value = *first;\n  while (++first != last) {\n    T tmp = *first;\n    *++result = binary_op(tmp, value);\n    value = tmp;\n  }\n  return ++result;\n}\n\ntemplate <class InputIterator, class OutputIterator, class BinaryOperation>\nOutputIterator adjacent_difference(InputIterator first, InputIterator last,\n                                   OutputIterator result,\n                                   BinaryOperation binary_op) {\n  if (first == last) return result;\n  *result = *first;\n  return __adjacent_difference(first, last, result, value_type(first),\n                               binary_op);\n}\n\n// Returns x ** n, where n >= 0.  Note that \"multiplication\"\n//  is required to be associative, but not necessarily commutative.\n    \ntemplate <class T, class Integer, class MonoidOperation>\nT power(T x, Integer n, MonoidOperation op) {\n  if (n == 0)\n    return identity_element(op);\n  else {\n    while ((n & 1) == 0) {\n      n >>= 1;\n      x = op(x, x);\n    }\n\n    T result = x;\n    n >>= 1;\n    while (n != 0) {\n      x = op(x, x);\n      if ((n & 1) != 0)\n        result = op(result, x);\n      n >>= 1;\n    }\n    return result;\n  }\n}\n\ntemplate <class T, class Integer>\ninline T power(T x, Integer n) {\n  return power(x, n, multiplies<T>());\n}\n\n\ntemplate <class ForwardIterator, class T>\nvoid iota(ForwardIterator first, ForwardIterator last, T value) {\n  while (first != last) *first++ = value++;\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_NUMERIC_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_pair.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_PAIR_H\n#define __SGI_STL_INTERNAL_PAIR_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class T1, class T2>\nstruct pair {\n  typedef T1 first_type;\n  typedef T2 second_type;\n\n  T1 first;\n  T2 second;\n  pair() : first(T1()), second(T2()) {}\n  pair(const T1& a, const T2& b) : first(a), second(b) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class U1, class U2>\n  pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}\n#endif\n};\n\ntemplate <class T1, class T2>\ninline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { \n  return x.first == y.first && x.second == y.second; \n}\n\ntemplate <class T1, class T2>\ninline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { \n  return x.first < y.first || (!(y.first < x.first) && x.second < y.second); \n}\n\ntemplate <class T1, class T2>\ninline pair<T1, T2> make_pair(const T1& x, const T2& y) {\n  return pair<T1, T2>(x, y);\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_PAIR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_queue.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_QUEUE_H\n#define __SGI_STL_INTERNAL_QUEUE_H\n\n__STL_BEGIN_NAMESPACE\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class T, class Sequence = deque<T> >\n#else\ntemplate <class T, class Sequence>\n#endif\nclass queue {\n  friend bool operator== __STL_NULL_TMPL_ARGS (const queue& x, const queue& y);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const queue& x, const queue& y);\npublic:\n  typedef typename Sequence::value_type value_type;\n  typedef typename Sequence::size_type size_type;\n  typedef typename Sequence::reference reference;\n  typedef typename Sequence::const_reference const_reference;\nprotected:\n  Sequence c;\npublic:\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  reference front() { return c.front(); }\n  const_reference front() const { return c.front(); }\n  reference back() { return c.back(); }\n  const_reference back() const { return c.back(); }\n  void push(const value_type& x) { c.push_back(x); }\n  void pop() { c.pop_front(); }\n};\n\ntemplate <class T, class Sequence>\nbool operator==(const queue<T, Sequence>& x, const queue<T, Sequence>& y) {\n  return x.c == y.c;\n}\n\ntemplate <class T, class Sequence>\nbool operator<(const queue<T, Sequence>& x, const queue<T, Sequence>& y) {\n  return x.c < y.c;\n}\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class T, class Sequence = vector<T>, \n          class Compare = less<typename Sequence::value_type> >\n#else\ntemplate <class T, class Sequence, class Compare>\n#endif\nclass  priority_queue {\npublic:\n  typedef typename Sequence::value_type value_type;\n  typedef typename Sequence::size_type size_type;\n  typedef typename Sequence::reference reference;\n  typedef typename Sequence::const_reference const_reference;\nprotected:\n  Sequence c;\n  Compare comp;\npublic:\n  priority_queue() : c() {}\n  explicit priority_queue(const Compare& x) :  c(), comp(x) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  priority_queue(InputIterator first, InputIterator last, const Compare& x)\n    : c(first, last), comp(x) { make_heap(c.begin(), c.end(), comp); }\n  template <class InputIterator>\n  priority_queue(InputIterator first, InputIterator last) \n    : c(first, last) { make_heap(c.begin(), c.end(), comp); }\n#else /* __STL_MEMBER_TEMPLATES */\n  priority_queue(const value_type* first, const value_type* last, \n                 const Compare& x) : c(first, last), comp(x) {\n    make_heap(c.begin(), c.end(), comp);\n  }\n  priority_queue(const value_type* first, const value_type* last) \n    : c(first, last) { make_heap(c.begin(), c.end(), comp); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  const_reference top() const { return c.front(); }\n  void push(const value_type& x) {\n    __STL_TRY {\n      c.push_back(x); \n      push_heap(c.begin(), c.end(), comp);\n    }\n    __STL_UNWIND(c.clear());\n  }\n  void pop() {\n    __STL_TRY {\n      pop_heap(c.begin(), c.end(), comp);\n      c.pop_back();\n    }\n    __STL_UNWIND(c.clear());\n  }\n};\n\n// no equality is provided\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_QUEUE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_raw_storage_iter.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n#define __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class ForwardIterator, class T>\nclass raw_storage_iterator {\nprotected:\n  ForwardIterator iter;\npublic:\n  typedef output_iterator_tag iterator_category;\n  typedef void                value_type;\n  typedef void                difference_type;\n  typedef void                pointer;\n  typedef void                reference;\n\n  explicit raw_storage_iterator(ForwardIterator x) : iter(x) {}\n  raw_storage_iterator<ForwardIterator, T>& operator*() { return *this; }\n  raw_storage_iterator<ForwardIterator, T>& operator=(const T& element) {\n    construct(&*iter, element);\n    return *this;\n  }        \n  raw_storage_iterator<ForwardIterator, T>& operator++() {\n    ++iter;\n    return *this;\n  }\n  raw_storage_iterator<ForwardIterator, T> operator++(int) {\n    raw_storage_iterator<ForwardIterator, T> tmp = *this;\n    ++iter;\n    return tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class ForwardIterator, class T>\ninline output_iterator_tag\niterator_category(const raw_storage_iterator<ForwardIterator, T>&)\n{\n  return output_iterator_tag();\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n#endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */\n\n__STL_END_NAMESPACE\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_relops.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_RELOPS\n#define __SGI_STL_INTERNAL_RELOPS\n\n__STL_BEGIN_RELOPS_NAMESPACE\n\ntemplate <class T>\ninline bool operator!=(const T& x, const T& y) {\n  return !(x == y);\n}\n\ntemplate <class T>\ninline bool operator>(const T& x, const T& y) {\n  return y < x;\n}\n\ntemplate <class T>\ninline bool operator<=(const T& x, const T& y) {\n  return !(y < x);\n}\n\ntemplate <class T>\ninline bool operator>=(const T& x, const T& y) {\n  return !(x < y);\n}\n\n__STL_END_RELOPS_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_RELOPS */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_rope.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_ROPE_H\n# define __SGI_STL_INTERNAL_ROPE_H\n\n# ifdef __GC\n#   define __GC_CONST const\n# else\n#   define __GC_CONST   // constant except for deallocation\n# endif\n# ifdef __STL_SGI_THREADS\n#    include <mutex.h>\n# endif\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n// The end-of-C-string character.\n// This is what the draft standard says it should be.\ntemplate <class charT>\ninline charT __eos(charT*) { return charT(); }\n\n// Test for basic character types.\n// For basic character types leaves having a trailing eos.\ntemplate <class charT>\ninline bool __is_basic_char_type(charT *) { return false; }\ntemplate <class charT>\ninline bool __is_one_byte_char_type(charT *) { return false; }\n\ninline bool __is_basic_char_type(char *) { return true; }\ninline bool __is_one_byte_char_type(char *) { return true; }\ninline bool __is_basic_char_type(wchar_t *) { return true; }\n\n// Store an eos iff charT is a basic character type.\n// Do not reference __eos if it isn't.\ntemplate <class charT>\ninline void __cond_store_eos(charT&) {}\n\ninline void __cond_store_eos(char& c) { c = 0; }\ninline void __cond_store_eos(wchar_t& c) { c = 0; }\n\t\n\n// rope<charT,Alloc> is a sequence of charT.\n// Ropes appear to be mutable, but update operations\n// really copy enough of the data structure to leave the original\n// valid.  Thus ropes can be logically copied by just copying\n// a pointer value.\n// The __eos function is used for those functions that\n// convert to/from C-like strings to detect the end of the string.\n// __compare is used as the character comparison function.\ntemplate <class charT>\nclass char_producer {\n    public:\n\tvirtual ~char_producer() {};\n\tvirtual void operator()(size_t start_pos, size_t len, charT* buffer)\n\t\t= 0;\n\t// Buffer should really be an arbitrary output iterator.\n\t// That way we could flatten directly into an ostream, etc.\n\t// This is thoroughly impossible, since iterator types don't\n\t// have runtime descriptions.\n};\n\n// Sequence buffers:\n//\n// Sequence must provide an append operation that appends an\n// array to the sequence.  Sequence buffers are useful only if\n// appending an entire array is cheaper than appending element by element.\n// This is true for many string representations.\n// This should  perhaps inherit from ostream<sequence::value_type>\n// and be implemented correspondingly, so that they can be used\n// for formatted.  For the sake of portability, we don't do this yet.\n//\n// For now, sequence buffers behave as output iterators.  But they also\n// behave a little like basic_ostringstream<sequence::value_type> and a\n// little like containers.\n\ntemplate<class sequence, size_t buf_sz = 100\n#   if defined(__sgi) && !defined(__GNUC__)\n#\t define __TYPEDEF_WORKAROUND\n         ,class v = typename sequence::value_type\n#   endif\n        >\n// The 3rd parameter works around a common compiler bug.\nclass sequence_buffer : public output_iterator {\n    public:\n#       ifndef __TYPEDEF_WORKAROUND\n\t    typedef typename sequence::value_type value_type;\n#\telse\n\t    typedef v value_type;\n#\tendif\n    protected:\n\tsequence *prefix;\n\tvalue_type buffer[buf_sz];\n\tsize_t buf_count;\n    public:\n\tvoid flush() {\n\t    prefix->append(buffer, buffer + buf_count);\n\t    buf_count = 0;\n\t}\n\t~sequence_buffer() { flush(); }\n\tsequence_buffer() : prefix(0), buf_count(0) {}\n\tsequence_buffer(const sequence_buffer & x) {\n\t    prefix = x.prefix;\n            buf_count = x.buf_count;\n            copy(x.buffer, x.buffer + x.buf_count, buffer);\n\t}\n\tsequence_buffer(sequence_buffer & x) {\n\t    x.flush();\n\t    prefix = x.prefix;\n\t    buf_count = 0;\n\t}\n\tsequence_buffer(sequence& s) : prefix(&s), buf_count(0) {}\n\tsequence_buffer& operator= (sequence_buffer& x) {\n\t    x.flush();\n\t    prefix = x.prefix;\n\t    buf_count = 0;\n\t    return *this;\n\t}\n\tsequence_buffer& operator= (const sequence_buffer& x) {\n\t    prefix = x.prefix;\n\t    buf_count = x.buf_count;\n\t    copy(x.buffer, x.buffer + x.buf_count, buffer);\n\t    return *this;\n\t}\n\tvoid push_back(value_type x)\n\t{\n\t    if (buf_count < buf_sz) {\n\t\tbuffer[buf_count] = x;\n\t\t++buf_count;\n\t    } else {\n\t\tflush();\n\t\tbuffer[0] = x;\n\t\tbuf_count = 1;\n\t    }\n\t}\n\tvoid append(value_type *s, size_t len)\n\t{\n\t    if (len + buf_count <= buf_sz) {\n\t\tsize_t i, j;\n\t\tfor (i = buf_count, j = 0; j < len; i++, j++) {\n\t\t    buffer[i] = s[j];\n\t\t}\n\t\tbuf_count += len;\n\t    } else if (0 == buf_count) {\n\t\tprefix->append(s, s + len);\n\t    } else {\n\t\tflush();\n\t\tappend(s, len);\n\t    }\n\t}\n\tsequence_buffer& write(value_type *s, size_t len)\n\t{\n\t    append(s, len);\n\t    return *this;\n\t}\n\tsequence_buffer& put(value_type x)\n\t{\n\t    push_back(x);\n\t    return *this;\n\t}\n\tsequence_buffer& operator=(const value_type& rhs)\n\t{\n\t    push_back(rhs);\n\t    return *this;\n\t}\n\tsequence_buffer& operator*() { return *this; }\n\tsequence_buffer& operator++() { return *this; }\n\tsequence_buffer& operator++(int) { return *this; }\n};\n\n// The following should be treated as private, at least for now.\ntemplate<class charT>\nclass __rope_char_consumer {\n    public:\n\t// If we had member templates, these should not be virtual.\n\t// For now we need to use run-time parametrization where\n\t// compile-time would do.  Hence this should all be private\n\t// for now.\n\t// The symmetry with char_producer is accidental and temporary.\n\tvirtual ~__rope_char_consumer() {};\n\tvirtual bool operator()(const charT* buffer, size_t len) = 0;\n};\n\n//\n// What follows should really be local to rope.  Unfortunately,\n// that doesn't work, since it makes it impossible to define generic\n// equality on rope iterators.  According to the draft standard, the\n// template parameters for such an equality operator cannot be inferred\n// from the occurence of a member class as a parameter.\n// (SGI compilers in fact allow this, but the result wouldn't be\n// portable.)\n// Similarly, some of the static member functions are member functions\n// only to avoid polluting the global namespace, and to circumvent\n// restrictions on type inference for template functions.\n//\n\ntemplate<class CharT, class Alloc=__ALLOC> class rope;\ntemplate<class CharT, class Alloc> struct __rope_RopeConcatenation;\ntemplate<class CharT, class Alloc> struct __rope_RopeLeaf;\ntemplate<class CharT, class Alloc> struct __rope_RopeFunction;\ntemplate<class CharT, class Alloc> struct __rope_RopeSubstring;\ntemplate<class CharT, class Alloc> class __rope_iterator;\ntemplate<class CharT, class Alloc> class __rope_const_iterator;\ntemplate<class CharT, class Alloc> class __rope_charT_ref_proxy;\ntemplate<class CharT, class Alloc> class __rope_charT_ptr_proxy;\n\n//\n// The internal data structure for representing a rope.  This is\n// private to the implementation.  A rope is really just a pointer\n// to one of these.\n//\n// A few basic functions for manipulating this data structure\n// are members of RopeBase.  Most of the more complex algorithms\n// are implemented as rope members.\n//\n// Some of the static member functions of RopeBase have identically\n// named functions in rope that simply invoke the RopeBase versions.\n//\n\ntemplate<class charT, class Alloc>\nstruct __rope_RopeBase {\n    typedef rope<charT,Alloc> my_rope;\n    typedef simple_alloc<charT, Alloc> DataAlloc;\n    typedef simple_alloc<__rope_RopeConcatenation<charT,Alloc>, Alloc> CAlloc;\n    typedef simple_alloc<__rope_RopeLeaf<charT,Alloc>, Alloc> LAlloc;\n    typedef simple_alloc<__rope_RopeFunction<charT,Alloc>, Alloc> FAlloc;\n    typedef simple_alloc<__rope_RopeSubstring<charT,Alloc>, Alloc> SAlloc;\n    public:\n    enum { max_rope_depth = 45 };\n    enum {leaf, concat, substringfn, function} tag:8;\n    bool is_balanced:8;\n    unsigned char depth;\n    size_t size;\n    __GC_CONST charT * c_string;\n\t\t\t/* Flattened version of string, if needed.  */\n\t\t\t/* typically 0.                             */\n\t\t\t/* If it's not 0, then the memory is owned  */\n\t\t\t/* by this node.                            */\n\t\t\t/* In the case of a leaf, this may point to */\n\t\t\t/* the same memory as the data field.\t    */\n#   ifndef __GC\n#       if defined(__STL_WIN32THREADS)\n\t    long refcount;  \t// InterlockedIncrement wants a long *\n#\telse\n\t    size_t refcount;\n#\tendif\n\t// We count references from rope instances\n\t// and references from other rope nodes.  We\n\t// do not count const_iterator references.\n\t// Iterator references are counted so that rope modifications\n\t// can be detected after the fact.\n\t// Generally function results are counted, i.e.\n\t// a pointer returned by a function is included at the\n\t// point at which the pointer is returned.\n\t// The recipient should decrement the count if the\n\t// result is not needed.\n\t// Generally function arguments are not reflected\n\t// in the reference count.  The callee should increment\n\t// the count before saving the argument someplace that\n\t// will outlive the call.\n#   endif\n#   ifndef __GC\n#       ifdef __STL_SGI_THREADS\n\t    // Reference counting with multiple threads and no\n\t    // hardware or thread package support is pretty awful.\n\t    // Mutexes are normally too expensive.\n\t    // We'll assume a COMPARE_AND_SWAP(destp, old, new)\n\t    // operation, which might be cheaper.\n#           if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))\n#               define __add_and_fetch(l,v) add_then_test((unsigned long *)l,v)\n#           endif\n\t    void init_refcount_lock() {}\n\t    void incr_refcount ()\n\t    {\n\t\t__add_and_fetch(&refcount, 1);\n\t    }\n\t    size_t decr_refcount ()\n\t    {\n\t\treturn __add_and_fetch(&refcount, (size_t)(-1));\n\t    }\n#       elif defined(__STL_WIN32THREADS)\n\t    void init_refcount_lock() {}\n            void incr_refcount ()\n            {\n                InterlockedIncrement(&refcount);\n            }\n            size_t decr_refcount ()\n            {\n                return InterlockedDecrement(&refcount);\n            }\n#\telif defined(__STL_PTHREADS)\n\t    // This should be portable, but performance is expected\n\t    // to be quite awful.  This really needs platform specific\n\t    // code.\n\t    pthread_mutex_t refcount_lock;\n\t    void init_refcount_lock() {\n\t\tpthread_mutex_init(&refcount_lock, 0);\n\t    }\n\t    void incr_refcount ()\n            {   \n\t\tpthread_mutex_lock(&refcount_lock);\n                ++refcount;\n\t\tpthread_mutex_unlock(&refcount_lock);\n            }\n            size_t decr_refcount ()\n            {   \n\t\tsize_t result;\n\t\tpthread_mutex_lock(&refcount_lock);\n                result = --refcount;\n\t\tpthread_mutex_unlock(&refcount_lock);\n                return result;\n            }\n#\telse\n\t    void init_refcount_lock() {}\n\t    void incr_refcount ()\n\t    {\n\t\t++refcount;\n\t    }\n\t    size_t decr_refcount ()\n\t    {\n\t\t--refcount;\n\t\treturn refcount;\n\t    }\n#       endif\n#   else\n\tvoid incr_refcount () {}\n#   endif\n\tstatic void free_string(charT *, size_t len);\n\t\t\t// Deallocate data section of a leaf.\n\t\t\t// This shouldn't be a member function.\n\t\t\t// But its hard to do anything else at the\n\t\t\t// moment, because it's templatized w.r.t.\n\t\t\t// an allocator.\n\t\t\t// Does nothing if __GC is defined.\n#   ifndef __GC\n\t  void free_c_string();\n\t  void free_tree();\n\t\t\t// Deallocate t. Assumes t is not 0.\n\t  void unref_nonnil()\n\t  {\n\t      if (0 == decr_refcount()) free_tree();\n\t  }\n\t  void ref_nonnil()\n\t  {\n\t      incr_refcount();\n\t  }\n\t  static void unref(__rope_RopeBase* t)\n\t  {\n\t      if (0 != t) {\n\t\t  t -> unref_nonnil();\n\t      }\n\t  }\n\t  static void ref(__rope_RopeBase* t)\n\t  {\n\t      if (0 != t) t -> incr_refcount();\n\t  }\n\t  static void free_if_unref(__rope_RopeBase* t)\n \t  {\n\t      if (0 != t && 0 == t -> refcount) t -> free_tree();\n\t  }\n#   else /* __GC */\n\t  void unref_nonnil() {}\n\t  void ref_nonnil() {}\n\t  static void unref(__rope_RopeBase* t) {}\n\t  static void ref(__rope_RopeBase* t) {}\n\t  static void fn_finalization_proc(void * tree, void *);\n\t  static void free_if_unref(__rope_RopeBase* t) {}\n#   endif\n\n    // The data fields of leaves are allocated with some\n    // extra space, to accomodate future growth and for basic\n    // character types, to hold a trailing eos character.\n    enum { alloc_granularity = 8 };\n    static size_t rounded_up_size(size_t n) {\n        size_t size_with_eos;\n\t     \n        if (__is_basic_char_type((charT *)0)) {\n    \t    size_with_eos = n + 1;\n    \t} else {\n  \t    size_with_eos = n;\n\t}\n#       ifdef __GC\n   \t   return size_with_eos;\n#\telse\n\t   // Allow slop for in-place expansion.\n\t   return (size_with_eos + alloc_granularity-1)\n\t\t\t&~ (alloc_granularity-1);\n#\tendif\n    }\n};\n\ntemplate<class charT, class Alloc>\nstruct __rope_RopeLeaf : public __rope_RopeBase<charT,Alloc> {\n  public:  // Apparently needed by VC++\n    __GC_CONST charT* data;     /* Not necessarily 0 terminated. */\n\t\t\t\t/* The allocated size is\t */\n\t\t\t\t/* rounded_up_size(size), except */\n\t\t\t\t/* in the GC case, in which it\t */\n\t\t\t\t/* doesn't matter.\t\t */\n};\n\ntemplate<class charT, class Alloc>\nstruct __rope_RopeConcatenation : public __rope_RopeBase<charT,Alloc> {\n  public:\n    __rope_RopeBase<charT,Alloc>* left;\n    __rope_RopeBase<charT,Alloc>* right;\n};\n\ntemplate<class charT, class Alloc>\nstruct __rope_RopeFunction : public __rope_RopeBase<charT,Alloc> {\n  public:\n    char_producer<charT>* fn;\n#   ifndef __GC\n      bool delete_when_done;\t// Char_producer is owned by the\n\t\t\t\t// rope and should be explicitly\n\t\t\t\t// deleted when the rope becomes\n\t\t\t\t// inaccessible.\n#   else\n      // In the GC case, we either register the rope for\n      // finalization, or not.  Thus the field is unnecessary;\n      // the information is stored in the collector data structures.\n#   endif\n};\n// Substring results are usually represented using just\n// concatenation nodes.  But in the case of very long flat ropes\n// or ropes with a functional representation that isn't practical.\n// In that case, we represent the result as a special case of\n// RopeFunction, whose char_producer points back to the rope itself.\n// In all cases except repeated substring operations and\n// deallocation, we treat the result as a RopeFunction.\ntemplate<class charT, class Alloc>\nstruct __rope_RopeSubstring: public __rope_RopeFunction<charT,Alloc>,\n\t\t\t     public char_producer<charT> {\n  public:\n    __rope_RopeBase<charT,Alloc> * base;\t// not 0\n    size_t start;\n    virtual ~__rope_RopeSubstring() {}\n    virtual void operator()(size_t start_pos, size_t req_len,\n\t\t\t    charT *buffer) {\n\tswitch(base -> tag) {\n\t    case function:\n\t    case substringfn:\n\t      {\n\t\tchar_producer<charT> *fn =\n\t\t\t((__rope_RopeFunction<charT,Alloc> *)base) -> fn;\n\t\t__stl_assert(start_pos + req_len <= size);\n\t\t__stl_assert(start + size <= base -> size);\n\t\t(*fn)(start_pos + start, req_len, buffer);\n\t      }\n\t      break;\n\t    case leaf:\n\t      {\n\t\t__GC_CONST charT * s =\n\t\t\t((__rope_RopeLeaf<charT,Alloc> *)base) -> data;\n\t\tuninitialized_copy_n(s + start_pos + start, req_len,\n\t\t\t\t     buffer);\n\t      }\n\t      break;\n\t    default:\n\t      __stl_assert(false);\n\t}\n    }\n    __rope_RopeSubstring(__rope_RopeBase<charT,Alloc> * b, size_t s, size_t l) :\n\tbase(b), start(s) {\n#       ifndef __GC\n\t    refcount = 1;\n\t    init_refcount_lock();\n\t    base -> ref_nonnil();\n#       endif\n\tsize = l;\n\ttag = substringfn;\n\tdepth = 0;\n\tc_string = 0;\n\tfn = this;\n    }\n};\n\n\n// Self-destructing pointers to RopeBase.\n// These are not conventional smart pointers.  Their\n// only purpose in life is to ensure that unref is called\n// on the pointer either at normal exit or if an exception\n// is raised.  It is the caller's responsibility to\n// adjust reference counts when these pointers are initialized\n// or assigned to.  (This convention significantly reduces\n// the number of potentially expensive reference count\n// updates.)\n#ifndef __GC\n  template<class charT, class Alloc>\n  struct __rope_self_destruct_ptr {\n    __rope_RopeBase<charT,Alloc> * ptr;\n    ~__rope_self_destruct_ptr() { __rope_RopeBase<charT,Alloc>::unref(ptr); }\n#   ifdef __STL_USE_EXCEPTIONS\n\t__rope_self_destruct_ptr() : ptr(0) {};\n#   else\n\t__rope_self_destruct_ptr() {};\n#   endif\n    __rope_self_destruct_ptr(__rope_RopeBase<charT,Alloc> * p) : ptr(p) {}\n    __rope_RopeBase<charT,Alloc> & operator*() { return *ptr; }\n    __rope_RopeBase<charT,Alloc> * operator->() { return ptr; }\n    operator __rope_RopeBase<charT,Alloc> *() { return ptr; }\n    __rope_self_destruct_ptr & operator= (__rope_RopeBase<charT,Alloc> * x)\n\t{ ptr = x; return *this; }\n  };\n#endif\n\n// Dereferencing a nonconst iterator has to return something\n// that behaves almost like a reference.  It's not possible to\n// return an actual reference since assignment requires extra\n// work.  And we would get into the same problems as with the\n// CD2 version of basic_string.\ntemplate<class charT, class Alloc>\nclass __rope_charT_ref_proxy {\n    friend class rope<charT,Alloc>;\n    friend class __rope_iterator<charT,Alloc>;\n    friend class __rope_charT_ptr_proxy<charT,Alloc>;\n#   ifdef __GC\n\ttypedef __rope_RopeBase<charT,Alloc> * self_destruct_ptr;\n#   else\n    \ttypedef __rope_self_destruct_ptr<charT,Alloc> self_destruct_ptr;\n#   endif\n    typedef __rope_RopeBase<charT,Alloc> RopeBase;\n    typedef rope<charT,Alloc> my_rope;\n    size_t pos;\n    charT current;\n    bool current_valid;\n    my_rope * root;     // The whole rope.\n  public:\n    __rope_charT_ref_proxy(my_rope * r, size_t p) :\n\tpos(p), root(r), current_valid(false) {}\n    __rope_charT_ref_proxy(my_rope * r, size_t p,\n\t\t    charT c) :\n\tpos(p), root(r), current(c), current_valid(true) {}\n    operator charT () const;\n    __rope_charT_ref_proxy& operator= (charT c);\n    __rope_charT_ptr_proxy<charT,Alloc> operator& () const;\n    __rope_charT_ref_proxy& operator= (const __rope_charT_ref_proxy& c) {\n\treturn operator=((charT)c); \n    }\n};\n\ntemplate<class charT, class Alloc>\nclass __rope_charT_ptr_proxy {\n    friend class __rope_charT_ref_proxy<charT,Alloc>;\n    size_t pos;\n    charT current;\n    bool current_valid;\n    rope<charT,Alloc> * root;     // The whole rope.\n  public:\n    __rope_charT_ptr_proxy(const __rope_charT_ref_proxy<charT,Alloc> & x) :\n\tpos(x.pos), root(x.root), current_valid(x.current_valid),\n\tcurrent(x.current) {}\n    __rope_charT_ptr_proxy(const __rope_charT_ptr_proxy & x) :\n\tpos(x.pos), root(x.root), current_valid(x.current_valid),\n\tcurrent(x.current) {}\n    __rope_charT_ptr_proxy() {}\n    __rope_charT_ptr_proxy(charT * x) : root(0), pos(0) {\n\t__stl_assert(0 == x);\n    }\n    __rope_charT_ptr_proxy& operator= (const __rope_charT_ptr_proxy& x) {\n\tpos = x.pos;\n\tcurrent = x.current;\n\tcurrent_valid = x.current_valid;\n\troot = x.root;\n\treturn *this;\n    }\n    friend bool operator== __STL_NULL_TMPL_ARGS\n                (const __rope_charT_ptr_proxy<charT,Alloc> & x,\n                 const __rope_charT_ptr_proxy<charT,Alloc> & y);\n    __rope_charT_ref_proxy<charT,Alloc> operator *() const {\n\tif (current_valid) {\n\t    return __rope_charT_ref_proxy<charT,Alloc>(root, pos, current);\n\t} else {\n\t    return __rope_charT_ref_proxy<charT,Alloc>(root, pos);\n\t}\n    }\n};\n\n// Rope iterators:\n// Unlike in the C version, we cache only part of the stack\n// for rope iterators, since they must be efficiently copyable.\n// When we run out of cache, we have to reconstruct the iterator\n// value.\n// Pointers from iterators are not included in reference counts.\n// Iterators are assumed to be thread private.  Ropes can\n// be shared.\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1375\n#endif\n\ntemplate<class charT, class Alloc>\nclass __rope_iterator_base:\n  public random_access_iterator<charT, ptrdiff_t> {\n  friend class rope<charT, Alloc>;\n  public:\n    typedef __rope_RopeBase<charT,Alloc> RopeBase;\n\t// Borland doesnt want this to be protected.\n  protected:\n    enum { path_cache_len = 4 }; // Must be <= 9.\n    enum { iterator_buf_len = 15 };\n    size_t current_pos;\n    RopeBase * root;     // The whole rope.\n    size_t leaf_pos;    // Starting position for current leaf\n    __GC_CONST charT * buf_start;\n\t\t\t// Buffer possibly\n\t\t\t// containing current char.\n    __GC_CONST charT * buf_ptr;\n\t\t\t// Pointer to current char in buffer.\n\t\t\t// != 0 ==> buffer valid.\n    __GC_CONST charT * buf_end;\n\t\t\t// One past last valid char in buffer.\n    // What follows is the path cache.  We go out of our\n    // way to make this compact.\n    // Path_end contains the bottom section of the path from\n    // the root to the current leaf.\n    const RopeBase * path_end[path_cache_len];\n    int leaf_index;     // Last valid pos in path_end;\n    \t\t\t// path_end[0] ... path_end[leaf_index-1]\n\t\t\t// point to concatenation nodes.\n    unsigned char path_directions;\n\t\t\t  // (path_directions >> i) & 1 is 1\n\t\t\t  // iff we got from path_end[leaf_index - i - 1]\n\t\t\t  // to path_end[leaf_index - i] by going to the\n\t\t\t  // right. Assumes path_cache_len <= 9.\n    charT tmp_buf[iterator_buf_len];\n\t\t\t// Short buffer for surrounding chars.\n\t\t\t// This is useful primarily for \n\t\t\t// RopeFunctions.  We put the buffer\n\t\t\t// here to avoid locking in the\n\t\t\t// multithreaded case.\n    // The cached path is generally assumed to be valid\n    // only if the buffer is valid.\n    static void setbuf(__rope_iterator_base &x);\n\t\t\t\t\t// Set buffer contents given\n\t\t\t\t\t// path cache.\n    static void setcache(__rope_iterator_base &x);\n\t\t\t\t\t// Set buffer contents and\n\t\t\t\t\t// path cache.\n    static void setcache_for_incr(__rope_iterator_base &x);\n\t\t\t\t\t// As above, but assumes path\n\t\t\t\t\t// cache is valid for previous posn.\n    __rope_iterator_base() {}\n    __rope_iterator_base(RopeBase * root, size_t pos):\n\t\t   root(root), current_pos(pos), buf_ptr(0) {}\n    __rope_iterator_base(const __rope_iterator_base& x) {\n\tif (0 != x.buf_ptr) {\n\t    *this = x;\n\t} else {\n\t    current_pos = x.current_pos;\n\t    root = x.root;\n\t    buf_ptr = 0;\n\t}\n    }\n    void incr(size_t n);\n    void decr(size_t n);\n  public:\n    size_t index() const { return current_pos; }\n};\n\ntemplate<class charT, class Alloc> class __rope_iterator;\n\ntemplate<class charT, class Alloc>\nclass __rope_const_iterator : public __rope_iterator_base<charT,Alloc> {\n    friend class rope<charT,Alloc>;\n  protected:\n    __rope_const_iterator(const RopeBase * root, size_t pos):\n\t\t   __rope_iterator_base<charT,Alloc>(\n\t\t     const_cast<RopeBase *>(root), pos)\n\t\t   // Only nonconst iterators modify root ref count\n    {}\n  public:\n    typedef charT reference;    // Really a value.  Returning a reference\n\t\t\t\t// Would be a mess, since it would have\n\t\t\t\t// to be included in refcount.\n    typedef const charT* pointer;\n\n  public:\n    __rope_const_iterator() {};\n    __rope_const_iterator(const __rope_const_iterator & x) :\n\t\t\t\t__rope_iterator_base<charT,Alloc>(x) { }\n    __rope_const_iterator(const __rope_iterator<charT,Alloc> & x);\n    __rope_const_iterator(const rope<charT,Alloc> &r, size_t pos) :\n\t__rope_iterator_base<charT,Alloc>(r.tree_ptr, pos) {}\n    __rope_const_iterator& operator= (const __rope_const_iterator & x) {\n\tif (0 != x.buf_ptr) {\n\t    *this = x;\n\t} else {\n\t    current_pos = x.current_pos;\n\t    root = x.root;\n\t    buf_ptr = 0;\n\t}\n\treturn(*this);\n    }\n    reference operator*() {\n\tif (0 == buf_ptr) setcache(*this);\n\treturn *buf_ptr;\n    }\n    __rope_const_iterator& operator++() {\n\t__GC_CONST charT * next;\n\tif (0 != buf_ptr && (next = buf_ptr + 1) < buf_end) {\n\t    buf_ptr = next;\n\t    ++current_pos;\n\t} else {\n\t    incr(1);\n\t}\n\treturn *this;\n    }\n    __rope_const_iterator& operator+=(ptrdiff_t n) {\n\tif (n >= 0) {\n\t    incr(n);\n\t} else {\n\t    decr(-n);\n\t}\n\treturn *this;\n    }\n    __rope_const_iterator& operator--() {\n\tdecr(1);\n\treturn *this;\n    }\n    __rope_const_iterator& operator-=(ptrdiff_t n) {\n\tif (n >= 0) {\n\t    decr(n);\n\t} else {\n\t    incr(-n);\n\t}\n\treturn *this;\n    }\n    __rope_const_iterator operator++(int) {\n\tsize_t old_pos = current_pos;\n\tincr(1);\n\treturn __rope_const_iterator<charT,Alloc>(root, old_pos);\n\t// This makes a subsequent dereference expensive.\n\t// Perhaps we should instead copy the iterator\n\t// if it has a valid cache?\n    }\n    __rope_const_iterator operator--(int) {\n\tsize_t old_pos = current_pos;\n\tdecr(1);\n\treturn __rope_const_iterator<charT,Alloc>(root, old_pos);\n    }\n    friend __rope_const_iterator<charT,Alloc> operator- __STL_NULL_TMPL_ARGS\n\t(const __rope_const_iterator<charT,Alloc> & x,\n\t ptrdiff_t n);\n    friend __rope_const_iterator<charT,Alloc> operator+ __STL_NULL_TMPL_ARGS\n\t(const __rope_const_iterator<charT,Alloc> & x,\n\t ptrdiff_t n);\n    friend __rope_const_iterator<charT,Alloc> operator+ __STL_NULL_TMPL_ARGS\n\t(ptrdiff_t n,\n\t const __rope_const_iterator<charT,Alloc> & x);\n    reference operator[](size_t n) {\n\treturn rope<charT,Alloc>::fetch(root, current_pos + n);\n    }\n    friend bool operator== __STL_NULL_TMPL_ARGS\n\t(const __rope_const_iterator<charT,Alloc> & x,\n\t const __rope_const_iterator<charT,Alloc> & y);\n    friend bool operator< __STL_NULL_TMPL_ARGS\n\t(const __rope_const_iterator<charT,Alloc> & x,\n\t const __rope_const_iterator<charT,Alloc> & y);\n    friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS\n\t(const __rope_const_iterator<charT,Alloc> & x,\n\t const __rope_const_iterator<charT,Alloc> & y);\n};\n\ntemplate<class charT, class Alloc>\nclass __rope_iterator : public __rope_iterator_base<charT,Alloc> {\n    friend class rope<charT,Alloc>;\n  protected:\n    rope<charT,Alloc> * root_rope;\n\t// root is treated as a cached version of this,\n\t// and is used to detect changes to the underlying\n\t// rope.\n\t// Root is included in the reference count.\n\t// This is necessary so that we can detect changes reliably.\n\t// Unfortunately, it requires careful bookkeeping for the\n\t// nonGC case.\n    __rope_iterator(rope<charT,Alloc> * r, size_t pos):\n\t     __rope_iterator_base<charT,Alloc>(r -> tree_ptr, pos),\n\t     root_rope(r) {\n\t\tRopeBase::ref(root);\n\t     }\n    void check();\n  public:\n    typedef __rope_charT_ref_proxy<charT,Alloc>  reference;\n    typedef __rope_charT_ref_proxy<charT,Alloc>* pointer;\n\n  public:\n    rope<charT,Alloc>& container() { return *root_rope; }\n    __rope_iterator() {\n\troot = 0;  // Needed for reference counting.\n    };\n    __rope_iterator(const __rope_iterator & x) :\n\t__rope_iterator_base<charT,Alloc>(x) {\n\troot_rope = x.root_rope;\n\tRopeBase::ref(root);\n    }\n    __rope_iterator(rope<charT,Alloc>& r, size_t pos);\n    ~__rope_iterator() {\n\tRopeBase::unref(root);\n    }\n    __rope_iterator& operator= (const __rope_iterator & x) {\n\tRopeBase *old = root;\n\n\tRopeBase::ref(x.root);\n\tif (0 != x.buf_ptr) {\n\t    *this = x;\n\t} else {\n\t    current_pos = x.current_pos;\n\t    root = x.root;\n\t    root_rope = x.root_rope;\n\t    buf_ptr = 0;\n\t}\n\tRopeBase::unref(old);\n\treturn(*this);\n    }\n    reference operator*() {\n\tcheck();\n\tif (0 == buf_ptr) {\n\t    return __rope_charT_ref_proxy<charT,Alloc>(root_rope, current_pos);\n\t} else {\n\t    return __rope_charT_ref_proxy<charT,Alloc>(root_rope,\n\t\t\t\t\t\t       current_pos, *buf_ptr);\n\t}\n    }\n    __rope_iterator& operator++() {\n\tincr(1);\n\treturn *this;\n    }\n    __rope_iterator& operator+=(difference_type n) {\n\tif (n >= 0) {\n\t    incr(n);\n\t} else {\n\t    decr(-n);\n\t}\n\treturn *this;\n    }\n    __rope_iterator& operator--() {\n\tdecr(1);\n\treturn *this;\n    }\n    __rope_iterator& operator-=(difference_type n) {\n\tif (n >= 0) {\n\t    decr(n);\n\t} else {\n\t    incr(-n);\n\t}\n\treturn *this;\n    }\n    __rope_iterator operator++(int) {\n\tsize_t old_pos = current_pos;\n\tincr(1);\n\treturn __rope_iterator<charT,Alloc>(root_rope, old_pos);\n    }\n    __rope_iterator operator--(int) {\n\tsize_t old_pos = current_pos;\n\tdecr(1);\n\treturn __rope_iterator<charT,Alloc>(root_rope, old_pos);\n    }\n    reference operator[](ptrdiff_t n) {\n\treturn __rope_charT_ref_proxy<charT,Alloc>(root_rope, current_pos + n);\n    }\n    friend bool operator== __STL_NULL_TMPL_ARGS\n\t(const __rope_iterator<charT,Alloc> & x,\n\t const __rope_iterator<charT,Alloc> & y);\n    friend bool operator< __STL_NULL_TMPL_ARGS\n\t(const __rope_iterator<charT,Alloc> & x,\n\t const __rope_iterator<charT,Alloc> & y);\n    friend ptrdiff_t operator- __STL_NULL_TMPL_ARGS\n\t(const __rope_iterator<charT,Alloc> & x,\n\t const __rope_iterator<charT,Alloc> & y);\n    friend __rope_iterator<charT,Alloc> operator- __STL_NULL_TMPL_ARGS\n\t(const __rope_iterator<charT,Alloc> & x,\n\t ptrdiff_t n);\n    friend __rope_iterator<charT,Alloc> operator+ __STL_NULL_TMPL_ARGS\n\t(const __rope_iterator<charT,Alloc> & x,\n\t ptrdiff_t n);\n    friend __rope_iterator<charT,Alloc> operator+ __STL_NULL_TMPL_ARGS\n\t(ptrdiff_t n,\n\t const __rope_iterator<charT,Alloc> & x);\n\n};\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1375\n#endif\n\ntemplate <class charT, class Alloc>\nclass rope {\n    public:\n\ttypedef charT value_type;\n\ttypedef ptrdiff_t difference_type;\n\ttypedef size_t size_type;\n\ttypedef charT const_reference;\n\ttypedef const charT* const_pointer;\n\ttypedef __rope_iterator<charT,Alloc> iterator;\n\ttypedef __rope_const_iterator<charT,Alloc> const_iterator;\n\ttypedef __rope_charT_ref_proxy<charT,Alloc> reference;\n\ttypedef __rope_charT_ptr_proxy<charT,Alloc> pointer;\n\n\tfriend class __rope_iterator<charT,Alloc>;\n\tfriend class __rope_const_iterator<charT,Alloc>;\n\tfriend struct __rope_RopeBase<charT,Alloc>;\n\tfriend class __rope_iterator_base<charT,Alloc>;\n\tfriend class __rope_charT_ptr_proxy<charT,Alloc>;\n\tfriend class __rope_charT_ref_proxy<charT,Alloc>;\n\tfriend struct __rope_RopeSubstring<charT,Alloc>;\n\n    protected:\n\ttypedef __GC_CONST charT * cstrptr;\n#       ifdef __STL_SGI_THREADS\n\t    static cstrptr atomic_swap(cstrptr *p, cstrptr q) {\n#               if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))\n                    return (cstrptr) test_and_set((unsigned long *)p,\n\t\t\t   \t\t          (unsigned long)q);\n#\t\telse\n                    return (cstrptr) __test_and_set((unsigned long *)p,\n\t\t\t   \t\t            (unsigned long)q);\n#\t\tendif\n            }\n#       elif defined(__STL_WIN32THREADS)\n\t    static cstrptr atomic_swap(cstrptr *p, cstrptr q) {\n\t\treturn (cstrptr) InterlockedExchange((LPLONG)p, (LONG)q);\n\t    }\n#\telif defined(__STL_PTHREADS)\n\t    // This should be portable, but performance is expected\n\t    // to be quite awful.  This really needs platform specific\n\t    // code.\n\t    static pthread_mutex_t swap_lock;\n\t    static cstrptr atomic_swap(cstrptr *p, cstrptr q) {\n\t\tpthread_mutex_lock(&swap_lock);\n\t\tcstrptr result = *p;\n\t\t*p = q;\n\t\tpthread_mutex_unlock(&swap_lock);\n\t\treturn result;\n            }\n#\telse\n\t    static cstrptr atomic_swap(cstrptr *p, cstrptr q) {\n                cstrptr result = *p;\n                *p = q;\n\t\treturn result;\n\t    }\n#       endif\n\n\tstatic charT empty_c_str[1];\n\n    \ttypedef simple_alloc<charT, Alloc> DataAlloc;\n    \ttypedef simple_alloc<__rope_RopeConcatenation<charT,Alloc>, Alloc> CAlloc;\n    \ttypedef simple_alloc<__rope_RopeLeaf<charT,Alloc>, Alloc> LAlloc;\n    \ttypedef simple_alloc<__rope_RopeFunction<charT,Alloc>, Alloc> FAlloc;\n    \ttypedef simple_alloc<__rope_RopeSubstring<charT,Alloc>, Alloc> SAlloc;\n\tstatic bool is0(charT c) { return c == __eos((charT *)0); }\n\tenum { copy_max = 23 };\n\t\t// For strings shorter than copy_max, we copy to\n\t\t// concatenate.\n\n\ttypedef __rope_RopeBase<charT,Alloc> RopeBase;\n\ttypedef __rope_RopeConcatenation<charT,Alloc> RopeConcatenation;\n\ttypedef __rope_RopeLeaf<charT,Alloc> RopeLeaf;\n\ttypedef __rope_RopeFunction<charT,Alloc> RopeFunction;\n\ttypedef __rope_RopeSubstring<charT,Alloc> RopeSubstring;\n\n\t// The only data member of a rope:\n\tRopeBase *tree_ptr;\n\n\t// Retrieve a character at the indicated position.\n\tstatic charT fetch(RopeBase * r, size_type pos);\n\n#\tifndef __GC\n\t    // Obtain a pointer to the character at the indicated position.\n\t    // The pointer can be used to change the character.\n\t    // If such a pointer cannot be produced, as is frequently the\n\t    // case, 0 is returned instead.\n\t    // (Returns nonzero only if all nodes in the path have a refcount\n\t    // of 1.)\n\t    static charT * fetch_ptr(RopeBase * r, size_type pos);\n#\tendif\n\n\tstatic bool apply_to_pieces(\n\t\t\t\t// should be template parameter\n\t\t\t\t__rope_char_consumer<charT>& c,\n\t\t\t\tconst RopeBase * r,\n\t\t\t\tsize_t begin, size_t end);\n\t\t\t\t// begin and end are assumed to be in range.\n\n#\tifndef __GC\n\t  static void unref(RopeBase* t)\n\t  {\n\t      RopeBase::unref(t);\n\t  }\n\t  static void ref(RopeBase* t)\n\t  {\n\t      RopeBase::ref(t);\n\t  }\n#       else /* __GC */\n\t  static void unref(RopeBase* t) {}\n\t  static void ref(RopeBase* t) {}\n#       endif\n\n\n#       ifdef __GC\n\t    typedef __rope_RopeBase<charT,Alloc> * self_destruct_ptr;\n#   \telse\n\t    typedef __rope_self_destruct_ptr<charT,Alloc> self_destruct_ptr;\n#\tendif\n\n\t// Result is counted in refcount.\n\tstatic RopeBase * substring(RopeBase * base,\n\t\t\t\t    size_t start, size_t endp1);\n\n\tstatic RopeBase * concat_char_iter(RopeBase * r,\n\t\t\t\t\t  const charT *iter, size_t slen);\n\t\t// Concatenate rope and char ptr, copying s.\n\t\t// Should really take an arbitrary iterator.\n\t\t// Result is counted in refcount.\n\tstatic RopeBase * destr_concat_char_iter(RopeBase * r,\n\t\t\t\t\t\t const charT *iter, size_t slen)\n\t\t// As above, but one reference to r is about to be\n\t\t// destroyed.  Thus the pieces may be recycled if all\n\t\t// relevent reference counts are 1.\n#\t    ifdef __GC\n\t\t// We can't really do anything since refcounts are unavailable.\n\t\t{ return concat_char_iter(r, iter, slen); }\n#\t    else\n\t\t;\n#\t    endif\n\n\tstatic RopeBase * concat(RopeBase *left, RopeBase *right);\n\t\t// General concatenation on RopeBase.  Result\n\t\t// has refcount of 1.  Adjusts argument refcounts.\n\n   public:\n\tvoid apply_to_pieces( size_t begin, size_t end,\n\t\t\t      __rope_char_consumer<charT>& c) const {\n\t    apply_to_pieces(c, tree_ptr, begin, end);\n\t}\n\n\n   protected:\n\n\tstatic size_t rounded_up_size(size_t n) {\n\t    return RopeBase::rounded_up_size(n);\n\t}\n\n\tstatic size_t allocated_capacity(size_t n) {\n\t    if (__is_basic_char_type((charT *)0)) {\n\t\treturn rounded_up_size(n) - 1;\n\t    } else {\n\t\treturn rounded_up_size(n);\n\t    }\n\t}\n\t\t\n\t// s should really be an arbitrary input iterator.\n\t// Adds a trailing NULL for basic char types.\n\tstatic charT * alloc_copy(const charT *s, size_t size)\n\t{\n\t    charT * result = DataAlloc::allocate(rounded_up_size(size));\n\n\t    uninitialized_copy_n(s, size, result);\n\t    __cond_store_eos(result[size]);\n\t    return(result);\n\t}\n\n\t// Basic constructors for rope tree nodes.\n\t// These return tree nodes with a 0 reference count.\n\tstatic RopeLeaf * RopeLeaf_from_char_ptr(__GC_CONST charT *s,\n\t\t\t\t\t\t size_t size);\n\t\t// Takes ownership of its argument.\n\t\t// Result has refcount 1.\n\t\t// In the nonGC, basic_char_type  case it assumes that s\n\t\t// is eos-terminated.\n\t\t// In the nonGC case, it was allocated from Alloc with\n\t\t// rounded_up_size(size).\n\n\tstatic RopeLeaf * RopeLeaf_from_unowned_char_ptr(const charT *s,\n\t\t\t\t\t\t         size_t size) {\n\t    charT * buf = alloc_copy(s, size);\n            __STL_TRY {\n              return RopeLeaf_from_char_ptr(buf, size);\n            }\n            __STL_UNWIND(RopeBase::free_string(buf, size))\n\t}\n\t    \n\n\t// Concatenation of nonempty strings.\n\t// Always builds a concatenation node.\n\t// Rebalances if the result is too deep.\n\t// Result has refcount 1.\n\t// Does not increment left and right ref counts even though\n\t// they are referenced.\n\tstatic RopeBase * tree_concat(RopeBase * left, RopeBase * right);\n\n\t// Result has refcount 1.\n\t// If delete_fn is true, then fn is deleted when the rope\n\t// becomes inaccessible.\n\tstatic RopeFunction * RopeFunction_from_fn\n\t\t\t(char_producer<charT> *fn, size_t size,\n\t\t\t bool delete_fn);\n\n\t// Concatenation helper functions\n\tstatic RopeLeaf * leaf_concat_char_iter\n\t\t\t(RopeLeaf * r, const charT * iter, size_t slen);\n\t\t// Concatenate by copying leaf.\n\t\t// should take an arbitrary iterator\n\t\t// result has refcount 1.\n#\tifndef __GC\n\t  static RopeLeaf * destr_leaf_concat_char_iter\n\t\t\t(RopeLeaf * r, const charT * iter, size_t slen);\n\t  // A version that potentially clobbers r if r -> refcount == 1.\n#       endif\n\n\t// A helper function for exponentiating strings.\n\t// This uses a nonstandard refcount convention.\n\t// The result has refcount 0.\n\tstruct concat_fn;\n\tfriend struct rope<charT,Alloc>::concat_fn;\n\n\tstruct concat_fn\n\t\t: public binary_function<rope<charT,Alloc>, rope<charT,Alloc>,\n\t\t\t\t         rope<charT,Alloc> > {\n\t\trope operator() (const rope& x, const rope& y) {\n\t\t    return x + y;\n\t\t}\n\t};\n\n        friend rope identity_element(concat_fn) { return rope<charT,Alloc>(); }\n\n\tstatic size_t char_ptr_len(const charT * s);\n\t\t\t// slightly generalized strlen\n\n\trope(RopeBase *t) : tree_ptr(t) { }\n\n\n\t// Copy r to the CharT buffer.\n\t// Returns buffer + r -> size.\n\t// Assumes that buffer is uninitialized.\n\tstatic charT * flatten(RopeBase * r, charT * buffer);\n\n\t// Again, with explicit starting position and length.\n\t// Assumes that buffer is uninitialized.\n\tstatic charT * flatten(RopeBase * r,\n\t\t\t       size_t start, size_t len,\n\t\t\t       charT * buffer);\n\n\tstatic const unsigned long min_len[RopeBase::max_rope_depth + 1];\n\n\tstatic bool is_balanced(RopeBase *r)\n\t\t{ return (r -> size >= min_len[r -> depth]); }\n\n\tstatic bool is_almost_balanced(RopeBase *r)\n\t\t{ return (r -> depth == 0 ||\n\t\t\t  r -> size >= min_len[r -> depth - 1]); }\n\n\tstatic bool is_roughly_balanced(RopeBase *r)\n\t\t{ return (r -> depth <= 1 ||\n\t\t\t  r -> size >= min_len[r -> depth - 2]); }\n\n\t// Assumes the result is not empty.\n\tstatic RopeBase * concat_and_set_balanced(RopeBase *left,\n\t\t\t\t\t\t  RopeBase *right)\n\t{\n\t    RopeBase * result = concat(left, right);\n\t    if (is_balanced(result)) result -> is_balanced = true;\n\t    return result;\n\t}\n\n\t// The basic rebalancing operation.  Logically copies the\n\t// rope.  The result has refcount of 1.  The client will\n\t// usually decrement the reference count of r.\n\t// The result isd within height 2 of balanced by the above\n\t// definition.\n\tstatic RopeBase * balance(RopeBase * r);\n\n\t// Add all unbalanced subtrees to the forest of balanceed trees.\n\t// Used only by balance.\n\tstatic void add_to_forest(RopeBase *r, RopeBase **forest);\n\t\n\t// Add r to forest, assuming r is already balanced.\n\tstatic void add_leaf_to_forest(RopeBase *r, RopeBase **forest);\n\n\t// Print to stdout, exposing structure\n\tstatic void dump(RopeBase * r, int indent = 0);\n\n\t// Return -1, 0, or 1 if x < y, x == y, or x > y resp.\n\tstatic int compare(const RopeBase *x, const RopeBase *y);\n\n   public:\n\tbool empty() const { return 0 == tree_ptr; }\n\n\t// Comparison member function.  This is public only for those\n\t// clients that need a ternary comparison.  Others\n\t// should use the comparison operators below.\n\tint compare(const rope &y) const {\n\t    return compare(tree_ptr, y.tree_ptr);\n\t}\n\n\trope(const charT *s)\n\t{\n\t    size_t len = char_ptr_len(s);\n\n\t    if (0 == len) {\n\t\ttree_ptr = 0;\n\t    } else {\n\t\ttree_ptr = RopeLeaf_from_unowned_char_ptr(s, len);\n#\t\tifndef __GC\n\t\t  __stl_assert(1 == tree_ptr -> refcount);\n#\t\tendif\n\t    }\n\t}\n\n\trope(const charT *s, size_t len)\n\t{\n\t    if (0 == len) {\n\t\ttree_ptr = 0;\n\t    } else {\n\t\ttree_ptr = RopeLeaf_from_unowned_char_ptr(s, len);\n\t    }\n\t}\n\n\trope(const charT *s, charT *e)\n\t{\n\t    size_t len = e - s;\n\n\t    if (0 == len) {\n\t\ttree_ptr = 0;\n\t    } else {\n\t\ttree_ptr = RopeLeaf_from_unowned_char_ptr(s, len);\n\t    }\n\t}\n\n\trope(const const_iterator& s, const const_iterator& e)\n\t{\n\t    tree_ptr = substring(s.root, s.current_pos, e.current_pos);\n\t}\n\n\trope(const iterator& s, const iterator& e)\n\t{\n\t    tree_ptr = substring(s.root, s.current_pos, e.current_pos);\n\t}\n\n\trope(charT c)\n\t{\n\t    charT * buf = DataAlloc::allocate(rounded_up_size(1));\n\n\t    construct(buf, c);\n\t    __STL_TRY {\n\t        tree_ptr = RopeLeaf_from_char_ptr(buf, 1);\n            }\n            __STL_UNWIND(RopeBase::free_string(buf, 1))\n\t}\n\n\trope(size_t n, charT c);\n\n\t// Should really be templatized with respect to the iterator type\n\t// and use sequence_buffer.  (It should perhaps use sequence_buffer\n\t// even now.)\n\trope(const charT *i, const charT *j)\n\t{\n\t    if (i == j) {\n\t\ttree_ptr = 0;\n\t    } else {\n\t\tsize_t len = j - i;\n\t\ttree_ptr = RopeLeaf_from_unowned_char_ptr(i, len);\n\t    }\n\t}\n\n\trope()\n\t{\n\t    tree_ptr = 0;\n\t}\n\n\t// Construct a rope from a function that can compute its members\n\trope(char_producer<charT> *fn, size_t len, bool delete_fn)\n\t{\n\t    tree_ptr = RopeFunction_from_fn(fn, len, delete_fn);\n\t}\n\n\trope(const rope &x)\n\t{\n\t    tree_ptr = x.tree_ptr;\n\t    ref(tree_ptr);\n\t}\n\n\t~rope()\n\t{\n\t    unref(tree_ptr);\n\t}\n\n\trope& operator=(const rope& x)\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    tree_ptr = x.tree_ptr;\n\t    ref(tree_ptr);\n\t    unref(old);\n\t    return(*this);\n\t}\n\n\tvoid push_back(charT x)\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    tree_ptr = concat_char_iter(tree_ptr, &x, 1);\n\t    unref(old);\n\t}\n\n\tvoid pop_back()\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    tree_ptr = substring(tree_ptr, 0, tree_ptr -> size - 1);\n\t    unref(old);\n\t}\n\n\tcharT back() const\n\t{\n\t    return fetch(tree_ptr, tree_ptr -> size - 1);\n\t}\n\n\tvoid push_front(charT x)\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    RopeBase *left;\n\n\t    left = RopeLeaf_from_unowned_char_ptr(&x, 1);\n\t    __STL_TRY {\n\t      tree_ptr = concat(left, tree_ptr);\n\t      unref(old);\n              unref(left);\n            }\n\t    __STL_UNWIND(unref(left))\n\t}\n\n\tvoid pop_front()\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    tree_ptr = substring(tree_ptr, 1, tree_ptr -> size);\n\t    unref(old);\n\t}\n\n\tcharT front() const\n\t{\n\t    return fetch(tree_ptr, 0);\n\t}\n\n\tvoid balance()\n\t{\n\t    RopeBase *old = tree_ptr;\n\t    tree_ptr = balance(tree_ptr);\n\t    unref(old);\n\t}\n\n\tvoid copy(charT * buffer) const {\n\t    destroy(buffer, buffer + size());\n\t    flatten(tree_ptr, buffer);\n\t}\n\n\t// This is the copy function from the standard, but\n\t// with the arguments reordered to make it consistent with the\n\t// rest of the interface.\n\t// Note that this guaranteed not to compile if the draft standard\n\t// order is assumed.\n\tsize_type copy(size_type pos, size_type n, charT *buffer) const {\n\t    size_t sz = size();\n\t    size_t len = (pos + n > sz? sz - pos : n);\n\n\t    destroy(buffer, buffer + len);\n\t    flatten(tree_ptr, pos, len, buffer);\n\t    return len;\n\t}\n\n\t// Print to stdout, exposing structure.  May be useful for\n\t// performance debugging.\n\tvoid dump() {\n\t    dump(tree_ptr);\n\t}\n\n\t// Convert to 0 terminated string in new allocated memory.\n\t// Embedded 0s in the input do not terminate the copy.\n\tconst charT * c_str() const;\n\n\t// As above, but lso use the flattened representation as the\n\t// the new rope representation.\n\tconst charT * replace_with_c_str();\n\n\t// Reclaim memory for the c_str generated flattened string.\n\t// Intentionally undocumented, since it's hard to say when this\n\t// is safe for multiple threads.\n\tvoid delete_c_str () {\n\t    if (0 == tree_ptr) return;\n\t    if (RopeBase::leaf == tree_ptr -> tag\n\t\t&& ((RopeLeaf *)tree_ptr) -> data == tree_ptr -> c_string) {\n\t\t// Representation shared\n\t\treturn;\n\t    }\n#\t    ifndef __GC\n\t      tree_ptr -> free_c_string();\n#\t    endif\n\t    tree_ptr -> c_string = 0;\n\t}\n\n\tcharT operator[] (size_type pos) const {\n\t    return fetch(tree_ptr, pos);\n\t}\n\n\tcharT at(size_type pos) const {\n\t   // if (pos >= size()) throw out_of_range;\n\t   return (*this)[pos];\n\t}\n\n\tconst_iterator begin() const {\n\t    return(const_iterator(tree_ptr, 0));\n\t}\n\n\t// An easy way to get a const iterator from a non-const container.\n\tconst_iterator const_begin() const {\n\t    return(const_iterator(tree_ptr, 0));\n\t}\n\n\tconst_iterator end() const {\n\t    return(const_iterator(tree_ptr, size()));\n\t}\n\n\tconst_iterator const_end() const {\n\t    return(const_iterator(tree_ptr, size()));\n\t}\n\n\tsize_type size() const { \n\t    return(0 == tree_ptr? 0 : tree_ptr -> size);\n\t}\n\n\tsize_type length() const {\n\t    return size();\n\t}\n\n\tsize_type max_size() const {\n\t    return min_len[RopeBase::max_rope_depth-1] - 1;\n\t    //  Guarantees that the result can be sufficirntly\n\t    //  balanced.  Longer ropes will probably still work,\n\t    //  but it's harder to make guarantees.\n\t}\n\n#     ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n        typedef reverse_iterator<const_iterator> const_reverse_iterator;\n#     else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ttypedef reverse_iterator<const_iterator, value_type, const_reference,\n\t\t\t\t difference_type>  const_reverse_iterator;\n#     endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \n\n\tconst_reverse_iterator rbegin() const {\n\t    return const_reverse_iterator(end());\n\t}\n\n\tconst_reverse_iterator const_rbegin() const {\n\t    return const_reverse_iterator(end());\n\t}\n\n\tconst_reverse_iterator rend() const {\n\t    return const_reverse_iterator(begin());\n\t}\n\n\tconst_reverse_iterator const_rend() const {\n\t    return const_reverse_iterator(begin());\n\t}\n\n\tfriend rope<charT,Alloc>\n        operator+ __STL_NULL_TMPL_ARGS (const rope<charT,Alloc> &left,\n                                        const rope<charT,Alloc> &right);\n\t\n\tfriend rope<charT,Alloc>\n        operator+ __STL_NULL_TMPL_ARGS (const rope<charT,Alloc> &left,\n                                        const charT* right);\n\t\n\tfriend rope<charT,Alloc>\n        operator+ __STL_NULL_TMPL_ARGS (const rope<charT,Alloc> &left,\n                                        charT right);\n\t\n\t// The symmetric cases are intentionally omitted, since they're presumed\n\t// to be less common, and we don't handle them as well.\n\n\t// The following should really be templatized.\n\t// The first argument should be an input iterator or\n\t// forward iterator with value_type charT.\n\trope& append(const charT* iter, size_t n) {\n\t    RopeBase* result = destr_concat_char_iter(tree_ptr, iter, n);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t    return *this;\n\t}\n\n\trope& append(const charT* c_string) {\n\t    size_t len = char_ptr_len(c_string);\n\t    append(c_string, len);\n\t    return(*this);\n\t}\n\n\trope& append(const charT* s, const charT* e) {\n\t    RopeBase* result =\n\t\t\tdestr_concat_char_iter(tree_ptr, s, e - s);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t    return *this;\n\t}\n\n\trope& append(const_iterator s, const_iterator e) {\n\t    __stl_assert(s.root == e.root);\n\t    self_destruct_ptr appendee(substring(s.root, s.current_pos,\n\t\t\t\t\t\t e.current_pos));\n\t    RopeBase* result = concat(tree_ptr, (RopeBase *)appendee);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t    return *this;\n\t}\n\n\trope& append(charT c) {\n\t    RopeBase* result = destr_concat_char_iter(tree_ptr, &c, 1);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t    return *this;\n\t}\n\n\trope& append() { return append(charT()); }\n\n\trope& append(const rope& y) {\n\t    RopeBase* result = concat(tree_ptr, y.tree_ptr);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t    return *this;\n\t}\n\n\trope& append(size_t n, charT c) {\n\t    rope<charT,Alloc> last(n, c);\n\t    return append(last);\n\t}\n\n\tvoid swap(rope& b) {\n\t    RopeBase * tmp = tree_ptr;\n\t    tree_ptr = b.tree_ptr;\n\t    b.tree_ptr = tmp;\n\t}\n\n\n    protected:\n\t// Result is included in refcount.\n\tstatic RopeBase * replace(RopeBase *old, size_t pos1,\n\t\t\t\t  size_t pos2, RopeBase *r) {\n\t    if (0 == old) { ref(r); return r; }\n\t    self_destruct_ptr left(substring(old, 0, pos1));\n\t    self_destruct_ptr right(substring(old, pos2, old -> size));\n\t    RopeBase * result;\n\n\t    if (0 == r) {\n\t\tresult = concat(left, right);\n\t    } else {\n\t\tself_destruct_ptr left_result(concat(left, r));\n\t\tresult = concat(left_result, right);\n\t    }\n\t    return result;\n\t}\n\n    public:\n\tvoid insert(size_t p, const rope& r) {\n\t    RopeBase * result = replace(tree_ptr, p, p,\n\t\t\t\t\t       r.tree_ptr);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t}\n\n\tvoid insert(size_t p, size_t n, charT c) {\n\t    rope<charT,Alloc> r(n,c);\n\t    insert(p, r);\n\t}\n\n\tvoid insert(size_t p, const charT * i, size_t n) {\n\t    self_destruct_ptr left(substring(tree_ptr, 0, p));\n\t    self_destruct_ptr right(substring(tree_ptr, p, size()));\n\t    self_destruct_ptr left_result(concat_char_iter(left, i, n));\n\t    RopeBase * result =\n\t\t\t\tconcat(left_result, right);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t}\n\n\tvoid insert(size_t p, const charT * c_string) {\n\t    insert(p, c_string, char_ptr_len(c_string));\n\t}\n\n\tvoid insert(size_t p, charT c) {\n\t    insert(p, &c, 1);\n\t}\n\n\tvoid insert(size_t p) {\n\t    charT c = charT();\n\t    insert(p, &c, 1);\n\t}\n\n\tvoid insert(size_t p, const charT *i, const charT *j) {\n\t    rope r(i, j);\n\t    insert(p, r);\n\t}\n\n\tvoid insert(size_t p, const const_iterator& i,\n\t\t\t      const const_iterator& j) {\n\t    rope r(i, j);\n\t    insert(p, r);\n\t}\n\n\tvoid insert(size_t p, const iterator& i,\n\t\t\t      const iterator& j) {\n\t    rope r(i, j);\n\t    insert(p, r);\n\t}\n\n\t// (position, length) versions of replace operations:\n\n\tvoid replace(size_t p, size_t n, const rope& r) {\n\t    RopeBase * result = replace(tree_ptr, p, p + n,\n\t\t\t\t\t       r.tree_ptr);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t}\n\n\tvoid replace(size_t p, size_t n, const charT *i, size_t i_len) {\n\t    rope r(i, i_len);\n\t    replace(p, n, r);\n\t}\n\n\tvoid replace(size_t p, size_t n, charT c) {\n\t    rope r(c);\n\t    replace(p, n, r);\n\t}\n\n\tvoid replace(size_t p, size_t n, const charT *c_string) {\n\t    rope r(c_string);\n\t    replace(p, n, r);\n\t}\n\n\tvoid replace(size_t p, size_t n, const charT *i, const charT *j) {\n\t    rope r(i, j);\n\t    replace(p, n, r);\n\t}\n\n\tvoid replace(size_t p, size_t n,\n\t\t     const const_iterator& i, const const_iterator& j) {\n\t    rope r(i, j);\n\t    replace(p, n, r);\n\t}\n\n\tvoid replace(size_t p, size_t n,\n\t\t     const iterator& i, const iterator& j) {\n\t    rope r(i, j);\n\t    replace(p, n, r);\n\t}\n\n\t// Single character variants:\n\tvoid replace(size_t p, charT c) {\n\t    iterator i(this, p);\n\t    *i = c;\n\t}\n\n\tvoid replace(size_t p, const rope& r) {\n\t    replace(p, 1, r);\n\t}\n\n\tvoid replace(size_t p, const charT *i, size_t i_len) {\n\t    replace(p, 1, i, i_len);\n\t}\n\n\tvoid replace(size_t p, const charT *c_string) {\n\t    replace(p, 1, c_string);\n\t}\n\n\tvoid replace(size_t p, const charT *i, const charT *j) {\n\t    replace(p, 1, i, j);\n\t}\n\n\tvoid replace(size_t p, const const_iterator& i,\n\t\t\t       const const_iterator& j) {\n\t    replace(p, 1, i, j);\n\t}\n\n\tvoid replace(size_t p, const iterator& i,\n\t\t\t       const iterator& j) {\n\t    replace(p, 1, i, j);\n\t}\n\n\t// Erase, (position, size) variant.\n\tvoid erase(size_t p, size_t n) {\n\t    RopeBase * result = replace(tree_ptr, p, p + n, 0);\n\t    unref(tree_ptr);\n\t    tree_ptr = result;\n\t}\n\n\t// Erase, single character\n\tvoid erase(size_t p) {\n\t    erase(p, p + 1);\n\t}\n\n\t// Insert, iterator variants.  \n\titerator insert(const iterator& p, const rope& r)\n\t\t{ insert(p.index(), r); return p; }\n\titerator insert(const iterator& p, size_t n, charT c)\n\t\t{ insert(p.index(), n, c); return p; }\n\titerator insert(const iterator& p, charT c) \n\t\t{ insert(p.index(), c); return p; }\n\titerator insert(const iterator& p ) \n\t\t{ insert(p.index()); return p; }\n\titerator insert(const iterator& p, const charT *c_string) \n\t\t{ insert(p.index(), c_string); return p; }\n\titerator insert(const iterator& p, const charT *i, size_t n)\n\t\t{ insert(p.index(), i, n); return p; }\n\titerator insert(const iterator& p, const charT *i, const charT *j)\n\t\t{ insert(p.index(), i, j);  return p; }\n\titerator insert(const iterator& p,\n\t\t\tconst const_iterator& i, const const_iterator& j)\n\t\t{ insert(p.index(), i, j); return p; }\n\titerator insert(const iterator& p,\n\t\t\tconst iterator& i, const iterator& j)\n\t\t{ insert(p.index(), i, j); return p; }\n\n\t// Replace, range variants.\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const rope& r)\n\t\t{ replace(p.index(), q.index() - p.index(), r); }\n\tvoid replace(const iterator& p, const iterator& q, charT c)\n\t\t{ replace(p.index(), q.index() - p.index(), c); }\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const charT * c_string)\n\t\t{ replace(p.index(), q.index() - p.index(), c_string); }\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const charT *i, size_t n)\n\t\t{ replace(p.index(), q.index() - p.index(), i, n); }\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const charT *i, const charT *j)\n\t\t{ replace(p.index(), q.index() - p.index(), i, j); }\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const const_iterator& i, const const_iterator& j)\n\t\t{ replace(p.index(), q.index() - p.index(), i, j); }\n\tvoid replace(const iterator& p, const iterator& q,\n\t\t     const iterator& i, const iterator& j)\n\t\t{ replace(p.index(), q.index() - p.index(), i, j); }\n\n\t// Replace, iterator variants.\n\tvoid replace(const iterator& p, const rope& r)\n\t\t{ replace(p.index(), r); }\n\tvoid replace(const iterator& p, charT c)\n\t\t{ replace(p.index(), c); }\n\tvoid replace(const iterator& p, const charT * c_string)\n\t\t{ replace(p.index(), c_string); }\n\tvoid replace(const iterator& p, const charT *i, size_t n)\n\t\t{ replace(p.index(), i, n); }\n\tvoid replace(const iterator& p, const charT *i, const charT *j)\n\t\t{ replace(p.index(), i, j); }\n\tvoid replace(const iterator& p, const_iterator i, const_iterator j)\n\t\t{ replace(p.index(), i, j); }\n\tvoid replace(const iterator& p, iterator i, iterator j)\n\t\t{ replace(p.index(), i, j); }\n\n\t// Iterator and range variants of erase\n\titerator erase(const iterator &p, const iterator &q) {\n            size_t p_index = p.index();\n            erase(p_index, q.index() - p_index);\n            return iterator(this, p_index);\n        }\n        iterator erase(const iterator &p) {\n            size_t p_index = p.index();\n            erase(p_index, 1);\n            return iterator(this, p_index);\n        }\n\n\trope substr(size_t start, size_t len = 1) const {\n\t    return rope<charT,Alloc>(\n\t\t\tsubstring(tree_ptr, start, start + len));\n\t}\n\n\trope substr(iterator start, iterator end) const {\n\t    return rope<charT,Alloc>(\n\t\t\tsubstring(tree_ptr, start.index(), end.index()));\n\t}\n\t\n\trope substr(iterator start) const {\n\t    size_t pos = start.index();\n\t    return rope<charT,Alloc>(\n\t\t\tsubstring(tree_ptr, pos, pos + 1));\n\t}\n\t\n\trope substr(const_iterator start, const_iterator end) const {\n\t    // This might eventually take advantage of the cache in the\n\t    // iterator.\n\t    return rope<charT,Alloc>\n\t\t(substring(tree_ptr, start.index(), end.index()));\n\t}\n\n\trope<charT,Alloc> substr(const_iterator start) {\n\t    size_t pos = start.index();\n\t    return rope<charT,Alloc>(substring(tree_ptr, pos, pos + 1));\n\t}\n\n\tsize_type find(charT c, size_type pos = 0) const;\n\tsize_type find(charT *s, size_type pos = 0) const {\n\t    const_iterator result = search(const_begin() + pos, const_end(),\n\t\t\t\t\t   s, s + char_ptr_len(s));\n\t    return result.index();\n\t}\n\n\titerator mutable_begin() {\n\t    return(iterator(this, 0));\n\t}\n\n\titerator mutable_end() {\n\t    return(iterator(this, size()));\n\t}\n\n#     ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n        typedef reverse_iterator<iterator> reverse_iterator;\n#     else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ttypedef reverse_iterator<iterator, value_type, reference,\n\t\t\t\t difference_type>  reverse_iterator;\n#     endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \n\n\treverse_iterator mutable_rbegin() {\n\t    return reverse_iterator(mutable_end());\n\t}\n\n\treverse_iterator mutable_rend() {\n\t    return reverse_iterator(mutable_begin());\n\t}\n\n\treference mutable_reference_at(size_type pos) {\n\t    return reference(this, pos);\n\t}\n\n#\tifdef __STD_STUFF\n\t    reference operator[] (size_type pos) {\n\t\treturn charT_ref_proxy(this, pos);\n\t    }\n\n\t    reference at(size_type pos) {\n\t\t// if (pos >= size()) throw out_of_range;\n\t\treturn (*this)[pos];\n\t    }\n\n\t    void resize(size_type n, charT c) {}\n\t    void resize(size_type n) {}\n\t    void reserve(size_type res_arg = 0) {}\n\t    size_type capacity() const {\n\t\treturn max_size();\n\t    }\n\n\t  // Stuff below this line is dangerous because it's error prone.\n\t  // I would really like to get rid of it.\n\t    // copy function with funny arg ordering.\n\t      size_type copy(charT *buffer, size_type n, size_type pos = 0)\n\t\t\t\t\t\t\t\tconst {\n\t\treturn copy(pos, n, buffer);\n\t      }\n\n\t    iterator end() { return mutable_end(); }\n\n\t    iterator begin() { return mutable_begin(); }\n\n\t    reverse_iterator rend() { return mutable_rend(); }\n\n\t    reverse_iterator rbegin() { return mutable_rbegin(); }\n\n#\telse\n\n\t    const_iterator end() { return const_end(); }\n\n\t    const_iterator begin() { return const_begin(); }\n\n\t    const_reverse_iterator rend() { return const_rend(); }\n  \n\t    const_reverse_iterator rbegin() { return const_rbegin(); }\n\n#\tendif\n\t\n};\n\ntemplate <class charT, class Alloc>\ninline bool operator== (const __rope_const_iterator<charT,Alloc> & x,\n\t\t\tconst __rope_const_iterator<charT,Alloc> & y) {\n\treturn (x.current_pos == y.current_pos && x.root == y.root);\n}\n\ntemplate <class charT, class Alloc>\ninline bool operator< (const __rope_const_iterator<charT,Alloc> & x,\n\t\t       const __rope_const_iterator<charT,Alloc> & y) {\n\treturn (x.current_pos < y.current_pos);\n}\n\ntemplate <class charT, class Alloc>\ninline ptrdiff_t operator-(const __rope_const_iterator<charT,Alloc> & x,\n\t\t\t   const __rope_const_iterator<charT,Alloc> & y) {\n\treturn x.current_pos - y.current_pos;\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_const_iterator<charT,Alloc>\noperator-(const __rope_const_iterator<charT,Alloc> & x,\n\t  ptrdiff_t n) {\n\treturn __rope_const_iterator<charT,Alloc>(x.root, x.current_pos - n);\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_const_iterator<charT,Alloc>\noperator+(const __rope_const_iterator<charT,Alloc> & x,\n\t  ptrdiff_t n) {\n\treturn __rope_const_iterator<charT,Alloc>(x.root, x.current_pos + n);\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_const_iterator<charT,Alloc>\noperator+(ptrdiff_t n,\n\t  const __rope_const_iterator<charT,Alloc> & x) {\n\treturn __rope_const_iterator<charT,Alloc>(x.root, x.current_pos + n);\n}\n\ntemplate <class charT, class Alloc>\ninline bool operator== (const __rope_iterator<charT,Alloc> & x,\n\t\t\tconst __rope_iterator<charT,Alloc> & y) {\n\treturn (x.current_pos == y.current_pos && x.root_rope == y.root_rope);\n}\n\ntemplate <class charT, class Alloc>\ninline bool operator< (const __rope_iterator<charT,Alloc> & x,\n\t\t\tconst __rope_iterator<charT,Alloc> & y) {\n\treturn (x.current_pos < y.current_pos);\n}\n\ntemplate <class charT, class Alloc>\ninline ptrdiff_t operator-(const __rope_iterator<charT,Alloc> & x,\n\t\t\t   const __rope_iterator<charT,Alloc> & y) {\n\treturn x.current_pos - y.current_pos;\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_iterator<charT,Alloc>\noperator-(const __rope_iterator<charT,Alloc> & x,\n\t  ptrdiff_t n) {\n\treturn __rope_iterator<charT,Alloc>(x.root_rope, x.current_pos - n);\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_iterator<charT,Alloc>\noperator+(const __rope_iterator<charT,Alloc> & x,\n\t  ptrdiff_t n) {\n\treturn __rope_iterator<charT,Alloc>(x.root_rope, x.current_pos + n);\n}\n\ntemplate <class charT, class Alloc>\ninline __rope_iterator<charT,Alloc>\noperator+(ptrdiff_t n,\n\t  const __rope_iterator<charT,Alloc> & x) {\n\treturn __rope_iterator<charT,Alloc>(x.root_rope, x.current_pos + n);\n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>\noperator+ (const rope<charT,Alloc> &left,\n\t   const rope<charT,Alloc> &right)\n{\n    return rope<charT,Alloc>\n\t\t(rope<charT,Alloc>::concat(left.tree_ptr, right.tree_ptr));\n    // Inlining this should make it possible to keep left and\n    // right in registers.\n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>&\noperator+= (rope<charT,Alloc> &left,\n\t    const rope<charT,Alloc> &right)\n{\n    left.append(right);\n    return left;\n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>\noperator+ (const rope<charT,Alloc> &left,\n\t   const charT* right) {\n    size_t rlen = rope<charT,Alloc>::char_ptr_len(right);\n    return rope<charT,Alloc>\n\t   (rope<charT,Alloc>::concat_char_iter(left.tree_ptr, right, rlen)); \n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>&\noperator+= (rope<charT,Alloc> &left,\n\t    const charT* right) {\n    left.append(right);\n    return left;\n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>\noperator+ (const rope<charT,Alloc> &left, charT right) {\n    return rope<charT,Alloc>\n\t\t(rope<charT,Alloc>::concat_char_iter(left.tree_ptr, &right, 1));\n}\n\ntemplate <class charT, class Alloc>\ninline\nrope<charT,Alloc>&\noperator+= (rope<charT,Alloc> &left, charT right) {\n    left.append(right);\n    return left;\n}\n\ntemplate <class charT, class Alloc>\nbool\noperator< (const rope<charT,Alloc> &left, const rope<charT,Alloc> &right) {\n    return left.compare(right) < 0;\n}\n\t\ntemplate <class charT, class Alloc>\nbool\noperator== (const rope<charT,Alloc> &left, const rope<charT,Alloc> &right) {\n    return left.compare(right) == 0;\n}\n\ntemplate <class charT, class Alloc>\ninline bool operator== (const __rope_charT_ptr_proxy<charT,Alloc> & x,\n\t\t\tconst __rope_charT_ptr_proxy<charT,Alloc> & y) {\n\treturn (x.pos == y.pos && x.root == y.root);\n}\n\ntemplate<class charT, class Alloc>\nostream& operator<< (ostream& o, const rope<charT, Alloc>& r);        \n\t\ntypedef rope<char, __ALLOC> crope;\ntypedef rope<wchar_t, __ALLOC> wrope;\n\ninline crope::reference __mutable_reference_at(crope& c, size_t i)\n{\n    return c.mutable_reference_at(i);\n}\n\ninline wrope::reference __mutable_reference_at(wrope& c, size_t i)\n{\n    return c.mutable_reference_at(i);\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class charT, class Alloc>\ninline void swap(rope<charT, Alloc>& x, rope<charT, Alloc>& y) {\n  x.swap(y);\n}\n\n#else\n\ninline void swap(crope x, crope y) { x.swap(y); }\ninline void swap(wrope x, wrope y) { x.swap(y); }\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n// Hash functions should probably be revisited later:\n__STL_TEMPLATE_NULL struct hash<crope>\n{\n  size_t operator()(const crope& str) const\n  {\n    size_t sz = str.size();\n\n    if (0 == sz) return 0;\n    return 13*str[0] + 5*str[sz - 1] + sz;\n  }\n};\n\n\n__STL_TEMPLATE_NULL struct hash<wrope>\n{\n  size_t operator()(const wrope& str) const\n  {\n    size_t sz = str.size();\n\n    if (0 == sz) return 0;\n    return 13*str[0] + 5*str[sz - 1] + sz;\n  }\n};\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n# include <ropeimpl.h>\n# endif /* __SGI_STL_INTERNAL_ROPE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_set.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_SET_H\n#define __SGI_STL_INTERNAL_SET_H\n\n__STL_BEGIN_NAMESPACE\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class Key, class Compare = less<Key>, class Alloc = alloc>\n#else\ntemplate <class Key, class Compare, class Alloc = alloc>\n#endif\nclass set {\npublic:\n  // typedefs:\n\n  typedef Key key_type;\n  typedef Key value_type;\n  typedef Compare key_compare;\n  typedef Compare value_compare;\nprivate:\n  typedef rb_tree<key_type, value_type, \n                  identity<value_type>, key_compare, Alloc> rep_type;\n  rep_type t;  // red-black tree representing set\npublic:\n  typedef typename rep_type::const_pointer pointer;\n  typedef typename rep_type::const_pointer const_pointer;\n  typedef typename rep_type::const_reference reference;\n  typedef typename rep_type::const_reference const_reference;\n  typedef typename rep_type::const_iterator iterator;\n  typedef typename rep_type::const_iterator const_iterator;\n  typedef typename rep_type::const_reverse_iterator reverse_iterator;\n  typedef typename rep_type::const_reverse_iterator const_reverse_iterator;\n  typedef typename rep_type::size_type size_type;\n  typedef typename rep_type::difference_type difference_type;\n\n  // allocation/deallocation\n\n  set() : t(Compare()) {}\n  explicit set(const Compare& comp) : t(comp) {}\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  set(InputIterator first, InputIterator last)\n    : t(Compare()) { t.insert_unique(first, last); }\n\n  template <class InputIterator>\n  set(InputIterator first, InputIterator last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n#else\n  set(const value_type* first, const value_type* last) \n    : t(Compare()) { t.insert_unique(first, last); }\n  set(const value_type* first, const value_type* last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n\n  set(const_iterator first, const_iterator last)\n    : t(Compare()) { t.insert_unique(first, last); }\n  set(const_iterator first, const_iterator last, const Compare& comp)\n    : t(comp) { t.insert_unique(first, last); }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  set(const set<Key, Compare, Alloc>& x) : t(x.t) {}\n  set<Key, Compare, Alloc>& operator=(const set<Key, Compare, Alloc>& x) { \n    t = x.t; \n    return *this;\n  }\n\n  // accessors:\n\n  key_compare key_comp() const { return t.key_comp(); }\n  value_compare value_comp() const { return t.key_comp(); }\n  iterator begin() const { return t.begin(); }\n  iterator end() const { return t.end(); }\n  reverse_iterator rbegin() const { return t.rbegin(); } \n  reverse_iterator rend() const { return t.rend(); }\n  bool empty() const { return t.empty(); }\n  size_type size() const { return t.size(); }\n  size_type max_size() const { return t.max_size(); }\n  void swap(set<Key, Compare, Alloc>& x) { t.swap(x.t); }\n\n  // insert/erase\n  typedef  pair<iterator, bool> pair_iterator_bool; \n  pair<iterator,bool> insert(const value_type& x) { \n    pair<typename rep_type::iterator, bool> p = t.insert_unique(x); \n    return pair<iterator, bool>(p.first, p.second);\n  }\n  iterator insert(iterator position, const value_type& x) {\n    typedef typename rep_type::iterator rep_iterator;\n    return t.insert_unique((rep_iterator&)position, x);\n  }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(InputIterator first, InputIterator last) {\n    t.insert_unique(first, last);\n  }\n#else\n  void insert(const_iterator first, const_iterator last) {\n    t.insert_unique(first, last);\n  }\n  void insert(const value_type* first, const value_type* last) {\n    t.insert_unique(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  void erase(iterator position) { \n    typedef typename rep_type::iterator rep_iterator;\n    t.erase((rep_iterator&)position); \n  }\n  size_type erase(const key_type& x) { \n    return t.erase(x); \n  }\n  void erase(iterator first, iterator last) { \n    typedef typename rep_type::iterator rep_iterator;\n    t.erase((rep_iterator&)first, (rep_iterator&)last); \n  }\n  void clear() { t.clear(); }\n\n  // set operations:\n\n  iterator find(const key_type& x) const { return t.find(x); }\n  size_type count(const key_type& x) const { return t.count(x); }\n  iterator lower_bound(const key_type& x) const {\n    return t.lower_bound(x);\n  }\n  iterator upper_bound(const key_type& x) const {\n    return t.upper_bound(x); \n  }\n  pair<iterator,iterator> equal_range(const key_type& x) const {\n    return t.equal_range(x);\n  }\n  friend bool operator== __STL_NULL_TMPL_ARGS (const set&, const set&);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const set&, const set&);\n};\n\ntemplate <class Key, class Compare, class Alloc>\ninline bool operator==(const set<Key, Compare, Alloc>& x, \n                       const set<Key, Compare, Alloc>& y) {\n  return x.t == y.t;\n}\n\ntemplate <class Key, class Compare, class Alloc>\ninline bool operator<(const set<Key, Compare, Alloc>& x, \n                      const set<Key, Compare, Alloc>& y) {\n  return x.t < y.t;\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class Compare, class Alloc>\ninline void swap(set<Key, Compare, Alloc>& x, \n                 set<Key, Compare, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_SET_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_slist.h",
    "content": "/*\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_SLIST_H\n#define __SGI_STL_INTERNAL_SLIST_H\n\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\nstruct __slist_node_base\n{\n  __slist_node_base* next;\n};\n\ninline __slist_node_base* __slist_make_link(__slist_node_base* prev_node,\n                                            __slist_node_base* new_node)\n{\n  new_node->next = prev_node->next;\n  prev_node->next = new_node;\n  return new_node;\n}\n\ninline __slist_node_base* __slist_previous(__slist_node_base* head,\n                                           const __slist_node_base* node)\n{\n  while (head && head->next != node)\n    head = head->next;\n  return head;\n}\n\ninline const __slist_node_base* __slist_previous(const __slist_node_base* head,\n                                                 const __slist_node_base* node)\n{\n  while (head && head->next != node)\n    head = head->next;\n  return head;\n}\n\ninline void __slist_splice_after(__slist_node_base* pos,\n                                 __slist_node_base* before_first,\n                                 __slist_node_base* before_last)\n{\n  if (pos != before_first && pos != before_last) {\n    __slist_node_base* first = before_first->next;\n    __slist_node_base* after = pos->next;\n    before_first->next = before_last->next;\n    pos->next = first;\n    before_last->next = after;\n  }\n}\n\ninline __slist_node_base* __slist_reverse(__slist_node_base* node)\n{\n  __slist_node_base* result = node;\n  node = node->next;\n  result->next = 0;\n  while(node) {\n    __slist_node_base* next = node->next;\n    node->next = result;\n    result = node;\n    node = next;\n  }\n  return result;\n}\n\ntemplate <class T>\nstruct __slist_node : public __slist_node_base\n{\n  T data;\n};\n\nstruct __slist_iterator_base\n{\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n  typedef forward_iterator_tag iterator_category;\n\n  __slist_node_base* node;\n\n  __slist_iterator_base(__slist_node_base* x) : node(x) {}\n  void incr() { node = node->next; }\n\n  bool operator==(const __slist_iterator_base& x) const {\n    return node == x.node;\n  }\n  bool operator!=(const __slist_iterator_base& x) const {\n    return node != x.node;\n  }\n};\n\ntemplate <class T, class Ref, class Ptr>\nstruct __slist_iterator : public __slist_iterator_base\n{\n  typedef __slist_iterator<T, T&, T*>             iterator;\n  typedef __slist_iterator<T, const T&, const T*> const_iterator;\n  typedef __slist_iterator<T, Ref, Ptr>           self;\n\n  typedef T value_type;\n  typedef Ptr pointer;\n  typedef Ref reference;\n  typedef __slist_node<T> list_node;\n\n  __slist_iterator(list_node* x) : __slist_iterator_base(x) {}\n  __slist_iterator() : __slist_iterator_base(0) {}\n  __slist_iterator(const iterator& x) : __slist_iterator_base(x.node) {}\n\n  reference operator*() const { return ((list_node*) node)->data; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  self& operator++()\n  {\n    incr();\n    return *this;\n  }\n  self operator++(int)\n  {\n    self tmp = *this;\n    incr();\n    return tmp;\n  }\n};\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ninline ptrdiff_t*\ndistance_type(const __slist_iterator_base&)\n{\n  return 0;\n}\n\ninline forward_iterator_tag\niterator_category(const __slist_iterator_base&)\n{\n  return forward_iterator_tag();\n}\n\ntemplate <class T, class Ref, class Ptr> \ninline T* \nvalue_type(const __slist_iterator<T, Ref, Ptr>&) {\n  return 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ninline size_t __slist_size(__slist_node_base* node)\n{\n  size_t result = 0;\n  for ( ; node != 0; node = node->next)\n    ++result;\n  return result;\n}\n\ntemplate <class T, class Alloc = alloc>\nclass slist\n{\npublic:\n  typedef T value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n  typedef __slist_iterator<T, T&, T*>             iterator;\n  typedef __slist_iterator<T, const T&, const T*> const_iterator;\n\nprivate:\n  typedef __slist_node<T> list_node;\n  typedef __slist_node_base list_node_base;\n  typedef __slist_iterator_base iterator_base;\n  typedef simple_alloc<list_node, Alloc> list_node_allocator;\n\n  static list_node* create_node(const value_type& x) {\n    list_node* node = list_node_allocator::allocate();\n    __STL_TRY {\n      construct(&node->data, x);\n      node->next = 0;\n    }\n    __STL_UNWIND(list_node_allocator::deallocate(node));\n    return node;\n  }\n  \n  static void destroy_node(list_node* node) {\n    destroy(&node->data);\n    list_node_allocator::deallocate(node);\n  }\n\n  void fill_initialize(size_type n, const value_type& x) {\n    head.next = 0;\n    __STL_TRY {\n      _insert_after_fill(&head, n, x);\n    }\n    __STL_UNWIND(clear());\n  }    \n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void range_initialize(InputIterator first, InputIterator last) {\n    head.next = 0;\n    __STL_TRY {\n      _insert_after_range(&head, first, last);\n    }\n    __STL_UNWIND(clear());\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void range_initialize(const value_type* first, const value_type* last) {\n    head.next = 0;\n    __STL_TRY {\n      _insert_after_range(&head, first, last);\n    }\n    __STL_UNWIND(clear());\n  }\n  void range_initialize(const_iterator first, const_iterator last) {\n    head.next = 0;\n    __STL_TRY {\n      _insert_after_range(&head, first, last);\n    }\n    __STL_UNWIND(clear());\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\nprivate:\n  list_node_base head;\n\npublic:\n  slist() { head.next = 0; }\n\n  slist(size_type n, const value_type& x) { fill_initialize(n, x); }\n  slist(int n, const value_type& x) { fill_initialize(n, x); }\n  slist(long n, const value_type& x) { fill_initialize(n, x); }\n  explicit slist(size_type n) { fill_initialize(n, value_type()); }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  slist(InputIterator first, InputIterator last) {\n    range_initialize(first, last);\n  }\n\n#else /* __STL_MEMBER_TEMPLATES */\n  slist(const_iterator first, const_iterator last) {\n    range_initialize(first, last);\n  }\n  slist(const value_type* first, const value_type* last) {\n    range_initialize(first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  slist(const slist& L) { range_initialize(L.begin(), L.end()); }\n\n  slist& operator= (const slist& L);\n\n  ~slist() { clear(); }\n\npublic:\n\n  iterator begin() { return iterator((list_node*)head.next); }\n  const_iterator begin() const { return const_iterator((list_node*)head.next);}\n\n  iterator end() { return iterator(0); }\n  const_iterator end() const { return const_iterator(0); }\n\n  size_type size() const { return __slist_size(head.next); }\n  \n  size_type max_size() const { return size_type(-1); }\n\n  bool empty() const { return head.next == 0; }\n\n  void swap(slist& L)\n  {\n    list_node_base* tmp = head.next;\n    head.next = L.head.next;\n    L.head.next = tmp;\n  }\n\npublic:\n  friend bool operator== __STL_NULL_TMPL_ARGS(const slist<T, Alloc>& L1,\n                                              const slist<T, Alloc>& L2);\n\npublic:\n\n  reference front() { return ((list_node*) head.next)->data; }\n  const_reference front() const { return ((list_node*) head.next)->data; }\n  void push_front(const value_type& x)   {\n    __slist_make_link(&head, create_node(x));\n  }\n  void pop_front() {\n    list_node* node = (list_node*) head.next;\n    head.next = node->next;\n    destroy_node(node);\n  }\n\n  iterator previous(const_iterator pos) {\n    return iterator((list_node*) __slist_previous(&head, pos.node));\n  }\n  const_iterator previous(const_iterator pos) const {\n    return const_iterator((list_node*) __slist_previous(&head, pos.node));\n  }\n\nprivate:\n  list_node* _insert_after(list_node_base* pos, const value_type& x) {\n    return (list_node*) (__slist_make_link(pos, create_node(x)));\n  }\n\n  void _insert_after_fill(list_node_base* pos,\n                          size_type n, const value_type& x) {\n    for (size_type i = 0; i < n; ++i)\n      pos = __slist_make_link(pos, create_node(x));\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InIter>\n  void _insert_after_range(list_node_base* pos, InIter first, InIter last) {\n    while (first != last) {\n      pos = __slist_make_link(pos, create_node(*first));\n      ++first;\n    }\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void _insert_after_range(list_node_base* pos,\n                           const_iterator first, const_iterator last) {\n    while (first != last) {\n      pos = __slist_make_link(pos, create_node(*first));\n      ++first;\n    }\n  }\n  void _insert_after_range(list_node_base* pos,\n                           const value_type* first, const value_type* last) {\n    while (first != last) {\n      pos = __slist_make_link(pos, create_node(*first));\n      ++first;\n    }\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  list_node_base* erase_after(list_node_base* pos) {\n    list_node* next = (list_node*) (pos->next);\n    list_node_base* next_next = next->next;\n    pos->next = next_next;\n    destroy_node(next);\n    return next_next;\n  }\n   \n  list_node_base* erase_after(list_node_base* before_first,\n                              list_node_base* last_node) {\n    list_node* cur = (list_node*) (before_first->next);\n    while (cur != last_node) {\n      list_node* tmp = cur;\n      cur = (list_node*) cur->next;\n      destroy_node(tmp);\n    }\n    before_first->next = last_node;\n    return last_node;\n  }\n\n\npublic:\n\n  iterator insert_after(iterator pos, const value_type& x) {\n    return iterator(_insert_after(pos.node, x));\n  }\n\n  iterator insert_after(iterator pos) {\n    return insert_after(pos, value_type());\n  }\n\n  void insert_after(iterator pos, size_type n, const value_type& x) {\n    _insert_after_fill(pos.node, n, x);\n  }\n  void insert_after(iterator pos, int n, const value_type& x) {\n    _insert_after_fill(pos.node, (size_type) n, x);\n  }\n  void insert_after(iterator pos, long n, const value_type& x) {\n    _insert_after_fill(pos.node, (size_type) n, x);\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InIter>\n  void insert_after(iterator pos, InIter first, InIter last) {\n    _insert_after_range(pos.node, first, last);\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert_after(iterator pos, const_iterator first, const_iterator last) {\n    _insert_after_range(pos.node, first, last);\n  }\n  void insert_after(iterator pos,\n                    const value_type* first, const value_type* last) {\n    _insert_after_range(pos.node, first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  iterator insert(iterator pos, const value_type& x) {\n    return iterator(_insert_after(__slist_previous(&head, pos.node), x));\n  }\n\n  iterator insert(iterator pos) {\n    return iterator(_insert_after(__slist_previous(&head, pos.node),\n                                  value_type()));\n  }\n\n  void insert(iterator pos, size_type n, const value_type& x) {\n    _insert_after_fill(__slist_previous(&head, pos.node), n, x);\n  } \n  void insert(iterator pos, int n, const value_type& x) {\n    _insert_after_fill(__slist_previous(&head, pos.node), (size_type) n, x);\n  } \n  void insert(iterator pos, long n, const value_type& x) {\n    _insert_after_fill(__slist_previous(&head, pos.node), (size_type) n, x);\n  } \n    \n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InIter>\n  void insert(iterator pos, InIter first, InIter last) {\n    _insert_after_range(__slist_previous(&head, pos.node), first, last);\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator pos, const_iterator first, const_iterator last) {\n    _insert_after_range(__slist_previous(&head, pos.node), first, last);\n  }\n  void insert(iterator pos, const value_type* first, const value_type* last) {\n    _insert_after_range(__slist_previous(&head, pos.node), first, last);\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n\npublic:\n  iterator erase_after(iterator pos) {\n    return iterator((list_node*)erase_after(pos.node));\n  }\n  iterator erase_after(iterator before_first, iterator last) {\n    return iterator((list_node*)erase_after(before_first.node, last.node));\n  }\n\n  iterator erase(iterator pos) {\n    return (list_node*) erase_after(__slist_previous(&head, pos.node));\n  }\n  iterator erase(iterator first, iterator last) {\n    return (list_node*) erase_after(__slist_previous(&head, first.node),\n                                    last.node);\n  }\n\n  void resize(size_type new_size, const T& x);\n  void resize(size_type new_size) { resize(new_size, T()); }\n  void clear() { erase_after(&head, 0); }\n\npublic:\n  // Moves the range [before_first + 1, before_last + 1) to *this,\n  //  inserting it immediately after pos.  This is constant time.\n  void splice_after(iterator pos, \n                    iterator before_first, iterator before_last)\n  {\n    if (before_first != before_last) \n      __slist_splice_after(pos.node, before_first.node, before_last.node);\n  }\n\n  // Moves the element that follows prev to *this, inserting it immediately\n  //  after pos.  This is constant time.\n  void splice_after(iterator pos, iterator prev)\n  {\n    __slist_splice_after(pos.node, prev.node, prev.node->next);\n  }\n\n\n  // Linear in distance(begin(), pos), and linear in L.size().\n  void splice(iterator pos, slist& L) {\n    if (L.head.next)\n      __slist_splice_after(__slist_previous(&head, pos.node),\n                           &L.head,\n                           __slist_previous(&L.head, 0));\n  }\n\n  // Linear in distance(begin(), pos), and in distance(L.begin(), i).\n  void splice(iterator pos, slist& L, iterator i) {\n    __slist_splice_after(__slist_previous(&head, pos.node),\n                         __slist_previous(&L.head, i.node),\n                         i.node);\n  }\n\n  // Linear in distance(begin(), pos), in distance(L.begin(), first),\n  // and in distance(first, last).\n  void splice(iterator pos, slist& L, iterator first, iterator last)\n  {\n    if (first != last)\n      __slist_splice_after(__slist_previous(&head, pos.node),\n                           __slist_previous(&L.head, first.node),\n                           __slist_previous(first.node, last.node));\n  }\n\npublic:\n  void reverse() { if (head.next) head.next = __slist_reverse(head.next); }\n\n  void remove(const T& val); \n  void unique(); \n  void merge(slist& L);\n  void sort();     \n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class Predicate> void remove_if(Predicate pred);\n  template <class BinaryPredicate> void unique(BinaryPredicate pred); \n  template <class StrictWeakOrdering> void merge(slist&, StrictWeakOrdering); \n  template <class StrictWeakOrdering> void sort(StrictWeakOrdering comp); \n#endif /* __STL_MEMBER_TEMPLATES */\n};\n\ntemplate <class T, class Alloc>\nslist<T, Alloc>& slist<T,Alloc>::operator=(const slist<T, Alloc>& L)\n{\n  if (&L != this) {\n    list_node_base* p1 = &head;\n    list_node* n1 = (list_node*) head.next;\n    const list_node* n2 = (const list_node*) L.head.next;\n    while (n1 && n2) {\n      n1->data = n2->data;\n      p1 = n1;\n      n1 = (list_node*) n1->next;\n      n2 = (const list_node*) n2->next;\n    }\n    if (n2 == 0)\n      erase_after(p1, 0);\n    else\n      _insert_after_range(p1,\n                          const_iterator((list_node*)n2), const_iterator(0));\n  }\n  return *this;\n} \n\ntemplate <class T, class Alloc>\nbool operator==(const slist<T, Alloc>& L1, const slist<T, Alloc>& L2)\n{\n  typedef typename slist<T,Alloc>::list_node list_node;\n  list_node* n1 = (list_node*) L1.head.next;\n  list_node* n2 = (list_node*) L2.head.next;\n  while (n1 && n2 && n1->data == n2->data) {\n    n1 = (list_node*) n1->next;\n    n2 = (list_node*) n2->next;\n  }\n  return n1 == 0 && n2 == 0;\n}\n\ntemplate <class T, class Alloc>\ninline bool operator<(const slist<T, Alloc>& L1, const slist<T, Alloc>& L2)\n{\n  return lexicographical_compare(L1.begin(), L1.end(), L2.begin(), L2.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class T, class Alloc>\ninline void swap(slist<T, Alloc>& x, slist<T, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class T, class Alloc>\nvoid slist<T, Alloc>::resize(size_type len, const T& x)\n{\n  list_node_base* cur = &head;\n  while (cur->next != 0 && len > 0) {\n    --len;\n    cur = cur->next;\n  }\n  if (cur->next) \n    erase_after(cur, 0);\n  else\n    _insert_after_fill(cur, len, x);\n}\n\ntemplate <class T, class Alloc>\nvoid slist<T,Alloc>::remove(const T& val)\n{\n  list_node_base* cur = &head;\n  while (cur && cur->next) {\n    if (((list_node*) cur->next)->data == val)\n      erase_after(cur);\n    else\n      cur = cur->next;\n  }\n}\n\ntemplate <class T, class Alloc> \nvoid slist<T,Alloc>::unique()\n{\n  list_node_base* cur = head.next;\n  if (cur) {\n    while (cur->next) {\n      if (((list_node*)cur)->data == ((list_node*)(cur->next))->data)\n        erase_after(cur);\n      else\n        cur = cur->next;\n    }\n  }\n}\n\ntemplate <class T, class Alloc>\nvoid slist<T,Alloc>::merge(slist<T,Alloc>& L)\n{\n  list_node_base* n1 = &head;\n  while (n1->next && L.head.next) {\n    if (((list_node*) L.head.next)->data < ((list_node*) n1->next)->data) \n      __slist_splice_after(n1, &L.head, L.head.next);\n    n1 = n1->next;\n  }\n  if (L.head.next) {\n    n1->next = L.head.next;\n    L.head.next = 0;\n  }\n}\n\ntemplate <class T, class Alloc>\nvoid slist<T,Alloc>::sort()\n{\n  if (head.next && head.next->next) {\n    slist carry;\n    slist counter[64];\n    int fill = 0;\n    while (!empty()) {\n      __slist_splice_after(&carry.head, &head, head.next);\n      int i = 0;\n      while (i < fill && !counter[i].empty()) {\n        counter[i].merge(carry);\n        carry.swap(counter[i]);\n        ++i;\n      }\n      carry.swap(counter[i]);\n      if (i == fill)\n        ++fill;\n    }\n\n    for (int i = 1; i < fill; ++i)\n      counter[i].merge(counter[i-1]);\n    this->swap(counter[fill-1]);\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class T, class Alloc> \ntemplate <class Predicate> void slist<T,Alloc>::remove_if(Predicate pred)\n{\n  list_node_base* cur = &head;\n  while (cur->next) {\n    if (pred(((list_node*) cur->next)->data))\n      erase_after(cur);\n    else\n      cur = cur->next;\n  }\n}\n\ntemplate <class T, class Alloc> template <class BinaryPredicate> \nvoid slist<T,Alloc>::unique(BinaryPredicate pred)\n{\n  list_node* cur = (list_node*) head.next;\n  if (cur) {\n    while (cur->next) {\n      if (pred(((list_node*)cur)->data, ((list_node*)(cur->next))->data))\n        erase_after(cur);\n      else\n        cur = (list_node*) cur->next;\n    }\n  }\n}\n\ntemplate <class T, class Alloc> template <class StrictWeakOrdering>\nvoid slist<T,Alloc>::merge(slist<T,Alloc>& L, StrictWeakOrdering comp)\n{\n  list_node_base* n1 = &head;\n  while (n1->next && L.head.next) {\n    if (comp(((list_node*) L.head.next)->data,\n             ((list_node*) n1->next)->data))\n      __slist_splice_after(n1, &L.head, L.head.next);\n    n1 = n1->next;\n  }\n  if (L.head.next) {\n    n1->next = L.head.next;\n    L.head.next = 0;\n  }\n}\n\ntemplate <class T, class Alloc> template <class StrictWeakOrdering> \nvoid slist<T,Alloc>::sort(StrictWeakOrdering comp)\n{\n  if (head.next && head.next->next) {\n    slist carry;\n    slist counter[64];\n    int fill = 0;\n    while (!empty()) {\n      __slist_splice_after(&carry.head, &head, head.next);\n      int i = 0;\n      while (i < fill && !counter[i].empty()) {\n        counter[i].merge(carry, comp);\n        carry.swap(counter[i]);\n        ++i;\n      }\n      carry.swap(counter[i]);\n      if (i == fill)\n        ++fill;\n    }\n\n    for (int i = 1; i < fill; ++i)\n      counter[i].merge(counter[i-1], comp);\n    this->swap(counter[fill-1]);\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_SLIST_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_stack.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_STACK_H\n#define __SGI_STL_INTERNAL_STACK_H\n\n__STL_BEGIN_NAMESPACE\n\n#ifndef __STL_LIMITED_DEFAULT_TEMPLATES\ntemplate <class T, class Sequence = deque<T> >\n#else\ntemplate <class T, class Sequence>\n#endif\nclass stack {\n  friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);\n  friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);\npublic:\n  typedef typename Sequence::value_type value_type;\n  typedef typename Sequence::size_type size_type;\n  typedef typename Sequence::reference reference;\n  typedef typename Sequence::const_reference const_reference;\nprotected:\n  Sequence c;\npublic:\n  bool empty() const { return c.empty(); }\n  size_type size() const { return c.size(); }\n  reference top() { return c.back(); }\n  const_reference top() const { return c.back(); }\n  void push(const value_type& x) { c.push_back(x); }\n  void pop() { c.pop_back(); }\n};\n\ntemplate <class T, class Sequence>\nbool operator==(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {\n  return x.c == y.c;\n}\n\ntemplate <class T, class Sequence>\nbool operator<(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {\n  return x.c < y.c;\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_STACK_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_tempbuf.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_TEMPBUF_H\n#define __SGI_STL_INTERNAL_TEMPBUF_H\n\n\n__STL_BEGIN_NAMESPACE\n\ntemplate <class T>\npair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t len, T*) {\n  if (len > ptrdiff_t(INT_MAX / sizeof(T)))\n    len = INT_MAX / sizeof(T);\n\n  while (len > 0) {\n    T* tmp = (T*) malloc((size_t)len * sizeof(T));\n    if (tmp != 0)\n      return pair<T*, ptrdiff_t>(tmp, len);\n    len /= 2;\n  }\n\n  return pair<T*, ptrdiff_t>((T*)0, 0);\n}\n\ntemplate <class T>\nvoid return_temporary_buffer(T* p) {\n  free(p);\n}\n\ntemplate <class ForwardIterator,\n          class T \n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n                  = iterator_traits<ForwardIterator>::value_type \n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n         >\nclass temporary_buffer {\nprivate:\n  ptrdiff_t original_len;\n  ptrdiff_t len;\n  T* buffer;\n\n  void allocate_buffer() {\n    original_len = len;\n    buffer = 0;\n\n    if (len > (ptrdiff_t)(INT_MAX / sizeof(T)))\n      len = INT_MAX / sizeof(T);\n\n    while (len > 0) {\n      buffer = (T*) malloc(len * sizeof(T));\n      if (buffer)\n        break;\n      len /= 2;\n    }\n  }\n\n  void initialize_buffer(const T&, __true_type) {}\n  void initialize_buffer(const T& val, __false_type) {\n    uninitialized_fill_n(buffer, len, val);\n  }\n\npublic:\n  ptrdiff_t size() const { return len; }\n  ptrdiff_t requested_size() const { return original_len; }\n  T* begin() { return buffer; }\n  T* end() { return buffer + len; }\n\n  temporary_buffer(ForwardIterator first, ForwardIterator last) {\n    __STL_TRY {\n      len = 0;\n      distance(first, last, len);\n      allocate_buffer();\n      if (len > 0)\n        initialize_buffer(*first,\n                          typename __type_traits<T>::has_trivial_default_constructor());\n    }\n    __STL_UNWIND(free(buffer); buffer = 0; len = 0);\n  }\n \n  ~temporary_buffer() {  \n    destroy(buffer, buffer + len);\n    free(buffer);\n  }\n\nprivate:\n  temporary_buffer(const temporary_buffer&) {}\n  void operator=(const temporary_buffer&) {}\n};\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_tree.h",
    "content": "/*\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#define __SGI_STL_INTERNAL_TREE_H\n\n/*\n\nRed-black tree class, designed for use in implementing STL\nassociative containers (set, multiset, map, and multimap). The\ninsertion and deletion algorithms are based on those in Cormen,\nLeiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990),\nexcept that\n\n(1) the header cell is maintained with links not only to the root\nbut also to the leftmost node of the tree, to enable constant time\nbegin(), and to the rightmost node of the tree, to enable linear time\nperformance when used with the generic set algorithms (set_union,\netc.);\n\n(2) when a node being deleted has two children its successor node is\nrelinked into its place, rather than copied, so that the only\niterators invalidated are those referring to the deleted node.\n\n*/\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_function.h>\n\n__STL_BEGIN_NAMESPACE \n\ntypedef bool __rb_tree_color_type;\nconst __rb_tree_color_type __rb_tree_red = false;\nconst __rb_tree_color_type __rb_tree_black = true;\n\nstruct __rb_tree_node_base\n{\n  typedef __rb_tree_color_type color_type;\n  typedef __rb_tree_node_base* base_ptr;\n\n  color_type color; \n  base_ptr parent;\n  base_ptr left;\n  base_ptr right;\n\n  static base_ptr minimum(base_ptr x)\n  {\n    while (x->left != 0) x = x->left;\n    return x;\n  }\n\n  static base_ptr maximum(base_ptr x)\n  {\n    while (x->right != 0) x = x->right;\n    return x;\n  }\n};\n\ntemplate <class Value>\nstruct __rb_tree_node : public __rb_tree_node_base\n{\n  typedef __rb_tree_node<Value>* link_type;\n  Value value_field;\n};\n\n\nstruct __rb_tree_base_iterator\n{\n  typedef __rb_tree_node_base::base_ptr base_ptr;\n  typedef bidirectional_iterator_tag iterator_category;\n  typedef ptrdiff_t difference_type;\n  base_ptr node;\n\n  void increment()\n  {\n    if (node->right != 0) {\n      node = node->right;\n      while (node->left != 0)\n        node = node->left;\n    }\n    else {\n      base_ptr y = node->parent;\n      while (node == y->right) {\n        node = y;\n        y = y->parent;\n      }\n      if (node->right != y)\n        node = y;\n    }\n  }\n\n  void decrement()\n  {\n    if (node->color == __rb_tree_red &&\n        node->parent->parent == node)\n      node = node->right;\n    else if (node->left != 0) {\n      base_ptr y = node->left;\n      while (y->right != 0)\n        y = y->right;\n      node = y;\n    }\n    else {\n      base_ptr y = node->parent;\n      while (node == y->left) {\n        node = y;\n        y = y->parent;\n      }\n      node = y;\n    }\n  }\n};\n\ntemplate <class Value, class Ref, class Ptr>\nstruct __rb_tree_iterator : public __rb_tree_base_iterator\n{\n  typedef Value value_type;\n  typedef Ref reference;\n  typedef Ptr pointer;\n  typedef __rb_tree_iterator<Value, Value&, Value*>             iterator;\n  typedef __rb_tree_iterator<Value, const Value&, const Value*> const_iterator;\n  typedef __rb_tree_iterator<Value, Ref, Ptr>                   self;\n  typedef __rb_tree_node<Value>* link_type;\n\n  __rb_tree_iterator() {}\n  __rb_tree_iterator(link_type x) { node = x; }\n  __rb_tree_iterator(const iterator& it) { node = it.node; }\n\n  reference operator*() const { return link_type(node)->value_field; }\n#ifndef __SGI_STL_NO_ARROW_OPERATOR\n  pointer operator->() const { return &(operator*()); }\n#endif /* __SGI_STL_NO_ARROW_OPERATOR */\n\n  self& operator++() { increment(); return *this; }\n  self operator++(int) {\n    self tmp = *this;\n    increment();\n    return tmp;\n  }\n    \n  self& operator--() { decrement(); return *this; }\n  self operator--(int) {\n    self tmp = *this;\n    decrement();\n    return tmp;\n  }\n};\n\ninline bool operator==(const __rb_tree_base_iterator& x,\n                       const __rb_tree_base_iterator& y) {\n  return x.node == y.node;\n}\n\ninline bool operator!=(const __rb_tree_base_iterator& x,\n                       const __rb_tree_base_iterator& y) {\n  return x.node != y.node;\n}\n\n#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ninline bidirectional_iterator_tag\niterator_category(const __rb_tree_base_iterator&) {\n  return bidirectional_iterator_tag();\n}\n\ninline __rb_tree_base_iterator::difference_type*\ndistance_type(const __rb_tree_base_iterator&) {\n  return (__rb_tree_base_iterator::difference_type*) 0;\n}\n\ntemplate <class Value, class Ref, class Ptr>\ninline Value* value_type(const __rb_tree_iterator<Value, Ref, Ptr>&) {\n  return (Value*) 0;\n}\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\ninline void \n__rb_tree_rotate_left(__rb_tree_node_base* x, __rb_tree_node_base*& root)\n{\n  __rb_tree_node_base* y = x->right;\n  x->right = y->left;\n  if (y->left !=0)\n    y->left->parent = x;\n  y->parent = x->parent;\n\n  if (x == root)\n    root = y;\n  else if (x == x->parent->left)\n    x->parent->left = y;\n  else\n    x->parent->right = y;\n  y->left = x;\n  x->parent = y;\n}\n\ninline void \n__rb_tree_rotate_right(__rb_tree_node_base* x, __rb_tree_node_base*& root)\n{\n  __rb_tree_node_base* y = x->left;\n  x->left = y->right;\n  if (y->right != 0)\n    y->right->parent = x;\n  y->parent = x->parent;\n\n  if (x == root)\n    root = y;\n  else if (x == x->parent->right)\n    x->parent->right = y;\n  else\n    x->parent->left = y;\n  y->right = x;\n  x->parent = y;\n}\n\ninline void \n__rb_tree_rebalance(__rb_tree_node_base* x, __rb_tree_node_base*& root)\n{\n  x->color = __rb_tree_red;\n  while (x != root && x->parent->color == __rb_tree_red) {\n    if (x->parent == x->parent->parent->left) {\n      __rb_tree_node_base* y = x->parent->parent->right;\n      if (y && y->color == __rb_tree_red) {\n        x->parent->color = __rb_tree_black;\n        y->color = __rb_tree_black;\n        x->parent->parent->color = __rb_tree_red;\n        x = x->parent->parent;\n      }\n      else {\n        if (x == x->parent->right) {\n          x = x->parent;\n          __rb_tree_rotate_left(x, root);\n        }\n        x->parent->color = __rb_tree_black;\n        x->parent->parent->color = __rb_tree_red;\n        __rb_tree_rotate_right(x->parent->parent, root);\n      }\n    }\n    else {\n      __rb_tree_node_base* y = x->parent->parent->left;\n      if (y && y->color == __rb_tree_red) {\n        x->parent->color = __rb_tree_black;\n        y->color = __rb_tree_black;\n        x->parent->parent->color = __rb_tree_red;\n        x = x->parent->parent;\n      }\n      else {\n        if (x == x->parent->left) {\n          x = x->parent;\n          __rb_tree_rotate_right(x, root);\n        }\n        x->parent->color = __rb_tree_black;\n        x->parent->parent->color = __rb_tree_red;\n        __rb_tree_rotate_left(x->parent->parent, root);\n      }\n    }\n  }\n  root->color = __rb_tree_black;\n}\n\ninline __rb_tree_node_base*\n__rb_tree_rebalance_for_erase(__rb_tree_node_base* z,\n                              __rb_tree_node_base*& root,\n                              __rb_tree_node_base*& leftmost,\n                              __rb_tree_node_base*& rightmost)\n{\n  __rb_tree_node_base* y = z;\n  __rb_tree_node_base* x = 0;\n  __rb_tree_node_base* x_parent = 0;\n  if (y->left == 0)             // z has at most one non-null child. y == z.\n    x = y->right;               // x might be null.\n  else\n    if (y->right == 0)          // z has exactly one non-null child.  y == z.\n      x = y->left;              // x is not null.\n    else {                      // z has two non-null children.  Set y to\n      y = y->right;             //   z's successor.  x might be null.\n      while (y->left != 0)\n        y = y->left;\n      x = y->right;\n    }\n  if (y != z) {                 // relink y in place of z.  y is z's successor\n    z->left->parent = y; \n    y->left = z->left;\n    if (y != z->right) {\n      x_parent = y->parent;\n      if (x) x->parent = y->parent;\n      y->parent->left = x;      // y must be a left child\n      y->right = z->right;\n      z->right->parent = y;\n    }\n    else\n      x_parent = y;  \n    if (root == z)\n      root = y;\n    else if (z->parent->left == z)\n      z->parent->left = y;\n    else \n      z->parent->right = y;\n    y->parent = z->parent;\n    __STD::swap(y->color, z->color);\n    y = z;\n    // y now points to node to be actually deleted\n  }\n  else {                        // y == z\n    x_parent = y->parent;\n    if (x) x->parent = y->parent;   \n    if (root == z)\n      root = x;\n    else \n      if (z->parent->left == z)\n        z->parent->left = x;\n      else\n        z->parent->right = x;\n    if (leftmost == z) \n      if (z->right == 0)        // z->left must be null also\n        leftmost = z->parent;\n    // makes leftmost == header if z == root\n      else\n        leftmost = __rb_tree_node_base::minimum(x);\n    if (rightmost == z)  \n      if (z->left == 0)         // z->right must be null also\n        rightmost = z->parent;  \n    // makes rightmost == header if z == root\n      else                      // x == z->left\n        rightmost = __rb_tree_node_base::maximum(x);\n  }\n  if (y->color != __rb_tree_red) { \n    while (x != root && (x == 0 || x->color == __rb_tree_black))\n      if (x == x_parent->left) {\n        __rb_tree_node_base* w = x_parent->right;\n        if (w->color == __rb_tree_red) {\n          w->color = __rb_tree_black;\n          x_parent->color = __rb_tree_red;\n          __rb_tree_rotate_left(x_parent, root);\n          w = x_parent->right;\n        }\n        if ((w->left == 0 || w->left->color == __rb_tree_black) &&\n            (w->right == 0 || w->right->color == __rb_tree_black)) {\n          w->color = __rb_tree_red;\n          x = x_parent;\n          x_parent = x_parent->parent;\n        } else {\n          if (w->right == 0 || w->right->color == __rb_tree_black) {\n            if (w->left) w->left->color = __rb_tree_black;\n            w->color = __rb_tree_red;\n            __rb_tree_rotate_right(w, root);\n            w = x_parent->right;\n          }\n          w->color = x_parent->color;\n          x_parent->color = __rb_tree_black;\n          if (w->right) w->right->color = __rb_tree_black;\n          __rb_tree_rotate_left(x_parent, root);\n          break;\n        }\n      } else {                  // same as above, with right <-> left.\n        __rb_tree_node_base* w = x_parent->left;\n        if (w->color == __rb_tree_red) {\n          w->color = __rb_tree_black;\n          x_parent->color = __rb_tree_red;\n          __rb_tree_rotate_right(x_parent, root);\n          w = x_parent->left;\n        }\n        if ((w->right == 0 || w->right->color == __rb_tree_black) &&\n            (w->left == 0 || w->left->color == __rb_tree_black)) {\n          w->color = __rb_tree_red;\n          x = x_parent;\n          x_parent = x_parent->parent;\n        } else {\n          if (w->left == 0 || w->left->color == __rb_tree_black) {\n            if (w->right) w->right->color = __rb_tree_black;\n            w->color = __rb_tree_red;\n            __rb_tree_rotate_left(w, root);\n            w = x_parent->left;\n          }\n          w->color = x_parent->color;\n          x_parent->color = __rb_tree_black;\n          if (w->left) w->left->color = __rb_tree_black;\n          __rb_tree_rotate_right(x_parent, root);\n          break;\n        }\n      }\n    if (x) x->color = __rb_tree_black;\n  }\n  return y;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare,\n          class Alloc = alloc>\nclass rb_tree {\nprotected:\n  typedef void* void_pointer;\n  typedef __rb_tree_node_base* base_ptr;\n  typedef __rb_tree_node<Value> rb_tree_node;\n  typedef simple_alloc<rb_tree_node, Alloc> rb_tree_node_allocator;\n  typedef __rb_tree_color_type color_type;\npublic:\n  typedef Key key_type;\n  typedef Value value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef rb_tree_node* link_type;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\nprotected:\n  link_type get_node() { return rb_tree_node_allocator::allocate(); }\n  void put_node(link_type p) { rb_tree_node_allocator::deallocate(p); }\n\n  link_type create_node(const value_type& x) {\n    link_type tmp = get_node();\n    __STL_TRY {\n      construct(&tmp->value_field, x);\n    }\n    __STL_UNWIND(put_node(tmp));\n    return tmp;\n  }\n\n  link_type clone_node(link_type x) {\n    link_type tmp = create_node(x->value_field);\n    tmp->color = x->color;\n    tmp->left = 0;\n    tmp->right = 0;\n    return tmp;\n  }\n\n  void destroy_node(link_type p) {\n    destroy(&p->value_field);\n    put_node(p);\n  }\n\nprotected:\n  size_type node_count; // keeps track of size of tree\n  link_type header;  \n  Compare key_compare;\n\n  link_type& root() const { return (link_type&) header->parent; }\n  link_type& leftmost() const { return (link_type&) header->left; }\n  link_type& rightmost() const { return (link_type&) header->right; }\n\n  static link_type& left(link_type x) { return (link_type&)(x->left); }\n  static link_type& right(link_type x) { return (link_type&)(x->right); }\n  static link_type& parent(link_type x) { return (link_type&)(x->parent); }\n  static reference value(link_type x) { return x->value_field; }\n  static const Key& key(link_type x) { return KeyOfValue()(value(x)); }\n  static color_type& color(link_type x) { return (color_type&)(x->color); }\n\n  static link_type& left(base_ptr x) { return (link_type&)(x->left); }\n  static link_type& right(base_ptr x) { return (link_type&)(x->right); }\n  static link_type& parent(base_ptr x) { return (link_type&)(x->parent); }\n  static reference value(base_ptr x) { return ((link_type)x)->value_field; }\n  static const Key& key(base_ptr x) { return KeyOfValue()(value(link_type(x)));} \n  static color_type& color(base_ptr x) { return (color_type&)(link_type(x)->color); }\n\n  static link_type minimum(link_type x) { \n    return (link_type)  __rb_tree_node_base::minimum(x);\n  }\n  static link_type maximum(link_type x) {\n    return (link_type) __rb_tree_node_base::maximum(x);\n  }\n\npublic:\n  typedef __rb_tree_iterator<value_type, reference, pointer> iterator;\n  typedef __rb_tree_iterator<value_type, const_reference, const_pointer> \n          const_iterator;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_bidirectional_iterator<iterator, value_type, reference,\n                                         difference_type>\n          reverse_iterator; \n  typedef reverse_bidirectional_iterator<const_iterator, value_type,\n                                         const_reference, difference_type>\n          const_reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ \nprivate:\n  iterator __insert(base_ptr x, base_ptr y, const value_type& v);\n  link_type __copy(link_type x, link_type p);\n  void __erase(link_type x);\n  void init() {\n    header = get_node();\n    color(header) = __rb_tree_red; // used to distinguish header from \n                                   // root, in iterator.operator++\n    root() = 0;\n    leftmost() = header;\n    rightmost() = header;\n  }\npublic:\n                                // allocation/deallocation\n  rb_tree(const Compare& comp = Compare())\n    : node_count(0), key_compare(comp) { init(); }\n\n  rb_tree(const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x) \n    : node_count(0), key_compare(x.key_compare)\n  { \n    header = get_node();\n    color(header) = __rb_tree_red;\n    if (x.root() == 0) {\n      root() = 0;\n      leftmost() = header;\n      rightmost() = header;\n    }\n    else {\n      __STL_TRY {\n        root() = __copy(x.root(), header);\n      }\n      __STL_UNWIND(put_node(header));\n      leftmost() = minimum(root());\n      rightmost() = maximum(root());\n    }\n    node_count = x.node_count;\n  }\n  ~rb_tree() {\n    clear();\n    put_node(header);\n  }\n  rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& \n  operator=(const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x);\n\npublic:    \n                                // accessors:\n  Compare key_comp() const { return key_compare; }\n  iterator begin() { return leftmost(); }\n  const_iterator begin() const { return leftmost(); }\n  iterator end() { return header; }\n  const_iterator end() const { return header; }\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin());\n  } \n  bool empty() const { return node_count == 0; }\n  size_type size() const { return node_count; }\n  size_type max_size() const { return size_type(-1); }\n\n  void swap(rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& t) {\n    __STD::swap(header, t.header);\n    __STD::swap(node_count, t.node_count);\n    __STD::swap(key_compare, t.key_compare);\n  }\n    \npublic:\n                                // insert/erase\n  pair<iterator,bool> insert_unique(const value_type& x);\n  iterator insert_equal(const value_type& x);\n\n  iterator insert_unique(iterator position, const value_type& x);\n  iterator insert_equal(iterator position, const value_type& x);\n\n#ifdef __STL_MEMBER_TEMPLATES  \n  template <class InputIterator>\n  void insert_unique(InputIterator first, InputIterator last);\n  template <class InputIterator>\n  void insert_equal(InputIterator first, InputIterator last);\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert_unique(const_iterator first, const_iterator last);\n  void insert_unique(const value_type* first, const value_type* last);\n  void insert_equal(const_iterator first, const_iterator last);\n  void insert_equal(const value_type* first, const value_type* last);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void erase(iterator position);\n  size_type erase(const key_type& x);\n  void erase(iterator first, iterator last);\n  void erase(const key_type* first, const key_type* last);\n  void clear() {\n    if (node_count != 0) {\n      __erase(root());\n      leftmost() = header;\n      root() = 0;\n      rightmost() = header;\n      node_count = 0;\n    }\n  }      \n\npublic:\n                                // set operations:\n  iterator find(const key_type& x);\n  const_iterator find(const key_type& x) const;\n  size_type count(const key_type& x) const;\n  iterator lower_bound(const key_type& x);\n  const_iterator lower_bound(const key_type& x) const;\n  iterator upper_bound(const key_type& x);\n  const_iterator upper_bound(const key_type& x) const;\n  pair<iterator,iterator> equal_range(const key_type& x);\n  pair<const_iterator, const_iterator> equal_range(const key_type& x) const;\n\npublic:\n                                // Debugging.\n  bool __rb_verify() const;\n};\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ninline bool operator==(const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x, \n                       const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& y) {\n  return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ninline bool operator<(const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x, \n                      const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& y) {\n  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ninline void swap(rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x, \n                 rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>& \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::\noperator=(const rb_tree<Key, Value, KeyOfValue, Compare, Alloc>& x) {\n  if (this != &x) {\n                                // Note that Key may be a constant type.\n    clear();\n    node_count = 0;\n    key_compare = x.key_compare;        \n    if (x.root() == 0) {\n      root() = 0;\n      leftmost() = header;\n      rightmost() = header;\n    }\n    else {\n      root() = __copy(x.root(), header);\n      leftmost() = minimum(root());\n      rightmost() = maximum(root());\n      node_count = x.node_count;\n    }\n  }\n  return *this;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::\n__insert(base_ptr x_, base_ptr y_, const Value& v) {\n  link_type x = (link_type) x_;\n  link_type y = (link_type) y_;\n  link_type z;\n\n  if (y == header || x != 0 || key_compare(KeyOfValue()(v), key(y))) {\n    z = create_node(v);\n    left(y) = z;                // also makes leftmost() = z when y == header\n    if (y == header) {\n      root() = z;\n      rightmost() = z;\n    }\n    else if (y == leftmost())\n      leftmost() = z;           // maintain leftmost() pointing to min node\n  }\n  else {\n    z = create_node(v);\n    right(y) = z;\n    if (y == rightmost())\n      rightmost() = z;          // maintain rightmost() pointing to max node\n  }\n  parent(z) = y;\n  left(z) = 0;\n  right(z) = 0;\n  __rb_tree_rebalance(z, header->parent);\n  ++node_count;\n  return iterator(z);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::insert_equal(const Value& v)\n{\n  link_type y = header;\n  link_type x = root();\n  while (x != 0) {\n    y = x;\n    x = key_compare(KeyOfValue()(v), key(x)) ? left(x) : right(x);\n  }\n  return __insert(x, y, v);\n}\n\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\npair<typename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator, bool>\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::insert_unique(const Value& v)\n{\n  link_type y = header;\n  link_type x = root();\n  bool comp = true;\n  while (x != 0) {\n    y = x;\n    comp = key_compare(KeyOfValue()(v), key(x));\n    x = comp ? left(x) : right(x);\n  }\n  iterator j = iterator(y);   \n  if (comp)\n    if (j == begin())     \n      return pair<iterator,bool>(__insert(x, y, v), true);\n    else\n      --j;\n  if (key_compare(key(j.node), KeyOfValue()(v)))\n    return pair<iterator,bool>(__insert(x, y, v), true);\n  return pair<iterator,bool>(j, false);\n}\n\n\ntemplate <class Key, class Val, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Val, KeyOfValue, Compare, Alloc>::iterator \nrb_tree<Key, Val, KeyOfValue, Compare, Alloc>::insert_unique(iterator position,\n                                                             const Val& v) {\n  if (position.node == header->left) // begin()\n    if (size() > 0 && key_compare(KeyOfValue()(v), key(position.node)))\n      return __insert(position.node, position.node, v);\n  // first argument just needs to be non-null \n    else\n      return insert_unique(v).first;\n  else if (position.node == header) // end()\n    if (key_compare(key(rightmost()), KeyOfValue()(v)))\n      return __insert(0, rightmost(), v);\n    else\n      return insert_unique(v).first;\n  else {\n    iterator before = position;\n    --before;\n    if (key_compare(key(before.node), KeyOfValue()(v))\n        && key_compare(KeyOfValue()(v), key(position.node)))\n      if (right(before.node) == 0)\n        return __insert(0, before.node, v); \n      else\n        return __insert(position.node, position.node, v);\n    // first argument just needs to be non-null \n    else\n      return insert_unique(v).first;\n  }\n}\n\ntemplate <class Key, class Val, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Val, KeyOfValue, Compare, Alloc>::iterator \nrb_tree<Key, Val, KeyOfValue, Compare, Alloc>::insert_equal(iterator position,\n                                                            const Val& v) {\n  if (position.node == header->left) // begin()\n    if (size() > 0 && key_compare(KeyOfValue()(v), key(position.node)))\n      return __insert(position.node, position.node, v);\n  // first argument just needs to be non-null \n    else\n      return insert_equal(v);\n  else if (position.node == header) // end()\n    if (!key_compare(KeyOfValue()(v), key(rightmost())))\n      return __insert(0, rightmost(), v);\n    else\n      return insert_equal(v);\n  else {\n    iterator before = position;\n    --before;\n    if (!key_compare(KeyOfValue()(v), key(before.node))\n        && !key_compare(key(position.node), KeyOfValue()(v)))\n      if (right(before.node) == 0)\n        return __insert(0, before.node, v); \n      else\n        return __insert(position.node, position.node, v);\n    // first argument just needs to be non-null \n    else\n      return insert_equal(v);\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES  \n\ntemplate <class K, class V, class KoV, class Cmp, class Al> template<class II>\nvoid rb_tree<K, V, KoV, Cmp, Al>::insert_equal(II first, II last) {\n  for ( ; first != last; ++first)\n    insert_equal(*first);\n}\n\ntemplate <class K, class V, class KoV, class Cmp, class Al> template<class II>\nvoid rb_tree<K, V, KoV, Cmp, Al>::insert_unique(II first, II last) {\n  for ( ; first != last; ++first)\n    insert_unique(*first);\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class K, class V, class KoV, class Cmp, class Al>\nvoid\nrb_tree<K, V, KoV, Cmp, Al>::insert_equal(const V* first, const V* last) {\n  for ( ; first != last; ++first)\n    insert_equal(*first);\n}\n\ntemplate <class K, class V, class KoV, class Cmp, class Al>\nvoid\nrb_tree<K, V, KoV, Cmp, Al>::insert_equal(const_iterator first,\n                                          const_iterator last) {\n  for ( ; first != last; ++first)\n    insert_equal(*first);\n}\n\ntemplate <class K, class V, class KoV, class Cmp, class A>\nvoid \nrb_tree<K, V, KoV, Cmp, A>::insert_unique(const V* first, const V* last) {\n  for ( ; first != last; ++first)\n    insert_unique(*first);\n}\n\ntemplate <class K, class V, class KoV, class Cmp, class A>\nvoid \nrb_tree<K, V, KoV, Cmp, A>::insert_unique(const_iterator first,\n                                          const_iterator last) {\n  for ( ; first != last; ++first)\n    insert_unique(*first);\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n         \ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ninline void\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::erase(iterator position) {\n  link_type y = (link_type) __rb_tree_rebalance_for_erase(position.node,\n                                                          header->parent,\n                                                          header->left,\n                                                          header->right);\n  destroy_node(y);\n  --node_count;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::size_type \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::erase(const Key& x) {\n  pair<iterator,iterator> p = equal_range(x);\n  size_type n = 0;\n  distance(p.first, p.second, n);\n  erase(p.first, p.second);\n  return n;\n}\n\ntemplate <class K, class V, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<K, V, KeyOfValue, Compare, Alloc>::link_type \nrb_tree<K, V, KeyOfValue, Compare, Alloc>::__copy(link_type x, link_type p) {\n                                // structural copy.  x and p must be non-null.\n  link_type top = clone_node(x);\n  top->parent = p;\n \n  __STL_TRY {\n    if (x->right)\n      top->right = __copy(right(x), top);\n    p = top;\n    x = left(x);\n\n    while (x != 0) {\n      link_type y = clone_node(x);\n      p->left = y;\n      y->parent = p;\n      if (x->right)\n        y->right = __copy(right(x), y);\n      p = y;\n      x = left(x);\n    }\n  }\n  __STL_UNWIND(__erase(top));\n\n  return top;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\nvoid rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::__erase(link_type x) {\n                                // erase without rebalancing\n  while (x != 0) {\n    __erase(right(x));\n    link_type y = left(x);\n    destroy_node(x);\n    x = y;\n  }\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\nvoid rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::erase(iterator first, \n                                                            iterator last) {\n  if (first == begin() && last == end())\n    clear();\n  else\n    while (first != last) erase(first++);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\nvoid rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::erase(const Key* first, \n                                                            const Key* last) {\n  while (first != last) erase(*first++);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::find(const Key& k) {\n  link_type y = header;        // Last node which is not less than k. \n  link_type x = root();        // Current node. \n\n  while (x != 0) \n    if (!key_compare(key(x), k))\n      y = x, x = left(x);\n    else\n      x = right(x);\n\n  iterator j = iterator(y);   \n  return (j == end() || key_compare(k, key(j.node))) ? end() : j;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::const_iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::find(const Key& k) const {\n  link_type y = header; /* Last node which is not less than k. */\n  link_type x = root(); /* Current node. */\n\n  while (x != 0) {\n    if (!key_compare(key(x), k))\n      y = x, x = left(x);\n    else\n      x = right(x);\n  }\n  const_iterator j = const_iterator(y);   \n  return (j == end() || key_compare(k, key(j.node))) ? end() : j;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::size_type \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::count(const Key& k) const {\n  pair<const_iterator, const_iterator> p = equal_range(k);\n  size_type n = 0;\n  distance(p.first, p.second, n);\n  return n;\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::lower_bound(const Key& k) {\n  link_type y = header; /* Last node which is not less than k. */\n  link_type x = root(); /* Current node. */\n\n  while (x != 0) \n    if (!key_compare(key(x), k))\n      y = x, x = left(x);\n    else\n      x = right(x);\n\n  return iterator(y);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::const_iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::lower_bound(const Key& k) const {\n  link_type y = header; /* Last node which is not less than k. */\n  link_type x = root(); /* Current node. */\n\n  while (x != 0) \n    if (!key_compare(key(x), k))\n      y = x, x = left(x);\n    else\n      x = right(x);\n\n  return const_iterator(y);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::upper_bound(const Key& k) {\n  link_type y = header; /* Last node which is greater than k. */\n  link_type x = root(); /* Current node. */\n\n   while (x != 0) \n     if (key_compare(k, key(x)))\n       y = x, x = left(x);\n     else\n       x = right(x);\n\n   return iterator(y);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ntypename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::const_iterator \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::upper_bound(const Key& k) const {\n  link_type y = header; /* Last node which is greater than k. */\n  link_type x = root(); /* Current node. */\n\n   while (x != 0) \n     if (key_compare(k, key(x)))\n       y = x, x = left(x);\n     else\n       x = right(x);\n\n   return const_iterator(y);\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\ninline pair<typename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator,\n            typename rb_tree<Key, Value, KeyOfValue, Compare, Alloc>::iterator>\nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::equal_range(const Key& k) {\n  return pair<iterator, iterator>(lower_bound(k), upper_bound(k));\n}\n\ntemplate <class Key, class Value, class KoV, class Compare, class Alloc>\ninline pair<typename rb_tree<Key, Value, KoV, Compare, Alloc>::const_iterator,\n            typename rb_tree<Key, Value, KoV, Compare, Alloc>::const_iterator>\nrb_tree<Key, Value, KoV, Compare, Alloc>::equal_range(const Key& k) const {\n  return pair<const_iterator,const_iterator>(lower_bound(k), upper_bound(k));\n}\n\ninline int __black_count(__rb_tree_node_base* node, __rb_tree_node_base* root)\n{\n  if (node == 0)\n    return 0;\n  else {\n    int bc = node->color == __rb_tree_black ? 1 : 0;\n    if (node == root)\n      return bc;\n    else\n      return bc + __black_count(node->parent, root);\n  }\n}\n\ntemplate <class Key, class Value, class KeyOfValue, class Compare, class Alloc>\nbool \nrb_tree<Key, Value, KeyOfValue, Compare, Alloc>::__rb_verify() const\n{\n  if (node_count == 0 || begin() == end())\n    return node_count == 0 && begin() == end() &&\n      header->left == header && header->right == header;\n  \n  int len = __black_count(leftmost(), root());\n  for (const_iterator it = begin(); it != end(); ++it) {\n    link_type x = (link_type) it.node;\n    link_type L = left(x);\n    link_type R = right(x);\n\n    if (x->color == __rb_tree_red)\n      if ((L && L->color == __rb_tree_red) ||\n          (R && R->color == __rb_tree_red))\n        return false;\n\n    if (L && key_compare(key(x), key(L)))\n      return false;\n    if (R && key_compare(key(R), key(x)))\n      return false;\n\n    if (!L && !R && __black_count(x, root()) != len)\n      return false;\n  }\n\n  if (leftmost() != __rb_tree_node_base::minimum(root()))\n    return false;\n  if (rightmost() != __rb_tree_node_base::maximum(root()))\n    return false;\n\n  return true;\n}\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_TREE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_uninitialized.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H\n#define __SGI_STL_INTERNAL_UNINITIALIZED_H\n\n__STL_BEGIN_NAMESPACE\n\n// Valid if copy construction is equivalent to assignment, and if the\n//  destructor is trivial.\ntemplate <class InputIterator, class ForwardIterator>\ninline ForwardIterator \n__uninitialized_copy_aux(InputIterator first, InputIterator last,\n                         ForwardIterator result,\n                         __true_type) {\n  return copy(first, last, result);\n}\n\ntemplate <class InputIterator, class ForwardIterator>\nForwardIterator \n__uninitialized_copy_aux(InputIterator first, InputIterator last,\n                         ForwardIterator result,\n                         __false_type) {\n  ForwardIterator cur = result;\n  __STL_TRY {\n    for ( ; first != last; ++first, ++cur)\n      construct(&*cur, *first);\n    return cur;\n  }\n  __STL_UNWIND(destroy(result, cur));\n}\n\n\ntemplate <class InputIterator, class ForwardIterator, class T>\ninline ForwardIterator\n__uninitialized_copy(InputIterator first, InputIterator last,\n                     ForwardIterator result, T*) {\n  typedef typename __type_traits<T>::is_POD_type is_POD;\n  return __uninitialized_copy_aux(first, last, result, is_POD());\n}\n\ntemplate <class InputIterator, class ForwardIterator>\ninline ForwardIterator\n  uninitialized_copy(InputIterator first, InputIterator last,\n                     ForwardIterator result) {\n  return __uninitialized_copy(first, last, result, value_type(result));\n}\n\ninline char* uninitialized_copy(const char* first, const char* last,\n                                char* result) {\n  memmove(result, first, last - first);\n  return result + (last - first);\n}\n\ninline wchar_t* uninitialized_copy(const wchar_t* first, const wchar_t* last,\n                                   wchar_t* result) {\n  memmove(result, first, sizeof(wchar_t) * (last - first));\n  return result + (last - first);\n}\n\ntemplate <class InputIterator, class Size, class ForwardIterator>\npair<InputIterator, ForwardIterator>\n__uninitialized_copy_n(InputIterator first, Size count,\n                       ForwardIterator result,\n                       input_iterator_tag) {\n  ForwardIterator cur = result;\n  __STL_TRY {\n    for ( ; count > 0 ; --count, ++first, ++cur) \n      construct(&*cur, *first);\n    return pair<InputIterator, ForwardIterator>(first, cur);\n  }\n  __STL_UNWIND(destroy(result, cur));\n}\n\ntemplate <class RandomAccessIterator, class Size, class ForwardIterator>\ninline pair<RandomAccessIterator, ForwardIterator>\n__uninitialized_copy_n(RandomAccessIterator first, Size count,\n                       ForwardIterator result,\n                       random_access_iterator_tag) {\n  RandomAccessIterator last = first + count;\n  return make_pair(last, uninitialized_copy(first, last, result));\n}\n\ntemplate <class InputIterator, class Size, class ForwardIterator>\ninline pair<InputIterator, ForwardIterator>\nuninitialized_copy_n(InputIterator first, Size count,\n                     ForwardIterator result) {\n  return __uninitialized_copy_n(first, count, result,\n                                iterator_category(first));\n}\n\n// Valid if copy construction is equivalent to assignment, and if the\n//  destructor is trivial.\ntemplate <class ForwardIterator, class T>\ninline void\n__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, \n                         const T& x, __true_type)\n{\n  fill(first, last, x);\n}\n\ntemplate <class ForwardIterator, class T>\nvoid\n__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, \n                         const T& x, __false_type)\n{\n  ForwardIterator cur = first;\n  __STL_TRY {\n    for ( ; cur != last; ++cur)\n      construct(&*cur, x);\n  }\n  __STL_UNWIND(destroy(first, cur));\n}\n\ntemplate <class ForwardIterator, class T, class T1>\ninline void __uninitialized_fill(ForwardIterator first, ForwardIterator last, \n                                 const T& x, T1*) {\n  typedef typename __type_traits<T1>::is_POD_type is_POD;\n  __uninitialized_fill_aux(first, last, x, is_POD());\n                   \n}\n\ntemplate <class ForwardIterator, class T>\ninline void uninitialized_fill(ForwardIterator first, ForwardIterator last, \n                               const T& x) {\n  __uninitialized_fill(first, last, x, value_type(first));\n}\n\n// Valid if copy construction is equivalent to assignment, and if the\n//  destructor is trivial.\ntemplate <class ForwardIterator, class Size, class T>\ninline ForwardIterator\n__uninitialized_fill_n_aux(ForwardIterator first, Size n,\n                           const T& x, __true_type) {\n  return fill_n(first, n, x);\n}\n\ntemplate <class ForwardIterator, class Size, class T>\nForwardIterator\n__uninitialized_fill_n_aux(ForwardIterator first, Size n,\n                           const T& x, __false_type) {\n  ForwardIterator cur = first;\n  __STL_TRY {\n    for ( ; n > 0; --n, ++cur)\n      construct(&*cur, x);\n    return cur;\n  }\n  __STL_UNWIND(destroy(first, cur));\n}\n\ntemplate <class ForwardIterator, class Size, class T, class T1>\ninline ForwardIterator __uninitialized_fill_n(ForwardIterator first, Size n,\n                                              const T& x, T1*) {\n  typedef typename __type_traits<T1>::is_POD_type is_POD;\n  return __uninitialized_fill_n_aux(first, n, x, is_POD());\n                                    \n}\n\ntemplate <class ForwardIterator, class Size, class T>\ninline ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n,\n                                            const T& x) {\n  return __uninitialized_fill_n(first, n, x, value_type(first));\n}\n\n// Copies [first1, last1) into [result, result + (last1 - first1)), and\n//  copies [first2, last2) into\n//  [result, result + (last1 - first1) + (last2 - first2)).\n\ntemplate <class InputIterator1, class InputIterator2, class ForwardIterator>\ninline ForwardIterator\n__uninitialized_copy_copy(InputIterator1 first1, InputIterator1 last1,\n                          InputIterator2 first2, InputIterator2 last2,\n                          ForwardIterator result) {\n  ForwardIterator mid = uninitialized_copy(first1, last1, result);\n  __STL_TRY {\n    return uninitialized_copy(first2, last2, mid);\n  }\n  __STL_UNWIND(destroy(result, mid));\n}\n\n// Fills [result, mid) with x, and copies [first, last) into\n//  [mid, mid + (last - first)).\ntemplate <class ForwardIterator, class T, class InputIterator>\ninline ForwardIterator \n__uninitialized_fill_copy(ForwardIterator result, ForwardIterator mid,\n                          const T& x,\n                          InputIterator first, InputIterator last) {\n  uninitialized_fill(result, mid, x);\n  __STL_TRY {\n    return uninitialized_copy(first, last, mid);\n  }\n  __STL_UNWIND(destroy(result, mid));\n}\n\n// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and\n//  fills [first2 + (last1 - first1), last2) with x.\ntemplate <class InputIterator, class ForwardIterator, class T>\ninline void\n__uninitialized_copy_fill(InputIterator first1, InputIterator last1,\n                          ForwardIterator first2, ForwardIterator last2,\n                          const T& x) {\n  ForwardIterator mid2 = uninitialized_copy(first1, last1, first2);\n  __STL_TRY {\n    uninitialized_fill(mid2, last2, x);\n  }\n  __STL_UNWIND(destroy(first2, mid2));\n}\n\n__STL_END_NAMESPACE\n\n#endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stl_vector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n/* NOTE: This is an internal header file, included by other STL headers.\n *   You should not attempt to use it directly.\n */\n\n#ifndef __SGI_STL_INTERNAL_VECTOR_H\n#define __SGI_STL_INTERNAL_VECTOR_H\n\n__STL_BEGIN_NAMESPACE \n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma set woff 1174\n#endif\n\ntemplate <class T, class Alloc = alloc>\nclass vector {\npublic:\n  typedef T value_type;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type* iterator;\n  typedef const value_type* const_iterator;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n  typedef reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef reverse_iterator<iterator> reverse_iterator;\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n  typedef reverse_iterator<const_iterator, value_type, const_reference, \n                           difference_type>  const_reverse_iterator;\n  typedef reverse_iterator<iterator, value_type, reference, difference_type>\n          reverse_iterator;\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\nprotected:\n  typedef simple_alloc<value_type, Alloc> data_allocator;\n  iterator start;\n  iterator finish;\n  iterator end_of_storage;\n  void insert_aux(iterator position, const T& x);\n  void deallocate() {\n    if (start) data_allocator::deallocate(start, end_of_storage - start);\n  }\n\n  void fill_initialize(size_type n, const T& value) {\n    start = allocate_and_fill(n, value);\n    finish = start + n;\n    end_of_storage = finish;\n  }\npublic:\n  iterator begin() { return start; }\n  const_iterator begin() const { return start; }\n  iterator end() { return finish; }\n  const_iterator end() const { return finish; }\n  reverse_iterator rbegin() { return reverse_iterator(end()); }\n  const_reverse_iterator rbegin() const { \n    return const_reverse_iterator(end()); \n  }\n  reverse_iterator rend() { return reverse_iterator(begin()); }\n  const_reverse_iterator rend() const { \n    return const_reverse_iterator(begin()); \n  }\n  size_type size() const { return size_type(end() - begin()); }\n  size_type max_size() const { return size_type(-1) / sizeof(T); }\n  size_type capacity() const { return size_type(end_of_storage - begin()); }\n  bool empty() const { return begin() == end(); }\n  reference operator[](size_type n) { return *(begin() + n); }\n  const_reference operator[](size_type n) const { return *(begin() + n); }\n\n  vector() : start(0), finish(0), end_of_storage(0) {}\n  vector(size_type n, const T& value) { fill_initialize(n, value); }\n  vector(int n, const T& value) { fill_initialize(n, value); }\n  vector(long n, const T& value) { fill_initialize(n, value); }\n  explicit vector(size_type n) { fill_initialize(n, T()); }\n\n  vector(const vector<T, Alloc>& x) {\n    start = allocate_and_copy(x.end() - x.begin(), x.begin(), x.end());\n    finish = start + (x.end() - x.begin());\n    end_of_storage = finish;\n  }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  vector(InputIterator first, InputIterator last) :\n    start(0), finish(0), end_of_storage(0)\n  {\n    range_initialize(first, last, iterator_category(first));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  vector(const_iterator first, const_iterator last) {\n    size_type n = 0;\n    distance(first, last, n);\n    start = allocate_and_copy(n, first, last);\n    finish = start + n;\n    end_of_storage = finish;\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n  ~vector() { \n    destroy(start, finish);\n    deallocate();\n  }\n  vector<T, Alloc>& operator=(const vector<T, Alloc>& x);\n  void reserve(size_type n) {\n    if (capacity() < n) {\n      const size_type old_size = size();\n      iterator tmp = allocate_and_copy(n, start, finish);\n      destroy(start, finish);\n      deallocate();\n      start = tmp;\n      finish = tmp + old_size;\n      end_of_storage = start + n;\n    }\n  }\n  reference front() { return *begin(); }\n  const_reference front() const { return *begin(); }\n  reference back() { return *(end() - 1); }\n  const_reference back() const { return *(end() - 1); }\n  void push_back(const T& x) {\n    if (finish != end_of_storage) {\n      construct(finish, x);\n      ++finish;\n    }\n    else\n      insert_aux(end(), x);\n  }\n  void swap(vector<T, Alloc>& x) {\n    __STD::swap(start, x.start);\n    __STD::swap(finish, x.finish);\n    __STD::swap(end_of_storage, x.end_of_storage);\n  }\n  iterator insert(iterator position, const T& x) {\n    size_type n = position - begin();\n    if (finish != end_of_storage && position == end()) {\n      construct(finish, x);\n      ++finish;\n    }\n    else\n      insert_aux(position, x);\n    return begin() + n;\n  }\n  iterator insert(iterator position) { return insert(position, T()); }\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void insert(iterator position, InputIterator first, InputIterator last) {\n    range_insert(position, first, last, iterator_category(first));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  void insert(iterator position,\n              const_iterator first, const_iterator last);\n#endif /* __STL_MEMBER_TEMPLATES */\n\n  void insert (iterator pos, size_type n, const T& x);\n  void insert (iterator pos, int n, const T& x) {\n    insert(pos, (size_type) n, x);\n  }\n  void insert (iterator pos, long n, const T& x) {\n    insert(pos, (size_type) n, x);\n  }\n\n  void pop_back() {\n    --finish;\n    destroy(finish);\n  }\n  iterator erase(iterator position) {\n    if (position + 1 != end())\n      copy(position + 1, finish, position);\n    --finish;\n    destroy(finish);\n    return position;\n  }\n  iterator erase(iterator first, iterator last) {\n    iterator i = copy(last, finish, first);\n    destroy(i, finish);\n    finish = finish - (last - first);\n    return first;\n  }\n  void resize(size_type new_size, const T& x) {\n    if (new_size < size()) \n      erase(begin() + new_size, end());\n    else\n      insert(end(), new_size - size(), x);\n  }\n  void resize(size_type new_size) { resize(new_size, T()); }\n  void clear() { erase(begin(), end()); }\n\nprotected:\n  iterator allocate_and_fill(size_type n, const T& x) {\n    iterator result = data_allocator::allocate(n);\n    __STL_TRY {\n      uninitialized_fill_n(result, n, x);\n      return result;\n    }\n    __STL_UNWIND(data_allocator::deallocate(result, n));\n  }\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class ForwardIterator>\n  iterator allocate_and_copy(size_type n,\n                             ForwardIterator first, ForwardIterator last) {\n    iterator result = data_allocator::allocate(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, result);\n      return result;\n    }\n    __STL_UNWIND(data_allocator::deallocate(result, n));\n  }\n#else /* __STL_MEMBER_TEMPLATES */\n  iterator allocate_and_copy(size_type n,\n                             const_iterator first, const_iterator last) {\n    iterator result = data_allocator::allocate(n);\n    __STL_TRY {\n      uninitialized_copy(first, last, result);\n      return result;\n    }\n    __STL_UNWIND(data_allocator::deallocate(result, n));\n  }\n#endif /* __STL_MEMBER_TEMPLATES */\n\n\n#ifdef __STL_MEMBER_TEMPLATES\n  template <class InputIterator>\n  void range_initialize(InputIterator first, InputIterator last,\n                        input_iterator_tag) {\n    for ( ; first != last; ++first)\n      push_back(*first);\n  }\n\n  // This function is only called by the constructor.  We have to worry\n  //  about resource leaks, but not about maintaining invariants.\n  template <class ForwardIterator>\n  void range_initialize(ForwardIterator first, ForwardIterator last,\n                        forward_iterator_tag) {\n    size_type n = 0;\n    distance(first, last, n);\n    start = allocate_and_copy(n, first, last);\n    finish = start + n;\n    end_of_storage = finish;\n  }\n\n  template <class InputIterator>\n  void range_insert(iterator pos,\n                    InputIterator first, InputIterator last,\n                    input_iterator_tag);\n\n  template <class ForwardIterator>\n  void range_insert(iterator pos,\n                    ForwardIterator first, ForwardIterator last,\n                    forward_iterator_tag);\n\n#endif /* __STL_MEMBER_TEMPLATES */\n};\n\ntemplate <class T, class Alloc>\ninline bool operator==(const vector<T, Alloc>& x, const vector<T, Alloc>& y) {\n  return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());\n}\n\ntemplate <class T, class Alloc>\ninline bool operator<(const vector<T, Alloc>& x, const vector<T, Alloc>& y) {\n  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());\n}\n\n#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER\n\ntemplate <class T, class Alloc>\ninline void swap(vector<T, Alloc>& x, vector<T, Alloc>& y) {\n  x.swap(y);\n}\n\n#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */\n\ntemplate <class T, class Alloc>\nvector<T, Alloc>& vector<T, Alloc>::operator=(const vector<T, Alloc>& x) {\n  if (&x != this) {\n    if (x.size() > capacity()) {\n      iterator tmp = allocate_and_copy(x.end() - x.begin(),\n                                       x.begin(), x.end());\n      destroy(start, finish);\n      deallocate();\n      start = tmp;\n      end_of_storage = start + (x.end() - x.begin());\n    }\n    else if (size() >= x.size()) {\n      iterator i = copy(x.begin(), x.end(), begin());\n      destroy(i, finish);\n    }\n    else {\n      copy(x.begin(), x.begin() + size(), start);\n      uninitialized_copy(x.begin() + size(), x.end(), finish);\n    }\n    finish = start + x.size();\n  }\n  return *this;\n}\n\ntemplate <class T, class Alloc>\nvoid vector<T, Alloc>::insert_aux(iterator position, const T& x) {\n  if (finish != end_of_storage) {\n    construct(finish, *(finish - 1));\n    ++finish;\n    T x_copy = x;\n    copy_backward(position, finish - 2, finish - 1);\n    *position = x_copy;\n  }\n  else {\n    const size_type old_size = size();\n    const size_type len = old_size != 0 ? 2 * old_size : 1;\n    iterator new_start = data_allocator::allocate(len);\n    iterator new_finish = new_start;\n    __STL_TRY {\n      new_finish = uninitialized_copy(start, position, new_start);\n      construct(new_finish, x);\n      ++new_finish;\n      new_finish = uninitialized_copy(position, finish, new_finish);\n    }\n\n#       ifdef  __STL_USE_EXCEPTIONS \n    catch(...) {\n      destroy(new_start, new_finish); \n      data_allocator::deallocate(new_start, len);\n      throw;\n    }\n#       endif /* __STL_USE_EXCEPTIONS */\n    destroy(begin(), end());\n    deallocate();\n    start = new_start;\n    finish = new_finish;\n    end_of_storage = new_start + len;\n  }\n}\n\ntemplate <class T, class Alloc>\nvoid vector<T, Alloc>::insert(iterator position, size_type n, const T& x) {\n  if (n != 0) {\n    if (size_type(end_of_storage - finish) >= n) {\n      T x_copy = x;\n      const size_type elems_after = finish - position;\n      iterator old_finish = finish;\n      if (elems_after > n) {\n        uninitialized_copy(finish - n, finish, finish);\n        finish += n;\n        copy_backward(position, old_finish - n, old_finish);\n        fill(position, position + n, x_copy);\n      }\n      else {\n        uninitialized_fill_n(finish, n - elems_after, x_copy);\n        finish += n - elems_after;\n        uninitialized_copy(position, old_finish, finish);\n        finish += elems_after;\n        fill(position, old_finish, x_copy);\n      }\n    }\n    else {\n      const size_type old_size = size();        \n      const size_type len = old_size + max(old_size, n);\n      iterator new_start = data_allocator::allocate(len);\n      iterator new_finish = new_start;\n      __STL_TRY {\n        new_finish = uninitialized_copy(start, position, new_start);\n        new_finish = uninitialized_fill_n(new_finish, n, x);\n        new_finish = uninitialized_copy(position, finish, new_finish);\n      }\n#         ifdef  __STL_USE_EXCEPTIONS \n      catch(...) {\n        destroy(new_start, new_finish);\n        data_allocator::deallocate(new_start, len);\n        throw;\n      }\n#         endif /* __STL_USE_EXCEPTIONS */\n      destroy(start, finish);\n      deallocate();\n      start = new_start;\n      finish = new_finish;\n      end_of_storage = new_start + len;\n    }\n  }\n}\n\n#ifdef __STL_MEMBER_TEMPLATES\n\ntemplate <class T, class Alloc> template <class InputIterator>\nvoid vector<T, Alloc>::range_insert(iterator pos,\n                                    InputIterator first, InputIterator last,\n                                    input_iterator_tag) {\n  for ( ; first != last; ++first) {\n    pos = insert(pos, *first);\n    ++pos;\n  }\n}\n\ntemplate <class T, class Alloc> template <class ForwardIterator>\nvoid vector<T, Alloc>::range_insert(iterator position,\n                                    ForwardIterator first,\n                                    ForwardIterator last,\n                                    forward_iterator_tag) {\n  if (first != last) {\n    size_type n = 0;\n    distance(first, last, n);\n    if (size_type(end_of_storage - finish) >= n) {\n      const size_type elems_after = finish - position;\n      iterator old_finish = finish;\n      if (elems_after > n) {\n        uninitialized_copy(finish - n, finish, finish);\n        finish += n;\n        copy_backward(position, old_finish - n, old_finish);\n        copy(first, last, position);\n      }\n      else {\n        ForwardIterator mid = first;\n        advance(mid, elems_after);\n        uninitialized_copy(mid, last, finish);\n        finish += n - elems_after;\n        uninitialized_copy(position, old_finish, finish);\n        finish += elems_after;\n        copy(first, mid, position);\n      }\n    }\n    else {\n      const size_type old_size = size();\n      const size_type len = old_size + max(old_size, n);\n      iterator new_start = data_allocator::allocate(len);\n      iterator new_finish = new_start;\n      __STL_TRY {\n        new_finish = uninitialized_copy(start, position, new_start);\n        new_finish = uninitialized_copy(first, last, new_finish);\n        new_finish = uninitialized_copy(position, finish, new_finish);\n      }\n#         ifdef __STL_USE_EXCEPTIONS\n      catch(...) {\n        destroy(new_start, new_finish);\n        data_allocator::deallocate(new_start, len);\n        throw;\n      }\n#         endif /* __STL_USE_EXCEPTIONS */\n      destroy(start, finish);\n      deallocate();\n      start = new_start;\n      finish = new_finish;\n      end_of_storage = new_start + len;\n    }\n  }\n}\n\n#else /* __STL_MEMBER_TEMPLATES */\n\ntemplate <class T, class Alloc>\nvoid vector<T, Alloc>::insert(iterator position, \n                              const_iterator first, \n                              const_iterator last) {\n  if (first != last) {\n    size_type n = 0;\n    distance(first, last, n);\n    if (size_type(end_of_storage - finish) >= n) {\n      const size_type elems_after = finish - position;\n      iterator old_finish = finish;\n      if (elems_after > n) {\n        uninitialized_copy(finish - n, finish, finish);\n        finish += n;\n        copy_backward(position, old_finish - n, old_finish);\n        copy(first, last, position);\n      }\n      else {\n        uninitialized_copy(first + elems_after, last, finish);\n        finish += n - elems_after;\n        uninitialized_copy(position, old_finish, finish);\n        finish += elems_after;\n        copy(first, first + elems_after, position);\n      }\n    }\n    else {\n      const size_type old_size = size();\n      const size_type len = old_size + max(old_size, n);\n      iterator new_start = data_allocator::allocate(len);\n      iterator new_finish = new_start;\n      __STL_TRY {\n        new_finish = uninitialized_copy(start, position, new_start);\n        new_finish = uninitialized_copy(first, last, new_finish);\n        new_finish = uninitialized_copy(position, finish, new_finish);\n      }\n#         ifdef __STL_USE_EXCEPTIONS\n      catch(...) {\n        destroy(new_start, new_finish);\n        data_allocator::deallocate(new_start, len);\n        throw;\n      }\n#         endif /* __STL_USE_EXCEPTIONS */\n      destroy(start, finish);\n      deallocate();\n      start = new_start;\n      finish = new_finish;\n      end_of_storage = new_start + len;\n    }\n  }\n}\n\n#endif /* __STL_MEMBER_TEMPLATES */\n\n#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)\n#pragma reset woff 1174\n#endif\n\n__STL_END_NAMESPACE \n\n#endif /* __SGI_STL_INTERNAL_VECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/stream.h",
    "content": "/* \nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _COMPAT_STREAM_H\n#define _COMPAT_STREAM_H\n\n// Compatibility with old library.\n// DO NOT USE THESE FUNCTIONS IN NEW CODE!\n// They are obsolete, non-standard, and non-reentrant.\n\n#define _STREAM_COMPAT\n#include <iostream.h>\n\nextern \"C++\" {\nextern char* form(const char*, ...);\n\nextern char* dec(long, int=0);\nextern char* dec(int, int=0);\nextern char* dec(unsigned long, int=0);\nextern char* dec(unsigned int, int=0);\n\nextern char* hex(long, int=0);\nextern char* hex(int, int=0);\nextern char* hex(unsigned long, int=0);\nextern char* hex(unsigned int, int=0);\n\nextern char* oct(long, int=0);\nextern char* oct(int, int=0);\nextern char* oct(unsigned long, int=0);\nextern char* oct(unsigned int, int=0);\n\nchar*        chr(char ch, int width = 0);\nchar*        str(const char* s, int width = 0);\n\ninline istream& WS(istream& str) { return ws(str); }\n} // extern \"C++\"\n\n#endif /* !_COMPAT_STREAM_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/streambuf.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n#ifndef _STREAMBUF_H\n#define _STREAMBUF_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n\n/* #define _G_IO_THROW */ /* Not implemented:  ios::failure */\n\n#define _IO_NEW_STREAMS // new optimizated stream representation\n\nextern \"C\" {\n#include <libio.h>\n}\n//#include <_G_config.h>\n#ifdef _G_NEED_STDARG_H\n#include <stdarg.h>\n#endif\n#ifndef _IO_va_list\n#define _IO_va_list char *\n#endif\n\n#ifndef EOF\n#define EOF (-1)\n#endif\n#ifndef NULL\n#ifdef __GNUG__\n#define NULL (__null)\n#else\n#define NULL (0)\n#endif\n#endif\n\n#ifndef _IO_wchar_t\n#if _G_IO_IO_FILE_VERSION == 0x20001\n#define _IO_wchar_t _G_wchar_t\n#else\n#define _IO_wchar_t short\n#endif\n#endif\n\nextern \"C++\" {\nclass istream; /* Work-around for a g++ name mangling bug. Fixed in 2.6. */\nclass ostream; class streambuf;\n\n// In case some header files defines these as macros.\n#undef open\n#undef close\n\n#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001\ntypedef _IO_off64_t streamoff;\ntypedef _IO_fpos64_t streampos;\n#else\ntypedef _IO_off_t streamoff;\ntypedef _IO_fpos_t streampos;\n#endif\ntypedef _IO_ssize_t streamsize;\n\ntypedef unsigned long __fmtflags;\ntypedef unsigned char __iostate;\n\nstruct _ios_fields\n{ // The data members of an ios.\n    streambuf *_strbuf;\n    ostream* _tie;\n    int _width;\n    __fmtflags _flags;\n    _IO_wchar_t _fill;\n    __iostate _state;\n    __iostate _exceptions;\n    int _precision;\n\n    void *_arrays; /* Support for ios::iword and ios::pword. */\n};\n\n#define _IOS_GOOD\t0\n#define _IOS_EOF\t1\n#define _IOS_FAIL\t2\n#define _IOS_BAD\t4\n\n#define _IO_INPUT\t1\n#define _IO_OUTPUT\t2\n#define _IO_ATEND\t4\n#define _IO_APPEND\t8\n#define _IO_TRUNC\t16\n#define _IO_NOCREATE\t32\n#define _IO_NOREPLACE\t64\n#define _IO_BIN\t\t128\n\n#ifdef _STREAM_COMPAT\nenum state_value {\n    _good = _IOS_GOOD,\n    _eof = _IOS_EOF,\n    _fail = _IOS_FAIL,\n    _bad = _IOS_BAD };\nenum open_mode {\n    input = _IO_INPUT,\n    output = _IO_OUTPUT,\n    atend = _IO_ATEND,\n    append = _IO_APPEND };\n#endif\n\nclass ios : public _ios_fields {\n  ios& operator=(ios&);  /* Not allowed! */\n  ios (const ios&); /* Not allowed! */\n  public:\n    typedef __fmtflags fmtflags;\n    typedef int iostate;\n    typedef int openmode;\n    typedef int streamsize;\n    enum io_state {\n\tgoodbit = _IOS_GOOD,\n\teofbit = _IOS_EOF,\n\tfailbit = _IOS_FAIL,\n\tbadbit = _IOS_BAD };\n    enum open_mode {\n\tin = _IO_INPUT,\n\tout = _IO_OUTPUT,\n\tate = _IO_ATEND,\n\tapp = _IO_APPEND,\n\ttrunc = _IO_TRUNC,\n\tnocreate = _IO_NOCREATE,\n\tnoreplace = _IO_NOREPLACE,\n\tbin = _IOS_BIN, // Deprecated - ANSI uses ios::binary.\n\tbinary = _IOS_BIN };\n    enum seek_dir { beg, cur, end};\n    typedef enum seek_dir seekdir;\n    // NOTE: If adding flags here, before to update ios::bitalloc().\n    enum { skipws=_IO_SKIPWS,\n\t   left=_IO_LEFT, right=_IO_RIGHT, internal=_IO_INTERNAL,\n\t   dec=_IO_DEC, oct=_IO_OCT, hex=_IO_HEX,\n\t   showbase=_IO_SHOWBASE, showpoint=_IO_SHOWPOINT,\n\t   uppercase=_IO_UPPERCASE, showpos=_IO_SHOWPOS,\n\t   scientific=_IO_SCIENTIFIC, fixed=_IO_FIXED,\n\t   unitbuf=_IO_UNITBUF, stdio=_IO_STDIO\n#ifndef _IO_NEW_STREAMS\n\t   , dont_close=_IO_DONT_CLOSE // Don't delete streambuf on stream destruction\n#endif\n\t   };\n    enum { // Masks.\n\tbasefield=dec+oct+hex,\n\tfloatfield = scientific+fixed,\n\tadjustfield = left+right+internal\n    };\n\n#ifdef _IO_THROW\n    class failure : public xmsg {\n\tios* _stream;\n      public:\n\tfailure(ios* stream) { _stream = stream; }\n\tfailure(string cause, ios* stream) { _stream = stream; }\n\tios* rdios() const { return _stream; }\n    };\n#endif\n\n    ostream* tie() const { return _tie; }\n    ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }\n\n    // Methods to change the format state.\n    _IO_wchar_t fill() const { return _fill; }\n    _IO_wchar_t fill(_IO_wchar_t newf)\n\t{_IO_wchar_t oldf = _fill; _fill = newf; return oldf;}\n    fmtflags flags() const { return _flags; }\n    fmtflags flags(fmtflags new_val) {\n\tfmtflags old_val = _flags; _flags = new_val; return old_val; }\n    int precision() const { return _precision; }\n    int precision(int newp) {\n\tunsigned short oldp = _precision; _precision = (unsigned short)newp;\n\treturn oldp; }\n    fmtflags setf(fmtflags val) {\n\tfmtflags oldbits = _flags;\n\t_flags |= val; return oldbits; }\n    fmtflags setf(fmtflags val, fmtflags mask) {\n\tfmtflags oldbits = _flags;\n\t_flags = (_flags & ~mask) | (val & mask); return oldbits; }\n    fmtflags unsetf(fmtflags mask) {\n\tfmtflags oldbits = _flags;\n\t_flags &= ~mask; return oldbits; }\n    int width() const { return _width; }\n    int width(int val) { int save = _width; _width = val; return save; }\n\n#ifdef _IO_THROW\n    void _throw_failure() const { throw new ios::failure(this); }\n#else\n    void _throw_failure() const { }\n#endif\n    void clear(iostate state = 0) {\n\t_state = _strbuf ? state : state|badbit;\n\tif (_state & _exceptions) _throw_failure(); }\n    void set(iostate flag) { _state |= flag;\n\tif (_state & _exceptions) _throw_failure(); }\n    void setstate(iostate flag) { _state |= flag; // ANSI\n\tif (_state & _exceptions) _throw_failure(); }\n    int good() const { return _state == 0; }\n    int eof() const { return _state & ios::eofbit; }\n    int fail() const { return _state & (ios::badbit|ios::failbit); }\n    int bad() const { return _state & ios::badbit; }\n    iostate rdstate() const { return _state; }\n    operator void*() const { return fail() ? (void*)0 : (void*)(-1); }\n    int operator!() const { return fail(); }\n    iostate exceptions() const { return _exceptions; }\n    void exceptions(iostate enable) {\n\t_exceptions = enable;\n\tif (_state & _exceptions) _throw_failure(); }\n\n    streambuf* rdbuf() const { return _strbuf; }\n    streambuf* rdbuf(streambuf *_s) {\n      streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; }\n\n    static int sync_with_stdio(int on);\n    static void sync_with_stdio() { sync_with_stdio(1); }\n    static fmtflags bitalloc();\n    static int xalloc();\n    void*& pword(int);\n    void* pword(int) const;\n    long& iword(int);\n    long iword(int) const;\n\n#ifdef _STREAM_COMPAT\n    void unset(state_value flag) { _state &= ~flag; }\n    void close();\n    int is_open();\n    int readable();\n    int writable();\n#endif\n\n    // Used to initialize standard streams. Not needed in this implementation.\n    class Init {\n    public:\n      Init () { }\n    };\n\n  protected:\n    inline ios(streambuf* sb = 0, ostream* tie_to = 0);\n    inline virtual ~ios();\n    inline void init(streambuf* sb, ostream* tie = 0);\n};\n\n#if __GNUG__==1\ntypedef int _seek_dir;\n#else\ntypedef ios::seek_dir _seek_dir;\n#endif\n\n// Magic numbers and bits for the _flags field.\n// The magic numbers use the high-order bits of _flags;\n// the remaining bits are abailable for variable flags.\n// Note: The magic numbers must all be negative if stdio\n// emulation is desired.\n\n// A streammarker remembers a position in a buffer.\n// You are guaranteed to be able to seek back to it if it is saving().\nclass streammarker : private _IO_marker {\n    friend class streambuf;\n    void set_offset(int offset) { _pos = offset; }\n  public:\n    streammarker(streambuf *sb);\n    ~streammarker();\n    int saving() { return  1; }\n    int delta(streammarker&);\n    int delta();\n};\n\nstruct streambuf : public _IO_FILE { // protected??\n    friend class ios;\n    friend class istream;\n    friend class ostream;\n    friend class streammarker;\n    const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); }\n  protected:\n    static streambuf* _list_all; /* List of open streambufs. */\n    _IO_FILE*& xchain() { return _chain; }\n    void _un_link();\n    void _link_in();\n    char* gptr() const\n      { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_ptr; }\n    char* pptr() const { return _IO_write_ptr; }\n    char* egptr() const\n      { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_end : _IO_read_end; }\n    char* epptr() const { return _IO_write_end; }\n    char* pbase() const { return _IO_write_base; }\n    char* eback() const\n      { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_base;}\n    char* base() const { return _IO_buf_base; }\n    char* ebuf() const { return _IO_buf_end; }\n    int blen() const { return _IO_buf_end - _IO_buf_base; }\n    void xput_char(char c) { *_IO_write_ptr++ = c; }\n    int xflags() { return _IO_file_flags; }\n    int xflags(int f) {int fl = _IO_file_flags; _IO_file_flags = f; return fl;}\n    void xsetflags(int f) { _IO_file_flags |= f; }\n    void xsetflags(int f, int mask)\n      { _IO_file_flags = (_IO_file_flags & ~mask) | (f & mask); }\n    void gbump(int n)\n      { _IO_file_flags & _IO_IN_BACKUP ? (_IO_save_base+=n):(_IO_read_ptr+=n);}\n    void pbump(int n) { _IO_write_ptr += n; }\n    void setb(char* b, char* eb, int a=0);\n    void setp(char* p, char* ep)\n      { _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; }\n    void setg(char* eb, char* g, char *eg) {\n      if (_IO_file_flags & _IO_IN_BACKUP) _IO_free_backup_area(this); \n      _IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; }\n    char *shortbuf() { return _shortbuf; }\n\n    int in_backup() { return _flags & _IO_IN_BACKUP; }\n    // The start of the main get area:  FIXME:  wrong for write-mode filebuf?\n    char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; }\n    // The end of the main get area:\n    char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; }\n    // The start of the backup area:\n    char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; }\n    char *Bptr() { return _IO_backup_base; }\n    // The end of the backup area:\n    char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; }\n    char *Nbase() { return _IO_save_base; }\n    char *eNptr() { return _IO_save_end; }\n    int have_backup() { return _IO_save_base != NULL; }\n    int have_markers() { return _markers != NULL; }\n    void free_backup_area();\n    void unsave_markers(); // Make all streammarkers !saving().\n    int put_mode() { return _flags & _IO_CURRENTLY_PUTTING; }\n    int switch_to_get_mode();\n    \n    streambuf(int flags=0);\n  public:\n    static int flush_all();\n    static void flush_all_linebuffered(); // Flush all line buffered files.\n    virtual ~streambuf();\n    virtual int overflow(int c = EOF); // Leave public for now\n    virtual int underflow(); // Leave public for now\n    virtual int uflow(); // Leave public for now\n    virtual int pbackfail(int c);\n//    virtual int showmany ();\n    virtual streamsize xsputn(const char* s, streamsize n);\n    virtual streamsize xsgetn(char* s, streamsize n);\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);\n\n    streampos pubseekoff(streamoff o, _seek_dir d, int mode=ios::in|ios::out)\n      { return _IO_seekoff (this, o, d, mode); }\n    streampos pubseekpos(streampos pos, int mode = ios::in|ios::out)\n      { return _IO_seekpos (this, pos, mode); }\n    streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    streampos sseekpos(streampos pos, int mode = ios::in|ios::out);\n    virtual streambuf* setbuf(char* p, int len);\n    virtual int sync();\n    virtual int doallocate();\n\n    int seekmark(streammarker& mark, int delta = 0);\n    int sputbackc(char c);\n    int sungetc();\n    int unbuffered() { return _flags & _IO_UNBUFFERED ? 1 : 0; }\n    int linebuffered() { return _flags & _IO_LINE_BUF ? 1 : 0; }\n    void unbuffered(int i)\n\t{ if (i) _flags |= _IO_UNBUFFERED; else _flags &= ~_IO_UNBUFFERED; }\n    void linebuffered(int i)\n\t{ if (i) _flags |= _IO_LINE_BUF; else _flags &= ~_IO_LINE_BUF; }\n    int allocate() { // For AT&T compatibility\n\tif (base() || unbuffered()) return 0;\n\telse return doallocate(); }\n    // Allocate a buffer if needed; use _shortbuf if appropriate.\n    void allocbuf() { if (base() == NULL) doallocbuf(); }\n    void doallocbuf();\n    int in_avail() { return _IO_read_end - _IO_read_ptr; }\n    int out_waiting() { return _IO_write_ptr - _IO_write_base; }\n    streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); }\n    streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); }\n    streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); }\n    int ignore(int);\n    int get_column();\n    int set_column(int);\n    long sgetline(char* buf, _IO_size_t n, char delim, int putback_delim);\n    int sputc(int c) { return _IO_putc(c, this); }\n    int sbumpc() { return _IO_getc(this); }\n    int sgetc() { return _IO_peekc(this); }\n    int snextc() {\n\tif (_IO_read_ptr >= _IO_read_end && __underflow(this) == EOF)\n\t  return EOF;\n\telse return _IO_read_ptr++, sgetc(); }\n    void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; }\n    int vscan(char const *fmt0, _IO_va_list ap, ios* stream = NULL);\n    int scan(char const *fmt0 ...);\n    int vform(char const *fmt0, _IO_va_list ap);\n    int form(char const *fmt0 ...);\n#if 0 /* Work in progress */\n    int column();  // Current column number (of put pointer). -1 is unknown.\n    void column(int c);  // Set column number of put pointer to c.\n#endif\n    virtual streamsize sys_read(char* buf, streamsize size);\n    virtual streamsize sys_write(const char*, streamsize);\n    virtual streampos sys_seek(streamoff, _seek_dir);\n    virtual int sys_close();\n    virtual int sys_stat(void*); // Actually, a (struct stat*)\n#if _G_IO_IO_FILE_VERSION == 0x20001\n    virtual int showmanyc();\n    virtual void imbue(void *);\n#endif\n};\n\n// A backupbuf is a streambuf with full backup and savepoints on reading.\n// All standard streambufs in the GNU iostream library are backupbufs.\n\nclass filebuf : public streambuf {\n  protected:\n    void init();\n  public:\n    static const int openprot; // Non-ANSI AT&T-ism:  Default open protection.\n    filebuf();\n    filebuf(int fd);\n    filebuf(int fd, char* p, int len);\n#if !_IO_UNIFIED_JUMPTABLES\n    static filebuf *__new();\n#endif\n    ~filebuf();\n    filebuf* attach(int fd);\n    filebuf* open(const char *filename, const char *mode);\n    filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);\n    virtual int underflow();\n    virtual int overflow(int c = EOF);\n    int is_open() const { return _fileno >= 0; }\n    int fd() const { return is_open() ? _fileno : EOF; }\n    filebuf* close();\n    virtual int doallocate();\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n    virtual streambuf* setbuf(char* p, int len);\n    streamsize xsputn(const char* s, streamsize n);\n    streamsize xsgetn(char* s, streamsize n);\n    virtual int sync();\n  protected: // See documentation in filebuf.C.\n//    virtual int pbackfail(int c);\n    int is_reading() { return eback() != egptr(); }\n    char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }\n    /* System's idea of pointer */\n    char* file_ptr() { return eGptr(); }\n    // Low-level operations (Usually invoke system calls.)\n    virtual streamsize sys_read(char* buf, streamsize size);\n    virtual streampos sys_seek(streamoff, _seek_dir);\n    virtual streamsize sys_write(const char*, streamsize);\n    virtual int sys_stat(void*); // Actually, a (struct stat*)\n    virtual int sys_close();\n#if 0\n    virtual uflow;\n    virtual showmany;\n#endif\n};\n\ninline void ios::init(streambuf* sb, ostream* tie_to) {\n\t\t_state = sb ? ios::goodbit : ios::badbit; _exceptions=0;\n\t\t_strbuf=sb; _tie = tie_to; _width=0; _fill=' ';\n#ifdef _IO_NEW_STREAMS\n\t\t_flags=ios::skipws|ios::dec;\n#else\n\t\t_flags=ios::skipws|ios::dec|ios::dont_close;\n#endif\n\t\t_precision=6; _arrays = 0; }\n\ninline ios::ios(streambuf* sb, ostream* tie_to) { init(sb, tie_to); }\n\ninline ios::~ios() {\n#ifndef _IO_NEW_STREAMS\n    if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf();\n#endif\n    if (_arrays) delete [] _arrays;\n}\n} // extern \"C++\"\n#endif /* _STREAMBUF_H */\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/strfile.h",
    "content": "/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.\n   This file is part of the GNU IO Library.\n\n   This library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU General Public License as\n   published by the Free Software Foundation; either version 2, or (at\n   your option) any later version.\n\n   This library is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this library; see the file COPYING.  If not, write to\n   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,\n   MA 02111-1307, USA.\n\n   As a special exception, if you link this library with files\n   compiled with a GNU compiler to produce an executable, this does\n   not cause the resulting executable to be covered by the GNU General\n   Public License.  This exception does not however invalidate any\n   other reasons why the executable file might be covered by the GNU\n   General Public License.  */\n\n#include <libio.h>\n#ifdef TODO\nMerge into  libio.h ?\n#endif\n\ntypedef void *(*_IO_alloc_type) __P ((_IO_size_t));\ntypedef void (*_IO_free_type) __P ((void*));\n\nstruct _IO_str_fields\n{\n  _IO_alloc_type _allocate_buffer;\n  _IO_free_type _free_buffer;\n};\n\n/* This is needed for the Irix6 N32 ABI, which has a 64 bit off_t type,\n   but a 32 bit pointer type.  In this case, we get 4 bytes of padding\n   after the vtable pointer.  Putting them in a structure together solves\n   this problem.  */\n\nstruct _IO_streambuf\n{\n  struct _IO_FILE _f;\n  const void *_vtable;\n};\n\ntypedef struct _IO_strfile_\n{\n  struct _IO_streambuf _sbf;\n  struct _IO_str_fields _s;\n} _IO_strfile;\n\n/* dynamic: set when the array object is allocated (or reallocated)  as\n   necessary to hold a character sequence that can change in length. */\n#define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0)\n\n/* frozen: set when the program has requested that the array object not\n   be altered, reallocated, or freed. */\n#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF)\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/string",
    "content": "// Main header for the -*- C++ -*- string classes.\n\n#ifndef __STRING__\n#define __STRING__\n\n#include <std/bastring.h>\n\nextern \"C++\" {\ntypedef basic_string <char> string;\n// typedef basic_string <wchar_t> wstring;\n} // extern \"C++\"\n\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/strstream",
    "content": "// -*- C++ -*- forwarding header.\n// This file is part of the GNU ANSI C++ Library.\n\n#ifndef __STRSTREAM__\n#define __STRSTREAM__\n#include <strstream.h>\n#endif\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/strstream.h",
    "content": "/* This is part of libio/iostream, providing -*- C++ -*- input/output.\nCopyright (C) 1993 Free Software Foundation\n\nThis file is part of the GNU IO Library.  This library is free\nsoftware; you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the\nFree Software Foundation; either version 2, or (at your option)\nany later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this library; see the file COPYING.  If not, write to the Free\nSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\nAs a special exception, if you link this library with files\ncompiled with a GNU compiler to produce an executable, this does not cause\nthe resulting executable to be covered by the GNU General Public License.\nThis exception does not however invalidate any other reasons why\nthe executable file might be covered by the GNU General Public License. */\n\n/* Written by Per Bothner (bothner@cygnus.com). */\n\n#ifndef __STRSTREAM_H\n#define __STRSTREAM_H\n#ifdef __GNUG__\n#pragma interface\n#endif\n#include <iostream.h>\n#include <strfile.h>\n\nextern \"C++\" {\nclass strstreambuf : public streambuf\n{\n  struct _IO_str_fields _s;\n  friend class istrstream;\n\n    void init_dynamic(_IO_alloc_type alloc, _IO_free_type free,\n\t\t      int initial_size = 0);\n    void init_static(char *ptr, int size, char *pstart);\n    void init_readonly(const char *ptr, int size);\n  protected:\n    virtual int overflow(int = EOF);\n    virtual int underflow();\n    virtual int pbackfail(int c);\n  public:\n    virtual ~strstreambuf();\n    strstreambuf() { init_dynamic(0, 0); }\n    strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); }\n    strstreambuf(void *(*alloc)(_IO_size_t), void (*free)(void*))\n\t{ init_dynamic(alloc, free); }\n    strstreambuf(char *ptr, int size, char *pstart = NULL)\n\t{ init_static(ptr, size, pstart); }\n    strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = NULL)\n\t{ init_static((char*)ptr, size, (char*)pstart); }\n    strstreambuf(const char *ptr, int size)\n\t{ init_readonly(ptr, size); }\n    strstreambuf(const unsigned char *ptr, int size)\n\t{ init_readonly((const char*)ptr, size); }\n    strstreambuf(signed char *ptr, int size, signed char *pstart = NULL)\n\t{ init_static((char*)ptr, size, (char*)pstart); }\n    strstreambuf(const signed char *ptr, int size)\n\t{ init_readonly((const char*)ptr, size); }\n    // Note: frozen() is always true if !_IO_STR_DYNAMIC(this).\n    int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; }\n    void freeze(int n=1)\n\t{ if (_IO_STR_DYNAMIC(this))\n\t    { if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } }\n    _IO_ssize_t pcount();\n    char *str();\n    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);\n};\n\nclass strstreambase : virtual public ios {\n  protected:\n    strstreambuf __my_sb;\n  public:\n    strstreambuf* rdbuf() { return &__my_sb; }\n  protected:\n    strstreambase() { init (&__my_sb); }\n    strstreambase(char *cp, int n, int mode=ios::out);\n};\n\nclass istrstream : public strstreambase, public istream {\n  public:\n    istrstream(const char*, int=0);\n};\n\nclass ostrstream : public strstreambase, public ostream {\n  public:\n    ostrstream() { }\n    ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}\n    _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }\n    char *str() { return ((strstreambuf*)_strbuf)->str(); }\n    void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }\n    int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }\n};\n\nclass strstream : public strstreambase, public iostream {\n  public:\n  strstream() { }\n    strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}\n    _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }\n    char *str() { return ((strstreambuf*)_strbuf)->str(); }\n    void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }\n    int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }\n};\n} // extern \"C++\"\n\n#endif /*!__STRSTREAM_H*/\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/tempbuf.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_TEMPBUF_H\n#define __SGI_STL_TEMPBUF_H\n\n#ifndef __SGI_STL_PAIR_H\n#include <pair.h>\n#endif\n#include <limits.h>\n#include <stddef.h>\n#include <stdlib.h>\n#ifndef __TYPE_TRAITS_H\n#include <type_traits.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H\n#include <stl_construct.h>\n#endif\n#ifndef __SGI_STL_INTERNAL_TEMPBUF_H\n#include <stl_tempbuf.h>\n#endif\n\n#ifdef __STL_USE_NAMESPACES\n\nusing __STD::get_temporary_buffer;\nusing __STD::return_temporary_buffer;\nusing __STD::temporary_buffer;\n\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_TEMPBUF_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/tree.h",
    "content": "/*\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n */\n\n#ifndef __SGI_STL_TREE_H\n#define __SGI_STL_TREE_H\n\n#ifndef __SGI_STL_INTERNAL_TREE_H\n#include <stl_tree.h>\n#endif\n#include <algobase.h>\n#include <alloc.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::rb_tree;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_TREE_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/type_traits.h",
    "content": "/*\n *\n * Copyright (c) 1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __TYPE_TRAITS_H\n#define __TYPE_TRAITS_H\n\n#ifndef __STL_CONFIG_H\n#include <stl_config.h>\n#endif\n\n/*\nThis header file provides a framework for allowing compile time dispatch\nbased on type attributes. This is useful when writing template code.\nFor example, when making a copy of an array of an unknown type, it helps\nto know if the type has a trivial copy constructor or not, to help decide\nif a memcpy can be used.\n\nThe class template __type_traits provides a series of typedefs each of\nwhich is either __true_type or __false_type. The argument to\n__type_traits can be any type. The typedefs within this template will\nattain their correct values by one of these means:\n    1. The general instantiation contain conservative values which work\n       for all types.\n    2. Specializations may be declared to make distinctions between types.\n    3. Some compilers (such as the Silicon Graphics N32 and N64 compilers)\n       will automatically provide the appropriate specializations for all\n       types.\n\nEXAMPLE:\n\n//Copy an array of elements which have non-trivial copy constructors\ntemplate <class T> void copy(T* source,T* destination,int n,__false_type);\n//Copy an array of elements which have trivial copy constructors. Use memcpy.\ntemplate <class T> void copy(T* source,T* destination,int n,__true_type);\n\n//Copy an array of any type by using the most efficient copy mechanism\ntemplate <class T> inline void copy(T* source,T* destination,int n) {\n   copy(source,destination,n,typename __type_traits<T>::has_trivial_copy_constructor());\n}\n*/\n\n\nstruct __true_type {\n};\n\nstruct __false_type {\n};\n\ntemplate <class type>\nstruct __type_traits { \n   typedef __true_type     this_dummy_member_must_be_first;\n                   /* Do not remove this member. It informs a compiler which\n                      automatically specializes __type_traits that this\n                      __type_traits template is special. It just makes sure that\n                      things work if an implementation is using a template\n                      called __type_traits for something unrelated. */\n\n   /* The following restrictions should be observed for the sake of\n      compilers which automatically produce type specific specializations \n      of this class:\n          - You may reorder the members below if you wish\n          - You may remove any of the members below if you wish\n          - You must not rename members without making the corresponding\n            name change in the compiler\n          - Members you add will be treated like regular members unless\n            you add the appropriate support in the compiler. */\n \n\n   typedef __false_type    has_trivial_default_constructor;\n   typedef __false_type    has_trivial_copy_constructor;\n   typedef __false_type    has_trivial_assignment_operator;\n   typedef __false_type    has_trivial_destructor;\n   typedef __false_type    is_POD_type;\n};\n\n\n\n// Provide some specializations.  This is harmless for compilers that\n//  have built-in __types_traits support, and essential for compilers\n//  that don't.\n\n__STL_TEMPLATE_NULL struct __type_traits<char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<signed char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned char> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<short> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned short> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<int> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned int> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<unsigned long> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<float> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<double> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n__STL_TEMPLATE_NULL struct __type_traits<long double> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION\n\ntemplate <class T>\nstruct __type_traits<T*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\nstruct __type_traits<char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\nstruct __type_traits<signed char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\nstruct __type_traits<unsigned char*> {\n   typedef __true_type    has_trivial_default_constructor;\n   typedef __true_type    has_trivial_copy_constructor;\n   typedef __true_type    has_trivial_assignment_operator;\n   typedef __true_type    has_trivial_destructor;\n   typedef __true_type    is_POD_type;\n};\n\n#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */\n\n\n#endif /* __TYPE_TRAITS_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/utility",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996,1997\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_UTILITY\n#define __SGI_STL_UTILITY\n\n#include <stl_config.h>\n#include <stl_relops.h>\n#include <stl_pair.h>\n\n#endif /* __SGI_STL_UTILITY */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/vector",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_VECTOR\n#define __SGI_STL_VECTOR\n\n#include <stl_algobase.h>\n#include <stl_alloc.h>\n#include <stl_construct.h>\n#include <stl_uninitialized.h>\n#include <stl_vector.h>\n#include <stl_bvector.h>\n\n#endif /* __SGI_STL_VECTOR */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  },
  {
    "path": "tass-sgi-stl-2.91.57-source/vector.h",
    "content": "/*\n *\n * Copyright (c) 1994\n * Hewlett-Packard Company\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Hewlett-Packard Company makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n *\n *\n * Copyright (c) 1996\n * Silicon Graphics Computer Systems, Inc.\n *\n * Permission to use, copy, modify, distribute and sell this software\n * and its documentation for any purpose is hereby granted without fee,\n * provided that the above copyright notice appear in all copies and\n * that both that copyright notice and this permission notice appear\n * in supporting documentation.  Silicon Graphics makes no\n * representations about the suitability of this software for any\n * purpose.  It is provided \"as is\" without express or implied warranty.\n */\n\n#ifndef __SGI_STL_VECTOR_H\n#define __SGI_STL_VECTOR_H\n\n#include <algobase.h>\n#include <alloc.h>\n#include <stl_vector.h>\n\n#ifdef __STL_USE_NAMESPACES\nusing __STD::vector;\n#endif /* __STL_USE_NAMESPACES */\n\n#endif /* __SGI_STL_VECTOR_H */\n\n// Local Variables:\n// mode:C++\n// End:\n"
  }
]