本文整理汇总了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++;
}
示例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);
}
示例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());
}
示例4: pop_front
inline void PackedDeque::pop_front() {
begin_idx++;
if (begin_idx == vec.size()) {
begin_idx = 0;
}
filled--;
contract();
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
}
示例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;
}
}
示例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);
}