⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _slist.h

📁 vc2005 wince 的 stlport 的工程源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 *
 * Copyright (c) 2003
 * Francois Dumont
 *
 * This material is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * Permission to use or copy this software for any purpose is hereby granted 
 * without fee, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 */

/* NOTE: This is an internal header file, included by other STL headers.
 *   You should not attempt to use it directly.
 */

#ifndef _STLP_SPECIALIZED_SLIST_H
#define _STLP_SPECIALIZED_SLIST_H

#ifndef _STLP_VOID_PTR_TRAITS_H
#  include <stl/pointers/_void_ptr_traits.h>
#endif

/*
 * The general slist class.
 */
template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
class slist {
private:
  typedef _STLP_PRIV::_Slist_impl<_Tp, _Alloc> _Base;
  typedef slist<_Tp, _Alloc> _Self;
public:
  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
  
  __IMPORT_WITH_ITERATORS(_Base)
  typedef typename _Base::_Iterator_category _Iterator_category;
  
  allocator_type get_allocator() const { return _M_impl.get_allocator(); }

  explicit slist(const allocator_type& __a = allocator_type()) : _M_impl(__a) {}

#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  explicit slist(size_type __n, const value_type& __x = value_type(),
#else
  slist(size_type __n, const value_type& __x,
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
        const allocator_type& __a =  allocator_type()) : _M_impl(__n, __x, __a) {}

#if defined(_STLP_DONT_SUP_DFLT_PARAM)
  explicit slist(size_type __n) : _M_impl(__n) {}
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/

#ifdef _STLP_MEMBER_TEMPLATES
  // We don't need any dispatching tricks here, because _M_insert_after_range
  // already does them.
  template <class _InputIterator>
  slist(_InputIterator __first, _InputIterator __last,
        const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _M_impl(__first, __last, __a) {}
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  // VC++ needs this crazyness
  template <class _InputIterator>
  slist(_InputIterator __first, _InputIterator __last) : _M_impl(__first, __last) {}
# endif

#else /* _STLP_MEMBER_TEMPLATES */
  slist(const_iterator __first, const_iterator __last,
        const allocator_type& __a =  allocator_type() ) : _M_impl(__first, __last, __a) {}
  slist(const value_type* __first, const value_type* __last,
        const allocator_type& __a =  allocator_type()) : _M_impl(__first, __last, __a) {}
#endif /* _STLP_MEMBER_TEMPLATES */

  slist(const _Self& __x) : _M_impl(__x._M_impl) {}

  slist(__move_source<_Self> src) : _M_impl(__move_source<_Base>(src.get()._M_impl)) {}

  _Self& operator= (const _Self& __x) {
    _M_impl = __x._M_impl; return *this;
  }

  void assign(size_type __n, const value_type& __val) { _M_impl.assign(__n, __val); }

#ifdef _STLP_MEMBER_TEMPLATES
  template <class _InputIterator>
  void assign(_InputIterator __first, _InputIterator __last) {
#else
  void assign(const value_type *__first, const value_type *__last) { _M_impl.assign(__first, __last); }
  void assign(const_iterator __first, const_iterator __last) {
#endif
    _M_impl.assign(__first, __last);
  }

  iterator before_begin()             { return _M_impl.before_begin(); }
  const_iterator before_begin() const { return _M_impl.before_begin(); }
  iterator begin()                    { return _M_impl.begin(); }
  const_iterator begin() const        { return _M_impl.begin(); }
  iterator end()                      { return _M_impl.end(); }
  const_iterator end() const          { return _M_impl.end(); }
  
  iterator previous(const_iterator __pos)             { return _M_impl.previous(__pos); }
  const_iterator previous(const_iterator __pos) const { return _M_impl.previous(__pos); }

  size_type size() const              { return _M_impl.size(); }
  size_type max_size() const          { return _M_impl.max_size(); }

  bool empty() const                  { return _M_impl.empty(); }

  void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }

  reference front()                   { return _M_impl.front(); }
  const_reference front() const       { return _M_impl.front(); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
  void push_front(const value_type& __x = value_type())   {
#else
  void push_front(const value_type& __x)   {
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
    _M_impl.push_front(__x);
  }

# if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
  void push_front() { _M_impl.push_front();}
# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/

  void pop_front()  { _M_impl.pop_front(); }

#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  iterator insert_after(iterator __pos, const value_type& __x = value_type()) {
#else
  iterator insert_after(iterator __pos, const value_type& __x) {
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
    return _M_impl.insert_after(__pos, __x);
  }

#if defined(_STLP_DONT_SUP_DFLT_PARAM)
  iterator insert_after(iterator __pos) { return _M_impl.insert_after(__pos); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/

  void insert_after(iterator __pos, size_type __n, const value_type& __x) {
    _M_impl.insert_after(__pos, __n, __x);
  }

#ifdef _STLP_MEMBER_TEMPLATES
  template <class _InIter>
  void insert_after(iterator __pos, _InIter __first, _InIter __last) {
#else /* _STLP_MEMBER_TEMPLATES */
  void insert_after(iterator __pos,
                    const value_type* __first, const value_type* __last) {
    _M_impl.insert_after(__pos, __first, __last);
  }
  void insert_after(iterator __pos,
                    const_iterator __first, const_iterator __last) {
#endif /* _STLP_MEMBER_TEMPLATES */
   _M_impl.insert_after(__pos, __first, __last);
  }

#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  iterator insert(iterator __pos, const value_type& __x = value_type()) {
#else
  iterator insert(iterator __pos, const value_type& __x) {
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
    return _M_impl.insert(__pos, __x);
  }

#if defined(_STLP_DONT_SUP_DFLT_PARAM)
  iterator insert(iterator __pos) { return _M_impl.insert(__pos); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/

  void insert(iterator __pos, size_type __n, const value_type& __x) {
    _M_impl.insert(__pos, __n, __x);
  } 
    
#ifdef _STLP_MEMBER_TEMPLATES
  // We don't need any dispatching tricks here, because _M_insert_after_range
  // already does them.
  template <class _InIter>
  void insert(iterator __pos, _InIter __first, _InIter __last) {
#else /* _STLP_MEMBER_TEMPLATES */
  void insert(iterator __pos, const value_type* __first, 
                              const value_type* __last) {
    _M_impl.insert(__pos, __first, __last);
  }
  void insert(iterator __pos, const_iterator __first, const_iterator __last) {
#endif /* _STLP_MEMBER_TEMPLATES */
    _M_impl.insert(__pos, __first, __last);
  }

  iterator erase_after(iterator __pos) 
  { return _M_impl.erase_after(__pos); }
  iterator erase_after(iterator __before_first, iterator __last) 
  { return _M_impl.erase_after(__before_first, __last); }

  iterator erase(iterator __pos) 
  { return _M_impl.erase(__pos); }
  iterator erase(iterator __first, iterator __last) 
  { return _M_impl.erase(__first, __last); }

#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
  void resize(size_type __new_size, const value_type& __x = value_type())
  { _M_impl.resize(__new_size, __x); }
#else
  void resize(size_type __new_size, const value_type& __x) 
  { _M_impl.resize(__new_size, __x); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/

#if defined(_STLP_DONT_SUP_DFLT_PARAM)
  void resize(size_type __new_size) { _M_impl.resize(__new_size); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/

  void clear() { _M_impl.clear(); }

  void splice_after(iterator __pos, 
                    iterator __before_first, iterator __before_last)
  { _M_impl.splice_after(__pos, __before_first, __before_last); }
  void splice_after(iterator __pos, iterator __prev) 
  { _M_impl.splice_after(__pos, __prev); }
  void splice_after(iterator __pos, _Self& __x) 
  { _M_impl.splice_after(__pos, __x._M_impl); }
  void splice(iterator __pos, _Self& __x) 
  { _M_impl.splice(__pos, __x._M_impl); }
  void splice(iterator __pos, _Self& __x, iterator __i) 
  { _M_impl.splice(__pos, __x._M_impl, __i); }
  void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) 
  { _M_impl.splice(__pos, __x._M_impl, __first, __last); }
  
  void reverse() { _M_impl.reverse(); }
  void remove(const value_type& __val) { _M_impl.remove(__val); }
  void unique() { _M_impl.unique(); }
  void merge(_Self& __x) { _M_impl.merge(__x._M_impl); }
  void sort() { _M_impl.sort(); }

#ifdef _STLP_MEMBER_TEMPLATES
  template <class _Predicate>
  void remove_if(_Predicate __pred) { _M_impl.remove_if(__pred); }
  template <class _BinaryPredicate> 
  void unique(_BinaryPredicate __pred) { _M_impl.unique(__pred); }
  template <class _StrictWeakOrdering>
  void merge(_Self& __x, _StrictWeakOrdering __comp) { _M_impl.merge(__x._M_impl, __comp); }
  template <class _StrictWeakOrdering> 
  void sort(_StrictWeakOrdering __comp) { _M_impl.sort(__comp); }
#endif /* _STLP_MEMBER_TEMPLATES */
private:
  _Base _M_impl;
};

#if defined (_STLP_USE_TEMPLATE_EXPORT)
_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV::_Slist_node<void*>;
typedef _STLP_PRIV::_Slist_node<void*> _VoidPtrSNode;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_STLP_PRIV::_Slist_node_base, _VoidPtrSNode, allocator<_VoidPtrSNode> >;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV::_Slist_base<void*, allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV::_Slist_impl<void*, allocator<void*> >;
#endif

/*
 * The pointer partial specialization.
 */
template <class _Tp, class _Alloc>
class slist<_Tp*, _Alloc> {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -