14#ifndef CPL_MASK_H_INCLUDED
15#define CPL_MASK_H_INCLUDED
30inline GUInt32 *CPLMaskCreate(std::size_t size,
bool default_value)
32 std::size_t nBytes = (size + 31) / 8;
38 std::memset(buf, default_value ? 0xff : 0, nBytes);
39 return static_cast<GUInt32 *
>(buf);
49inline bool CPLMaskGet(
GUInt32 *mask, std::size_t i)
51 return mask[i >> 5] & (0x01 << (i & 0x1f));
60inline void CPLMaskClear(
GUInt32 *mask, std::size_t i)
62 mask[i >> 5] &= ~(0x01 << (i & 0x1f));
71inline void CPLMaskClearAll(
GUInt32 *mask, std::size_t size)
73 auto nBytes = (size + 31) / 8;
74 std::memset(mask, 0, nBytes);
83inline void CPLMaskSet(
GUInt32 *mask, std::size_t i)
85 mask[i >> 5] |= (0x01 << (i & 0x1f));
94inline void CPLMaskSetAll(
GUInt32 *mask, std::size_t size)
96 auto nBytes = (size + 31) / 8;
97 std::memset(mask, 0xff, nBytes);
107inline void CPLMaskMerge(
GUInt32 *mask1,
GUInt32 *mask2, std::size_t n)
109 std::size_t nBytes = (n + 31) / 8;
110 std::size_t nIter = nBytes / 4;
111 for (std::size_t i = 0; i < nIter; i++)
113 mask1[i] |= mask2[i];
Core portability definitions for CPL.
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:167
#define VSI_MALLOC_VERBOSE(size)
VSI_MALLOC_VERBOSE.
Definition cpl_vsi.h:338