File size: 1,830 Bytes
7fc5a59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef OPENPOSE_UTILITIES_STANDARD_HPP
#define OPENPOSE_UTILITIES_STANDARD_HPP

#include <openpose/core/common.hpp>

namespace op
{
    template <typename T>
    bool vectorsAreEqual(const std::vector<T>& vectorA, const std::vector<T>& vectorB)
    {
        try
        {
            if (vectorA.size() != vectorB.size())
                return false;
            else
            {
                for (auto i = 0u ; i < vectorA.size() ; i++)
                    if (vectorA[i] != vectorB[i])
                        return false;
                return true;
            }
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
            return false;
        }
    }

    /**
     * std::vector<T> concatenator.
     * Auxiliary function that concatenate std::vectors of any class type T.
     * It assumes basic copy (ideal for smart pointers, pointers, etc.), so note that the copy still shares the same
     * internal data. It will not work for element that cannot be copied.
     * @param vectorA First std::shared_ptr<T> element to be concatenated.
     * @param vectorB Second std::shared_ptr<T> element to be concatenated.
     * @return Concatenated std::vector<T> of both vectorA and vectorB.
     */
    template <typename T>
    std::vector<T> mergeVectors(const std::vector<T>& vectorA, const std::vector<T>& vectorB)
    {
        try
        {
            auto vectorToReturn(vectorA);
            for (auto& tElement : vectorB)
                vectorToReturn.emplace_back(tElement);
            return vectorToReturn;
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
            return std::vector<T>{};
        }
    }
}

#endif // OPENPOSE_UTILITIES_STANDARD_HPP