mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
removed unnecessary \param and \return lines from doxygen comments for container classes, refs #91
This commit is contained in:
@@ -52,27 +52,21 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
*/
|
||||
CCollection(const CCollection &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
* \param other
|
||||
*/
|
||||
CCollection(CCollection &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
CCollection &operator =(const CCollection &other) { m_pimpl.reset(other.pimpl() ? other.pimpl()->clone() : nullptr); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Move assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
CCollection &operator =(CCollection && other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
@@ -80,7 +74,6 @@ namespace BlackMisc
|
||||
* \brief Create a new collection with a specific implementation type.
|
||||
* \tparam C Becomes the collection's implementation type.
|
||||
* \param c Initial value for the collection; default is empty, but it could contain elements if desired. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class C> static CCollection fromImpl(C c = C()) { return CCollection(new Pimpl<C>(std::move(c))); }
|
||||
|
||||
@@ -92,68 +85,57 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Like changeImpl, but uses the implementation type of another collection.
|
||||
* \param other
|
||||
* \pre The other collection must be initialized.
|
||||
*/
|
||||
void useImplOf(const CCollection &other) { PimplPtr p = other.pimpl()->cloneEmpty(); for (auto i = cbegin(); i != cend(); ++i) p->insert(*i); m_pimpl.reset(p.take()); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the collection.
|
||||
* \return
|
||||
*/
|
||||
iterator begin() { return pimpl() ? pimpl()->begin() : iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the collection.
|
||||
* \return
|
||||
*/
|
||||
const_iterator begin() const { return pimpl() ? pimpl()->begin() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the collection.
|
||||
* \return
|
||||
*/
|
||||
const_iterator cbegin() const { return pimpl() ? pimpl()->cbegin() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the collection.
|
||||
* \return
|
||||
*/
|
||||
iterator end() { return pimpl() ? pimpl()->end() : iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the collection.
|
||||
* \return
|
||||
*/
|
||||
const_iterator end() const { return pimpl() ? pimpl()->end() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the collection.
|
||||
* \return
|
||||
*/
|
||||
const_iterator cend() const { return pimpl() ? pimpl()->cend() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Swap this collection with another.
|
||||
* \param other
|
||||
*/
|
||||
void swap(CCollection &other) { m_pimpl.swap(other.m_pimpl); }
|
||||
|
||||
/*!
|
||||
* \brief Returns number of elements in the collection.
|
||||
* \return
|
||||
*/
|
||||
size_type size() const { return pimpl() ? pimpl()->size() : 0; }
|
||||
|
||||
/*!
|
||||
* \brief Returns true if the collection is empty.
|
||||
* \return
|
||||
*/
|
||||
bool empty() const { return pimpl() ? pimpl()->empty() : true; }
|
||||
|
||||
/*!
|
||||
* \brief Synonym for empty.
|
||||
* \return
|
||||
*/
|
||||
bool isEmpty() const { return empty(); }
|
||||
|
||||
@@ -164,7 +146,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Inserts an element into the collection.
|
||||
* \param value
|
||||
* \return An iterator to the position where value was inserted.
|
||||
* \pre The collection must be initialized.
|
||||
*/
|
||||
@@ -172,7 +153,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Synonym for insert.
|
||||
* \param value
|
||||
* \return An iterator to the position where value was inserted.
|
||||
* \pre The collection must be initialized.
|
||||
*/
|
||||
@@ -180,7 +160,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Remove the element pointed to by the given iterator.
|
||||
* \param pos
|
||||
* \return An iterator to the position of the next element after the one removed.
|
||||
* \pre The collection must be initialized.
|
||||
*/
|
||||
@@ -188,8 +167,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Remove the range of elements between two iterators.
|
||||
* \param it1
|
||||
* \param it2
|
||||
* \return An iterator to the position of the next element after the one removed.
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
@@ -197,16 +174,12 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Test for equality.
|
||||
* \param other
|
||||
* \return
|
||||
* \todo Improve inefficient implementation.
|
||||
*/
|
||||
bool operator ==(const CCollection &other) const { return (empty() && other.empty()) ? true : (size() != other.size() ? false : *pimpl() == *other.pimpl()); }
|
||||
|
||||
/*!
|
||||
* \brief Test for inequality.
|
||||
* \param other
|
||||
* \return
|
||||
* \todo Improve inefficient implementation.
|
||||
*/
|
||||
bool operator !=(const CCollection &other) const { return !(*this == other); }
|
||||
|
||||
@@ -29,8 +29,6 @@ namespace BlackMisc
|
||||
public:
|
||||
/*!
|
||||
* \brief Return a copy containing only those elements for which a given predicate returns true.
|
||||
* \param p
|
||||
* \return
|
||||
*/
|
||||
template <class Predicate>
|
||||
C<T> findBy(Predicate p) const
|
||||
@@ -44,7 +42,6 @@ namespace BlackMisc
|
||||
* \brief Return a copy containing only those elements matching a particular key/value pair.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
C<T> findBy(K1 key1, V1 value1) const
|
||||
@@ -58,7 +55,6 @@ namespace BlackMisc
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \param key2 A pointer to a member function of T.
|
||||
* \param value2 Will be compared to the return value of key2.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class V1, class K2, class V2>
|
||||
C<T> findBy(K1 key1, V1 value1, K2 key2, V2 value2) const
|
||||
@@ -74,7 +70,6 @@ namespace BlackMisc
|
||||
* \param value2 Will be compared to the return value of key2.
|
||||
* \param key3 A pointer to a member function of T.
|
||||
* \param value3 Will be compared to the return value of key3.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class V1, class K2, class V2, class K3, class V3>
|
||||
C<T> findBy(K1 key1, V1 value1, K2 key2, V2 value2, K3 key3, V3 value3) const
|
||||
@@ -84,8 +79,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Return a copy containing only those elements matching a given value map.
|
||||
* \param valueMap
|
||||
* \return
|
||||
*/
|
||||
C<T> findBy(const CValueMap &valueMap) const
|
||||
{
|
||||
@@ -94,8 +87,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Return true if there is an element for which a given predicate returns true
|
||||
* \param p
|
||||
* \return
|
||||
*/
|
||||
template <class Predicate>
|
||||
bool contains(Predicate p) const
|
||||
@@ -107,7 +98,6 @@ namespace BlackMisc
|
||||
* \brief Return a copy containing only those elements matching a particular key/value pair.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
bool contains(K1 key1, V1 value1) const
|
||||
@@ -117,7 +107,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Remove elements for which a given predicate returns true.
|
||||
* \param p
|
||||
*/
|
||||
template <class Predicate>
|
||||
void removeIf(Predicate p)
|
||||
|
||||
@@ -46,27 +46,21 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
*/
|
||||
ConstForwardIterator(const ConstForwardIterator &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
* \param other
|
||||
*/
|
||||
ConstForwardIterator(ConstForwardIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
ConstForwardIterator &operator =(const ConstForwardIterator &other) { m_pimpl.reset(other.pimpl() ? other.pimpl()->clone() : nullptr); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Move assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
ConstForwardIterator &operator =(ConstForwardIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
@@ -74,20 +68,17 @@ namespace BlackMisc
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static ConstForwardIterator fromImpl(I i) { return ConstForwardIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_reference operator *() const { Q_ASSERT(m_pimpl); return **pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Arrow operator provides access to members of the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_pointer operator ->() const { Q_ASSERT(m_pimpl); return &**pimpl(); }
|
||||
@@ -108,7 +99,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Reference to the iterator at the new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -116,7 +106,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Copy of the iterator in its new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -124,23 +113,18 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Test for equality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator ==(const ConstForwardIterator &other) const { return (pimpl() && other.pimpl()) ? *pimpl() == *other.pimpl() : pimpl() == other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Test for inequality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator !=(const ConstForwardIterator &other) const { return !(*this == other); }
|
||||
|
||||
/*!
|
||||
* \brief Return opaque pointer to underlying implementation iterator object.
|
||||
* \return
|
||||
* \pre The iterator must have been initialized.
|
||||
* \todo Returning by void* is rotten, but GCC gives a very cryptic error if I make it a function template with a cast inside.
|
||||
*/
|
||||
@@ -210,27 +194,21 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
*/
|
||||
ConstBidirectionalIterator(const ConstBidirectionalIterator &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
* \param other
|
||||
*/
|
||||
ConstBidirectionalIterator(ConstBidirectionalIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
ConstBidirectionalIterator &operator =(const ConstBidirectionalIterator &other) { m_pimpl.reset(other.pimpl() ? other.pimpl()->clone() : nullptr); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Move assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
ConstBidirectionalIterator &operator =(ConstBidirectionalIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
@@ -238,20 +216,17 @@ namespace BlackMisc
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static ConstBidirectionalIterator fromImpl(I i) { return ConstBidirectionalIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_reference operator *() const { Q_ASSERT(m_pimpl); return **pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Arrow operator provides access to members of the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_pointer operator ->() const { Q_ASSERT(m_pimpl); return &**pimpl(); }
|
||||
@@ -286,7 +261,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Reference to the iterator at the new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -294,7 +268,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Copy of the iterator in its new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -302,7 +275,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Backtrack the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Reference to the iterator at the new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -310,7 +282,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Backtrack the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Copy of the iterator in its new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -318,39 +289,30 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Return the distance between two iterators.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
difference_type operator -(const ConstBidirectionalIterator &other) const { Q_ASSERT(m_pimpl && other.m_pimpl); return *pimpl() - *other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Test for equality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator ==(const ConstBidirectionalIterator &other) const { return (pimpl() && other.pimpl()) ? *pimpl() == *other.pimpl() : pimpl() == other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Test for inequality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator !=(const ConstBidirectionalIterator &other) const { return !(*this == other); }
|
||||
|
||||
/*!
|
||||
* \brief For sorting.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator <(const ConstBidirectionalIterator &other) const { Q_ASSERT(m_pimpl && other.m_pimpl); return *pimpl() < *other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Return opaque pointer to underlying implementation iterator object.
|
||||
* \return
|
||||
* \pre The iterator must have been initialized.
|
||||
* \todo Returning by void* is rotten, but GCC gives a very cryptic error if I make it a function template with a cast inside.
|
||||
*/
|
||||
@@ -428,27 +390,21 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
*/
|
||||
BidirectionalIterator(const BidirectionalIterator &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
* \param other
|
||||
*/
|
||||
BidirectionalIterator(BidirectionalIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
BidirectionalIterator &operator =(const BidirectionalIterator &other) { m_pimpl.reset(other.pimpl() ? other.pimpl()->clone() : nullptr); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Move assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
BidirectionalIterator &operator =(BidirectionalIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
@@ -456,34 +412,29 @@ namespace BlackMisc
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static BidirectionalIterator fromImpl(I i) { return BidirectionalIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_reference operator *() const { Q_ASSERT(m_pimpl); return **pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
reference operator *() { Q_ASSERT(m_pimpl); return **pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Arrow operator provides access to members of the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
const_pointer operator ->() const { Q_ASSERT(m_pimpl); return &**pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Arrow operator provides access to members of the object pointed to.
|
||||
* \return
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
pointer operator ->() { Q_ASSERT(m_pimpl); return &**pimpl(); }
|
||||
@@ -518,7 +469,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Reference to the iterator at the new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -526,7 +476,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Advance the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Copy of the iterator in its new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -534,7 +483,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Backtrack the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Reference to the iterator at the new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -542,7 +490,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Backtrack the iterator by a certain amount.
|
||||
* \param n
|
||||
* \return Copy of the iterator in its new position.
|
||||
* \pre The iterator must be initialized and valid.
|
||||
*/
|
||||
@@ -550,39 +497,30 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Return the distance between two iterators.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
difference_type operator -(const BidirectionalIterator &other) const { Q_ASSERT(m_pimpl && other.m_pimpl); return *pimpl() - *other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Test for equality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator ==(const BidirectionalIterator &other) const { return (pimpl() && other.pimpl()) ? *pimpl() == *other.pimpl() : pimpl() == other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Test for inequality.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator !=(const BidirectionalIterator &other) const { return !(*this == other); }
|
||||
|
||||
/*!
|
||||
* \brief For sorting.
|
||||
* \param other
|
||||
* \return
|
||||
* \pre Both iterators must originate from the same collection, and not mix begin/end with cbegin/cend.
|
||||
*/
|
||||
bool operator <(const BidirectionalIterator &other) const { Q_ASSERT(m_pimpl && other.m_pimpl); return *pimpl() < *other.pimpl(); }
|
||||
|
||||
/*!
|
||||
* \brief Return opaque pointer to underlying implementation iterator object.
|
||||
* \return
|
||||
* \pre The iterator must have been initialized.
|
||||
* \todo Returning by void* is rotten, but GCC gives a very cryptic error if I make it a function template with a cast inside.
|
||||
*/
|
||||
|
||||
@@ -52,27 +52,21 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
*/
|
||||
CSequence(const CSequence &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
* \param other
|
||||
*/
|
||||
CSequence(CSequence &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
CSequence &operator =(const CSequence &other) { m_pimpl.reset(other.pimpl() ? other.pimpl()->clone() : nullptr); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Move assignment.
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
CSequence &operator =(CSequence &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
@@ -80,7 +74,6 @@ namespace BlackMisc
|
||||
* \brief Create a new sequence with a specific implementation type.
|
||||
* \tparam C Becomes the sequence's implementation type.
|
||||
* \param c Initial value for the sequence; default is empty, but it could contain elements if desired. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class C> static CSequence fromImpl(C c = C()) { return CSequence(new Pimpl<C>(std::move(c))); }
|
||||
|
||||
@@ -92,112 +85,93 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Like changeImpl, but uses the implementation type of another sequence.
|
||||
* \param other
|
||||
* \pre The other sequence must be initialized.
|
||||
*/
|
||||
void useImplOf(const CSequence &other) { PimplPtr p = other.pimpl()->cloneEmpty(); for (auto i = cbegin(); i != cend(); ++i) p->push_back(*i); m_pimpl.reset(p.take()); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the sequence.
|
||||
* \return
|
||||
*/
|
||||
iterator begin() { return pimpl() ? pimpl()->begin() : iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the sequence.
|
||||
* \return
|
||||
*/
|
||||
const_iterator begin() const { return pimpl() ? pimpl()->begin() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator at the beginning of the sequence.
|
||||
* \return
|
||||
*/
|
||||
const_iterator cbegin() const { return pimpl() ? pimpl()->cbegin() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the sequence.
|
||||
* \return
|
||||
*/
|
||||
iterator end() { return pimpl() ? pimpl()->end() : iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the sequence.
|
||||
* \return
|
||||
*/
|
||||
const_iterator end() const { return pimpl() ? pimpl()->end() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns iterator one past the end of the sequence.
|
||||
* \return
|
||||
*/
|
||||
const_iterator cend() const { return pimpl() ? pimpl()->cend() : const_iterator(); }
|
||||
|
||||
/*!
|
||||
* \brief Swap this sequence with another.
|
||||
* \param other
|
||||
*/
|
||||
void swap(CSequence &other) { m_pimpl.swap(other.m_pimpl); }
|
||||
|
||||
/*!
|
||||
* \brief Access an element by its index.
|
||||
* \param index
|
||||
* \return
|
||||
* \pre The sequence must be initialized and the index in bounds.
|
||||
*/
|
||||
reference operator [](size_type index) { Q_ASSERT(pimpl()); return pimpl()->operator [](index); }
|
||||
|
||||
/*!
|
||||
* \brief Access an element by its index.
|
||||
* \param index
|
||||
* \return
|
||||
* \pre The sequence must be initialized and the index in bounds.
|
||||
*/
|
||||
const_reference operator [](size_type index) const { Q_ASSERT(pimpl()); return pimpl()->operator [](index); }
|
||||
|
||||
/*!
|
||||
* \brief Access the first element.
|
||||
* \return
|
||||
* \pre The sequence must not be empty.
|
||||
*/
|
||||
reference front() { Q_ASSERT(!empty()); return pimpl()->front(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the first element.
|
||||
* \return
|
||||
* \pre The sequence must not be empty.
|
||||
*/
|
||||
const_reference front() const { Q_ASSERT(!empty()); return pimpl()->front(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the last element.
|
||||
* \return
|
||||
* \pre The sequence must not be empty.
|
||||
*/
|
||||
reference back() { Q_ASSERT(!empty()); return pimpl()->back(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the last element.
|
||||
* \return
|
||||
* \pre The sequence must not be empty.
|
||||
*/
|
||||
const_reference back() const { Q_ASSERT(!empty()); return pimpl()->back(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns number of elements in the sequence.
|
||||
* \return
|
||||
*/
|
||||
size_type size() const { return pimpl() ? pimpl()->size() : 0; }
|
||||
|
||||
/*!
|
||||
* \brief Returns true if the sequence is empty.
|
||||
* \return
|
||||
*/
|
||||
bool empty() const { return pimpl() ? pimpl()->empty() : true; }
|
||||
|
||||
/*!
|
||||
* \brief Synonym for empty.
|
||||
* \return
|
||||
*/
|
||||
bool isEmpty() const { return empty(); }
|
||||
|
||||
@@ -208,8 +182,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Inserts an element into the sequence.
|
||||
* \param before
|
||||
* \param value
|
||||
* \return An iterator to the position where value was inserted.
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
@@ -217,14 +189,12 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Appends an element at the end of the sequence.
|
||||
* \param value
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
void push_back(const T &value) { Q_ASSERT(pimpl()); pimpl()->push_back(value); }
|
||||
|
||||
/*!
|
||||
* \brief Synonym for push_back.
|
||||
* \param value
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
void insert(const T &value) { push_back(value); }
|
||||
@@ -237,7 +207,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Remove the element pointed to by the given iterator.
|
||||
* \param pos
|
||||
* \return An iterator to the position of the next element after the one removed.
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
@@ -245,8 +214,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Remove the range of elements between two iterators.
|
||||
* \param it1
|
||||
* \param it2
|
||||
* \return An iterator to the position of the next element after the one removed.
|
||||
* \pre The sequence must be initialized.
|
||||
*/
|
||||
@@ -254,8 +221,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Modify by applying a value map to each element for which a given predicate returns true.
|
||||
* \param p
|
||||
* \param newValues
|
||||
*/
|
||||
template <class Predicate>
|
||||
void applyIf(Predicate p, const CValueMap &newValues)
|
||||
@@ -267,7 +232,6 @@ namespace BlackMisc
|
||||
* \brief Modify by applying a value map to each element matching a particular key/value pair.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \param newValues
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
void applyIf(K1 key1, V1 value1, const CValueMap &newValues)
|
||||
@@ -277,8 +241,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Modify by applying a value map to each element matching a given value map.
|
||||
* \param pattern
|
||||
* \param newValues
|
||||
*/
|
||||
void applyIf(const CValueMap &pattern, const CValueMap &newValues)
|
||||
{
|
||||
@@ -287,8 +249,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Replace elements for which a given predicate returns true.
|
||||
* \param p
|
||||
* \param replacement
|
||||
*/
|
||||
template <class Predicate>
|
||||
void replaceIf(Predicate p, const T &replacement)
|
||||
@@ -300,7 +260,6 @@ namespace BlackMisc
|
||||
* \brief Replace elements matching a particular key/value pair.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \param replacement
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
void replaceIf(K1 key1, V1 value1, const T &replacement)
|
||||
@@ -310,8 +269,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Replace elements for which a given predicate returns true. If there is no match, push the new element on the end.
|
||||
* \param p
|
||||
* \param replacement
|
||||
*/
|
||||
template <class Predicate>
|
||||
void replaceOrAdd(Predicate p, const T &replacement)
|
||||
@@ -324,7 +281,6 @@ namespace BlackMisc
|
||||
* \brief Replace elements matching a particular key/value pair. If there is no match, push the new element on the end.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param value1 Will be compared to the return value of key1.
|
||||
* \param replacement
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
void replaceOrAdd(K1 key1, V1 value1, const T &replacement)
|
||||
@@ -335,7 +291,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief In-place sort by a given comparator predicate.
|
||||
* \param p
|
||||
*/
|
||||
template <class Predicate> void sort(Predicate p)
|
||||
{
|
||||
@@ -374,8 +329,6 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Return a copy sorted by a given comparator predicate.
|
||||
* \param p
|
||||
* \return
|
||||
*/
|
||||
template <class Predicate>
|
||||
CSequence sorted(Predicate p) const
|
||||
@@ -388,7 +341,6 @@ namespace BlackMisc
|
||||
/*!
|
||||
* \brief Return a copy sorted by a particular key.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \return
|
||||
*/
|
||||
template <class K1>
|
||||
CSequence sortedBy(K1 key1) const
|
||||
@@ -400,7 +352,6 @@ namespace BlackMisc
|
||||
* \brief Return a copy sorted by some particular keys.
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param key2 A pointer to a member function of T.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class K2>
|
||||
CSequence sortedBy(K1 key1, K2 key2) const
|
||||
@@ -413,7 +364,6 @@ namespace BlackMisc
|
||||
* \param key1 A pointer to a member function of T.
|
||||
* \param key2 A pointer to a member function of T.
|
||||
* \param key3 A pointer to a member function of T.
|
||||
* \return
|
||||
*/
|
||||
template <class K1, class K2, class K3>
|
||||
CSequence sortedBy(K1 key1, K2 key2, K3 key3) const
|
||||
@@ -423,16 +373,12 @@ namespace BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Test for equality.
|
||||
* \param other
|
||||
* \return
|
||||
* \todo Improve inefficient implementation.
|
||||
*/
|
||||
bool operator ==(const CSequence &other) const { return (empty() && other.empty()) ? true : (size() != other.size() ? false : *pimpl() == *other.pimpl()); }
|
||||
|
||||
/*!
|
||||
* \brief Test for inequality.
|
||||
* \param other
|
||||
* \return
|
||||
* \todo Improve inefficient implementation.
|
||||
*/
|
||||
bool operator !=(const CSequence &other) const { return !(*this == other); }
|
||||
|
||||
Reference in New Issue
Block a user