CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::GenericCluster< Base > Class Template Reference

#include <GenericCluster.hh>

+ Inheritance diagram for CASM::GenericCluster< Base >:

Detailed Description

template<typename Base>
class CASM::GenericCluster< Base >

A CRTP base class for a cluster of anything.

GenericCluster provides a standard interface for clusters of various type. In particular, it is commonly necessary to iterate over elements in the cluster, access elements in the cluster, sort/permute elements in the cluster into a canonical representation, and compare clusters.

To implement this, there must be a traits class for the particular derived type of cluster with the following members:

  • typename traits<MostDerived>::Element

The derived cluster type must implement public methods:

  • std::vector<Element>& MostDerived::elements();
  • const std::vector<Element>& MostDerived::elements() const;

Optionally, the derived cluster type may specialize protected methods:

To implement the CRTP pattern:

  • _Base must inherit from CRTPBase<MostDerived>

Definition at line 47 of file GenericCluster.hh.

Public Types

typedef Base::MostDerived MostDerived
 
typedef traits< MostDerived >::Element Element
 
typedef Index size_type
 
typedef std::vector< Element >::value_type value_type
 
typedef std::vector< Element >::iterator iterator
 
typedef std::vector< Element >::const_iterator const_iterator
 

Public Member Functions

iterator begin ()
 Iterator to first element in the cluster. More...
 
const_iterator begin () const
 Iterator to first element in the cluster. More...
 
iterator end ()
 Iterator to the past-the-last element in the cluster. More...
 
const_iterator end () const
 Iterator to the past-the-last element in the cluster. More...
 
const_iterator cbegin () const
 Iterator to first element in the cluster. More...
 
const_iterator cend () const
 Iterator to the past-the-last element in the cluster. More...
 
size_type size () const
 Number of elements in the cluster. More...
 
value_typeoperator[] (size_type index)
 Access an element in the cluster by index. More...
 
value_type const & operator[] (size_type index) const
 Access an element in the cluster by index. More...
 
value_typeelement (size_type index)
 Access an element in the cluster by index. More...
 
value_type const & element (size_type index) const
 Access a UnitCellCoord in the cluster by index. More...
 
MostDerivedsort ()
 
MostDerived sorted () const
 
bool is_sorted () const
 
Permutation sort_permutation () const
 
bool operator< (MostDerived const &B) const
 
bool operator> (const MostDerived &B) const
 
bool operator<= (const MostDerived &B) const
 
bool operator>= (const MostDerived &B) const
 
bool operator== (const MostDerived &B) const
 
bool operator!= (const MostDerived &B) const
 

Protected Member Functions

 GenericCluster ()
 Construct an empty GenericCluster. More...
 
MostDerivedsort_impl ()
 
bool is_sorted_impl () const
 
Permutation sort_permutation_impl () const
 
bool compare_impl (MostDerived const &B) const
 
bool eq_impl (const MostDerived &B) const
 
bool ne_impl (const MostDerived &B) const
 

Member Typedef Documentation

◆ const_iterator

template<typename Base >
typedef std::vector<Element>::const_iterator CASM::GenericCluster< Base >::const_iterator

Definition at line 57 of file GenericCluster.hh.

◆ Element

template<typename Base >
typedef traits<MostDerived>::Element CASM::GenericCluster< Base >::Element

Definition at line 52 of file GenericCluster.hh.

◆ iterator

template<typename Base >
typedef std::vector<Element>::iterator CASM::GenericCluster< Base >::iterator

Definition at line 56 of file GenericCluster.hh.

◆ MostDerived

template<typename Base >
typedef Base::MostDerived CASM::GenericCluster< Base >::MostDerived

Definition at line 49 of file GenericCluster.hh.

◆ size_type

template<typename Base >
typedef Index CASM::GenericCluster< Base >::size_type

Definition at line 53 of file GenericCluster.hh.

◆ value_type

template<typename Base >
typedef std::vector<Element>::value_type CASM::GenericCluster< Base >::value_type

Definition at line 55 of file GenericCluster.hh.

Constructor & Destructor Documentation

◆ GenericCluster()

template<typename Base >
CASM::GenericCluster< Base >::GenericCluster ( )
inlineprotected

Construct an empty GenericCluster.

Definition at line 115 of file GenericCluster.hh.

Member Function Documentation

◆ begin() [1/2]

template<typename Base >
iterator CASM::GenericCluster< Base >::begin ( )
inline

Iterator to first element in the cluster.

Definition at line 60 of file GenericCluster.hh.

◆ begin() [2/2]

template<typename Base >
const_iterator CASM::GenericCluster< Base >::begin ( ) const
inline

Iterator to first element in the cluster.

Definition at line 63 of file GenericCluster.hh.

◆ cbegin()

template<typename Base >
const_iterator CASM::GenericCluster< Base >::cbegin ( ) const
inline

Iterator to first element in the cluster.

