15#ifndef CPL_MASK_H_INCLUDED
16#define CPL_MASK_H_INCLUDED
31inline GUInt32 *CPLMaskCreate(std::size_t size,
bool default_value)
33 std::size_t nBytes = (size + 31) / 8;
39 std::memset(buf, default_value ? 0xff : 0, nBytes);
40 return static_cast<GUInt32 *
>(buf);
50inline bool CPLMaskGet(
GUInt32 *mask, std::size_t i)
52 return mask[i >> 5] & (0x01 << (i & 0x1f));
61inline void CPLMaskClear(
GUInt32 *mask, std::size_t i)
63 mask[i >> 5] &= ~(0x01 << (i & 0x1f));
72inline void CPLMaskClearAll(
GUInt32 *mask, std::size_t size)
74 auto nBytes = (size + 31) / 8;
75 std::memset(mask, 0, nBytes);
84inline void CPLMaskSet(
GUInt32 *mask, std::size_t i)
86 mask[i >> 5] |= (0x01 << (i & 0x1f));
95inline void CPLMaskSetAll(
GUInt32 *mask, std::size_t size)
97 auto nBytes = (size + 31) / 8;
98 std::memset(mask, 0xff, nBytes);
108inline void CPLMaskMerge(
GUInt32 *mask1,
GUInt32 *mask2, std::size_t n)
110 std::size_t nBytes = (n + 31) / 8;
111 std::size_t nIter = nBytes / 4;
112 for (std::size_t i = 0; i < nIter; i++)
114 mask1[i] |= mask2[i];
Core portability definitions for CPL.
unsigned int GUInt32
Unsigned int32 type.
Definition: cpl_port.h:161
#define VSI_MALLOC_VERBOSE(size)
VSI_MALLOC_VERBOSE.
Definition: cpl_vsi.h:332