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


C++ array_view::begin方法代码示例

本文整理汇总了C++中array_view::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ array_view::begin方法的具体用法?C++ array_view::begin怎么用?C++ array_view::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在array_view的用法示例。


在下文中一共展示了array_view::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: key_qvalue_pairs

inline std::string key_qvalue_pairs(array_view<kv_pair> pairs)
{
    std::string buffer;
    // Ensure string is large enough for our use, to avoid useless internal resize
    size_t maj = std::accumulate(pairs.begin(), pairs.end(), size_t{0},
        [](size_t acc, kv_pair p){return acc + p.key.size()+p.value.size()+8;});
    // reserve some space for 8 quoted chars inside value
    // if there is more string is on it's own and will spend slightly more time
    buffer.reserve(maj+8);
    return key_qvalue_pairs(buffer, pairs);
}
开发者ID:pykoder,项目名称:redemption,代码行数:11,代码来源:key_qvalue_pairs.hpp

示例2: equal

    bool operator == (const array_view & other) const noexcept
    {
        // Pointers to same memory (or both null).
        if (data() == other.data())
        {
            return true;
        }

        // Different sizes, whole sequence can't be identical.
        if (size() != other.size())
        {
            return false;
        }

        // Compare each element:
        return std::equal(begin(), end(), other.begin());
    }
开发者ID:glampert,项目名称:array_view,代码行数:17,代码来源:array_view.hpp

示例3: make_bitmap_level

static bitmap make_bitmap_level (const array_view<std::uint8_t>& data, const array_view<bitmap::value_type>& colormap, int level, const wal_header& header) {

    auto div1 = 1 << level;
    
    auto width = header.width / div1 ;
    auto height = header.height / div1 ;
    
    auto buffer = std::make_unique<bitmap::value_type[]> (width*height);
    
    auto data_view = array_view<std::uint8_t> {
        data.begin () + header.offset [level],
        data.begin () + header.offset [level] + width*height
    };
    
    for (auto i = 0; i < width*height; ++i) {
        buffer [i] = colormap [data_view [i]];
    }
    
    return bitmap (std::move (buffer), width, height);
};
开发者ID:Coldberg,项目名称:q2bsp_experiment,代码行数:20,代码来源:wal.cpp

示例4: mdarray

 explicit mdarray(const array_view<ATYPE> &view):
     _imap(map_utils<map_type>::create(view.template shape<shape_t>())),
     _data(container_utils<storage_type>::create(view.size()))
 {
     std::copy(view.begin(),view.end(),_data.begin());
 }
开发者ID:pni-libraries,项目名称:libpnicore,代码行数:6,代码来源:mdarray.hpp

示例5: pcx_decode

bitmap xtk::pcx_decode (const array_view<std::uint8_t>& data) {

    static_assert (sizeof (pcx_header) == 128, "Header length incorrect");

    const auto& header = *(const pcx_header*)data.data();
    
    auto width  = header.xmax - header.xmin + 1;
    auto height = header.ymax - header.ymin + 1;
    
    __xtk_assert (std::invalid_argument, header.vendor_id == 0x0A && header.version >= 5);
    
    xtk::Debug::log(
        "load_pcx: \n"
        "\tversion = %d\n"
        "\tbits_per_pixel = %d\n"
        "\tcolor_planes = %d\n"
        "\twidth = %u\n"
        "\theight = %u\n"
        ,
        header.version,
        header.bits_per_pixel,
        header.color_planes,
        width,
        height
    );
    
    __xtk_assert(std::invalid_argument,
        header.bits_per_pixel == 8 &&
        header.color_planes == 0);
    
    auto buffer = std::make_unique<bitmap::value_type []> (width*height);
    
    auto stream = array_view<const std::uint8_t> {data.begin() + sizeof (header), data.end()};

    auto next_pixel = 0u;
    auto next_sbyte = stream.begin ();
        
    auto palette = xtk::array_view<glm::tvec3<std::uint8_t>> {
        (const glm::tvec3<std::uint8_t> *)data.end () - 256,
        (const glm::tvec3<std::uint8_t> *)data.end ()
    };
    
    while (next_sbyte < stream.end ()) {
        auto rle = *next_sbyte;
        
        ++next_sbyte;
        
        if (rle >= 0xc0) {
            rle &= 0x3f;
            auto pixel = bitmap::value_type (palette [*next_sbyte], 255);
            ++next_sbyte;
            for (auto j = 0; j < rle; ++j) {
                buffer [next_pixel] = pixel;
                ++next_pixel;
                __xtk_assert (std::overflow_error, next_pixel <= width*height);
            }
        }
        else {
            buffer [next_pixel] = bitmap::value_type (palette [rle], 255);
            ++next_pixel;
            __xtk_assert (std::overflow_error, next_pixel <= width*height);
        }
        
        if (next_pixel >= width*height) {
            break;
        }
    }
    
    __xtk_assert (std::invalid_argument, next_pixel == width*height);
    
    return bitmap (std::move (buffer), width, height);
}
开发者ID:Coldberg,项目名称:q2bsp_experiment,代码行数:72,代码来源:pcx.cpp


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