Definition at line 72 of file GenericCluster.hh.

◆ cend()

template<typename Base >
const_iterator CASM::GenericCluster< Base >::cend ( ) const
inline

Iterator to the past-the-last element in the cluster.

Definition at line 75 of file GenericCluster.hh.

◆ compare_impl()

template<typename Base >
bool CASM::GenericCluster< Base >::compare_impl ( MostDerived const &  B) const
inlineprotected

Definition at line 135 of file GenericCluster.hh.

◆ element() [1/2]

template<typename Base >
value_type& CASM::GenericCluster< Base >::element ( size_type  index)
inline

Access an element in the cluster by index.

Definition at line 89 of file GenericCluster.hh.

◆ element() [2/2]

template<typename Base >
value_type const& CASM::GenericCluster< Base >::element ( size_type  index) const
inline

Access a UnitCellCoord in the cluster by index.

Definition at line 92 of file GenericCluster.hh.

◆ end() [1/2]

template<typename Base >
iterator CASM::GenericCluster< Base >::end ( )
inline

Iterator to the past-the-last element in the cluster.

Definition at line 66 of file GenericCluster.hh.

◆ end() [2/2]

template<typename Base >
const_iterator CASM::GenericCluster< Base >::end ( ) const
inline

Iterator to the past-the-last element in the cluster.

Definition at line 69 of file GenericCluster.hh.

◆ eq_impl()

template<typename Base >
bool notstd::Comparisons< Base >::eq_impl ( const MostDerived B) const
inlineprotectedinherited

Definition at line 40 of file Comparisons.hh.

◆ is_sorted()

template<typename Base >
bool CASM::GenericCluster< Base >::is_sorted ( ) const
inline

Definition at line 103 of file GenericCluster.hh.

◆ is_sorted_impl()

template<typename Base >
bool CASM::GenericCluster< Base >::is_sorted_impl ( ) const
inlineprotected

Definition at line 122 of file GenericCluster.hh.

◆ ne_impl()

template<typename Base >
bool notstd::Comparisons< Base >::ne_impl ( const MostDerived B) const
inlineprotectedinherited

Definition at line 44 of file Comparisons.hh.

◆ operator!=()

template<typename Base >
bool notstd::Comparisons< Base >::operator!= ( const MostDerived B) const
inlineinherited

Definition at line 37 of file Comparisons.hh.

◆ operator<()

template<typename Base >
bool CASM::GenericCluster< Base >::operator< ( MostDerived const &  B) const
inline

Definition at line 109 of file GenericCluster.hh.

◆ operator<=()

template<typename Base >
bool notstd::Comparisons< Base >::operator<= ( const MostDerived B) const
inlineinherited

Definition at line 31 of file Comparisons.hh.

◆ operator==()

template<typename Base >
bool notstd::Comparisons< Base >::operator== ( const MostDerived B) const
inlineinherited

Definition at line 35 of file Comparisons.hh.

◆ operator>()

template<typename Base >
bool notstd::Comparisons< Base >::operator> ( const MostDerived B) const
inlineinherited

Definition at line 29 of file Comparisons.hh.

◆ operator>=()

template<typename Base >
bool notstd::Comparisons< Base >::operator>= ( const MostDerived B) const
inlineinherited

Definition at line 33 of file Comparisons.hh.

◆ operator[]() [1/2]

template<typename Base >
value_type& CASM::GenericCluster< Base >::operator[] ( size_type  index)
inline

Access an element in the cluster by index.

Definition at line 81 of file GenericCluster.hh.

◆ operator[]() [2/2]

template<typename Base >
value_type const& CASM::GenericCluster< Base >::operator[] ( size_type  index) const
inline

Access an element in the cluster by index.

Definition at line 84 of file GenericCluster.hh.

◆ size()

template<typename Base >
size_type CASM::GenericCluster< Base >::size ( ) const
inline

Number of elements in the cluster.

Definition at line 78 of file GenericCluster.hh.

◆ sort()

template<typename Base >
MostDerived& CASM::GenericCluster< Base >::sort ( )
inline

Definition at line 96 of file GenericCluster.hh.

◆ sort_impl()

template<typename Base >
MostDerived& CASM::GenericCluster< Base >::sort_impl ( )
inlineprotected

Definition at line 117 of file GenericCluster.hh.

◆ sort_permutation()

template<typename Base >
Permutation CASM::GenericCluster< Base >::sort_permutation ( ) const
inline

Definition at line 105 of file GenericCluster.hh.

◆ sort_permutation_impl()

template<typename Base >
Permutation CASM::GenericCluster< Base >::sort_permutation_impl ( ) const
inlineprotected

Definition at line 124 of file GenericCluster.hh.

◆ sorted()

template<typename Base >
MostDerived CASM::GenericCluster< Base >::sorted ( ) const
inline

Definition at line 98 of file GenericCluster.hh.


The documentation for this class was generated from the following file: