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

📄 assoc_cntnr.hpp

📁 linux下编程用 编译软件
💻 HPP
📖 第 1 页 / 共 3 页
字号:
// -*- C++ -*-// Copyright (C) 2005 Free Software Foundation, Inc.//// This file is part of the GNU ISO C++ Library.  This library is free// software; you can redistribute it and/or modify it under the// terms of the GNU General Public License as published by the// Free Software Foundation; either version 2, or (at your option)// any later version.// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License along// with this library; see the file COPYING.  If not, write to the Free// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,// USA.// As a special exception, you may use this file as part of a free software// library without restriction.  Specifically, if other files instantiate// templates or use macros or inline functions from this file, or you compile// this file and link it with other files to produce an executable, this// file does not by itself cause the resulting executable to be covered by// the GNU General Public License.  This exception does not however// invalidate any other reasons why the executable file might be covered by// the GNU General Public License.// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.// Permission to use, copy, modify, sell, and distribute this software// is hereby granted without fee, provided that the above copyright// notice appears in all copies, and that both that copyright notice and// this permission notice appear in supporting documentation. None of// the above authors, nor IBM Haifa Research Laboratories, make any// representation about the suitability of this software for any// purpose. It is provided "as is" without express or implied warranty./** * @file assoc_cntnr.hpp * Contains associative containers. */#ifndef ASSOC_CNTNR_HPP#define ASSOC_CNTNR_HPP#include <ext/pb_assoc/ms_trait.hpp>#include <ext/pb_assoc/ds_trait.hpp>#include <ext/pb_assoc/detail/type_utils.hpp>#include <ext/pb_assoc/detail/typelist.hpp>#include <ext/pb_assoc/detail/standard_policies.hpp>#include <ext/pb_assoc/detail/mapping_level_imp.hpp>#include <ext/pb_assoc/detail/assoc_cntnr_base.hpp>#include <ext/pb_assoc/detail/value_type_adapter/value_type_adapter.hpp>namespace pb_assoc{#define PB_ASSOC_CLASS_T_DEC \	template< \		typename Key, \		typename Data, \		class DS_Tag, \		class Policy_Tl, \		class Allocator>#define PB_ASSOC_CLASS_C_DEC \	basic_assoc_cntnr< \		Key, \		Data, \		DS_Tag, \		Policy_Tl, \		Allocator>#define PB_ASSOC_BASE_C_DEC \	detail::assoc_cntnr_base< \		Key, \		Data, \		DS_Tag, \		Policy_Tl, \		Allocator>::type#define PB_ASSOC_DIRECT_BASE_C_DEC \	detail::assoc_cntnr_base< \		Key, \		Data, \		DS_Tag, \		Policy_Tl, \		Allocator>::type  template<typename Key,	   typename Data,	   class DS_Tag,	   class Policy_Tl,	   class Allocator>  class basic_assoc_cntnr   : public detail::assoc_cntnr_base<Key, Data, DS_Tag, Policy_Tl, Allocator>::type  {  public:    typedef typename Allocator::size_type size_type;    typedef typename Allocator::difference_type difference_type;    typedef DS_Tag ds_category;    typedef data_enabled_ms_tag ms_category;    typedef Allocator allocator;    typedef    typename allocator::template rebind<      Key>::other::value_type    key_type;    typedef    typename allocator::template rebind<      Key>::other::reference    key_reference;    typedef    typename allocator::template rebind<      Key>::other::const_reference    const_key_reference;    typedef    typename allocator::template rebind<      Key>::other::pointer    key_pointer;    typedef    typename allocator::template rebind<      Key>::other::const_pointer    const_key_pointer;    typedef    typename allocator::template rebind<      Data>::other::value_type    data_type;    typedef    typename allocator::template rebind<      Data>::other::reference    data_reference;    typedef    typename allocator::template rebind<      Data>::other::const_reference    const_data_reference;    typedef    typename allocator::template rebind<      Data>::other::pointer    data_pointer;    typedef    typename allocator::template rebind<      Data>::other::const_pointer    const_data_pointer;    typedef    typename allocator::template rebind<      std::pair<const key_type, data_type> >::other::value_type    value_type;    typedef    typename allocator::template rebind<      std::pair<const key_type, data_type> >::other::reference    reference;    typedef    typename allocator::template rebind<      std::pair<const key_type, data_type> >::other::const_reference    const_reference;    typedef    typename allocator::template rebind<      std::pair<const key_type, data_type> >::other::pointer    pointer;    typedef    typename allocator::template rebind<      std::pair<const key_type, data_type> >::other::const_pointer    const_pointer;    typedef    typename PB_ASSOC_BASE_C_DEC::const_find_iterator    const_find_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator;  public:    virtual    ~basic_assoc_cntnr();    inline size_type    size() const;    inline size_type    max_size() const;    inline bool    empty() const;    inline static const_key_reference    extract_key(const_reference r_val);    inline std::pair<find_iterator, bool>    insert(const_reference r_val);    inline data_reference    operator[](const_key_reference r_key);    inline find_iterator    find(const_key_reference r_key)    {      return (my_base::find(r_key));    }    inline const_find_iterator    find(const_key_reference r_key) const    {      return (my_base::find(r_key));    }    inline const_data_reference    operator[](const_key_reference r_key) const;    inline size_type    erase(const_key_reference r_key);    template<class Pred>    inline size_type    erase_if(Pred prd);    void    clear();    inline iterator    begin();    inline const_iterator    begin() const;    inline iterator    end();    inline const_iterator    end() const;  protected:#define PB_ASSOC_CLASS_NAME basic_assoc_cntnr#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \	typename PB_ASSOC_DIRECT_BASE_C_DEC#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp>#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC#undef PB_ASSOC_CLASS_NAME  private:    typedef typename PB_ASSOC_BASE_C_DEC my_base;  private:    basic_assoc_cntnr&     operator=(const PB_ASSOC_CLASS_C_DEC& r_other);  };#include <ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp>#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp>#undef PB_ASSOC_CLASS_T_DEC#undef PB_ASSOC_CLASS_C_DEC#undef PB_ASSOC_BASE_C_DEC#undef PB_ASSOC_DIRECT_BASE_C_DEC#define PB_ASSOC_CLASS_T_DEC \	template< \		typename Key, \		class Cntnr, \		class DS_Tag, \		class Policy_Tl, \		class Allocator>#define PB_ASSOC_CLASS_C_DEC \	basic_assoc_cntnr< \		Key, \		compound_data_type< \			Cntnr>, \		DS_Tag, \		Policy_Tl, \		Allocator>#define PB_ASSOC_DIRECT_BASE_C_DEC \	detail::value_type_adapter< \		Key, \		compound_data_type< \			Cntnr>, \		DS_Tag, \		Policy_Tl, \		Allocator, \		detail::mapping_level_imp< \			compound_data_type< \				Cntnr> >::value - 1>#define PB_ASSOC_BASE_C_DEC \	detail::assoc_cntnr_base< \		Key, \		compound_data_type< \			Cntnr>, \		DS_Tag, \		Policy_Tl, \		Allocator>::type  template<typename Key,	   class Cntnr,	   class DS_Tag,	   class Policy_Tl,	   class Allocator>  class basic_assoc_cntnr<Key, compound_data_type< Cntnr>, DS_Tag, Policy_Tl, Allocator> : public PB_ASSOC_DIRECT_BASE_C_DEC  {  public:    typedef typename Allocator::size_type size_type;    typedef typename Allocator::difference_type difference_type;    typedef DS_Tag ds_category;    typedef compound_data_enabled_ms_tag ms_category;    typedef Allocator allocator;    typedef    typename allocator::template rebind<      Key>::other::value_type    key_type;    typedef    typename allocator::template rebind<      Key>::other::reference    key_reference;    typedef    typename allocator::template rebind<      Key>::other::const_reference    const_key_reference;    typedef    typename allocator::template rebind<      Key>::other::pointer    key_pointer;    typedef    typename allocator::template rebind<      Key>::other::const_pointer    const_key_pointer;    typedef    typename allocator::template rebind<      Cntnr>::other::value_type    data_type;    typedef    typename allocator::template rebind<      Cntnr>::other::reference    data_reference;    typedef    typename allocator::template rebind<      Cntnr>::other::const_reference    const_data_reference;    typedef    typename allocator::template rebind<      Cntnr>::other::pointer    data_pointer;    typedef    typename allocator::template rebind<      Cntnr>::other::const_pointer    const_data_pointer;    typedef    typename allocator::template rebind<      std::pair<const key_type, Cntnr> >::other::value_type    value_type;    typedef    typename allocator::template rebind<      std::pair<const key_type, Cntnr> >::other::reference    reference;    typedef    typename allocator::template rebind<      std::pair<const key_type, Cntnr> >::other::const_reference    const_reference;    typedef    typename allocator::template rebind<      std::pair<const key_type, Cntnr> >::other::pointer    pointer;    typedef    typename allocator::template rebind<      std::pair<const key_type, Cntnr> >::other::const_pointer    const_pointer;    typedef    typename PB_ASSOC_BASE_C_DEC::const_find_iterator    const_find_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator;    typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator;    template<int Mapping_Level>    struct rebind    {    private:      enum	{	  mapping_level =	  detail::mapping_level_imp<compound_data_type<Cntnr> >::value	};    public:      typedef      detail::value_type_adapter<	Key,	compound_data_type<	Cntnr>,	DS_Tag,	Policy_Tl,	Allocator,	mapping_level - Mapping_Level>      other;    };  public:    virtual    ~basic_assoc_cntnr();    inline size_type    size() const;    inline size_type    max_size() const;    inline bool    empty() const;    inline static const_key_reference    extract_key(const_reference r_val);    inline std::pair<find_iterator, bool>    insert(const_reference r_val);    inline data_reference    operator[](const_key_reference r_key);    inline find_iterator    find(const_key_reference r_key)    {      return (my_base::find(r_key));    }    inline const_find_iterator    find(const_key_reference r_key) const    {      return (my_base::find(r_key));    }    inline const_data_reference    operator[](const_key_reference r_key) const;    inline size_type    erase(const_key_reference r_key);    template<class Pred>    inline size_type    erase_if(Pred prd);    void    clear();    inline iterator    begin();    inline const_iterator    begin() const;    inline iterator    end();    inline const_iterator    end() const;  protected:#define PB_ASSOC_CLASS_NAME basic_assoc_cntnr#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \	typename PB_ASSOC_DIRECT_BASE_C_DEC#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp>#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC#undef PB_ASSOC_CLASS_NAME  private:    typedef typename PB_ASSOC_BASE_C_DEC my_base;  private:    basic_assoc_cntnr&     operator=(const PB_ASSOC_CLASS_C_DEC& r_other);  };#include <ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp>

⌨️ 快捷键说明

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