Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=634c6f1a4838adc119da9476b3c9979ee36501f2
commit 634c6f1a4838adc119da9476b3c9979ee36501f2 Author: Michel Hermier <[email protected]> Date: Mon Sep 8 18:47:57 2014 +0200 libpacman: Move code for swapping items of a list to FCListItem. Prune now unecessary friends. diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h index 15cc61e..26006cc 100644 --- a/lib/libpacman/util/flist.h +++ b/lib/libpacman/util/flist.h @@ -376,10 +376,7 @@ class FCListItem public: friend struct flib::iterable_traits<FCListItem *>; - friend FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn); friend bool _pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp fn, void **data); - friend FPtrList *f_ptrlist_add(FPtrList *list, void *data); - friend class FPtrList; typedef void *value_type; typedef value_type *pointer; @@ -450,6 +447,24 @@ public: } protected: + void swap(FCListItem &o) { + std::swap(m_next, o.m_next); + std::swap(m_previous, o.m_previous); + if(m_next != &o) { + m_next->m_previous = this; + m_previous->m_next = this; + } else { + m_next = m_previous = this; + } + if(o.m_next != this) { + o.m_next->m_previous = &o; + o.m_previous->m_next = &o; + } else { + o.m_next = o.m_previous = &o; + } + } + +protected: FCListItem *m_next; FCListItem *m_previous; }; diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h index 332a8e1..a76058e 100644 --- a/lib/libpacman/util/fptrlist.h +++ b/lib/libpacman/util/fptrlist.h @@ -54,8 +54,6 @@ class FPtrList { public: friend FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn); - friend bool _pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp fn, void **data); - friend FPtrList *f_ptrlist_add(FPtrList *list, void *data); typedef FPtrListItem *iterator; typedef const iterator const_iterator; @@ -169,21 +167,9 @@ public: } void swap(FPtrList &o) { - std::swap(m_next, o.m_next); - std::swap(m_previous, o.m_previous); - if(m_next != &o) { - m_next->m_previous = this; - m_previous->m_next = this; - } else { - m_next = m_previous = this; - } - if(o.m_next != this) { - o.m_next->m_previous = &o; - o.m_previous->m_next = &o; - } else { - o.m_next = o.m_previous = &o; - } + FCListItem::swap(o); } + private: FPtrList(const FPtrList &o); FPtrList &operator = (const FPtrList &o); _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
