swift
Loading...
Searching...
No Matches
swift::misc::CSequence< T > Class Template Reference

Generic sequential container with value semantics. More...

#include <sequence.h>

Inheritance diagram for swift::misc::CSequence< T >:
[legend]

Public Types

using key_type = T
 STL compatibility.
using value_type = T
 STL compatilibty.
using reference = T &
 STL compatibility.
using const_reference = const T &
 STL compatibility.
using pointer = T *
 STL compatibility.
using const_pointer = const T *
 STL compatibility.
using const_iterator = typename QVector<T>::const_iterator
 STL compatibility.
using iterator = typename QVector<T>::iterator
 STL compatibility.
using const_reverse_iterator = typename QVector<T>::const_reverse_iterator
 STL compatibility.
using reverse_iterator = typename QVector<T>::reverse_iterator
 STL compatibility.
using difference_type = ptrdiff_t
 STL compatibility.
using size_type = int
 STL compatibility.

Public Member Functions

 CSequence ()=default
 Default constructor.
 CSequence (std::initializer_list< T > il)
 Initializer list constructor.
 CSequence (QList< T > &&list)
 By QList of type T.
 CSequence (const QList< T > &list)
 By QList of type T.
template<typename It>
 CSequence (It first, It last)
 Range constructor.
 CSequence (const CSequence &other)=default
 Copy constructor.
 CSequence (CSequence &&other)=default
 Move constructor.
CSequence & operator= (const CSequence &other)=default
 Copy assignment.
CSequence & operator= (CSequence &&other)=default
 Move assignment.
 ~CSequence ()=default
 Destructor.
QVector< T > toVector () const &
 Copy of internal vector.
QVector< T > toVector () &&
 Copy of internal vector.
iterator begin ()
 Returns iterator at the beginning of the sequence.
const_iterator begin () const
 Returns const iterator at the beginning of the sequence.
const_iterator cbegin () const
 Returns const iterator at the beginning of the sequence.
iterator end ()
 Returns iterator one past the end of the sequence.
const_iterator end () const
 Returns const iterator one past the end of the sequence.
const_iterator cend () const
 Returns const iterator one past the end of the sequence.
reverse_iterator rbegin ()
 Returns iterator at the beginning of the reversed sequence.
const_reverse_iterator rbegin () const
 Returns const iterator at the beginning of the reversed sequence.
const_reverse_iterator crbegin () const
 Returns const iterator at the beginning of the reversed sequence.
reverse_iterator rend ()
 Returns iterator at the end of the reversed sequence.
const_reverse_iterator rend () const
 Returns const iterator at the end of the reversed sequence.
const_reverse_iterator crend () const
 Returns const iterator at the end of the reversed sequence.
void swap (CSequence &other) noexcept
 Swap this sequence with another.
reference operator[] (size_type index)
 Access an element by its index.
const_reference operator[] (size_type index) const
 Access an element by its index.
reference front ()
 Access the first element.
const_reference front () const
 Access the first element.
const_reference frontOrDefault () const
 Access the first element, or a default-initialized value if the sequence is empty.
value_type frontOrDefault (value_type def) const
 Access the first element, or a default-initialized value if the sequence is empty.
reference back ()
 Access the last element.
const_reference back () const
 Access the last element.
const_reference backOrDefault () const
 Access the last element, or a default value if the sequence is empty.
value_type backOrDefault (value_type def) const
 Access the last element, or a default value if the sequence is empty.
size_type size () const
 Returns number of elements in the sequence.
int sizeInt () const
 Avoid compiler warnings when using with int.
QString sizeString () const
 Convenience function.
bool empty () const
 Returns true if the sequence is empty.
bool isEmpty () const
 Synonym for empty.
void clear ()
 Removes all elements in the sequence.
void truncate (size_type maxSize)
 Changes the size of the sequence, if it is bigger than the given size.
iterator insert (iterator before, const T &value)
 Inserts an element into the sequence.
iterator insert (iterator before, T &&value)
 Moves an element into the sequence.
void push_back (const T &value)
 Appends an element at the end of the sequence.
void push_front (const T &value)
 Insert as first element.
void push_front (const CSequence &other)
 Inserts all elements from another sequence at the beginning of this sequence.
void push_frontMaxElements (const T &value, int maxElements)
 Insert as first element by keep maxElements.
void push_backMaxElements (const T &value, int maxElements)
 Insert as last element by keep maxElements.
void push_back (T &&value)
 Move-appends an element at the end of the sequence.
void push_front (T &&value)
 Move-insert as first element.
void push_back (const CSequence &other)
 Appends all elements from another sequence at the end of this sequence.
