1 #ifndef CASM_GenericCluster
2 #define CASM_GenericCluster
46 template <
typename Base>
55 typedef typename std::vector<Element>::value_type
value_type;
56 typedef typename std::vector<Element>::iterator
iterator;
85 return derived().element(index);
93 return derived().elements()[index];
103 bool is_sorted()
const {
return derived().is_sorted_impl(); }
106 return derived().sort_permutation_impl();
110 return derived().compare_impl(B);
128 std::sort(ind.begin(), ind.end(), [&](
const Index &a,
const Index &b) {
129 return (this->derived().element(a) < this->derived().element(b));
136 if (
size() != B.size()) {
137 return size() < B.size();
139 return lexicographical_compare(
begin(),
end(), B.begin(), B.end());
A CRTP base class for a cluster of anything.
value_type const & element(size_type index) const
Access a UnitCellCoord in the cluster by index.
GenericCluster()
Construct an empty GenericCluster.
value_type & element(size_type index)
Access an element in the cluster by index.
std::vector< Element >::const_iterator const_iterator
MostDerived & sort_impl()
const_iterator begin() const
Iterator to first element in the cluster.
bool is_sorted_impl() const
iterator end()
Iterator to the past-the-last element in the cluster.
bool operator<(MostDerived const &B) const
value_type & operator[](size_type index)
Access an element in the cluster by index.
const_iterator cbegin() const
Iterator to first element in the cluster.
const_iterator cend() const
Iterator to the past-the-last element in the cluster.
bool compare_impl(MostDerived const &B) const
traits< MostDerived >::Element Element
iterator begin()
Iterator to first element in the cluster.
size_type size() const
Number of elements in the cluster.
const_iterator end() const
Iterator to the past-the-last element in the cluster.
Base::MostDerived MostDerived
Permutation sort_permutation() const
std::vector< Element >::value_type value_type
std::vector< Element >::iterator iterator
Permutation sort_permutation_impl() const
value_type const & operator[](size_type index) const
Access an element in the cluster by index.
MostDerived sorted() const
std::vector< T > sequence(T first, T last)
INDEX_TYPE Index
For long integer indexing:
Implements other comparisons in terms of '<'.