TBTK
Need a break? Support the development by playing Polarity Puzzles
HoppingAmplitudeList.h
Go to the documentation of this file.
1 /* Copyright 2018 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_HOPPING_AMPLITUDE_LIST
24 #define COM_DAFER45_TBTK_HOPPING_AMPLITUDE_LIST
25 
26 #include "TBTK/HoppingAmplitude.h"
27 #include "TBTK/Serializable.h"
28 
29 #include <vector>
30 
31 namespace TBTK{
32 
35 public:
38 
47  const std::string &serializeation,
49  );
50 
54  void add(const HoppingAmplitude &hoppingAmplitude);
55 
59  unsigned int getSize() const;
60 
66  const HoppingAmplitude& operator[](unsigned int n) const;
67 
74  std::string serialize(Serializable::Mode mode) const;
75 
79  unsigned int getSizeInBytes() const;
80 private:
82  std::vector<HoppingAmplitude> hoppingAmplitudes;
83 };
84 
86  const HoppingAmplitude &hoppingAmplitude
87 ){
88  hoppingAmplitudes.push_back(hoppingAmplitude);
89 }
90 
91 inline unsigned int HoppingAmplitudeList::getSize() const{
92  return hoppingAmplitudes.size();
93 }
94 
96  unsigned int n
97 ) const{
98  return hoppingAmplitudes[n];
99 }
100 
101 inline unsigned int HoppingAmplitudeList::getSizeInBytes() const{
102  unsigned int sizeInBytes = 0;
103  for(size_t n = 0; n < hoppingAmplitudes.size(); n++)
104  sizeInBytes += hoppingAmplitudes[n].getSizeInBytes();
105  sizeInBytes += (
106  hoppingAmplitudes.capacity() - hoppingAmplitudes.size()
107  )*sizeof(HoppingAmplitude);
108  sizeInBytes += sizeof(HoppingAmplitudeList);
109 
110  return sizeInBytes;
111 }
112 
113 }; //End of namespace TBTK
114 
115 #endif
TBTK::HoppingAmplitudeList
List of HoppingAmplitudes .
Definition: HoppingAmplitudeList.h:34
TBTK::HoppingAmplitudeList::operator[]
const HoppingAmplitude & operator[](unsigned int n) const
Definition: HoppingAmplitudeList.h:95
TBTK::HoppingAmplitudeList::serialize
std::string serialize(Serializable::Mode mode) const
TBTK::HoppingAmplitudeList::getSizeInBytes
unsigned int getSizeInBytes() const
Definition: HoppingAmplitudeList.h:101
TBTK::Serializable
Definition: Serializable.h:43
TBTK::HoppingAmplitudeList::add
void add(const HoppingAmplitude &hoppingAmplitude)
Definition: HoppingAmplitudeList.h:85
Serializable.h
Abstract base class for serializable objects.
TBTK::HoppingAmplitude
Hopping amplitude from state 'from' to state 'to'.
Definition: HoppingAmplitude.h:53
TBTK::HoppingAmplitudeList::HoppingAmplitudeList
HoppingAmplitudeList()
HoppingAmplitude.h
Hopping amplitude from state 'from' to state 'to'.
TBTK::Serializable::Mode
Mode
Definition: Serializable.h:47
TBTK::HoppingAmplitudeList::getSize
unsigned int getSize() const
Definition: HoppingAmplitudeList.h:91