24 #ifndef COM_DAFER45_TBTK_BASIS_STATE_SET
25 #define COM_DAFER45_TBTK_BASIS_STATE_SET
27 #include "TBTK/AbstractState.h"
39 class BasisStateSet :
public Serializable{
51 BasisStateSet(
const std::string &serializeation, Mode mode);
54 virtual ~BasisStateSet();
59 void add(
const AbstractState &state);
66 AbstractState& get(
const Index &index);
73 const AbstractState& get(
const Index &index)
const;
80 template<
bool isConstIterator>
85 typedef typename std::conditional<
89 >::type BasisStateReferenceType;
98 bool operator==(
const _Iterator &rhs);
105 typedef typename std::conditional<
107 IndexedDataTree<AbstractState*>::ConstIterator,
108 IndexedDataTree<AbstractState*>::Iterator
109 >::type IteratorType;
112 IteratorType iterator;
115 IteratorType iteratorEnd;
119 friend class Iterator;
120 friend class ConstIterator;
124 typedef typename std::conditional<
126 const IndexedDataTree<AbstractState*>,
127 IndexedDataTree<AbstractState*>
128 >::type BasisStateTreeType;
133 BasisStateTreeType &basisStateTree,
139 class Iterator :
public _Iterator<false>{
142 IndexedDataTree<AbstractState*> &basisStateTree,
144 ) : _Iterator(basisStateTree, end){};
147 friend class BasisStateSet;
151 class ConstIterator :
public _Iterator<true>{
154 const IndexedDataTree<
158 ) : _Iterator(basisStateTree, end){};
161 friend class BasisStateSet;
168 BasisStateSet::Iterator begin();
174 BasisStateSet::ConstIterator begin()
const;
180 BasisStateSet::ConstIterator cbegin()
const;
185 BasisStateSet::Iterator end();
190 BasisStateSet::ConstIterator end()
const;
195 BasisStateSet::ConstIterator cend()
const;
198 virtual std::string serialize(Mode mode)
const;
201 unsigned int getSizeInBytes()
const;
204 IndexedDataTree<AbstractState*> basisStateTree;
207 inline void BasisStateSet::add(
const AbstractState &state){
214 inline AbstractState& BasisStateSet::get(
const Index &index){
215 return *basisStateTree.get(index);
218 inline const AbstractState& BasisStateSet::get(
const Index &index)
const{
219 return *basisStateTree.get(index);
222 inline unsigned int BasisStateSet::getSizeInBytes()
const{
223 TBTKNotYetImplemented(
"BasisStateSet::getSizeInBytes()");
226 template<
bool isConstIterator>
227 BasisStateSet::_Iterator<isConstIterator>::_Iterator(
228 BasisStateTreeType &basisStateTree,
232 end ? basisStateTree.end() : basisStateTree.begin()
234 iteratorEnd(basisStateTree.end())
238 template<
bool isConstIterator>
239 void BasisStateSet::_Iterator<isConstIterator>::operator++(){
240 if(iterator != iteratorEnd)
244 template<
bool isConstIterator>
245 typename BasisStateSet::_Iterator<isConstIterator>::BasisStateReferenceType
246 BasisStateSet::_Iterator<isConstIterator>::operator*(){
250 template<
bool isConstIterator>
251 bool BasisStateSet::_Iterator<isConstIterator>::operator==(
252 const _Iterator<isConstIterator> &rhs
254 if(iterator == rhs.iterator)
260 template<
bool isConstIterator>
261 bool BasisStateSet::_Iterator<isConstIterator>::operator!=(
262 const _Iterator<isConstIterator> &rhs
264 if(iterator != rhs.iterator)