本文整理汇总了C++中Alloc::allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ Alloc::allocate方法的具体用法?C++ Alloc::allocate怎么用?C++ Alloc::allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alloc
的用法示例。
在下文中一共展示了Alloc::allocate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WeightedDirectedGraphAsAdjMatrix
WeightedDirectedGraphAsAdjMatrix(int numVertex, T initWeight = T()) :
mNumVertex(numVertex) {
int size = mNumVertex * mNumVertex;
Alloc alloc;
mData = alloc.allocate(size);
for (int i = 0; i < size; ++i) {
mData[i] = initWeight;
}
}
示例2: T
Array1D(int size, bool init = false, T initValue = T()) :
mSize(size) {
Alloc alloc;
mData = alloc.allocate(mSize);
if (init) {
for (int i = 0; i < mSize; ++i) {
alloc.construct(&mData[i], initValue);
}
}
}
示例3: get_context
ResizeContext Resize::get_context(Alloc &alloc, PixelType type) const
{
ResizeContext ctx{};
if (!m_skip_h && !m_skip_v) {
double xscale = (double)m_dst_width / (double)m_src_width;
double yscale = (double)m_dst_height / (double)m_src_height;
bool h_first = resize_h_first(xscale, yscale);
ctx.impl1 = h_first ? m_impl_h.get() : m_impl_v.get();
ctx.impl2 = h_first ? m_impl_v.get() : m_impl_h.get();
ctx.tmp_width = h_first ? m_dst_width : m_src_width;
ctx.tmp_height = h_first ? m_src_height : m_dst_height;
ctx.in_buffering1 = std::min(ctx.impl1->input_buffering(type), m_src_height);
ctx.in_buffering2 = std::min(ctx.impl2->input_buffering(type), ctx.tmp_height);
ctx.out_buffering1 = ctx.impl1->output_buffering(type);
ctx.out_buffering2 = ctx.impl2->output_buffering(type);
ctx.src_border_buf = alloc_line_buffer(alloc, ctx.in_buffering1, m_src_width, type);
ctx.dst_border_buf = alloc_line_buffer(alloc, ctx.out_buffering2, m_dst_width, type);
ctx.tmp_buf = alloc_line_buffer(alloc, ctx.out_buffering1 + ctx.in_buffering2 - 1, ctx.tmp_width, type);
ctx.tmp_data = alloc.allocate(std::max(ctx.impl1->tmp_size(type, ctx.tmp_width), ctx.impl2->tmp_size(type, m_dst_width)));
} else if (!(m_skip_h && m_skip_v)) {
ctx.impl1 = m_impl_h ? m_impl_h.get() : m_impl_v.get();
ctx.in_buffering1 = std::min(ctx.impl1->input_buffering(type), m_src_height);
ctx.out_buffering1 = ctx.impl1->output_buffering(type);
ctx.src_border_buf = alloc_line_buffer(alloc, ctx.in_buffering1, m_src_width, type);
ctx.dst_border_buf = alloc_line_buffer(alloc, ctx.out_buffering1, m_dst_width, type);
ctx.tmp_data = alloc.allocate(ctx.impl1->tmp_size(type, m_dst_width));
}
return ctx;
}
示例4: allocator
// variableLengthOffsetStart
// ^ _____________
// | | |
// |______________________||____________||______V___________________|
// int,date(long),float offsets strings/variable length
// |____________________________________|
// Fixed Length |
// V
// fixedSizedOffset
//
// offsets() creates a pair of arrays with offset at each index to its
// associated Attribute's offset in the returned serialized buffer
// It uses maxOffsetBuffer and lastOffsetOfWrittenBuffer as temporary
// holders to fill in the const members: fixedSizedOffset,
// variableLengthOffsetStart
//
RecordSerializer::RecordSerializer(srch2::instantsearch::Schema& schema,
Alloc& allocator) : allocator(allocator), schema(schema),
maxOffsetOfBuffer(0), lastOffsetOfWrittenBuffer(0),
offsets(initAttributeOffsetArray(schema, maxOffsetOfBuffer,
lastOffsetOfWrittenBuffer)),
fixedSizedOffset(maxOffsetOfBuffer),
variableLengthOffsetStart(lastOffsetOfWrittenBuffer) {
lastOffsetOfWrittenBuffer = fixedSizedOffset;
//rounds default size of the nearest allocation page size
maxOffsetOfBuffer = allocator.round(fixedSizedOffset +
DEFAULT_VARIBLE_ATTRIBUTE_LENGTH * (offsets.first.size()));
buffer = allocator.allocate(maxOffsetOfBuffer);
std::memset(buffer, 0x0, fixedSizedOffset);
}
示例5: allocate
static pointer allocate(Alloc& a, size_type n)
{
return a.allocate(n);
}
示例6: initer
initer()
: a()
, success(false)
, m_t(nullptr) {
m_t = a.allocate(1);
}
示例7:
pointer allocator_traits<Alloc>::allocate(Alloc& a, size_type n) {
return a.allocate(n);
}