|
Boost-Commit : |
From: asutton_at_[hidden]
Date: 2008-07-05 07:46:37
Author: asutton
Date: 2008-07-05 07:46:36 EDT (Sat, 05 Jul 2008)
New Revision: 47097
URL: http://svn.boost.org/trac/boost/changeset/47097
Log:
Restructuring containers library.
Text files modified:
sandbox/SOC/2008/graphs/branches/descrip/container.hpp | 77 +++++++++++++++++++++++----------------
sandbox/SOC/2008/graphs/branches/descrip/des.cpp | 24 +++++++++---
sandbox/SOC/2008/graphs/branches/descrip/descriptor.hpp | 4 +-
3 files changed, 66 insertions(+), 39 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:46:36 EDT (Sat, 05 Jul 2008)
@@ -29,18 +29,28 @@
// These define the basic concepts of STL containers. Note the use of
// virtual inheritance because there are lots of inheritance diamonds.
struct container_tag { };
-struct forward_container_tag : virtual public container_tag { };
-struct reversible_container_tag : virtual public forward_container_tag { };
-struct random_access_container_tag : virtual public reversible_container_tag { };
-struct sequence_tag : virtual public forward_container_tag { };
-struct associative_container_tag : virtual public forward_container_tag { };
-struct sorted_associative_container_tag : virtual public associative_container_tag , virtual public reversible_container_tag { };
-struct front_insertion_sequence_tag : virtual public sequence_tag { };
-struct back_insertion_sequence_tag : virtual public sequence_tag { };
-struct unique_associative_container_tag : virtual public associative_container_tag { };
-struct multiple_associative_container_tag : virtual public associative_container_tag { };
-struct simple_associative_container_tag : virtual public associative_container_tag { };
-struct pair_associative_container_tag : virtual public associative_container_tag { };
+struct forward_container_tag : virtual container_tag { };
+struct reversible_container_tag : virtual forward_container_tag { };
+struct random_access_container_tag : virtual reversible_container_tag { };
+
+// Sequential containers
+struct sequence_tag : virtual forward_container_tag { };
+struct front_insertion_sequence_tag : virtual sequence_tag { };
+struct back_insertion_sequence_tag : virtual sequence_tag { };
+
+// Associative containers
+struct associative_container_tag : virtual forward_container_tag { };
+struct sorted_associative_container_tag : virtual associative_container_tag, virtual reversible_container_tag { };
+struct unique_associative_container_tag : virtual associative_container_tag { };
+struct multiple_associative_container_tag : virtual associative_container_tag { };
+struct simple_associative_container_tag : virtual associative_container_tag { };
+struct pair_associative_container_tag : virtual associative_container_tag { };
+
+// These aren't real concepts, just combinations of others.
+struct set_container_tag : virtual simple_associative_container_tag, virtual unique_associative_container_tag { };
+struct map_container_tag : virtual pair_associative_container_tag, virtual unique_associative_container_tag { };
+struct multiset_container_tag : virtual simple_associative_container_tag, virtual multiple_associative_container_tag { };
+struct multimap_container_tag : virtual pair_associative_container_tag, virtual multiple_associative_container_tag { };
// Iterator Stability Tags
// These tags determine the "stability" of iterators. Do mutating operations
@@ -109,8 +119,8 @@
// Vector
struct vector_tag :
- virtual public random_access_container_tag,
- virtual public back_insertion_sequence_tag
+ virtual random_access_container_tag,
+ virtual back_insertion_sequence_tag
{ };
template <class T, class Alloc>
@@ -122,9 +132,9 @@
// List
struct list_tag :
- virtual public reversible_container_tag,
- virtual public back_insertion_sequence_tag,
- virtual public front_insertion_sequence_tag
+ virtual reversible_container_tag,
+ virtual back_insertion_sequence_tag,
+ virtual front_insertion_sequence_tag
{ };
template <class T, class Alloc>
@@ -138,9 +148,9 @@
// Set
struct set_tag :
- virtual public sorted_associative_container_tag,
- virtual public simple_associative_container_tag,
- virtual public unique_associative_container_tag
+ virtual sorted_associative_container_tag,
+ virtual simple_associative_container_tag,
+ virtual unique_associative_container_tag
{ };
@@ -153,9 +163,9 @@
// Multiset
struct multiset_tag :
- virtual public sorted_associative_container_tag,
- virtual public simple_associative_container_tag,
- virtual public multiple_associative_container_tag
+ virtual sorted_associative_container_tag,
+ virtual simple_associative_container_tag,
+ virtual multiple_associative_container_tag
{ };
template <class T, class Compare, class Alloc>
@@ -167,9 +177,9 @@
// Map
struct map_tag :
- virtual public sorted_associative_container_tag,
- virtual public pair_associative_container_tag,
- virtual public unique_associative_container_tag
+ virtual sorted_associative_container_tag,
+ virtual pair_associative_container_tag,
+ virtual unique_associative_container_tag
{ };
template <class Key, class T, class Compare, class Alloc>
@@ -181,9 +191,9 @@
// Multimap
struct multimap_tag :
- virtual public sorted_associative_container_tag,
- virtual public pair_associative_container_tag,
- virtual public multiple_associative_container_tag
+ virtual sorted_associative_container_tag,
+ virtual pair_associative_container_tag,
+ virtual multiple_associative_container_tag
{ };
template <class Key, class T, class Compare, class Alloc>
@@ -209,14 +219,19 @@
template <typename Container, typename Value>
inline typename Container::iterator
- insert(Container& c, Value const& x, simple_associative_container_tag)
+ insert(Container& c, Value const& x, unique_associative_container_tag)
{ return c.insert(x).first; }
+
+ template <typename Container, typename Value>
+ inline typename Container::iterator
+ insert(Container& c, Value const& x, multiple_associative_container_tag)
+ { return c.insert(x); }
}
template <typename Container, typename T>
inline typename Container::iterator
insert(Container& c, T const& x)
-{ return dispatch(c, x, container_category(c)); }
+{ return dispatch::insert(c, x, container_category(c)); }
#if 0
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:46:36 EDT (Sat, 05 Jul 2008)
@@ -12,12 +12,24 @@
namespace dispatch
{
- // A little help for mapped values.
- template <typename Container, typename Value>
- void insert(Container& c, Value const& x, pair_associative_container_tag)
+ template <typename Container, typename T>
+ void insert_value(Container& c, T const& x, back_insertion_sequence_tag)
+ { c.push_back(x); }
+
+ template <typename Container, typename T>
+ void insert_value(Container& c, T const& x, simple_associative_container_tag)
+ { c.insert(x); }
+
+ template <typename Container, typename T>
+ void insert_value(Container& c, T const& x, pair_associative_container_tag)
{ c.insert(make_pair(x, x)); }
}
+template <typename Container, typename T>
+void insert_value(Container& c, T const& x)
+{ dispatch::insert_value(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 << ")"; }
@@ -41,9 +53,9 @@
cout << "mapped elements: " << contains_mapped_elements<Container>::value << endl;
Container c;
- insert(c, 0.0);
- insert(c, 6.28);
- insert(c, 3.14);
+ insert_value(c, 0.0);
+ insert_value(c, 6.28);
+ insert_value(c, 3.14);
Descriptor d1 = make_descriptor(c, c.begin());
Descriptor d2 = make_descriptor(c, next(c.begin(), 1));
Modified: sandbox/SOC/2008/graphs/branches/descrip/descriptor.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/branches/descrip/descriptor.hpp (original)
+++ sandbox/SOC/2008/graphs/branches/descrip/descriptor.hpp 2008-07-05 07:46:36 EDT (Sat, 05 Jul 2008)
@@ -9,8 +9,8 @@
#include "blob.hpp"
// Descriptor implementations.
-#include "descriptor/node.hpp"
-#include "descriptor/index.hpp"
+#include "descriptor/node_descriptor.hpp"
+#include "descriptor/index_descriptor.hpp"
// Descriptors Take 2 (or 3 or 4).
//
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