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


C++ PackedVector::size方法代码示例

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


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

示例1: append_front

inline void PackedDeque::append_front(const uint64_t& value) {
    if (filled == vec.size()) {
        size_t new_capacity = size_t(factor * vec.size()) + 1;
        PackedVector new_vec;
        new_vec.resize(new_capacity);
        
        new_vec.set(0, value);
        for (size_t i = 0; i < filled; i++) {
            new_vec.set(i + 1, get(i));
        }
        
        vec = std::move(new_vec);
        begin_idx = 0;
    }
    else {
        if (begin_idx == 0) {
            begin_idx = vec.size() - 1;
        }
        else {
            begin_idx--;
        }
        vec.set(begin_idx, value);
    }
    
    filled++;
}
开发者ID:glennhickey,项目名称:vg,代码行数:26,代码来源:packed_structs.hpp

示例2: append_back

inline void PackedDeque::append_back(const uint64_t& value) {
    // expand capacity if necessary
    if (filled == vec.size()) {
        size_t new_capacity = size_t(factor * vec.size()) + 1;
        reserve(new_capacity);
    }
    
    // update the pointer to the back
    filled++;
    
    // set the value
    vec.set(internal_index(filled - 1), value);
}
开发者ID:vgteam,项目名称:vg,代码行数:13,代码来源:packed_structs.hpp

示例3:

TEST_F(FidoVectorTest, makeSparse){
  EXPECT_EQ(3,pv.size());
  EXPECT_EQ(3,pv.numberEntries());
  PackedVector sparse = pv.makeSparse();
  EXPECT_EQ(6,sparse.size());
  EXPECT_EQ(6,sparse.numberEntries());
}
开发者ID:AndSi,项目名称:percolator,代码行数:7,代码来源:UnitTest_Percolator_Fido.cpp

示例4: pop_front

inline void PackedDeque::pop_front() {
    begin_idx++;
    if (begin_idx == vec.size()) {
        begin_idx = 0;
    }
    filled--;
    contract();
}
开发者ID:glennhickey,项目名称:vg,代码行数:8,代码来源:packed_structs.hpp

示例5: append_back

inline void PackedDeque::append_back(const uint64_t& value) {
    if (filled == vec.size()) {
        size_t new_capacity = size_t(factor * vec.size()) + 1;
        PackedVector new_vec;
        new_vec.resize(new_capacity);
        
        for (size_t i = 0; i < filled; i++) {
            new_vec.set(i, get(i));
        }
        new_vec.set(filled, value);
        
        vec = std::move(new_vec);
        begin_idx = 0;
        filled++;
    }
    else {
        filled++;
        vec.set(internal_index(filled - 1), value);
    }
}
开发者ID:glennhickey,项目名称:vg,代码行数:20,代码来源:packed_structs.hpp

示例6: append_front

inline void PackedDeque::append_front(const uint64_t& value) {
    // expand capacity if necessary
    if (filled == vec.size()) {
        size_t new_capacity = size_t(factor * vec.size()) + 1;
        reserve(new_capacity);
    }
    
    // update the pointer to the front
    if (begin_idx == 0) {
        begin_idx = vec.size() - 1;
    }
    else {
        begin_idx--;
    }
    // update the pointer to the back
    filled++;
    
    // set the value
    vec.set(internal_index(0), value);
}
开发者ID:vgteam,项目名称:vg,代码行数:20,代码来源:packed_structs.hpp

示例7: pop_front

inline void PackedDeque::pop_front() {
    // update the pointer to the beginning
    begin_idx++;
    if (begin_idx == vec.size()) {
        begin_idx = 0;
    }
    // update the pointer to the end
    filled--;
    
    // shrink if necessary
    contract();
}
开发者ID:vgteam,项目名称:vg,代码行数:12,代码来源:packed_structs.hpp

示例8: reserve

inline void PackedDeque::reserve(const size_t& future_size) {
    if (future_size > vec.size()) {
        PackedVector new_vec;
        new_vec.resize(future_size);
        
        for (size_t i = 0; i < filled; i++) {
            new_vec.set(i, get(i));
        }
        vec = std::move(new_vec);
        begin_idx = 0;
    }
}
开发者ID:vgteam,项目名称:vg,代码行数:12,代码来源:packed_structs.hpp

示例9: contract

inline void PackedDeque::contract() {
    size_t shrink_capacity = vec.size() / (factor * factor);
    if (filled <= shrink_capacity) {
        PackedVector new_vec;
        new_vec.resize(filled);
        for (size_t i = 0; i < filled; i++) {
            new_vec.set(i, get(i));
        }
        
        vec = std::move(new_vec);
        begin_idx = 0;
    }
}
开发者ID:glennhickey,项目名称:vg,代码行数:13,代码来源:packed_structs.hpp

示例10: internal_index

inline size_t PackedDeque::internal_index(const size_t& i) const {
    assert(i < filled);
    return i < vec.size() - begin_idx ? begin_idx + i : i - (vec.size() - begin_idx);
}
开发者ID:glennhickey,项目名称:vg,代码行数:4,代码来源:packed_structs.hpp


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