Skip to content

Commit 267af2c

Browse files
Adding the less-than comparison for genome_four_bit_itr iterators
1 parent 1d4914b commit 267af2c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

dna_four_bit.hpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,35 @@ struct genome_four_bit_itr {
118118
offset = (offset - 1) & 15ul;
119119
return *this;
120120
}
121+
121122
genome_four_bit_itr operator--(int) {
122123
genome_four_bit_itr tmp(*this);
123124
itr -= (offset == 0);
124125
offset = (offset - 1) & 15ul;
125126
return tmp;
126127
}
128+
127129
genome_four_bit_itr operator+(const size_t step) const {
128130
// whether the sum of offsets is >= 16
129131
const bool shift_one_pos =
130-
(((offset + (static_cast<int>(step) & 15)) & 16) >> 4);
132+
((offset + (static_cast<int>(step) & 15)) & 16) >> 4;
131133

132134
const int new_offset = (offset + step) & 15;
133-
return genome_four_bit_itr(itr + step/16 + shift_one_pos,
134-
new_offset);
135+
return genome_four_bit_itr(itr + step / 16 + shift_one_pos, new_offset);
135136
}
137+
136138
bool operator!=(const genome_four_bit_itr &rhs) const {
137139
return itr != rhs.itr || offset != rhs.offset;
138140
}
141+
142+
bool operator<(const genome_four_bit_itr &rhs) const {
143+
return itr < rhs.itr || (itr == rhs.itr && offset < rhs.offset);
144+
}
145+
146+
bool operator<=(const genome_four_bit_itr &rhs) const {
147+
return itr < rhs.itr || (itr == rhs.itr && offset <= rhs.offset);
148+
}
149+
139150
std::vector<size_t>::const_iterator itr;
140151
int offset;
141152
};

0 commit comments

Comments
 (0)