diff options
author | Max Horn | 2006-04-04 20:49:26 +0000 |
---|---|---|
committer | Max Horn | 2006-04-04 20:49:26 +0000 |
commit | bca4dd001fae016b5c137d00d7c13d58c9f7937f (patch) | |
tree | 034733309ed658b33fcab0a8f7b6cf8da54b46fb /backends/fs/fs.cpp | |
parent | db8715fffdeaa0edf5c037a7c422920e14440ea0 (diff) | |
download | scummvm-rg350-bca4dd001fae016b5c137d00d7c13d58c9f7937f.tar.gz scummvm-rg350-bca4dd001fae016b5c137d00d7c13d58c9f7937f.tar.bz2 scummvm-rg350-bca4dd001fae016b5c137d00d7c13d58c9f7937f.zip |
Rewrote sort code to use iterators (means it can be used with any container now, in theory at least)
svn-id: r21596
Diffstat (limited to 'backends/fs/fs.cpp')
-rw-r--r-- | backends/fs/fs.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/backends/fs/fs.cpp b/backends/fs/fs.cpp index 60766cb073..df4a76bf07 100644 --- a/backends/fs/fs.cpp +++ b/backends/fs/fs.cpp @@ -26,13 +26,15 @@ void FSList::sort() { // Simple selection sort - for (int i = 0; i < _size-1; i++) { - int min = i; - for (int j = i+1; j < _size; j++) - if (_data[j] < _data[min]) + for (iterator i = begin(); i != end(); ++i) { + iterator min(i); + iterator j(i); + ++j; + for (; j != end(); ++j) + if (*j < *min) min = j; if (min != i) - SWAP(_data[min], _data[i]); + SWAP(*min, *i); } } |