void push_back (CSequence &&other)
 Appends all elements from another sequence at the end of this sequence. This version moves elements instead of copying.
template<typename I>
void push_back (const CRange< I > &range)
 Appends all elements from a range at the end of this sequence.
CSequence join (const CSequence &other) const
 Concatenates two sequences and returns the result.
template<typename I>
CSequence join (const CRange< I > &range) const
 Concatenates a sequence and a range and returns the result.
void pop_back ()
 Removes an element at the end of the sequence.
void pop_front ()
 Removes an element at the front of the sequence.
iterator erase (iterator pos)
 Remove the element pointed to by the given iterator.
iterator erase (iterator it1, iterator it2)
 Remove the range of elements between two iterators.
iterator find (const T &object)
 Return an iterator to the first element equal to the given object, or the end iterator if not found. O(n).
const_iterator find (const T &object) const
 Return an iterator to the first element equal to the given object, or the end iterator if not found. O(n).
template<class Predicate>
CSequence findBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
template<class Predicate, class VariantMap>
int applyIf (Predicate p, const VariantMap &newValues, bool skipEqualValues=false)
 Modify by applying a value map to each element for which a given predicate returns true.
template<class K1, class V1, class VariantMap>
int applyIf (K1 key1, V1 value1, const VariantMap &newValues, bool skipEqualValues=false)
 Modify by applying a value map to each element matching a particular key/value pair.
int remove (const T &object)
 Remove all elements equal to the given object, if it is contained.
template<class Predicate>
int removeIf (Predicate p)
 Remove elements for which a given predicate returns true.
template<class K0, class V0, class... KeysValues>
int removeIf (K0 k0, V0 v0, KeysValues... keysValues)
 Remove elements matching some particular key/value pair(s).
int removeIfIn (const CSequence &other)
 Remove all elements if they are in other.
void removeIfInSubset (const CSequence &other)
 Remove all elements if they are in other.
int replace (const T &original, const T &replacement)
 Replace elements matching the given element with a replacement.
template<class Predicate>
int replaceIf (Predicate p, const T &replacement)
 Replace elements for which a given predicate returns true.
template<class K1, class V1>
int replaceIf (K1 key1, V1 value1, const T &replacement)
 Replace elements matching a particular key/value pair.
void replaceOrAdd (const T &original, const T &replacement)
 Replace elements matching the given element. If there is no match, push the new element on the end.
void replaceOrAdd (const T &replacement)
 Replace elements matching the given element. If there is no match, push the new element on the end.
void replaceOrAdd (const CSequence< T > &replacements)
 Replace or add given elements.
template<class K1, class V1>
void replaceOrAdd (K1 key1, V1 value1, const T &replacement)
 Replace elements matching a particular key/value pair. If there is no match, push the new element on the end.
void reverse ()
 In-place reverse.
Q_REQUIRED_RESULT CSequence reversed () const
 Reversed order.
template<class Predicate>
void sort (Predicate p)
 In-place sort by a given comparator predicate.
template<class K1, class... Keys>
void sortBy (K1 key1, Keys... keys)
 In-place sort by some particular key(s).
template<class Predicate>
Q_REQUIRED_RESULT CSequence sorted (Predicate p) const
 Return a copy sorted by a given comparator predicate.
template<class K1, class... Keys>
CSequence sortedBy (K1 key1, Keys... keys) const
 Return a copy sorted by some particular key(s).
template<class Predicate>
void partiallySort (size_type n, Predicate p)
 In-place move the smallest n elements to the beginning and sort them.
template<class K1, class... Keys>
void partiallySortBy (size_type n, K1 key1, Keys... keys)
 In-place partially sort by some particular key(s).
template<class Predicate>
Q_REQUIRED_RESULT CSequence partiallySorted (size_type n, Predicate p) const
 Return a copy with the smallest n elements at the beginning and sorted.
template<class K1, class... Keys>
CSequence partiallySortedBy (size_type n, K1 key1, Keys... keys) const
 Return a copy partially sorted by some particular key(s).
template<class U, class Key0, class... Keys>
bool unorderedEqualsByKeys (const U &other, Key0 k0, Keys... keys) const
 Return true if this container equals another container, considering only the given element members. Order of elements is not considered; this is implemented using a transient sort, so don't overuse.
template<class Predicate>
auto separate (Predicate p) const -> QMap< decltype(p(std::declval< T >())), CSequence >
 Split up the sequence into subsequences for which the given predicate returns the same value.
template<class Key>
auto separateBy (Key k) const -> QMap< decltype(std::invoke(k, std::declval< T >())), CSequence >
 Split up the sequence into subsequences of elements having the same value for the given key.
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream.
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream.
Public Member Functions inherited from swift::misc::CContainerBase< CSequence< T > >
auto to () const
 Return a new container of a different type, containing the same elements as this one.
