Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2008-07-05 07:18:25


Author: asutton
Date: 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
New Revision: 47094
URL: http://svn.boost.org/trac/boost/changeset/47094

Log:
A little restructuring...

Added:
   sandbox/SOC/2008/graphs/branches/descrip/descriptor/index_descriptor.hpp
      - copied unchanged from r47075, /sandbox/SOC/2008/graphs/branches/descrip/descriptor/index.hpp
   sandbox/SOC/2008/graphs/branches/descrip/descriptor/node_descriptor.hpp
      - copied unchanged from r47075, /sandbox/SOC/2008/graphs/branches/descrip/descriptor/node.hpp
Removed:
   sandbox/SOC/2008/graphs/branches/descrip/descriptor/index.hpp
   sandbox/SOC/2008/graphs/branches/descrip/descriptor/node.hpp
Text files modified:
   sandbox/SOC/2008/graphs/branches/descrip/container.hpp | 187 ++++++++++++++++++++++++++++-----------
   sandbox/SOC/2008/graphs/branches/descrip/container/functions.hpp | 28 -----
   sandbox/SOC/2008/graphs/branches/descrip/container/list.hpp | 13 --
   sandbox/SOC/2008/graphs/branches/descrip/container/map.hpp | 13 --
   sandbox/SOC/2008/graphs/branches/descrip/container/multimap.hpp | 13 --
   sandbox/SOC/2008/graphs/branches/descrip/container/multiset.hpp | 13 --
   sandbox/SOC/2008/graphs/branches/descrip/container/set.hpp | 14 --
   sandbox/SOC/2008/graphs/branches/descrip/container/vector.hpp | 12 --
   sandbox/SOC/2008/graphs/branches/descrip/des.cpp | 14 --
   9 files changed, 134 insertions(+), 173 deletions(-)

Modified: sandbox/SOC/2008/graphs/branches/descrip/container.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -7,6 +7,8 @@
 #ifndef CONTAINER_HPP
 #define CONTAINER_HPP
 
+#include <boost/type_traits.hpp>
+
 // Forward declarations of stdandard types. Jeremy's right! There does need
 // to be an <stlfwd> header since there's no guarantee that these are the
 // correct signatures for these types.
@@ -59,6 +61,8 @@
     typedef typename Container::iterator_stability iterator_stability;
 };
 
+// Trait accessors
+
 /** Return the container category tag of the given container. */
 template <typename Container>
 inline typename container_traits<Container>::category
@@ -71,75 +75,150 @@
 iterator_stability(Container const&)
 { return typename container_traits<Container>::iterator_stability(); }
 
-// Pull specializtions and metafunctions.
-#include "container/functions.hpp"
-#include "container/vector.hpp"
-#include "container/list.hpp"
-#include "container/set.hpp"
-#include "container/map.hpp"
-#include "container/multiset.hpp"
-#include "container/multimap.hpp"
+// Metafunctions
 
-// Use this as a compile-time assertion that X is stable
-// inline void require_stable(stable_tag) { }
+/**
+ * Evaluates to true if the container contains unique elements.
+ */
+template <typename Container>
+struct contains_unique_elements
+{
+ static bool const value =
+ boost::is_convertible<
+ typename container_traits<Container>::category,
+ unique_associative_container_tag
+ >::value;
+};
 
-#if 0
- // deque
+/**
+ * Evaluates to true if the container's elements are mapped to a key. This is
+ * only true for pair associative containers, not sets (which are a little
+ * different).
+ */
+template <typename Container>
+struct contains_mapped_elements
+{
+ static bool const value =
+ boost::is_convertible<
+ typename container_traits<Container>::category,
+ pair_associative_container_tag
+ >::value;
+};
 
- // std::map
+// Specializations
 
- template <class Key, class T, class Cmp, class Alloc>
- map_tag container_category(const std::map<Key,T,Cmp,Alloc>&)
- { return map_tag(); }
+// Vector
+struct vector_tag :
+ virtual public random_access_container_tag,
+ virtual public back_insertion_sequence_tag
+{ };
 
- template <class Key, class T, class Cmp, class Alloc>
- stable_tag iterator_stability(const std::map<Key,T,Cmp,Alloc>&)
- { return stable_tag(); }
+template <class T, class Alloc>
+struct container_traits<std::vector<T,Alloc>>
+{
+ typedef vector_tag category;
+ typedef unstable_iterator_tag iterator_stability;
+};
 
