本文整理汇总了C++中PartVector类的典型用法代码示例。如果您正苦于以下问题:C++ PartVector类的具体用法?C++ PartVector怎么用?C++ PartVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PartVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort_and_unique
void sort_and_unique( PartVector & partVector )
{
PartVector::iterator begin = partVector.begin();
PartVector::iterator end = partVector.end();
std::sort( begin , end , PartLess() );
PartVector::iterator new_end = std::unique( begin , end );
partVector.erase( new_end , end );
}
示例2: remove
void remove( PartVector & v , Part & part )
{
const PartVector::iterator e = v.end();
PartVector::iterator i = v.begin();
i = std::lower_bound( i , e , part , PartLess() );
if ( i != e && *i == & part ) { v.erase( i ); }
}
示例3: contain
bool contain( const PartVector & v , const Part & part )
{
const PartVector::const_iterator e = v.end();
PartVector::const_iterator i = v.begin();
i = std::lower_bound( i , e , part , PartLess() );
return i != e && *i == & part ;
}
示例4: add_parts_to_partset
void Transaction::add_parts_to_partset ( Entity &e , PartSet &pl )
{
PartVector parts;
e.bucket().supersets ( parts );
for ( PartVector::iterator part_iter = parts.begin(); part_iter != parts.end() ; ++part_iter )
pl.insert ( *part_iter );
}
示例5: selectIntersection
Selector selectIntersection( const PartVector& intersection_part_vector )
{
Selector selector;
if (intersection_part_vector.size() > 0) {
selector = *intersection_part_vector[0];
for (unsigned i = 1 ; i < intersection_part_vector.size() ; ++i) {
selector &= *intersection_part_vector[i];
}
}
return selector;
}
示例6: assert_ok_to_modify
void BulkData::destroy_relation( Entity & e_from , Entity & e_to )
{
static const char method[]= "stk::mesh::BulkData::destroy_relation" ;
assert_ok_to_modify( method );
assert_valid_relation( method , *this , e_from , e_to );
//------------------------------
// When removing a relationship may need to
// remove part membership and set field relation pointer to NULL
PartVector del , keep ;
for ( PairIterRelation i = e_to.relations() ; i.first != i.second ; ++(i.first) ) {
if ( !( i.first->entity() == & e_from ) &&
( e_to.entity_rank() < i.first->entity_rank() ) )
{
induced_part_membership( * i.first->entity(), del, e_to.entity_rank(),
i.first->identifier(), keep );
}
}
for ( PairIterRelation i = e_from.relations() ; i.first != i.second ; ++(i.first) ) {
if ( i.first->entity() == & e_to ) {
induced_part_membership( e_from, keep, e_to.entity_rank(),
i.first->identifier(), del );
clear_field_relations( e_from , e_to.entity_rank() ,
i.first->identifier() );
}
}
//------------------------------
// 'keep' contains the parts deduced from kept relations
// 'del' contains the parts deduced from deleted relations
// that are not in 'keep'
// Only remove these part memberships the entity is not shared.
// If the entity is shared then wait until modificaton_end_synchronize.
//------------------------------
if ( ! del.empty() && (parallel_size() < 2 || e_to.sharing().empty()) ) {
PartVector add ;
internal_change_entity_parts( e_to , add , del );
}
//delete relations from the entities
m_entity_repo.destroy_relation( e_from, e_to);
}
示例7: insert
bool insert( PartVector & v , Part & part )
{
const PartVector::iterator e = v.end();
PartVector::iterator i = v.begin();
i = std::lower_bound( i , e , part , PartLess() );
const bool new_member = i == e || *i != & part ;
if ( new_member ) { v.insert( i , &part ); }
return new_member ;
}
示例8:
std::ostream & operator << ( std::ostream & s , const Bucket & k )
{
const MetaData & mesh_meta_data = k.mesh().mesh_meta_data();
const std::string & entity_name =
mesh_meta_data.entity_rank_names()[ k.entity_rank() ];
PartVector parts ; k.supersets( parts );
s << "Bucket( " << entity_name << " : " ;
for ( PartVector::iterator i = parts.begin() ; i != parts.end() ; ++i ) {
s << (*i)->name() << " " ;
}
s << ")" ;
return s ;
}
示例9: internal_verify_change_parts
void BulkData::internal_verify_change_parts( const MetaData & meta ,
const Entity & entity ,
const PartVector & parts ) const
{
const std::vector<std::string> & rank_names = meta.entity_rank_names();
const EntityRank undef_rank = InvalidEntityRank;
const EntityRank entity_rank = entity.entity_rank();
bool ok = true ;
std::ostringstream msg ;
for ( PartVector::const_iterator
i = parts.begin() ; i != parts.end() ; ++i ) {
const Part * const p = *i ;
const unsigned part_rank = p->primary_entity_rank();
bool intersection_ok, rel_target_ok, rank_ok;
internal_basic_part_check(p, entity_rank, undef_rank, intersection_ok, rel_target_ok, rank_ok);
if ( !intersection_ok || !rel_target_ok || !rank_ok ) {
if ( ok ) {
ok = false ;
msg << "change parts for entity " << print_entity_key( entity );
msg << " , { " ;
}
else {
msg << " , " ;
}
msg << p->name() << "[" ;
if ( part_rank < rank_names.size() ) {
msg << rank_names[ part_rank ];
}
else {
msg << part_rank ;
}
msg << "] " ;
if ( !intersection_ok ) { msg << "is_intersection " ; }
if ( !rel_target_ok ) { msg << "is_relation_target " ; }
if ( !rank_ok ) { msg << "is_bad_rank " ; }
}
}
ThrowErrorMsgIf( !ok, msg.str() << "}" );
}
示例10: key
bool Bucket::member_any( const PartVector & parts ) const
{
const unsigned * const i_beg = key() + 1 ;
const unsigned * const i_end = key() + key()[0] ;
const PartVector::const_iterator ip_end = parts.end();
PartVector::const_iterator ip = parts.begin() ;
bool result_none = true ;
for ( ; result_none && ip_end != ip ; ++ip ) {
const unsigned ord = (*ip)->mesh_meta_data_ordinal();
const unsigned * const i = std::lower_bound( i_beg , i_end , ord );
result_none = i_end == i || ord != *i ;
}
return ! result_none ;
}
示例11: translate_partset_to_partvector
void Transaction::translate_partset_to_partvector ( const PartSet &in , PartVector &out ) const
{
out.resize ( in.size() );
unsigned i = 0;
for ( PartSet::const_iterator cur_in = in.begin() ; cur_in != in.end() ; cur_in++ )
{
out[i] = *cur_in;
++i;
}
}
示例12: has_superset
bool has_superset( const Bucket & bucket , const PartVector & ps )
{
const std::pair<const unsigned *, const unsigned *>
part_ord = bucket.superset_part_ordinals();
bool result = ! ps.empty();
for ( PartVector::const_iterator
i = ps.begin() ; result && i != ps.end() ; ++i ) {
const unsigned ordinal = (*i)->mesh_meta_data_ordinal();
const unsigned * iter =
std::lower_bound( part_ord.first , part_ord.second , ordinal );
result = iter < part_ord.second && ordinal == *iter ;
}
return result ;
}
示例13: get_involved_parts
void get_involved_parts(
const PartVector & union_parts,
const Bucket & candidate,
PartVector & involved_parts
)
{
involved_parts.clear();
if (union_parts.size() == 0) {
return;
}
// Used to convert part ordinals to part pointers:
MetaData & meta_data = MetaData::get( * union_parts[0]);
const PartVector & all_parts = meta_data.get_parts();
const std::pair<const unsigned *,const unsigned *>
bucket_part_begin_end_iterators = candidate.superset_part_ordinals(); // sorted and unique
std::vector<unsigned> union_parts_ids;
copy_ids( union_parts_ids , union_parts ); // sorted and unique
std::vector<unsigned>::const_iterator union_part_id_it = union_parts_ids.begin();
const unsigned * bucket_part_id_it = bucket_part_begin_end_iterators.first ;
while ( union_part_id_it != union_parts_ids.end() &&
bucket_part_id_it != bucket_part_begin_end_iterators.second )
{
if ( *union_part_id_it < *bucket_part_id_it ) {
++union_part_id_it ;
}
else if ( *bucket_part_id_it < *union_part_id_it ) {
++bucket_part_id_it ;
}
else {
// Find every match:
Part * const part = all_parts[ *union_part_id_it ];
involved_parts.push_back( part );
++union_part_id_it;
++bucket_part_id_it;
}
}
}
示例14: intersect
size_t intersect( const PartVector & v , const PartVector & p )
{
// Both lists must be sorted, assume v.size() > p.size()
const PartVector::const_iterator ev = v.end();
PartVector::const_iterator iv = v.begin();
const PartVector::const_iterator ep = p.end();
PartVector::const_iterator ip = p.begin();
size_t count = 0 ;
for ( ; ip != ep && iv != ev ; ++ip ) {
Part * const q = *ip ;
iv = std::lower_bound( iv , ev , q , PartLess() );
if ( iv != ev && *iv == q ) { ++count ; }
}
return count ;
}
示例15: supersets
void Bucket::supersets( PartVector & ps ) const
{
const MetaData & mesh_meta_data = mesh().mesh_meta_data();
std::pair<const unsigned *, const unsigned *>
part_ord = superset_part_ordinals();
ps.resize( part_ord.second - part_ord.first );
for ( unsigned i = 0 ;
part_ord.first < part_ord.second ; ++(part_ord.first) , ++i ) {
ps[i] = & mesh_meta_data.get_part( * part_ord.first );
}
}