pointerContainer.hpp 1.1 KB
Newer Older
1 2
#ifndef OPENPOSE_UTILITIES_POINTER_CONTAINER_HPP
#define OPENPOSE_UTILITIES_POINTER_CONTAINER_HPP
G
gineshidalgo99 已提交
3 4 5 6 7 8 9 10 11

namespace op
{
    template<typename TPointerContainer>
    inline bool checkNoNullNorEmpty(const TPointerContainer& tPointerContainer)
    {
        return (tPointerContainer != nullptr && tPointerContainer->size() > 0);
    }

12
    template<typename TDatumsSP>
13
    class PointerContainerGreater
G
gineshidalgo99 已提交
14 15
    {
    public:
16
        bool operator() (const TDatumsSP& a, const TDatumsSP& b)
G
gineshidalgo99 已提交
17 18 19 20 21 22
        {
            if (!b || b->empty())
                return true;
            else if (!a || a->empty())
                return false;
            else
23
                return *(*a)[0] > *(*b)[0];
G
gineshidalgo99 已提交
24 25 26
        }
    };

27
    template<typename TDatumsSP>
28
    class PointerContainerLess
G
gineshidalgo99 已提交
29 30
    {
    public:
31
        bool operator() (const TDatumsSP& a, const TDatumsSP& b)
G
gineshidalgo99 已提交
32 33 34 35 36 37
        {
            if (!b || b->empty())
                return false;
            else if (!a || a->empty())
                return true;
            else
38
                return *(*a)[0] < *(*b)[0];
G
gineshidalgo99 已提交
39 40 41 42
        }
    };
}

43
#endif // OPENPOSE_UTILITIES_POINTER_CONTAINER_HPP