map.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_MAP_HH
00021 #define PALUDIS_GUARD_PALUDIS_UTIL_MAP_HH 1
00022 
00023 #include <paludis/util/map-fwd.hh>
00024 #include <paludis/util/attributes.hh>
00025 #include <paludis/util/instantiation_policy.hh>
00026 #include <paludis/util/private_implementation_pattern.hh>
00027 #include <paludis/util/wrapped_output_iterator-fwd.hh>
00028 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00029 
00030 #include <utility>
00031 
00032 /** \file
00033  * Declarations for the Map<> class.
00034  *
00035  * \ingroup g_data_structures
00036  *
00037  * \section Examples
00038  *
00039  * - None at this time.
00040  */
00041 
00042 namespace paludis
00043 {
00044     /**
00045      * A wrapper around a map, avoiding the need to include lots of STL bloat
00046      * everywhere.
00047      *
00048      * \ingroup g_data_structures
00049      * \since 0.26
00050      * \nosubgrouping
00051      */
00052     template <typename K_, typename V_, typename C_>
00053     class PALUDIS_VISIBLE Map :
00054         private PrivateImplementationPattern<Map<K_, V_, C_> >,
00055         private InstantiationPolicy<Map<K_, V_, C_>, instantiation_method::NonCopyableTag>
00056     {
00057         private:
00058             using PrivateImplementationPattern<Map<K_, V_, C_> >::_imp;
00059 
00060         public:
00061             ///\name Basic operations
00062             ///\{
00063 
00064             Map();
00065             ~Map();
00066 
00067             ///\}
00068 
00069             ///\name Iteration
00070             ///\{
00071 
00072             struct ConstIteratorTag;
00073             typedef WrappedForwardIterator<ConstIteratorTag, const std::pair<const K_, V_> > ConstIterator;
00074             ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
00075             ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
00076             ConstIterator find(const K_ &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00077 
00078             struct InserterTag;
00079             typedef WrappedOutputIterator<InserterTag, std::pair<const K_, V_> > Inserter;
00080             Inserter inserter() PALUDIS_ATTRIBUTE((warn_unused_result));
00081 
00082             ///\}
00083 
00084             ///\name Content information
00085             ///\{
00086 
00087             bool empty() const PALUDIS_ATTRIBUTE((warn_unused_result));
00088             unsigned size() const PALUDIS_ATTRIBUTE((warn_unused_result));
00089 
00090             ///\}
00091 
00092             ///\name Content modification
00093             ///\{
00094 
00095             void insert(const K_ &, const V_ &);
00096             void erase(const ConstIterator &);
00097             void erase(const K_ &);
00098 
00099             ///\}
00100     };
00101 }
00102 
00103 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4