TBTK
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 pushBack(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 
85 inline void HoppingAmplitudeList::pushBack(const HoppingAmplitude &hoppingAmplitude){
86  hoppingAmplitudes.push_back(hoppingAmplitude);
87 }
88 
89 inline unsigned int HoppingAmplitudeList::getSize() const{
90  return hoppingAmplitudes.size();
91 }
92 
93 inline const HoppingAmplitude& HoppingAmplitudeList::operator[](unsigned int n) const{
94  return hoppingAmplitudes[n];
95 }
96 
97 inline unsigned int HoppingAmplitudeList::getSizeInBytes() const{
98  unsigned int sizeInBytes = 0;
99  for(size_t n = 0; n < hoppingAmplitudes.size(); n++)
100  sizeInBytes += hoppingAmplitudes[n].getSizeInBytes();
101  sizeInBytes += (
102  hoppingAmplitudes.capacity() - hoppingAmplitudes.size()
103  )*sizeof(HoppingAmplitude);
104  sizeInBytes += sizeof(HoppingAmplitudeList);
105 
106  return sizeInBytes;
107 }
108 
109 }; //End of namespace TBTK
110 
111 #endif
unsigned int getSize() const
Definition: HoppingAmplitudeList.h:89
List of HoppingAmplitudes .
Definition: HoppingAmplitudeList.h:34
Hopping amplitude from state &#39;from&#39; to state &#39;to&#39;.
Definition: Serializable.h:40
std::string serialize(Serializable::Mode mode) const
unsigned int getSizeInBytes() const
Definition: HoppingAmplitudeList.h:97
const HoppingAmplitude & operator[](unsigned int n) const
Definition: HoppingAmplitudeList.h:93
Hopping amplitude from state &#39;from&#39; to state &#39;to&#39;.
Definition: HoppingAmplitude.h:49
Definition: ModelFactory.h:35
void pushBack(const HoppingAmplitude &hoppingAmplitude)
Definition: HoppingAmplitudeList.h:85
Mode
Definition: Serializable.h:44
Abstract base class for serializable objects.