Qx v0.5.7
Qt Extensions Library
Loading...
Searching...
No Matches
qx-list.h
1#ifndef QX_LIST_H
2#define QX_LIST_H
3
4// Qt Includes
5#include <QList>
6
7// Extra-component Includes
9
10namespace Qx
11{
12
13class List
14{
15//-Class Functions----------------------------------------------------------------------------------------------
16public:
17 template<typename T>
18 static QList<T>* subListThatContains(T element, QList<QList<T>*> listOfLists)
19 {
20 // Returns pointer to the first list that contains "element". Returns nullptr if none
21 for(QList<T>* currentList : listOfLists)
22 if(currentList->contains(element))
23 return currentList;
24
25 return nullptr;
26 }
27
28 template<typename T> static QList<T> difference(QList<T>& listA, QList<T>& listB)
29 {
30 // Difference list to fill
31 QList<T> differenceList;
32
33 for(T entry : listA)
34 {
35 if(!listB.contains(entry))
36 differenceList << entry;
37 }
38 return differenceList;
39 }
40
41 template<typename T, typename F>
44 {
45 QList<T*> toList;
46 toList.reserve(fromList.size());
47 for(F* item : qAsConst(fromList))
48 toList.append(static_cast<T*>(item));
49
50 return toList;
51 }
52
53};
54
55}
56
57#endif // QX_LIST_H
The List class is a collection of static functions pertaining to lists.
Definition qx-list.h:14
static QList< T > * subListThatContains(T element, QList< QList< T > * > listOfLists)
Definition qx-list.h:18
QList< T * > static_pointer_cast(const QList< F * > fromList)
Definition qx-list.h:43
static QList< T > difference(QList< T > &listA, QList< T > &listB)
Definition qx-list.h:28
Specifies that a type can be statically cast to another type.
Definition qx-concepts.h:509
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
void append(QList::parameter_type value)
bool contains(const AT &value) const const
void reserve(qsizetype size)
qsizetype size() const const
The qx-concepts header file provides a library of general purpose concepts as an extension of the sta...