23 #ifndef ICL_CORE_Z_BUFFER_H_INCLUDED 24 #define ICL_CORE_Z_BUFFER_H_INCLUDED 28 #include <boost/optional.hpp> 42 template <
typename T,
typename TCompare = std::less<T> >
47 typedef std::vector<boost::optional<T> >
Buffer;
56 explicit ZBuffer(
const std::size_t
size,
const TCompare& cmp = TCompare())
68 bool update(
const std::size_t pos,
const T& value)
86 boost::optional<T>
at(
const std::size_t pos)
const {
return m_buffer[pos]; }
Buffer::size_type size_type
Shorthand to vector size type.
const size_type size() const
Returns the buffer size.
std::vector< boost::optional< T > > Buffer
The type of the internal buffer.
Buffer m_buffer
The actual buffer (a vector with optionally empty elements).
boost::optional< T > at(const std::size_t pos) const
Read-only access to a specific buffer element.
const Buffer & buffer() const
Read-only access to the buffer.
void reset()
Empties the Z buffer.
bool update(const std::size_t pos, const T &value)
TCompare m_cmp
The comparison operator.
ZBuffer(const std::size_t size, const TCompare &cmp=TCompare())
boost::optional< T > operator[](const std::size_t pos) const
Read-only access to a specific buffer element.