- // std::multimap
+// List
+struct list_tag :
+ virtual public reversible_container_tag,
+ virtual public back_insertion_sequence_tag,
+ virtual public front_insertion_sequence_tag
+{ };
 
- template <class Key, class T, class Cmp, class Alloc>
- multimap_tag container_category(const std::multimap<Key,T,Cmp,Alloc>&)
- { return multimap_tag(); }
+template <class T, class Alloc>
+struct container_traits<std::list<T,Alloc>>
+{
+ typedef list_tag category;
+ typedef stable_iterator_tag iterator_stability;
+};
 
- template <class Key, class T, class Cmp, class Alloc>
- stable_tag iterator_stability(const std::multimap<Key,T,Cmp,Alloc>&)
- { return stable_tag(); }
+// TODO: Dequeue
 
+// Set
+struct set_tag :
+ virtual public sorted_associative_container_tag,
+ virtual public simple_associative_container_tag,
+ virtual public unique_associative_container_tag
+{ };
 
- // hash_set, hash_map
 
-#ifndef BOOST_NO_HASH
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- template <class Key, class Eq, class Hash, class Alloc>
- struct container_traits< BOOST_STD_EXTENSION_NAMESPACE::hash_set<Key,Eq,Hash,Alloc> > {
+template <class Key, class Cmp, class Alloc>
+struct container_traits<std::set<Key,Cmp,Alloc>>
+{
     typedef set_tag category;
- typedef stable_tag iterator_stability; // is this right?
- };
- template <class Key, class T, class Eq, class Hash, class Alloc>
- struct container_traits< BOOST_STD_EXTENSION_NAMESPACE::hash_map<Key,T,Eq,Hash,Alloc> > {
+ typedef stable_iterator_tag iterator_stability;
+};
+
+// Multiset
+struct multiset_tag :
+ virtual public sorted_associative_container_tag,
+ virtual public simple_associative_container_tag,
+ virtual public multiple_associative_container_tag
+{ };
+
+template <class T, class Compare, class Alloc>
+struct container_traits<std::multiset<T, Compare, Alloc>>
+{
+ typedef multiset_tag category;
+ typedef stable_iterator_tag iterator_stability;
+};
+
+// Map
+struct map_tag :
+ virtual public sorted_associative_container_tag,
+ virtual public pair_associative_container_tag,
+ virtual public unique_associative_container_tag
+{ };
+
+template <class Key, class T, class Compare, class Alloc>
+struct container_traits<std::map<Key, T, Compare, Alloc>>
+{
     typedef map_tag category;
- typedef stable_tag iterator_stability; // is this right?
- };
-#endif
- template <class Key, class Eq, class Hash, class Alloc>
- set_tag container_category(const BOOST_STD_EXTENSION_NAMESPACE::hash_set<Key,Eq,Hash,Alloc>&)
- { return set_tag(); }
-
- template <class Key, class T, class Eq, class Hash, class Alloc>
- map_tag container_category(const BOOST_STD_EXTENSION_NAMESPACE::hash_map<Key,T,Eq,Hash,Alloc>&)
- { return map_tag(); }
-
- template <class Key, class Eq, class Hash, class Alloc>
- stable_tag iterator_stability(const BOOST_STD_EXTENSION_NAMESPACE::hash_set<Key,Eq,Hash,Alloc>&)
- { return stable_tag(); }
-
- template <class Key, class T, class Eq, class Hash, class Alloc>
- stable_tag iterator_stability(const BOOST_STD_EXTENSION_NAMESPACE::hash_map<Key,T,Eq,Hash,Alloc>&)
- { return stable_tag(); }
-#endif
+ typedef stable_iterator_tag iterator_stability;
+};
 
+// Multimap
+struct multimap_tag :
+ virtual public sorted_associative_container_tag,
+ virtual public pair_associative_container_tag,
+ virtual public multiple_associative_container_tag
+{ };
 
+template <class Key, class T, class Compare, class Alloc>
+struct container_traits<std::multimap<Key, T, Compare, Alloc>>
+{
+ typedef multimap_tag category;
+ typedef stable_iterator_tag iterator_stability;
+};
+
+// TODO: Unordered Set
+// TODO: Unordered Multiset
+// TODO: Unordered Map
+// TODO: Unordered Multimap
+
+// Generic insert/remove functions
+
+namespace dispatch
+{
+ template <typename Container, typename Value>
+ inline typename Container::iterator
+ insert(Container& c, Value const& x, back_insertion_sequence_tag)
+ { return c.insert(c.end(), x); }
+
+ template <typename Container, typename Value>
+ inline typename Container::iterator
+ insert(Container& c, Value const& x, simple_associative_container_tag)
+ { return c.insert(x).first; }
+}
+
+template <typename Container, typename T>
+inline typename Container::iterator
+insert(Container& c, T const& x)
+{ return dispatch(c, x, container_category(c)); }
+
+#if 0
 
   //===========================================================================
   // Generalized Container Functions

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/functions.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/functions.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/functions.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -4,32 +4,4 @@
 
 #include <boost/type_traits.hpp>
 
