diff options
author | Nathan Binkert <nate@binkert.org> | 2009-06-05 17:01:19 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2009-06-05 17:01:19 -0700 |
commit | baa0d695b20875ed65a52de475708bab2ee7aeaf (patch) | |
tree | aa92878147357897b5c458de0df1439016756797 | |
parent | c76a8b1c15fb6e0a1f9da60cd7ee73efd14200e5 (diff) | |
download | gem5-baa0d695b20875ed65a52de475708bab2ee7aeaf.tar.xz |
cleanup: Make use of types properly and make the loop a little more clear.
-rw-r--r-- | src/base/range_ops.hh | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/base/range_ops.hh b/src/base/range_ops.hh index f2b11b649..26fadacde 100644 --- a/src/base/range_ops.hh +++ b/src/base/range_ops.hh @@ -30,6 +30,7 @@ #ifndef __BASE_RANGE_OPS_HH__ #define __BASE_RANGE_OPS_HH__ + #include <list> #include <vector> @@ -37,16 +38,19 @@ template <class T> inline void -FilterRangeList(std::vector<Range<T> > filter_list, std::list<Range<T> > - &range_list) { - typename std::list<Range<T> >::iterator i; - for (int x = 0; x < filter_list.size(); x++) { - for (i = range_list.begin(); i != range_list.end(); ) { +FilterRangeList(std::vector<Range<T> > filter_list, + std::list<Range<T> > &range_list) +{ + typedef typename std::list<Range<T> > RangeList; + + for (typename RangeList::size_type x = 0; x < filter_list.size(); x++) { + typename RangeList::iterator i = range_list.begin(); + while (i != range_list.end()) { // Is the range within one of our filter ranges? if (filter_list[x] == i->start || filter_list[x] == i->end) - range_list.erase(i++); + i = range_list.erase(i); else - i++; + ++i; } } } |