summaryrefslogtreecommitdiff
path: root/src/SegList.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-30 00:13:08 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-30 00:13:08 +0900
commite23e9a4a65a24454d9b1181eebb598b95476a647 (patch)
tree70cb2879e7cec0c57d72514477f0569378a3d4c9 /src/SegList.h
parent5749647ae5559098cb077d35b496eb3fd15b579d (diff)
Code cleanup
Diffstat (limited to 'src/SegList.h')
-rw-r--r--src/SegList.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/SegList.h b/src/SegList.h
index ef6923fc..c84b9a74 100644
--- a/src/SegList.h
+++ b/src/SegList.h
@@ -51,7 +51,7 @@ public:
void clear()
{
- seg_.clear();
+ segs_.clear();
index_ = 0;
val_ = std::numeric_limits<T>::min();
}
@@ -61,12 +61,12 @@ public:
// are all merged into one. This function resets current position.
void normalize()
{
- if(!seg_.empty()) {
- std::sort(seg_.begin(), seg_.end());
+ if(!segs_.empty()) {
+ std::sort(segs_.begin(), segs_.end());
std::vector<std::pair<T, T> > s;
- s.push_back(seg_.front());
- for(size_t i = 1, len = seg_.size(); i < len; ++i) {
- const std::pair<T, T>& x = seg_[i];
+ s.push_back(segs_.front());
+ for(size_t i = 1, len = segs_.size(); i < len; ++i) {
+ const std::pair<T, T>& x = segs_[i];
if(x.first <= s.back().second) {
if(s.back().second < x.second) {
s.back().second = x.second;
@@ -75,9 +75,9 @@ public:
s.push_back(x);
}
}
- s.swap(seg_);
+ s.swap(segs_);
index_ = 0;
- val_ = seg_.front().first;
+ val_ = segs_.front().first;
}
}
@@ -85,17 +85,17 @@ public:
void add(T a, T b)
{
if(a < b) {
- if(seg_.empty()) {
+ if(segs_.empty()) {
val_ = std::max(val_, a);
}
- seg_.push_back(std::make_pair(a, b));
+ segs_.push_back(std::make_pair(a, b));
}
}
// Returns true if next value is available. Otherwise returns false.
bool hasNext() const
{
- return index_ < seg_.size() && val_ < seg_[index_].second;
+ return index_ < segs_.size() && val_ < segs_[index_].second;
}
// Returns next value. Advance current position to the next. If
@@ -103,11 +103,11 @@ public:
T next()
{
T res;
- if(index_ < seg_.size()) {
+ if(index_ < segs_.size()) {
res = val_++;
- if(val_ == seg_[index_].second) {
+ if(val_ == segs_[index_].second) {
++index_;
- val_ = seg_[index_].first;
+ val_ = segs_[index_].first;
}
} else {
res = 0;
@@ -120,7 +120,7 @@ public:
T peek() const
{
T res;
- if(index_ < seg_.size()) {
+ if(index_ < segs_.size()) {
res = val_;
} else {
res = 0;
@@ -128,7 +128,7 @@ public:
return res;
}
private:
- std::vector<std::pair<T, T> > seg_;
+ std::vector<std::pair<T, T> > segs_;
size_t index_;
T val_;
};