-/**
- * Evaluates to true if the container contains unique elements.
- */
-template <typename Container>
-struct contains_unique_elements
-{
- static bool const value =
- boost::is_convertible<
- typename container_traits<Container>::category,
- unique_associative_container_tag
- >::value;
-};
-
-/**
- * Evaluates to true if the container's elements are mapped to a key. This is
- * only true for pair associative containers, not sets (which are a little
- * different).
- */
-template <typename Container>
-struct contains_mapped_elements
-{
- static bool const value =
- boost::is_convertible<
- typename container_traits<Container>::category,
- pair_associative_container_tag
- >::value;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/list.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/list.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/list.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,17 +2,4 @@
 #ifndef CONTAINER_LIST_HPP
 #define CONTAINER_LIST_HPP
 
-struct list_tag :
- virtual public reversible_container_tag,
- virtual public back_insertion_sequence_tag,
- virtual public front_insertion_sequence_tag
-{ };
-
-template <class T, class Alloc>
-struct container_traits<std::list<T,Alloc>>
-{
- typedef list_tag category;
- typedef stable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/map.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/map.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/map.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,17 +2,4 @@
 #ifndef CONTAINER_MAP_HPP
 #define CONTAINER_MAP_HPP
 
-struct map_tag :
- virtual public sorted_associative_container_tag,
- virtual public pair_associative_container_tag,
- virtual public unique_associative_container_tag
-{ };
-
-template <class Key, class T, class Compare, class Alloc>
-struct container_traits<std::map<Key, T, Compare, Alloc>>
-{
- typedef map_tag category;
- typedef stable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/multimap.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/multimap.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/multimap.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,17 +2,4 @@
 #ifndef CONTAINER_MULTIMAP_HPP
 #define CONTAINER_MULTIMAP_HPP
 
-struct multimap_tag :
- virtual public sorted_associative_container_tag,
- virtual public pair_associative_container_tag,
- virtual public multiple_associative_container_tag
-{ };
-
-template <class Key, class T, class Compare, class Alloc>
-struct container_traits<std::multimap<Key, T, Compare, Alloc>>
-{
- typedef multimap_tag category;
- typedef stable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/multiset.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/multiset.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/multiset.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,17 +2,4 @@
 #ifndef CONTAINER_MULTISET_HPP
 #define CONTAINER_MULTISET_HPP
 
-struct multiset_tag :
- virtual public sorted_associative_container_tag,
- virtual public simple_associative_container_tag,
- virtual public multiple_associative_container_tag
-{ };
-
-template <class T, class Compare, class Alloc>
-struct container_traits<std::multiset<T, Compare, Alloc>>
-{
- typedef multiset_tag category;
- typedef stable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/set.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/set.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/set.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,18 +2,4 @@
 #ifndef CONTAINER_SET_HPP
 #define CONTAINER_SET_HPP
 
-struct set_tag :
- virtual public sorted_associative_container_tag,
- virtual public simple_associative_container_tag,
- virtual public unique_associative_container_tag
-{ };
-
-
-template <class Key, class Cmp, class Alloc>
-struct container_traits<std::set<Key,Cmp,Alloc>>
-{
- typedef set_tag category;
- typedef stable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/container/vector.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/container/vector.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/container/vector.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -2,16 +2,4 @@
 #ifndef CONTAINER_VECTOR_HPP
 #define CONTAINER_VECTOR_HPP
 
-struct vector_tag :
- virtual public random_access_container_tag,
- virtual public back_insertion_sequence_tag
-{ };
-
-template <class T, class Alloc>
-struct container_traits<std::vector<T,Alloc>>
-{
- typedef vector_tag category;
- typedef unstable_iterator_tag iterator_stability;
-};
-
 #endif

Modified: sandbox/SOC/2008/graphs/branches/descrip/des.cpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/des.cpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/des.cpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
@@ -12,24 +12,12 @@
 
 namespace dispatch
 {
- template <typename Container, typename Value>
- void insert(Container& c, Value const& x, back_insertion_sequence_tag)
- { c.push_back(x); }
-
- template <typename Container, typename Value>
- void insert(Container& c, Value const& x, simple_associative_container_tag)
- { c.insert(x); }
-
+ // A little help for mapped values.
     template <typename Container, typename Value>
     void insert(Container& c, Value const& x, pair_associative_container_tag)
     { c.insert(make_pair(x, x)); }
 }
 
-// A little tag dispatch for the soul. So pretty.
-template <typename Container, typename Value>
-void insert(Container& c, Value const& x)
-{ dispatch::insert(c, x, container_category(c)); }
-
 template <typename T, typename U>
 ostream& operator<<(ostream& os, pair<T, U> const& x)
 { return os << "(" << x.first << "," << x.second << ")"; }

Deleted: sandbox/SOC/2008/graphs/branches/descrip/descriptor/index.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/descriptor/index.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
+++ (empty file)
@@ -1,71 +0,0 @@
-
-#ifndef INDEX_DESCRIPTOR_HPP
-#define INDEX_DESCRIPTOR_HPP
-
-#include <boost/functional/hash.hpp>
-
-/**
- * The index_descriptor simply maintains the descriptor as an index into the
- * given offset.
- */
-template <typename Index>
-struct index_descriptor
-{
- typedef Index descriptor_type;
-
- inline index_descriptor()
- : value(-1)
- { }
-
- inline index_descriptor(descriptor_type d)
- : value(d)
- { }
-
- template <typename Container>
- inline index_descriptor(Container& c, typename Container::iterator i)
- : value(std::distance(c.begin(), i))
- { }
-
- inline bool is_null() const
- { return value == descriptor_type(-1); }
-
- /** @name Equality Comparable */
- //@{
- inline bool operator==(index_descriptor const& x)
- { return value == x.value; }
-
- inline bool operator!=(index_descriptor const& x)
- { return value != x.value; }
- //@}
-
- /** @name Less Than Comparable */
- //@{
- inline bool operator<(index_descriptor const& x)
- { return value < x.value; }
-
- inline bool operator>(index_descriptor const& x)
- { return value > x.value; }
-
- inline bool operator<=(index_descriptor const& x)
- { return value <= x.value; }
-
- inline bool operator>=(index_descriptor const& x)
- { return value >= x.value; }
- //@}
-
- template <typename Container>
- inline typename Container::iterator get(Container& c) const
- { return std::next(c.begin(), value); }
-
- descriptor_type value;
-};
-
-// A hash function for indexed descriptors.
-template <typename Index>
-std::size_t hash_value(index_descriptor<Index> const& x)
-{
- using boost::hash_value;
- return hash_value(x.value);
-}
-
-#endif

Deleted: sandbox/SOC/2008/graphs/branches/descrip/descriptor/node.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/descriptor/node.hpp 2008-07-05 07:18:24 EDT (Sat, 05 Jul 2008)
+++ (empty file)
@@ -1,62 +0,0 @@
-
-#ifndef VECTOR_DESCRIPTOR_HPP
-#define VECTOR_DESCRIPTOR_HPP
-
-/**
- * The node descriptor contains an iterator into the target container. The
- * container iterator is just a pattern for the actual iterator and has no
- * real type (it's opaque).
- */
-template <typename Blob>
-struct node_descriptor
-{
- typedef Blob descriptor_type;
-
- inline node_descriptor()
- : value()
- { }
-
- inline node_descriptor(descriptor_type const& x)
- : value(x)
- { }
-
- template <typename Container>
- inline node_descriptor(Container&, typename Container::iterator i)
- : value(i)
- { }
-
- inline bool is_null()
- { return value == descriptor_type(); }
-
- /** @name Equality Comparable */
- //@{
- inline bool operator==(node_descriptor const& x)
- { return value == x.value; }
-
- inline bool operator!=(node_descriptor const& x)
- { return value != x.value; }
- //@}
-
- /** @name Less Than Comparable */
- //@{
- inline bool operator<(node_descriptor const& x)
- { return value < x.value; }
-
- inline bool operator>(node_descriptor const& x)
- { return value > x.value; }
-
- inline bool operator<=(node_descriptor const& x)
- { return value <= x.value; }
-
- inline bool operator>=(node_descriptor const& x)
- { return value >= x.value; }
- //@}
-
- template <typename Container>
- inline typename Container::iterator get(Container& c) const
- { return value.get<typename Container::iterator>(); }
-
- descriptor_type value;
-};
-
-#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk