mirror of
https://github.com/boostorg/graph.git
synced 2025-05-11 21:34:00 +00:00
Fix bucket_sorter example. Bug #151
Changed ID toidentity_property_map. Added concept check to bucket_sorter.hpp. Fixed minor grammar nits.
This commit is contained in:
parent
1324532d83
commit
4e270bd62b
@ -26,7 +26,7 @@ exe boost_web_graph : boost_web_graph.cpp ;
|
||||
exe boykov_kolmogorov-eg : boykov_kolmogorov-eg.cpp ;
|
||||
exe bron_kerbosch_clique_number : bron_kerbosch_clique_number.cpp ;
|
||||
exe bron_kerbosch_print_cliques : bron_kerbosch_print_cliques.cpp ;
|
||||
#exe bucket_sorter : bucket_sorter.cpp ;
|
||||
exe bucket_sorter : bucket_sorter.cpp ;
|
||||
exe canonical_ordering : canonical_ordering.cpp ;
|
||||
# exe cc-internet : cc-internet.cpp ../build//boost_graph ;
|
||||
exe city_visitor : city_visitor.cpp ;
|
||||
|
@ -13,17 +13,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <boost/pending/bucket_sorter.hpp>
|
||||
|
||||
template <class Integral>
|
||||
struct trivial_id {
|
||||
std::size_t operator[](Integral i) {
|
||||
return i;
|
||||
}
|
||||
std::size_t operator[](Integral i) const {
|
||||
return i;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
using namespace std;
|
||||
using boost::bucket_sorter;
|
||||
@ -34,10 +23,10 @@ int main() {
|
||||
for (std::size_t i=0; i<N; i++) {
|
||||
bucket[i] = rand() % N;
|
||||
cout.width(6);
|
||||
cout << "Number " << i << " has its bucket " << bucket[i] << endl;
|
||||
cout << "Number " << i << " is in bucket " << bucket[i] << endl;
|
||||
}
|
||||
|
||||
typedef trivial_id<int> ID;
|
||||
typedef boost::identity_property_map ID;
|
||||
typedef bucket_sorter<std::size_t, int,
|
||||
vector<std::size_t>::iterator, ID> BS;
|
||||
BS my_bucket_sorter(N, N, bucket.begin());
|
||||
@ -57,7 +46,7 @@ int main() {
|
||||
} while ( ! my_bucket_sorter[j].empty() );
|
||||
cout << endl;
|
||||
} else {
|
||||
cout << " has no number associated with." << endl;
|
||||
cout << " has no number associated with it." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +56,7 @@ int main() {
|
||||
my_bucket_sorter.remove(5);
|
||||
my_bucket_sorter.remove(7);
|
||||
|
||||
cout << "Afer remove number 5 and 7, check correctness again." << endl;
|
||||
cout << "After removing numbers 5 and 7, check correctness again." << endl;
|
||||
|
||||
for (j=0; j<N; j++) {
|
||||
cout << "The bucket " << j;
|
||||
@ -80,7 +69,7 @@ int main() {
|
||||
} while ( ! my_bucket_sorter[j].empty() );
|
||||
cout << endl;
|
||||
} else {
|
||||
cout << " has no number associated with." << endl;
|
||||
cout << " has no number associated with it." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,15 @@
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/concept/assert.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class BucketType, class ValueType, class Bucket,
|
||||
class ValueIndexMap>
|
||||
class bucket_sorter {
|
||||
BOOST_CONCEPT_ASSERT(( ReadablePropertyMapConcept<ValueIndexMap, ValueType> ));
|
||||
public:
|
||||
typedef BucketType bucket_type;
|
||||
typedef ValueType value_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user