本文整理汇总了C++中std::deque::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::resize方法的具体用法?C++ deque::resize怎么用?C++ deque::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
reference operator[](size_type index)
{
if(index < pos_vec.size()) {
return pos_vec[index];
} else {
pos_vec.resize(index + 1, 0);
return pos_vec[index];
}
};
示例2: parse
static inline void parse(const bbb::json &json, std::deque<type, alloc> &vec) {
if(!json.is_array()) {
detail::print_parse_error("bbb::json_utils::parse deque", skip_json_isnt_array);
return;
}
vec.resize(json.size());
for(std::size_t i = 0; i < json.size(); ++i) {
parse(json[i], vec[i]);
}
}
示例3: unpack
inline void unpack( Stream& s, std::deque<T>& value ) {
unsigned_int size; unpack( s, size );
FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE );
value.resize(size.value);
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::unpack( s, *itr );
++itr;
}
}
示例4: push
/**
* Push an item into the queue.
*
* @param value The item to push into the queue.
* @param num Number to describe ordering for the items.
* It must increase monotonically.
*/
void push(T value, size_type num) {
std::lock_guard<std::mutex> lock(m_mutex);
num -= m_offset;
if (m_queue.size() <= num + 1) {
m_queue.resize(num + 2);
}
m_queue[num] = std::move(value);
m_data_available.notify_one();
}
示例5: load
//! Loading for std::deque
template <class Archive, class T, class A> inline
void load( Archive & ar, std::deque<T, A> & deque )
{
size_t size;
ar( make_size_tag( size ) );
deque.resize( size );
for( auto & i : deque )
ar( i );
}
示例6: CEREAL_LOAD_FUNCTION_NAME
//! Loading for std::deque
template <class Archive, class T, class A> inline
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::deque<T, A> & deque )
{
size_type size;
ar( make_size_tag( size ) );
deque.resize( static_cast<size_t>( size ) );
for( auto & i : deque )
ar( i );
}
示例7: addpollfd
void addpollfd(int fd, short events, FDTYPE type, std::string name) {
if(fdinfos.size() <= (size_t) fd) fdinfos.resize(fd + 1);
if(fdinfos[fd].type != FDTYPE::NONE) {
fprintf(stderr, "Attempt to add duplicate fd to poll array detected, ignoring: fd: %d\n", fd);
return;
}
fdinfos[fd].type = type;
fdinfos[fd].pollfd_offset = pollfds.size();
fdinfos[fd].name = std::move(name);
pollfds.push_back({ fd, events, 0 });
}
示例8: RRTstar_planning
void RRTstar_planning(){
ROS_INFO("RRT star planning");
ob::StateSpacePtr space(new ob::RealVectorStateSpace(2));
space->as<ob::RealVectorStateSpace>()->setBounds(minX(local_map->info), maxX(local_map->info));
space->setLongestValidSegmentFraction(0.01/(maxX(local_map->info)-minX(local_map->info)));
ob::SpaceInformationPtr si(new ob::SpaceInformation(space));
si->setStateValidityChecker(ob::StateValidityCheckerPtr(new ValidityChecker(si)));
si->setup();
ob::ScopedState<> start(space);
start->as<ob::RealVectorStateSpace::StateType>()->values[0] = startState[0];
start->as<ob::RealVectorStateSpace::StateType>()->values[1] = startState[1];
ob::ScopedState<> goal(space);
goal->as<ob::RealVectorStateSpace::StateType>()->values[0] = goalState[0];
goal->as<ob::RealVectorStateSpace::StateType>()->values[1] = goalState[1];
ob::ProblemDefinitionPtr pdef(new ob::ProblemDefinition(si));
pdef->setStartAndGoalStates(start, goal);
pdef->setOptimizationObjective(ob::OptimizationObjectivePtr(new ClearanceObjective(si)));
og::RRTstar *plan_pt=new og::RRTstar(si);
plan_pt->setGoalBias(0.05);
plan_pt->setRange(1.0);
ob::PlannerPtr optimizingPlanner(plan_pt);
optimizingPlanner->setProblemDefinition(pdef);
optimizingPlanner->setup();
ob::PlannerStatus solved;
int it=0;
while(solved!=ompl::base::PlannerStatus::StatusType::EXACT_SOLUTION && it<100){
it++;
solved = optimizingPlanner->solve(1.0);
}
if(solved==ompl::base::PlannerStatus::StatusType::EXACT_SOLUTION){
std::vector< ob::State * > sol = boost::static_pointer_cast<og::PathGeometric>(pdef->getSolutionPath())->getStates();
current_path_raw.resize(sol.size());
std::transform(sol.begin(), sol.end(), current_path_raw.begin(), &obstateState);
/*std::cout << "Path length: " << pdef->getSolutionPath()->length() << std::endl;
std::cout << "Path cost: " << pdef->getSolutionPath()->cost(pdef->getOptimizationObjective()) << std::endl;
std::cout << "Path :" << std::endl;
for(std::deque<State<2>>::iterator it=current_path_raw.begin(),end=current_path_raw.end();it!=end;++it){
std::cout << (*it) << " -- ";
}
std::cout << std::endl;*/
planned=true;
}else{
ROS_INFO("Planning failed");
planned=false;
}
}
示例9: logic_error
pos& operator+= (int i)
{
if(i == 0)
throw std::logic_error("Cannot add zero to a pos class");
int index = abs(i) - 1;
int len = pos_vec.size();
if(index < len)
pos_vec[index] += Utility::sign(i);
else {
pos_vec.resize(index + 1, 0);
pos_vec[index] += Utility::sign(i);
}
return *this;
};
示例10: main
int main(int argc, char **argv) {
signal(SIGINT, handler);
while (1) {
std::string args;
args = readline();
if (args.length() < 1) break;
std::deque<std::string> tokens;
tokens = split(args, '|', tokens);
pids.resize(tokens.size());
std::deque<int *> ffd(tokens.size(), new int[2]);
for (int i = 0; i < tokens.size() - 1; ++i) {
pipe(ffd[i]);
}
for (int i = 0; i < tokens.size(); ++i) {
int id;
if ((id = fork()) > 0) {
pids[i] = id;
} else {
if (i != 0) {
//dup2(ffd[i - 1][1], ffd[i][0]);
dup2(ffd[i - 1][1], STDIN_FILENO);
close(ffd[i - 1][0]);
}
if (i != tokens.size() - 1) {
dup2(ffd[i][1], STDOUT_FILENO);
}
proceedCommand(tokens[i]);
close(ffd[i][1]);
close(ffd[i][0]);
}
if (id < 0) return 0;
}
for (int i = 0, j; i < tokens.size(); ++i) {
waitpid(pids[i], &j, 0);
}
for (int i = 0; i < tokens.size() - 1; ++i) {
close(ffd[i][0]);
close(ffd[i][1]);
}
pids.clear();
}
}
示例11: Rand
// 产生uRandNum个不相同的随机数,并添加到queRand末尾
void Rand(std::deque<unsigned int> &queRand, unsigned int uRandNum)
{
if (uRandNum <= 0)
{
return;
}
unsigned uSizeOld = queRand.size();
unsigned uSizeNew = uSizeOld + uRandNum;
queRand.resize(uSizeNew);
srand(unsigned(time(NULL)));
for(unsigned i = uSizeOld; i < uSizeNew; i++)
{
queRand[i] = i;
}
for(unsigned i = uSizeOld; i < uSizeNew; i++)
{
std::swap(queRand[i], queRand[rand() % uSizeNew]);
}
}
示例12: pop_values
void pop_values(int nbValues)
{
valueStack.resize(valueStack.size() - nbValues);
}
示例13: super
in_order(T_arg_list args = {})
: super(args)
{
parse(args, false);
inter_pkt_delays.resize(max_inter_pkt_delays);
}
示例14: resize_back
void resize_back(size_type new_size)
{
pos_vec.resize(new_size,0);
};
示例15: CorrectPairedReads
void CorrectPairedReads(AssemblyInfo &assembly_info, std::deque<Sequence> &contigs,
std::deque<ContigInfo> &contig_infos, const std::string &align_file, double mean, double sd, int max_mismatch, int min_match)
{
int read_length = assembly_info.read_length();
vector<vector<uint32_t> > read_counts(contigs.size());
deque<vector<Score> > scores_table(contigs.size());
deque<vector<short> > overlap(contigs.size());
#pragma omp parallel for
for (int64_t i = 0; i < (int64_t)contigs.size(); ++i)
{
scores_table[i].resize(contigs[i].size());
overlap[i].resize(contigs[i].size(), 0);
read_counts[i].resize(omp_get_max_threads(), 0);
}
FILE *falign = OpenFile(align_file, "rb");
deque<ShortSequence> &reads = assembly_info.reads;
int64_t buffer_size = (1 << 20) * omp_get_max_threads();
for (int64_t offset = 0; offset < (int64_t)reads.size(); offset += buffer_size)
{
int64_t size = min((int64_t)buffer_size, (int64_t)(reads.size() - offset));
vector<HashAlignerRecord> all_records(size);
ReadHashAlignerRecordBlock(falign, all_records);
#pragma omp parallel for
for (int64_t i = 0; i < size; ++i)
{
HashAlignerRecord &record = all_records[i];
if (record.match_length != 0)
//if (record.match_length != 0 && record.query_length - record.match_length <= max_mismatch)
{
//#pragma omp atomic
++read_counts[record.ref_id][omp_get_thread_num()];
Sequence seq(reads[offset + i]);
bool is_reverse = record.is_reverse;
if (is_reverse)
{
record.ReverseComplement();
seq.ReverseComplement();
}
vector<Score> &scores = scores_table[record.ref_id];
int id = record.ref_id;
for (unsigned j = 0; j < seq.size(); ++j)
{
int index = record.ref_from + j;
#pragma omp atomic
scores[index][seq[j]]++;
if (min(int(j), int(seq.size() - j)) >= read_length/3)
{
#pragma omp atomic
overlap[id][index]++;
}
}
if (is_reverse)
{
record.ReverseComplement();
seq.ReverseComplement();
}
}
}
}
fclose(falign);
int64_t conformed_bases = 0;
// int64_t t1 = 0;
// int64_t t2 = 0;
// int64_t t3 = 0;
#pragma omp parallel for reduction(+: conformed_bases)
for (int64_t i = 0; i < (int64_t)contigs.size(); ++i)
{
for (unsigned j = 0; j < contigs[i].size(); ++j)
{
int aux[4];
for (int k = 0; k < 4; ++k)
aux[k] = scores_table[i][j][k];
sort(aux, aux + 4);
if (aux[3] > aux[2] * 4 && aux[3] >= min_match && overlap[i][j] >= 1)
{
++conformed_bases;
int best = -1;
for (int k = 0; k < 4; ++k)
{
if (scores_table[i][j][k] == aux[3])
best = k;
}
contigs[i][j] = best;
scores_table[i][j].best = best;
}
}
}
falign = OpenFile(align_file, "rb");
int64_t corrected_reads = 0;
int64_t corrected_bases = 0;
//.........这里部分代码省略.........