proxygen
folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type > Class Template Reference

#include <Padded.h>

Classes

union  Storage
 

Public Types

typedef T value_type
 

Public Member Functions

Tdata ()
 
const Tdata () const
 
bool operator== (const Node &other) const
 
bool operator!= (const Node &other) const
 

Static Public Member Functions

static constexpr size_t nodeCount (size_t n)
 
static constexpr size_t paddedByteSize (size_t n)
 
static constexpr size_t paddingBytes (size_t n)
 
static constexpr size_t unpaddedByteSize (size_t n)
 

Static Public Attributes

static constexpr size_t kNodeSize = NS
 
static constexpr size_t kElementCount = NS / sizeof(T)
 
static constexpr size_t kPaddingBytes = NS % sizeof(T)
 

Private Attributes

union folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::Storage storage_
 

Detailed Description

template<class T, size_t NS>
class folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >

Definition at line 75 of file Padded.h.

Member Typedef Documentation

template<class T , size_t NS>
typedef T folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::value_type

Definition at line 77 of file Padded.h.

Member Function Documentation

template<class T , size_t NS>
T* folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::data ( )
inline

Definition at line 82 of file Padded.h.

82  {
83  return storage_.data;
84  }
union folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::Storage storage_
template<class T , size_t NS>
const T* folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::data ( ) const
inline

Definition at line 85 of file Padded.h.

85  {
86  return storage_.data;
87  }
union folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::Storage storage_
template<class T , size_t NS>
static constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::nodeCount ( size_t  n)
inlinestatic

Return the number of nodes needed to represent n values. Rounds up.

Definition at line 99 of file Padded.h.

99  {
100  return (n + kElementCount - 1) / kElementCount;
101  }
template<class T , size_t NS>
bool folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::operator!= ( const Node< T, NS, typename detail::NodeValid< T, NS >::type > &  other) const
inline

Definition at line 92 of file Padded.h.

92  {
93  return !(*this == other);
94  }
template<class T , size_t NS>
bool folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::operator== ( const Node< T, NS, typename detail::NodeValid< T, NS >::type > &  other) const
inline

Definition at line 89 of file Padded.h.

References folly::data(), and folly::T.

89  {
90  return memcmp(data(), other.data(), sizeof(T) * kElementCount) == 0;
91  }
folly::std T
template<class T , size_t NS>
static constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::paddedByteSize ( size_t  n)
inlinestatic

Return the total byte size needed to represent n values, rounded up to the nearest full node.

Definition at line 107 of file Padded.h.

107  {
108  return nodeCount(n) * NS;
109  }
template<class T , size_t NS>
static constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::paddingBytes ( size_t  n)
inlinestatic

Return the number of bytes used for padding n values. Note that, even if n is a multiple of kElementCount, this may return non-zero if kPaddingBytes != 0, as the padding at the end of the last node is not included in the result.

Definition at line 117 of file Padded.h.

References folly::T.

117  {
118  return (
119  n ? (kPaddingBytes +
120  (kElementCount - 1 - (n - 1) % kElementCount) * sizeof(T))
121  : 0);
122  }
folly::std T
template<class T , size_t NS>
static constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::unpaddedByteSize ( size_t  n)
inlinestatic

Return the minimum byte size needed to represent n values. Does not round up. Even if n is a multiple of kElementCount, this may be different from paddedByteSize() if kPaddingBytes != 0, as the padding at the end of the last node is not included in the result. Note that the calculation below works for n=0 correctly (returns 0).

Definition at line 131 of file Padded.h.

131  {
132  return paddedByteSize(n) - paddingBytes(n);
133  }

Member Data Documentation

template<class T , size_t NS>
constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::kElementCount = NS / sizeof(T)
static

Definition at line 79 of file Padded.h.

template<class T , size_t NS>
constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::kNodeSize = NS
static

Definition at line 78 of file Padded.h.

template<class T , size_t NS>
constexpr size_t folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::kPaddingBytes = NS % sizeof(T)
static

Definition at line 80 of file Padded.h.

template<class T , size_t NS>
union folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::Storage folly::padded::Node< T, NS, typename detail::NodeValid< T, NS >::type >::storage_
private

The documentation for this class was generated from the following file: