#if __cplusplus >= 201103L
#include <unordered_set>
#include <forward_list>
+#include <initializer_list>
#endif
#include <list>
#include <deque>
inline iterator_type& operator--() { --_iter;; return static_cast<iterator_type&>(*this); }
inline iterator_type operator--(int) { iterator_type tmp(*this); operator--(); return tmp; }
inline iterator_type operator-(typename container_iterator::difference_type const &n) { return iterator_type(_iter - n); }
+ inline typename container_iterator::difference_type operator-(iterator_type const &b) { return (_iter - b._iter); }
inline iterator_type operator-=(typename container_iterator::difference_type const &n) { _iter -= n; return static_cast<iterator_type&>(*this); }
inline bool operator!=(iterator_type const &i) const { return _iter != i._iter; }
inline bool operator==(iterator_type const &i) const { return _iter == i._iter; }
typedef Container_const_reverse_iterator<PackageContainerInterface, Container, PackageContainer> const_reverse_iterator;
typedef Container_reverse_iterator<PackageContainerInterface, Container, PackageContainer> reverse_iterator;
typedef typename Container::value_type value_type;
+ typedef typename Container::pointer pointer;
+ typedef typename Container::const_pointer const_pointer;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
typedef typename Container::difference_type difference_type;
typedef typename Container::size_type size_type;
+ typedef typename Container::allocator_type allocator_type;
bool insert(pkgCache::PkgIterator const &P) APT_OVERRIDE { if (P.end() == true) return false; _cont.insert(P); return true; }
template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); }
PackageContainer() : PackageContainerInterface(CacheSetHelper::UNKNOWN) {}
explicit PackageContainer(CacheSetHelper::PkgSelector const &by) : PackageContainerInterface(by) {}
APT_IGNORE_DEPRECATED_PUSH
- APT_DEPRECATED PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {}
+ APT_DEPRECATED explicit PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {}
APT_IGNORE_DEPRECATED_POP
+ template<typename Itr> PackageContainer(Itr first, Itr last) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(first, last) {}
+#if __cplusplus >= 201103L
+ PackageContainer(std::initializer_list<value_type> list) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(list) {}
+ void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); }
+ template<typename... Args> void emplace_back(Args&&... args) { _cont.emplace_back(std::forward<Args>(args)...); }
+#endif
+ void push_back(const value_type& P) { _cont.push_back(P); }
/** \brief sort all included versions with given comparer
};
typedef const_iterator iterator;
typedef pkgCache::PkgIterator value_type;
+ typedef typename pkgCache::PkgIterator* pointer;
+ typedef typename pkgCache::PkgIterator const* const_pointer;
typedef const pkgCache::PkgIterator& const_reference;
typedef const_reference reference;
typedef const_iterator::difference_type difference_type;
typedef Container_const_reverse_iterator<VersionContainerInterface, Container, VersionContainer> const_reverse_iterator;
typedef Container_reverse_iterator<VersionContainerInterface, Container, VersionContainer> reverse_iterator;
typedef typename Container::value_type value_type;
+ typedef typename Container::pointer pointer;
+ typedef typename Container::const_pointer const_pointer;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
typedef typename Container::difference_type difference_type;
typedef typename Container::size_type size_type;
+ typedef typename Container::allocator_type allocator_type;
bool insert(pkgCache::VerIterator const &V) APT_OVERRIDE { if (V.end() == true) return false; _cont.insert(V); return true; }
template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); }
reverse_iterator rend() { return reverse_iterator(_cont.rend()); }
const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); }
+ VersionContainer() : VersionContainerInterface() {}
+ template<typename Itr> VersionContainer(Itr first, Itr last) : VersionContainerInterface(), _cont(first, last) {}
+#if __cplusplus >= 201103L
+ VersionContainer(std::initializer_list<value_type> list) : VersionContainerInterface(), _cont(list) {}
+ void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); }
+ template<typename... Args> void emplace_back(Args&&... args) { _cont.emplace_back(std::forward<Args>(args)...); }
+#endif
+ void push_back(const value_type& P) { _cont.push_back(P); }
+
/** \brief sort all included versions with given comparer
Some containers are sorted by default, some are not and can't be,
bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
- auto part = std::stable_partition(pkgset.begin(), pkgset.end(),
+ auto const part = std::stable_partition(pkgset.begin(), pkgset.end(),
[](pkgCache::PkgIterator const &P) { return P->SelectedState == pkgCache::State::Hold; });
- auto doneBegin = MarkHold ? pkgset.begin() : part;
- auto doneEnd = MarkHold ? part : pkgset.end();
- auto changeBegin = MarkHold ? part : pkgset.begin();
- auto changeEnd = MarkHold ? pkgset.end() : part;
+ auto const doneBegin = MarkHold ? pkgset.begin() : part;
+ auto const doneEnd = MarkHold ? part : pkgset.end();
+ auto const changeBegin = MarkHold ? part : pkgset.begin();
+ auto const changeEnd = MarkHold ? pkgset.end() : part;
std::for_each(doneBegin, doneEnd, [&MarkHold](pkgCache::PkgIterator const &P) {
if (MarkHold == true)
}
APT::PackageList keepoffset;
- for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
- {
- if (Pkg->CurrentVer != 0)
- continue;
- keepoffset.insert(*Pkg);
- }
+ std::copy_if(changeBegin, changeEnd, std::back_inserter(keepoffset),
+ [](pkgCache::PkgIterator const &P) { return P->CurrentVer == 0; });
if (keepoffset.empty() == false)
{