本文整理汇总了C++中typenamestd::vector类的典型用法代码示例。如果您正苦于以下问题:C++ vector类的具体用法?C++ vector怎么用?C++ vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: purge
void IdCollection<ESXRecordT>::merge()
{
for (typename std::vector<Record<ESXRecordT> >::iterator iter (mRecords.begin()); iter!=mRecords.end(); ++iter)
iter->merge();
purge();
}
开发者ID:charles-stafford,项目名称:openmw,代码行数:7,代码来源:idcollection.hpp
示例2: add
// adds a value, returning false if the given token is not
// "reasonable". A reasonable token is one not currently in use,
// and if any previously used tokens are available, it must be one
// of the previously used ones. If no previously used tokens are
// available, it must be the smallest unused token. You'll get
// good performance if you never choose a bad token and use the
// most recently dropped token.
bool add(token_type known_token, T const& value) {
if (free_.empty()) {
if (known_token == values_.size()) {
values_.push_back(value);
#ifndef NDEBUG
is_free_.push_back(false);
#endif
return true;
} else {
return false;
}
} else {
// If a replicand used add(), then it picked the token
// from the bock of its free list. So the replicant, the
// presumed caller of this function, searches in reverse
// order.
typename std::vector<token_t>::reverse_iterator p = std::find(free_.rbegin(), free_.rend(), known_token);
if (p == free_.rend()) {
return false;
}
if (values_.size() > known_token) {
free_.erase(p.base() - 1);
values_[known_token] = value;
rassert(is_free_[known_token]);
#ifndef NDEBUG
is_free_[known_token] = false;
#endif
return true;
} else {
return false;
}
}
}
开发者ID:AVGP,项目名称:rethinkdb,代码行数:42,代码来源:thick_list.hpp
示例3: correctKiKfEventHelper
void CorrectKiKf::correctKiKfEventHelper(std::vector<T>& wevector, double efixed,const std::string emodeStr)
{
double Ei,Ef;
float kioverkf;
typename std::vector<T>::iterator it;
for (it=wevector.begin(); it<wevector.end();)
{
if (emodeStr == "Direct") //Ei=Efixed
{
Ei = efixed;
Ef = Ei - it->tof();
} else //Ef=Efixed
{
Ef = efixed;
Ei = Ef + it->tof();
}
// if Ei or Ef is negative, delete the event
if ((Ei <= 0)||(Ef <= 0))
{
it=wevector.erase(it);
}
else
{
kioverkf = static_cast<float>(std::sqrt( Ei / Ef ));
it->m_weight*=kioverkf;
it->m_errorSquared*=kioverkf*kioverkf;
++it;
}
}
}
开发者ID:BigShows,项目名称:mantid,代码行数:30,代码来源:CorrectKiKf.cpp
示例4:
//
// BinaryTokenACS::output_ACS0
//
template<typename T> void BinaryTokenACS::output_ACS0
(std::ostream *out, std::vector<T> const &instructions)
{
typename std::vector<T>::const_iterator instr;
// 0
*out << 'A' << 'C' << 'S' << '\0';
write_ACS0_32(out, ObjectExpression::get_address_count());
// 8
for (instr = instructions.begin(); instr != instructions.end(); ++instr)
instr->writeACS0(out);
// directoryOffset
ObjectData::Script::Iterate(write_ACS0_script_counter, NULL);
write_ACS0_script_count(out);
// directoryOffset+4
ObjectData::Script::Iterate(write_ACS0_script, out);
// directoryOffset+4+(scriptCount*12)
ObjectData::String::Iterate(write_ACS0_string_counter, NULL);
write_ACS0_string_count(out);
// directoryOffset+4+(scriptCount*12)+4
ObjectData::String::Iterate(write_ACS0_string_offset, out);
// directoryOffset+4+(scriptCount*12)+4+(stringCount*4)
ObjectData::String::Iterate(write_ACS0_string, out);
}
开发者ID:DavidPH,项目名称:DH-acc,代码行数:33,代码来源:output.cpp
示例5: print
//Prints graph node's adjacency lists
void print() {
for(typename std::vector<node>::iterator it = nodeL.begin(); it != nodeL.end(); it ++) {
cout << "Node " << it->val << "'s adj list:\n";
it->print();
cout << endl;
}
}
开发者ID:Ganglians,项目名称:Practice,代码行数:8,代码来源:4_2.cpp
示例6: cancelAll
void cancelAll() {
assert(*_closed);
for (typename std::vector< Future<T> >::iterator it = this->_futures.begin();
it != this->_futures.end();
++it)
it->cancel();
}
开发者ID:dmerejkowsky,项目名称:libqi,代码行数:7,代码来源:futurebarrier.hpp
示例7:
int GenomicRegionCollection<T>::TotalWidth() const {
int wid = 0;
for (typename std::vector<T>::const_iterator i = m_grv->begin(); i != m_grv->end(); ++i)
// for (auto& i : *m_grv)
wid += i->Width();
return wid;
}
开发者ID:jwalabroad,项目名称:SnowTools,代码行数:7,代码来源:GenomicRegionCollection.cpp
示例8: while
void Array2D<T>::resize( const std::size_t& x, const std::size_t& y )
{
// scale x-dimension up or down
if( x != m_SizeX )
{
m_Array.resize( x );
while( x > m_SizeX )
{
m_Array[m_SizeX].resize( m_SizeY, m_DefaultContent );
++m_SizeX;
}
m_SizeX = x;
}
// scale y-dimension up or down
if( y != m_SizeY )
{
for( typename std::vector< std::vector<T> >::iterator it = m_Array.begin(); it != m_Array.end(); ++it )
{
it->resize( y, m_DefaultContent );
}
m_SizeY = y;
}
}
开发者ID:TheComet93,项目名称:chocobun,代码行数:25,代码来源:Array2D.hpp
示例9: appendEventListData
void SaveNexusProcessed::appendEventListData(std::vector<T> events,
size_t offset, double *tofs,
float *weights,
float *errorSquareds,
int64_t *pulsetimes) {
// Do nothing if there are no events.
if (events.empty())
return;
typename std::vector<T>::const_iterator it;
typename std::vector<T>::const_iterator it_end = events.end();
size_t i = offset;
// Fill the C-arrays with the fields from all the events, as requested.
for (it = events.begin(); it != it_end; it++) {
if (tofs)
tofs[i] = it->tof();
if (weights)
weights[i] = static_cast<float>(it->weight());
if (errorSquareds)
errorSquareds[i] = static_cast<float>(it->errorSquared());
if (pulsetimes)
pulsetimes[i] = it->pulseTime().totalNanoseconds();
i++;
}
}
开发者ID:,项目名称:,代码行数:26,代码来源:
示例10: cancelAll
void cancelAll() {
QI_ASSERT(_closed.load());
for (typename std::vector< Future<T> >::iterator it = this->_futures.begin();
it != this->_futures.end();
++it)
it->cancel();
}
开发者ID:ZhaozhengPlus,项目名称:libqi,代码行数:7,代码来源:futurebarrier.hpp
示例11:
inline void BaseGeneticAlgorithm<FITNESS_TYPE>::registerObserver(const std::shared_ptr<AlgorithmObserver<FITNESS_TYPE>> &observer)
{
typedef std::set<typename AlgorithmObserver<FITNESS_TYPE>::ObserveableEvent> setType;
const setType events = observer->getSubscribedEvents();
for (const auto &it :events)
{
typename observers_map::iterator lb = _observers.lower_bound(it);
if (lb != _observers.end() && !(_observers.key_comp()(it, lb->first)))
{
// key already exists
// update lb->second if you care to
lb->second.emplace_back(observer);
}
else
{
// the key does not exist in the map
// add it to the map
typename std::vector<std::shared_ptr<AlgorithmObserver<FITNESS_TYPE>>> list;
list.emplace_back(observer);
_observers.insert(lb, typename observers_map::value_type(it, list)); // Use lb as a hint to insert,
}
}
}
开发者ID:geneial,项目名称:geneial,代码行数:27,代码来源:BaseGeneticAlgorithm.hpp
示例12: volumes
//**********************************************************************
PHX_EVALUATE_FIELDS(GlobalStatistics,workset)
{
if (workset.num_cells == 0)
return;
Intrepid::FunctionSpaceTools::integrate<ScalarT>(volumes, ones,
(this->wda(workset).int_rules[ir_index])->weighted_measure,
Intrepid::COMP_BLAS);
for (std::size_t cell = 0; cell < workset.num_cells; ++cell)
total_volume += volumes(cell);
typename std::vector<PHX::MDField<ScalarT,Cell,IP> >::size_type field_index = 0;
for (typename std::vector<PHX::MDField<ScalarT,Cell,IP> >::iterator field = field_values.begin();
field != field_values.end(); ++field,++field_index) {
Intrepid::FunctionSpaceTools::integrate<ScalarT>(tmp, *field,
(this->wda(workset).int_rules[ir_index])->weighted_measure,
Intrepid::COMP_BLAS);
for (std::size_t cell = 0; cell < workset.num_cells; ++cell) {
averages[field_index] += tmp(cell);
for (typename PHX::MDField<ScalarT,Cell,IP>::size_type ip = 0; ip < (field->dimension(1)); ++ip) {
maxs[field_index] = std::max( (*field)(cell,ip), maxs[field_index]);
mins[field_index] = std::min( (*field)(cell,ip), mins[field_index]);
}
}
}
}
开发者ID:biddisco,项目名称:Trilinos,代码行数:32,代码来源:Panzer_GlobalStatistics_impl.hpp
示例13:
std::vector<std::string> get_names() const
{
typename std::vector<std::string> lst;
for(const_iterator i = begin(); i != end(); ++i)
{
lst.push_back(i->second);
}
return lst;
}
开发者ID:brojudd,项目名称:ubuntu,代码行数:9,代码来源:enum_box.hpp
示例14: if
inline boost::shared_ptr< Base > Construct(
std::vector< t_OriginalVectorType >& vectors,
std::vector< double >& labels,
unsigned int const trainingSize,
std::vector< std::string > const& kernelParameters,
unsigned int const cacheSize = 0
)
{
uint64_t sparseSize = 0;
if ( t_Traits::SPARSE_ALLOWED ) {
typename std::vector< SparseVector< t_Type > >::const_iterator ii = vectors.begin();
typename std::vector< SparseVector< t_Type > >::const_iterator iiEnd = vectors.end();
for ( ; ii != iiEnd; ++ii )
sparseSize += ii->Size();
}
uint64_t spanSize = 0;
if ( t_Traits::SPAN_ALLOWED ) {
typename std::vector< SparseVector< t_Type > >::const_iterator ii = vectors.begin();
typename std::vector< SparseVector< t_Type > >::const_iterator iiEnd = vectors.end();
for ( ; ii != iiEnd; ++ii )
spanSize += SpanVector< t_Type >( *ii ).Size();
}
uint64_t denseSize = 0;
{ typename std::vector< SparseVector< t_Type > >::const_iterator ii = vectors.begin();
typename std::vector< SparseVector< t_Type > >::const_iterator iiEnd = vectors.end();
for ( ; ii != iiEnd; ++ii )
denseSize += DenseVector< t_Type >( *ii ).Size();
}
boost::shared_ptr< Base > result;
if (
t_Traits::SPARSE_ALLOWED &&
( ( ! t_Traits::SPAN_ALLOWED ) || ( sparseSize <= spanSize ) ) &&
( sparseSize <= denseSize )
)
{
result = boost::shared_ptr< Base >( new t_KernelType< SparseVector< t_Type >, t_Traits >( vectors, labels, trainingSize, kernelParameters, cacheSize ) );
}
else if (
t_Traits::SPAN_ALLOWED &&
( spanSize <= denseSize )
)
{
result = boost::shared_ptr< Base >( new t_KernelType< SpanVector< t_Type >, t_Traits >( vectors, labels, trainingSize, kernelParameters, cacheSize ) );
}
else {
result = boost::shared_ptr< Base >( new t_KernelType< DenseVector< t_Type >, t_Traits >( vectors, labels, trainingSize, kernelParameters, cacheSize ) );
}
return result;
}
开发者ID:maliq,项目名称:issvm,代码行数:57,代码来源:svm_kernel_construct.hpp
示例15:
property_t(const std::vector<std::vector<T> >& mtx) {
vector matrix;
for(typename std::vector<std::vector<T> >::const_iterator i = mtx.begin(); i != mtx.end(); ++i) {
vector row;
for(typename std::vector<T>::const_iterator j = i->begin(); j != i->end(); ++j)
row.push_back(*j);
matrix.push_back(row);
}
property_base::operator= <vector>(matrix);
}
开发者ID:NicholasBertocchi,项目名称:QuantLibAddin-Old,代码行数:10,代码来源:property.hpp
示例16: waitForFirst
qi::FutureSync< qi::Future<T> > waitForFirst(std::vector< Future<T> >& vect) {
typename std::vector< Future<T> >::iterator it;
qi::Promise< qi::Future<T> > prom;
qi::Atomic<int>* count = new qi::Atomic<int>();
count->swap((int)vect.size());
for (it = vect.begin(); it != vect.end(); ++it) {
it->connect(boost::bind<void>(&detail::waitForFirstHelper<T>, prom, *it, count));
}
return prom.future();
}
开发者ID:dmerejkowsky,项目名称:libqi,代码行数:10,代码来源:futurebarrier.hpp
示例17: getCallbacks
std::vector<T> getCallbacks() {
typename std::vector<T> result;
result.reserve(functionList.size() - invalidIndexCount);
for (typename TypedFunctionPointerWrapperRefVector<T>::type::iterator it = functionList.begin(); it != functionList.end(); it++) {
if (*it) {
result.push_back((*it)->callback);
}
}
return result;
}
开发者ID:MrApplejuice,项目名称:spacedocking-analysis,代码行数:10,代码来源:CallbackListManager.hpp
示例18: update
void update() {
typename std::vector<Element>::iterator i;
int count = 0;
SDL_Rect * warn_if_same_pos = grid.begin()->getSize();
int warn_count = 0;
for (i = grid.begin(); i != grid.end(); i++) {
#ifndef NO_WARNINGS
if(i->getSize()->x == warn_if_same_pos->x
&&
i->getSize()->y == warn_if_same_pos->y)
{
warn_count++;
}
if(warn_count > 2)
{
printf("Warning!!!! you may be using the same object over and over again!\nuse object * name = new * object(args); in your population routine: gridObject.append(*object); delete name; name = new * object(args);\n");
}
#endif
#ifdef DEBUG
printf("Render[%d]: at (%d,%d)\n",count,i->getSize()->x,i->getSize()->y);
#endif
SDL_RenderCopy(i->getRenderer(), i->getImage(), NULL, i->getSize());
warn_if_same_pos = i->getSize();
count++;
}
}
开发者ID:Xecantur,项目名称:yap,代码行数:27,代码来源:grid.hpp
示例19: interpolate
Y interpolate(const X&x) const {
if (mElements.size() == 0) return Y();
typename std::vector<element_type>::const_iterator it;
it = std::lower_bound(mElements.begin(), mElements.end(), element_type(x));
if (it != mElements.begin()) {
it--;
}
return it->eval(x);
}
开发者ID:obergshavefun,项目名称:icap,代码行数:11,代码来源:spline-lane.hpp
示例20: execute
virtual void execute(const DOM::Node<string_type, string_adaptor>& node, ExecutionContext<string_type, string_adaptor>& context) const
{
if(context.sink().start_element(name_, namespace_))
{
for(typename std::vector<InlineAttribute<string_type, string_adaptor> >::const_iterator a = attrs_.begin(), ae = attrs_.end(); a != ae; ++a)
a->execute(node, context);
ChainStackFrame<string_type, string_adaptor> frame(context);
this->execute_children(node, context);
context.sink().end_element(name_, namespace_);
}
} // execute
开发者ID:QuentinFiard,项目名称:arabica,代码行数:12,代码来源:xslt_inline_element.hpp
注:本文中的typenamestd::vector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论