12 template <
typename Count>
15 template <
typename Count>
19 return count[i]!=maxCount ? count[i] :
overflow.find(i)->second;
20 map_type::const_iterator it=
overflow.find(i);
21 return it==
overflow.end() ? 0 : it->second;
24 template <
typename Count>
30 if (count[i]!=maxCount)
31 if (++count[i]==maxCount)
33 else return count[i]==1;
38 if (i<count.capacity())
40 while (count.size()<i) count.push_back(0);
46 std::pair<map_type::iterator,bool>
p =
overflow.insert(std::make_pair(i,1));
47 if (not p.second) ++p.first->second;
51 template <
typename Count>
57 if (count[i]!=maxCount)
58 if (count[i]+multiplicity<maxCount)
60 bool result= count[i]==0;
61 count[i]+=multiplicity;
73 if (i<count.capacity())
75 while (count.size()<i) count.push_back(0);
76 if (multiplicity>=maxCount)
79 multiplicity=maxCount;
81 count.push_back(multiplicity);
86 std::pair<map_type::iterator,bool>
p 87 =
overflow.insert(std::make_pair(i,multiplicity));
89 p.first->second+=multiplicity;
93 template <
typename Count>
96 if (i>=max) { i=
size();
return; }
99 while (i<count.size())
100 if (count[i]!=0)
return;
104 map_type::const_iterator it=
overflow.lower_bound(i);
109 template <
typename Count>
114 map_type::const_iterator it=
overflow.lower_bound(i);
115 if (it!=
overflow.begin() and (--it)->first>=count.size())
116 { i=it->first;
return true; }
123 if (count[i]!=0)
return true;
128 template <
typename Count>
133 for (
size_t i=0; i<count.size(); ++i)
135 for (map_type::const_iterator it=
overflow.begin();
138 basic_io::write_bytes<sizeof(Index)>(it->first,
out);
139 basic_io::write_bytes<sizeof(ullong)>(it->second,
out);
143 template <
typename Count>
145 : count(0),
overflow(), max(0), total(0)
147 file.seekg(0,std::ios_base::beg);
148 count.resize(basic_io::read_bytes<4>(file));
150 size_t ovf_size=basic_io::read_bytes<4>(
file);
151 for (
size_t i=0; i<
count.size(); ++i)
153 for (
size_t i=0; i<ovf_size; ++i)
155 Index k=basic_io::read_bytes<sizeof(Index)>(
file);
157 ullong v=basic_io::read_bytes<sizeof(ullong)>(
file);
158 overflow.insert(std::make_pair(k,v));
162 template <
typename Count>
166 file.seekg(0,std::ios_base::beg);
167 count.resize(basic_io::read_bytes<4>(file));
169 size_t ovf_size=basic_io::read_bytes<4>(
file);
170 for (
size_t i=0; i<
count.size(); ++i)
172 for (
size_t i=0; i<ovf_size; ++i)
177 overflow.insert(std::make_pair(k,v));
181 template <
typename Count>
182 template <
typename MuCount>
unsigned long long read_bytes(std::istream &in)
Definition: basic_io_def.h:51
unsigned long long read_var_bytes(unsigned int n, std::istream &in)
Definition: basic_io.cpp:168
void write_to(std::ostream &out) const
Definition: tally_def.h:129
unsigned long size
Definition: testprint.cpp:46
ullong total
Definition: tally.h:54
uA p
Definition: lists.cpp:26
Index max
Definition: tally.h:53
char * limit
Definition: common.c:91
Index size() const
Definition: tally.h:66
unsigned long long int Index
Definition: tally.h:44
void put_int(unsigned int val, std::ostream &out)
Definition: basic_io.cpp:182
static const Count maxCount
Definition: tally.h:49
bool tally(Index i)
Definition: tally_def.h:25
void advance(Index &i) const
Definition: tally_def.h:94
#define out(c)
Definition: cweave.c:205
bool lower(Index &i) const
Definition: tally_def.h:110
TallyVec(size_t limit)
Definition: tally.h:57
TallyVec< MuCount > derived(size_t limit) const
Definition: tally_def.h:183
map_type overflow
Definition: tally.h:52
struct f file[max_include_depth]
Definition: common.c:93
#define overflow(t)
Definition: common.c:53
unsigned long long int ullong
Definition: tally.h:45
ullong multiplicity(Index i) const
Definition: tally_def.h:16
std::vector< Count > count
Definition: tally.h:51
Vertex v
Definition: graph.cpp:116
void write_bytes(unsigned int n, unsigned long long val, std::ostream &out)
Definition: basic_io.cpp:183