summaryrefslogtreecommitdiff
path: root/apt-pkg/cacheset.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-17 13:30:14 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-08-10 17:25:25 +0200
commitc687384b7a53887ea455fd824824429615d94f7b (patch)
tree58b8bce779ac6217232e7bbbeaeec5c15932a43b /apt-pkg/cacheset.h
parent6c55f07a5fa3612a5d59c61a17da5fe640eadc8b (diff)
cleanup Container.erase API to look more like std::containers
C++11 slightly changes the API again to const_iterator, but we are find with iterators in the C++03 style for now as long as they look and behave equally to the methods of the standard containers. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/cacheset.h')
-rw-r--r--apt-pkg/cacheset.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index 4fe1eba87..29f7540ca 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -346,13 +346,10 @@ public: /*{{{*/
bool empty() const { return _cont.empty(); }
void clear() { return _cont.clear(); }
- //FIXME: on ABI break, replace the first with the second without bool
- void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
- iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
- size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); }
- void erase(iterator first, iterator last) { _cont.erase(first, last); }
size_t size() const { return _cont.size(); }
-
+ iterator erase( iterator pos ) { return iterator(_cont.erase(pos)); }
+ iterator erase( iterator first, iterator last ) { return iterator(_cont.erase(first, last)); }
+ size_t erase(pkgCache::PkgIterator const & P) { size_t oldsize = size(); _cont.erase(std::remove(_cont.begin(), _cont.end(), P), _cont.end()); return oldsize - size(); }
const_iterator begin() const { return const_iterator(_cont.begin()); }
const_iterator end() const { return const_iterator(_cont.end()); }
iterator begin() { return iterator(_cont.begin()); }
@@ -578,9 +575,9 @@ private:
void insert(const_iterator, const_iterator) { }
void clear() { }
- iterator& erase(iterator &iter) { return iter; }
- size_t erase(const pkgCache::PkgIterator) { return 0; }
- void erase(iterator, iterator) { }
+ iterator erase( iterator pos );
+ iterator erase( iterator first, iterator last );
+ size_t erase(pkgCache::PkgIterator const & P);
};
/*}}}*/
typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
@@ -780,12 +777,10 @@ public: /*{{{*/
void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
bool empty() const { return _cont.empty(); }
void clear() { return _cont.clear(); }
- //FIXME: on ABI break, replace the first with the second without bool
- void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
- iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
- size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); }
- void erase(iterator first, iterator last) { _cont.erase(first, last); }
size_t size() const { return _cont.size(); }
+ iterator erase( iterator pos ) { return iterator(_cont.erase(pos)); }
+ iterator erase( iterator first, iterator last ) { return iterator(_cont.erase(first, last)); }
+ size_t erase(pkgCache::VerIterator const & V) { size_t oldsize = size(); _cont.erase(std::remove(_cont.begin(), _cont.end(), V), _cont.end()); return oldsize - size(); }
const_iterator begin() const { return const_iterator(_cont.begin()); }
const_iterator end() const { return const_iterator(_cont.end()); }
@@ -989,6 +984,13 @@ template<> inline void VersionContainer<std::vector<pkgCache::VerIterator> >::in
}
/*}}}*/
+template<> inline size_t PackageContainer<std::set<pkgCache::PkgIterator> >::erase(pkgCache::PkgIterator const &P) {
+ return _cont.erase(P);
+}
+template<> inline size_t VersionContainer<std::set<pkgCache::VerIterator> >::erase(pkgCache::VerIterator const &V) {
+ return _cont.erase(V);
+}
+
template<> template<class Compare> inline bool VersionContainer<std::vector<pkgCache::VerIterator> >::sort(Compare Comp) {
std::sort(_cont.begin(), _cont.end(), Comp);
return true;