int removeIf (K0 k0, V0 v0, KeysValues... keysValues)
 Remove elements matching some particular key/value pair(s).
QJsonObject toJson () const
 Cast to JSON object.
QString toJsonString (QJsonDocument::JsonFormat format=QJsonDocument::Indented) const
 Convenience function JSON as string.
void convertFromJson (const QJsonObject &json)
 Assign from JSON object.
CStatusMessage convertFromJsonNoThrow (const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that is thrown and return it as CStatusMessage.
QString convertToQString (bool i18n=false) const
 Cast as QString.
QStringList toStringList (bool i18n=false) const
 To string list.
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object.
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object.
Public Member Functions inherited from swift::misc::CRangeBase< CSequence< T > >
auto transform (F function) const
 Return a new container generated by applying some transformation function to all elements of this one.
auto findBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
const auto & findFirstBy (Predicate p) const
 Return a reference to the first element for which a given predicate returns true. Undefined if there is none.
auto findFirstByOrDefault (Predicate p, const Value &def) const
 Return a copy of the first element for which a given predicate returns true, or a default value if there is none.
bool containsBy (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
bool contains (const T &object) const
 Return true if there is an element equal to given object. Uses the most efficient implementation available in the derived container.
bool equalsBy (const T &other, Predicate c) const
 Return true if this container equals another container according to the given element equality predicate.
bool equalsByKeys (const T &other, Key0 k0, Keys... keys) const
 Return true if this container equals another container, considering only the given element members.
T randomElement () const
 Pick one random element.
CSequence< T > randomElements (int n) const
 Copy n elements from the container at random.
CSequence< T > sampleElements (int n) const
 Copy n elements from the container, randomly selected but evenly distributed.
Public Member Functions inherited from swift::misc::mixin::MetaType< CSequence< T > >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
QString getClassName () const
 Class name.
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
Public Member Functions inherited from swift::misc::mixin::String< CSequence< T > >
QString toQString (bool i18n=false) const
 Cast as QString.
std::string toStdString (bool i18n=false) const
 To std string.
QString stringForStreaming () const
 String for streaming operators.
Public Member Functions inherited from swift::misc::mixin::Icon< CSequence< T > >
CIcons::CIcons::StandardIconUnknown16 toIcon () const
 As icon, not implemented by all classes.

Friends

bool operator== (const CSequence &a, const CSequence &b)
 Equals operator.
bool operator!= (const CSequence &a, const CSequence &b)
 Not equals operator.
bool operator< (const CSequence &a, const CSequence &b)
 Less than operator.
bool operator> (const CSequence &a, const CSequence &b)
 Greater than operator.
bool operator<= (const CSequence &a, const CSequence &b)
 Less or equal than operator.
bool operator>= (const CSequence &a, const CSequence &b)
 Greater or equal operator.

Additional Inherited Members

Static Public Member Functions inherited from swift::misc::CContainerBase< CSequence< T > >
static CSequence< T > fromJson (const QJsonObject &json)
 Static version of convertFromJson.
static CSequence< T > fromJsonNoThrow (const QString &jsonString, bool acceptCacheJson, bool &success, QString &errMsg)
 Static version of convertFromJson.
Static Public Member Functions inherited from swift::misc::mixin::MetaType< CSequence< T > >
static void registerMetadata ()
 Register metadata.
Protected Member Functions inherited from swift::misc::CContainerBase< CSequence< T > >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
Static Protected Member Functions inherited from swift::misc::CRangeBase< CSequence< T > >
static bool equalPointers (const T *a, const U *b)
 Efficiently compare addresses of two objects. Return false if types are not compatible.

Detailed Description

template<class T>
class swift::misc::CSequence< T >

Generic sequential container with value semantics.

Template Parameters
Tthe type of elements contained.

Definition at line 82 of file sequence.h.

Member Typedef Documentation

◆ const_iterator

template<class T>
using swift::misc::CSequence< T >::const_iterator = typename QVector<T>::const_iterator

STL compatibility.

Definition at line 107 of file sequence.h.

◆ const_pointer

template<class T>
using swift::misc::CSequence< T >::const_pointer = const T *

STL compatibility.

Definition at line 104 of file sequence.h.

◆ const_reference

template<class T>
using swift::misc::CSequence< T >::const_reference = const T &

STL compatibility.

Definition at line 98 of file sequence.h.

◆ const_reverse_iterator

template<class T>
using swift::misc::CSequence< T >::const_reverse_iterator = typename QVector<T>::const_reverse_iterator

STL compatibility.

Definition at line 113 of file sequence.h.

◆ difference_type

template<class T>
using swift::misc::CSequence< T >::difference_type = ptrdiff_t

STL compatibility.

Definition at line 119 of file sequence.h.

◆ iterator

template<class T>
using swift::misc::CSequence< T >::iterator = typename QVector<T>::iterator

STL compatibility.

Definition at line 110 of file sequence.h.

◆ key_type

template<class T>
using swift::misc::CSequence< T >::key_type = T

STL compatibility.

Definition at line 89 of file sequence.h.

◆ pointer

template<class T>
using swift::misc::CSequence< T >::pointer = T *

STL compatibility.

Definition at line 101 of file sequence.h.

◆ reference

template<class T>
using swift::misc::CSequence< T >::reference = T &

STL compatibility.

Definition at line 95 of file sequence.h.

◆ reverse_iterator

template<class T>
using swift::misc::CSequence< T >::reverse_iterator = typename QVector<T>::reverse_iterator

STL compatibility.

Definition at line 116 of file sequence.h.

◆ size_type

template<class T>
using swift::misc::CSequence< T >::size_type = int

STL compatibility.

Definition at line 122 of file sequence.h.

◆ value_type

template<class T>
using swift::misc::CSequence< T >::value_type = T

STL compatilibty.

Definition at line 92 of file sequence.h.

Constructor & Destructor Documentation

◆ CSequence() [1/4]

template<class T>
swift::misc::CSequence< T >::CSequence ( std::initializer_list< T > il)
inline

Initializer list constructor.

Definition at line 128 of file sequence.h.

◆ CSequence() [2/4]

template<class T>
swift::misc::CSequence< T >::CSequence ( QList< T > && list)
inline

By QList of type T.

Definition at line 131 of file sequence.h.

◆ CSequence() [3/4]

template<class T>
swift::misc::CSequence< T >::CSequence ( const QList< T > & list)
inline

By QList of type T.

Definition at line 134 of file sequence.h.

◆ CSequence() [4/4]

template<class T>
template<typename It>
swift::misc::CSequence< T >::CSequence ( It first,
It last )
inline

Range constructor.

Definition at line 138 of file sequence.h.

Member Function Documentation

◆ applyIf() [1/2]

template<class T>
template<class K1, class V1, class VariantMap>
int swift::misc::CSequence< T >::applyIf ( K1 key1,
V1 value1,
const VariantMap & newValues,
bool skipEqualValues = false )
inline

Modify by applying a value map to each element matching a particular key/value pair.

Parameters
key1A pointer to a member function of T.
value1Will be compared to the return value of key1.
newValuesValues from this map will be put into each matching element.
skipEqualValuesEqual values will not be updated
Returns
The number of elements modified.

Definition at line 440 of file sequence.h.

◆ applyIf() [2/2]

template<class T>
template<class Predicate, class VariantMap>
int swift::misc::CSequence< T >::applyIf ( Predicate p,
const VariantMap & newValues,
bool skipEqualValues = false )
inline

Modify by applying a value map to each element for which a given predicate returns true.

Returns
The number of elements modified.

Definition at line 420 of file sequence.h.

◆ back() [1/2]

template<class T>
reference swift::misc::CSequence< T >::back ( )
inline

Access the last element.

Definition at line 249 of file sequence.h.

◆ back() [2/2]

template<class T>
const_reference swift::misc::CSequence< T >::back ( ) const
inline

Access the last element.

Definition at line 256 of file sequence.h.

◆ backOrDefault() [1/2]

template<class T>
const_reference swift::misc::CSequence< T >::backOrDefault ( ) const
inline

Access the last element, or a default value if the sequence is empty.

Definition at line 263 of file sequence.h.

◆ backOrDefault() [2/2]

template<class T>
value_type swift::misc::CSequence< T >::backOrDefault ( value_type def) const
inline

Access the last element, or a default value if the sequence is empty.

Definition at line 270 of file sequence.h.

◆ begin() [1/2]

template<class T>
iterator swift::misc::CSequence< T >::begin ( )
inline

Returns iterator at the beginning of the sequence.

Definition at line 163 of file sequence.h.

◆ begin() [2/2]

template<class T>
const_iterator swift::misc::CSequence< T >::begin ( ) const
inline

Returns const iterator at the beginning of the sequence.

Definition at line 166 of file sequence.h.

◆ cbegin()

template<class T>
const_iterator swift::misc::CSequence< T >::cbegin ( ) const
inline

Returns const iterator at the beginning of the sequence.

Definition at line 169 of file sequence.h.

◆ cend()

template<class T>
const_iterator swift::misc::CSequence< T >::cend ( ) const
inline

Returns const iterator one past the end of the sequence.

Definition at line 178 of file sequence.h.

◆ clear()

template<class T>
void swift::misc::CSequence< T >::clear ( )
inline

Removes all elements in the sequence.

Definition at line 288 of file sequence.h.

◆ crbegin()

template<class T>
const_reverse_iterator swift::misc::CSequence< T >::crbegin ( ) const
inline

Returns const iterator at the beginning of the reversed sequence.

Definition at line 187 of file sequence.h.

◆ crend()

template<class T>
const_reverse_iterator swift::misc::CSequence< T >::crend ( ) const
inline

Returns const iterator at the end of the reversed sequence.

Definition at line 196 of file sequence.h.

◆ empty()

template<class T>
bool swift::misc::CSequence< T >::empty ( ) const
inline

Returns true if the sequence is empty.

Definition at line 282 of file sequence.h.

◆ end() [1/2]

template<class T>
iterator swift::misc::CSequence< T >::end ( )
inline

Returns iterator one past the end of the sequence.

Definition at line 172 of file sequence.h.

◆ end() [2/2]

template<class T>
const_iterator swift::misc::CSequence< T >::end ( ) const
inline

Returns const iterator one past the end of the sequence.

Definition at line 175 of file sequence.h.

◆ erase() [1/2]

template<class T>
iterator swift::misc::CSequence< T >::erase ( iterator it1,
iterator it2 )
inline

Remove the range of elements between two iterators.

Returns
An iterator to the position of the next element after the one removed.

Definition at line 395 of file sequence.h.

◆ erase() [2/2]

template<class T>
iterator swift::misc::CSequence< T >::erase ( iterator pos)
inline

Remove the element pointed to by the given iterator.

Returns
An iterator to the position of the next element after the one removed.

Definition at line 391 of file sequence.h.

◆ find() [1/2]

template<class T>
iterator swift::misc::CSequence< T >::find ( const T & object)
inline

Return an iterator to the first element equal to the given object, or the end iterator if not found. O(n).

Definition at line 398 of file sequence.h.

◆ find() [2/2]

template<class T>
const_iterator swift::misc::CSequence< T >::find ( const T & object) const
inline

Return an iterator to the first element equal to the given object, or the end iterator if not found. O(n).

Definition at line 401 of file sequence.h.

◆ findBy()

template<class T>
template<class Predicate>
CSequence swift::misc::CSequence< T >::findBy ( Predicate p) const
inline

Return a copy containing only those elements for which a given predicate returns true.

Definition at line 407 of file sequence.h.

◆ front() [1/2]

template<class T>
reference swift::misc::CSequence< T >::front ( )
inline

Access the first element.

Definition at line 225 of file sequence.h.

◆ front() [2/2]

template<class T>
const_reference swift::misc::CSequence< T >::front ( ) const
inline

Access the first element.

Definition at line 232 of file sequence.h.

◆ frontOrDefault() [1/2]

template<class T>
const_reference swift::misc::CSequence< T >::frontOrDefault ( ) const
inline

Access the first element, or a default-initialized value if the sequence is empty.

Definition at line 239 of file sequence.h.

◆ frontOrDefault() [2/2]

template<class T>
value_type swift::misc::CSequence< T >::frontOrDefault ( value_type def) const
inline

Access the first element, or a default-initialized value if the sequence is empty.

Definition at line 246 of file sequence.h.

◆ insert() [1/2]

template<class T>
iterator swift::misc::CSequence< T >::insert ( iterator before,
const T & value )
inline

Inserts an element into the sequence.

Returns
An iterator to the position where value was inserted.

Definition at line 301 of file sequence.h.

◆ insert() [2/2]

template<class T>
iterator swift::misc::CSequence< T >::insert ( iterator before,
T && value )
inline

Moves an element into the sequence.

Returns
An iterator to the position where value was inserted.

Definition at line 305 of file sequence.h.

◆ isEmpty()

template<class T>
bool swift::misc::CSequence< T >::isEmpty ( ) const
inline

Synonym for empty.

Definition at line 285 of file sequence.h.

◆ join() [1/2]

template<class T>
template<typename I>
CSequence swift::misc::CSequence< T >::join ( const CRange< I > & range) const
inline

Concatenates a sequence and a range and returns the result.

Definition at line 368 of file sequence.h.

◆ join() [2/2]

template<class T>
CSequence swift::misc::CSequence< T >::join ( const CSequence< T > & other) const
inline

Concatenates two sequences and returns the result.

Definition at line 359 of file sequence.h.

◆ marshalToDataStream()

template<class T>
void swift::misc::CSequence< T >::marshalToDataStream ( QDataStream & stream) const
inline

Marshal a value to a QDataStream.

Definition at line 723 of file sequence.h.

◆ operator[]() [1/2]

template<class T>
reference swift::misc::CSequence< T >::operator[] ( size_type index)
inline

Access an element by its index.

Definition at line 207 of file sequence.h.

◆ operator[]() [2/2]

template<class T>
const_reference swift::misc::CSequence< T >::operator[] ( size_type index) const
inline

Access an element by its index.

Definition at line 214 of file sequence.h.

◆ partiallySort()

template<class T>
template<class Predicate>
void swift::misc::CSequence< T >::partiallySort ( size_type n,
Predicate p )
inline

In-place move the smallest n elements to the beginning and sort them.

Definition at line 628 of file sequence.h.

◆ partiallySortBy()

template<class T>
template<class K1, class... Keys>
void swift::misc::CSequence< T >::partiallySortBy ( size_type n,
K1 key1,
Keys... keys )
inline

In-place partially sort by some particular key(s).

Parameters
nsize.
key1A pointer to a member function of T.
keysZero or more additional pointers to member functions of T.

Definition at line 638 of file sequence.h.

◆ partiallySorted()

template<class T>
template<class Predicate>
Q_REQUIRED_RESULT CSequence swift::misc::CSequence< T >::partiallySorted ( size_type n,
Predicate p ) const
inline

Return a copy with the smallest n elements at the beginning and sorted.

Definition at line 645 of file sequence.h.

◆ partiallySortedBy()

template<class T>
template<class K1, class... Keys>
CSequence swift::misc::CSequence< T >::partiallySortedBy ( size_type n,
K1 key1,
Keys... keys ) const
inline

Return a copy partially sorted by some particular key(s).

Parameters
nsize
key1A pointer to a member function of T.
keysZero or more additional pointers to member functions of T.

Definition at line 657 of file sequence.h.

◆ pop_back()

template<class T>
void swift::misc::CSequence< T >::pop_back ( )
inline

Removes an element at the end of the sequence.

Definition at line 376 of file sequence.h.

◆ pop_front()

template<class T>
void swift::misc::CSequence< T >::pop_front ( )
inline

Removes an element at the front of the sequence.

Definition at line 383 of file sequence.h.

◆ push_back() [1/5]

template<class T>
template<typename I>
void swift::misc::CSequence< T >::push_back ( const CRange< I > & range)
inline

Appends all elements from a range at the end of this sequence.

Definition at line 353 of file sequence.h.

◆ push_back() [2/5]

template<class T>
void swift::misc::CSequence< T >::push_back ( const CSequence< T > & other)
inline

Appends all elements from another sequence at the end of this sequence.

Definition at line 345 of file sequence.h.

◆ push_back() [3/5]

template<class T>
void swift::misc::CSequence< T >::push_back ( const T & value)
inline

Appends an element at the end of the sequence.

Definition at line 308 of file sequence.h.

◆ push_back() [4/5]

template<class T>
void swift::misc::CSequence< T >::push_back ( CSequence< T > && other)
inline

Appends all elements from another sequence at the end of this sequence. This version moves elements instead of copying.

Definition at line 349 of file sequence.h.

◆ push_back() [5/5]

template<class T>
void swift::misc::CSequence< T >::push_back ( T && value)
inline

Move-appends an element at the end of the sequence.

Definition at line 339 of file sequence.h.

◆ push_backMaxElements()

template<class T>
void swift::misc::CSequence< T >::push_backMaxElements ( const T & value,
int maxElements )
inline

Insert as last element by keep maxElements.

Definition at line 328 of file sequence.h.

◆ push_front() [1/3]

template<class T>
void swift::misc::CSequence< T >::push_front ( const CSequence< T > & other)
inline

Inserts all elements from another sequence at the beginning of this sequence.

Definition at line 314 of file sequence.h.

◆ push_front() [2/3]

template<class T>
void swift::misc::CSequence< T >::push_front ( const T & value)
inline

Insert as first element.

Definition at line 311 of file sequence.h.

◆ push_front() [3/3]

template<class T>
void swift::misc::CSequence< T >::push_front ( T && value)
inline

Move-insert as first element.

Definition at line 342 of file sequence.h.

◆ push_frontMaxElements()

template<class T>
void swift::misc::CSequence< T >::push_frontMaxElements ( const T & value,
int maxElements )
inline

Insert as first element by keep maxElements.

Definition at line 317 of file sequence.h.

◆ rbegin() [1/2]

template<class T>
reverse_iterator swift::misc::CSequence< T >::rbegin ( )
inline

Returns iterator at the beginning of the reversed sequence.

Definition at line 181 of file sequence.h.

◆ rbegin() [2/2]

template<class T>
const_reverse_iterator swift::misc::CSequence< T >::rbegin ( ) const
inline

Returns const iterator at the beginning of the reversed sequence.

Definition at line 184 of file sequence.h.

◆ remove()

template<class T>
int swift::misc::CSequence< T >::remove ( const T & object)
inline

Remove all elements equal to the given object, if it is contained.

Returns
The number of elements removed.

Definition at line 447 of file sequence.h.

◆ removeIf() [1/2]

template<class T>
template<class K0, class V0, class... KeysValues>
int swift::misc::CSequence< T >::removeIf ( K0 k0,
V0 v0,
KeysValues... keysValues )
inline

Remove elements matching some particular key/value pair(s).

Parameters
k0A pointer to a member function of T.
v0A value to compare against the value returned by k0.
keysValuesZero or more additional pairs of { pointer to member function of T, value to compare it against }.
Returns
The number of elements removed.

Definition at line 468 of file sequence.h.

◆ removeIf() [2/2]

template<class T>
template<class Predicate>
int swift::misc::CSequence< T >::removeIf ( Predicate p)
inline

Remove elements for which a given predicate returns true.

Returns
The number of elements removed.

Definition at line 458 of file sequence.h.

◆ removeIfIn()

template<class T>
int swift::misc::CSequence< T >::removeIfIn ( const CSequence< T > & other)
inline

Remove all elements if they are in other.

Returns
The number of elements removed.

Definition at line 476 of file sequence.h.

◆ removeIfInSubset()

template<class T>
void swift::misc::CSequence< T >::removeIfInSubset ( const CSequence< T > & other)
inline

Remove all elements if they are in other.

Precondition
All elements of other must be present in the same order in this.

Definition at line 483 of file sequence.h.

◆ rend() [1/2]

template<class T>
reverse_iterator swift::misc::CSequence< T >::rend ( )
inline

Returns iterator at the end of the reversed sequence.

Definition at line 190 of file sequence.h.

◆ rend() [2/2]

template<class T>
const_reverse_iterator swift::misc::CSequence< T >::rend ( ) const
inline

Returns const iterator at the end of the reversed sequence.

Definition at line 193 of file sequence.h.

◆ replace()

template<class T>
int swift::misc::CSequence< T >::replace ( const T & original,
const T & replacement )
inline

Replace elements matching the given element with a replacement.

Returns
The number of elements replaced.

Definition at line 490 of file sequence.h.

◆ replaceIf() [1/2]

template<class T>
template<class K1, class V1>
int swift::misc::CSequence< T >::replaceIf ( K1 key1,
V1 value1,
const T & replacement )
inline

Replace elements matching a particular key/value pair.

Parameters
key1A pointer to a member function of T.
value1Will be compared to the return value of key1.
replacementAll matching elements will be replaced by copies of this one.
Returns
The number of elements replaced.

Definition at line 527 of file sequence.h.

◆ replaceIf() [2/2]

template<class T>
template<class Predicate>
int swift::misc::CSequence< T >::replaceIf ( Predicate p,
const T & replacement )
inline

Replace elements for which a given predicate returns true.

Returns
The number of elements replaced.

Definition at line 507 of file sequence.h.

◆ replaceOrAdd() [1/4]

template<class T>
void swift::misc::CSequence< T >::replaceOrAdd ( const CSequence< T > & replacements)
inline

Replace or add given elements.

Definition at line 549 of file sequence.h.

◆ replaceOrAdd() [2/4]

template<class T>
void swift::misc::CSequence< T >::replaceOrAdd ( const T & original,
const T & replacement )
inline

Replace elements matching the given element. If there is no match, push the new element on the end.

Definition at line 533 of file sequence.h.

◆ replaceOrAdd() [3/4]

template<class T>
void swift::misc::CSequence< T >::replaceOrAdd ( const T & replacement)
inline

Replace elements matching the given element. If there is no match, push the new element on the end.

Definition at line 546 of file sequence.h.

◆ replaceOrAdd() [4/4]

template<class T>
template<class K1, class V1>
void swift::misc::CSequence< T >::replaceOrAdd ( K1 key1,
V1 value1,
const T & replacement )
inline

Replace elements matching a particular key/value pair. If there is no match, push the new element on the end.

Parameters
key1A pointer to a member function of T.
value1Will be compared to the return value of key1.
replacementAll matching elements will be replaced by copies of this one, or a copy will be added.

Definition at line 562 of file sequence.h.

◆ reverse()

template<class T>
void swift::misc::CSequence< T >::reverse ( )
inline

In-place reverse.

Definition at line 575 of file sequence.h.

◆ reversed()

template<class T>
Q_REQUIRED_RESULT CSequence swift::misc::CSequence< T >::reversed ( ) const
inline

Reversed order.

Definition at line 578 of file sequence.h.

◆ separate()

template<class T>
template<class Predicate>
auto swift::misc::CSequence< T >::separate ( Predicate p) const->QMap< decltype(p(std::declval< T >())), CSequence >
inline

Split up the sequence into subsequences for which the given predicate returns the same value.

Definition at line 680 of file sequence.h.

◆ separateBy()

template<class T>
template<class Key>
auto swift::misc::CSequence< T >::separateBy ( Key k) const->QMap< decltype(std::invoke(k, std::declval< T >())), CSequence >
inline

Split up the sequence into subsequences of elements having the same value for the given key.

Definition at line 696 of file sequence.h.

◆ size()

template<class T>
size_type swift::misc::CSequence< T >::size ( ) const
inline

Returns number of elements in the sequence.

Definition at line 273 of file sequence.h.

◆ sizeInt()

template<class T>
int swift::misc::CSequence< T >::sizeInt ( ) const
inline

Avoid compiler warnings when using with int.

Definition at line 276 of file sequence.h.

◆ sizeString()

template<class T>
QString swift::misc::CSequence< T >::sizeString ( ) const
inline

Convenience function.

Definition at line 279 of file sequence.h.

◆ sort()

template<class T>
template<class Predicate>
void swift::misc::CSequence< T >::sort ( Predicate p)
inline

In-place sort by a given comparator predicate.

Definition at line 587 of file sequence.h.

◆ sortBy()

template<class T>
template<class K1, class... Keys>
void swift::misc::CSequence< T >::sortBy ( K1 key1,
Keys... keys )
inline

In-place sort by some particular key(s).

Parameters
key1A pointer to a member function of T.
keysZero or more additional pointers to member functions of T.

Definition at line 603 of file sequence.h.

◆ sorted()

template<class T>
template<class Predicate>
Q_REQUIRED_RESULT CSequence swift::misc::CSequence< T >::sorted ( Predicate p) const
inline

Return a copy sorted by a given comparator predicate.

Definition at line 610 of file sequence.h.

◆ sortedBy()

template<class T>
template<class K1, class... Keys>
CSequence swift::misc::CSequence< T >::sortedBy ( K1 key1,
Keys... keys ) const
inline

Return a copy sorted by some particular key(s).

Parameters
key1A pointer to a member function of T.
keysZero or more additional pointers to member functions of T.

Definition at line 621 of file sequence.h.

◆ swap()

template<class T>
void swift::misc::CSequence< T >::swap ( CSequence< T > & other)
inlinenoexcept

Swap this sequence with another.

Definition at line 199 of file sequence.h.

◆ toVector() [1/2]

template<class T>
QVector< T > swift::misc::CSequence< T >::toVector ( ) &&
inline

Copy of internal vector.

Definition at line 160 of file sequence.h.

◆ toVector() [2/2]

template<class T>
QVector< T > swift::misc::CSequence< T >::toVector ( ) const &
inline

Copy of internal vector.

Definition at line 157 of file sequence.h.

◆ truncate()

template<class T>
void swift::misc::CSequence< T >::truncate ( size_type maxSize)
inline

Changes the size of the sequence, if it is bigger than the given size.

Definition at line 291 of file sequence.h.

◆ unmarshalFromDataStream()

template<class T>
void swift::misc::CSequence< T >::unmarshalFromDataStream ( QDataStream & stream)
inline

Unmarshal a value from a QDataStream.

Definition at line 726 of file sequence.h.

◆ unorderedEqualsByKeys()

template<class T>
template<class U, class Key0, class... Keys>
bool swift::misc::CSequence< T >::unorderedEqualsByKeys ( const U & other,
Key0 k0,
Keys... keys ) const
inline

Return true if this container equals another container, considering only the given element members. Order of elements is not considered; this is implemented using a transient sort, so don't overuse.

Definition at line 665 of file sequence.h.

◆ operator!=

template<class T>
bool operator!= ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Not equals operator.

Definition at line 708 of file sequence.h.

◆ operator<

template<class T>
bool operator< ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Less than operator.

Definition at line 711 of file sequence.h.

◆ operator<=

template<class T>
bool operator<= ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Less or equal than operator.

Definition at line 717 of file sequence.h.

◆ operator==

template<class T>
bool operator== ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Equals operator.

Definition at line 705 of file sequence.h.

◆ operator>

template<class T>
bool operator> ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Greater than operator.

Definition at line 714 of file sequence.h.

◆ operator>=

template<class T>
bool operator>= ( const CSequence< T > & a,
const CSequence< T > & b )
friend

Greater or equal operator.

Definition at line 720 of file sequence.h.


The documentation for this class was generated from the following file: