当前位置: 首页>>代码示例>>C++>>正文


C++ Alloc::allocate方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:yuchenguangfd,项目名称:Arena,代码行数:9,代码来源:P2502.cpp

示例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);
         }
     }
 }
开发者ID:yuchenguangfd,项目名称:Arena,代码行数:10,代码来源:P3624.cpp

示例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;
}
开发者ID:darcyg,项目名称:vapoursynth-plugins,代码行数:39,代码来源:resize.cpp

示例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); 
}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:31,代码来源:RecordSerializer.cpp

示例5: allocate

 static pointer allocate(Alloc& a, size_type n)
 {
     return a.allocate(n);
 }
开发者ID:karimcambridge,项目名称:SAMPAC,代码行数:4,代码来源:allocator_helpers.hpp

示例6: initer

 initer()
   : a()
   , success(false)
   , m_t(nullptr) {
   m_t = a.allocate(1);
 }
开发者ID:cbeck88,项目名称:strict-variant,代码行数:6,代码来源:alloc_wrapper.hpp

示例7:

 pointer allocator_traits<Alloc>::allocate(Alloc& a, size_type n) {
   return a.allocate(n);
 }
开发者ID:GdelP,项目名称:SimpleSTL,代码行数:3,代码来源:allocator_traits.impl.hpp


注:本文中的Alloc::allocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。