Switch to unified view

a/upqo/ohpool.cpp b/upqo/ohpool.cpp
...
...
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
17
18
#include "ohpool.h"
18
#include "ohpool.h"
19
19
20
#ifndef UNORDERED_SET_INCLUDE
20
#include <unordered_set>
21
#define UNORDERED_SET_INCLUDE <unordered_set>
22
#endif
23
24
#include UNORDERED_SET_INCLUDE
25
#include <string>
21
#include <string>
26
#include <vector>
22
#include <vector>
27
23
28
#include <QDebug>
24
#include <QDebug>
29
25
...
...
32
28
33
using namespace std;
29
using namespace std;
34
30
35
template <class T>
31
template <class T>
36
bool ohupdmetapool(const vector<int>& nids, int curid,
32
bool ohupdmetapool(const vector<int>& nids, int curid,
37
                   STD_UNORDERED_MAP<int, UPnPClient::UPnPDirObject>& metapool,
33
                   std::unordered_map<int, UPnPClient::UPnPDirObject>& metapool,
38
                   T srv)
34
                   T srv)
39
{
35
{
40
    // Clean up metapool entries not in ids. We build a set with
36
    // Clean up metapool entries not in ids. We build a set with
41
    // the new ids list first. For small lists it does not matter,
37
    // the new ids list first. For small lists it does not matter,
42
    // for big ones, this will prevent what would otherwise be a
38
    // for big ones, this will prevent what would otherwise be a
43
    // linear search the repeated search to make this
39
    // linear search the repeated search to make this
44
    // quadratic. We're sort of O(n * log(n)) instead.
40
    // quadratic. We're sort of O(n * log(n)) instead.
45
    if (!metapool.empty() && !nids.empty()){
41
    if (!metapool.empty() && !nids.empty()){
46
        STD_UNORDERED_SET<int> tmpset(nids.begin(), nids.end());
42
        std::unordered_set<int> tmpset(nids.begin(), nids.end());
47
        for (STD_UNORDERED_MAP<int, UPnPClient::UPnPDirObject>::iterator it
43
        for (std::unordered_map<int, UPnPClient::UPnPDirObject>::iterator it
48
                 = metapool.begin(); it != metapool.end(); ) {
44
                 = metapool.begin(); it != metapool.end(); ) {
49
            if (tmpset.find(it->first) == tmpset.end()) {
45
            if (tmpset.find(it->first) == tmpset.end()) {
50
                it = metapool.erase(it);
46
                it = metapool.erase(it);
51
            } else {
47
            } else {
52
                it++;
48
                it++;
...
...
97
        i += j;
93
        i += j;
98
    }
94
    }
99
95
100
#if 0
96
#if 0
101
    qDebug() << "Metadata Pool now: ";
97
    qDebug() << "Metadata Pool now: ";
102
    for (STD_UNORDERED_MAP<int, UPnPClient::UPnPDirObject>::const_iterator it
98
    for (std::unordered_map<int, UPnPClient::UPnPDirObject>::const_iterator it
103
             =  metapool.begin(); it != metapool.end(); it++) {
99
             =  metapool.begin(); it != metapool.end(); it++) {
104
        qDebug() << "Id " << it->first << "->\n" << it->second.dump().c_str();
100
        qDebug() << "Id " << it->first << "->\n" << it->second.dump().c_str();
105
    }
101
    }
106
#endif
102
#endif
107
    return true;
103
    return true;
108
}
104
}
109
105
110
template bool
106
template bool
111
ohupdmetapool<UPnPClient::OHPLH>
107
ohupdmetapool<UPnPClient::OHPLH>
112
(const vector<int>&, int, 
108
(const vector<int>&, int, 
113
 STD_UNORDERED_MAP<int, UPnPClient::UPnPDirObject>& ,
109
 std::unordered_map<int, UPnPClient::UPnPDirObject>& ,
114
 UPnPClient::OHPLH);
110
 UPnPClient::OHPLH);
115
template bool
111
template bool
116
ohupdmetapool<UPnPClient::OHRDH>
112
ohupdmetapool<UPnPClient::OHRDH>
117
(const vector<int>&, int, 
113
(const vector<int>&, int, 
118
 STD_UNORDERED_MAP<int, UPnPClient::UPnPDirObject>& ,
114
 std::unordered_map<int, UPnPClient::UPnPDirObject>& ,
119
 UPnPClient::OHRDH);
115
 UPnPClient::OHRDH);