typename IndexContainer::iterator sort_indices( const Container &v , IndexContainer &idx ) { idx.resize( v.size() ); for( size_t i = 0 ; i != idx.size() ; ++i ) idx[i] = i; auto iter = std::partition( idx.begin() , idx.end() , [&v]( size_t i ) { return std::isfinite( v[i] ); } ); std::sort( idx.begin() , iter , [&v]( size_t i1 , size_t i2 ) { return ( v[i1] < v[i2] ); } ); return iter; }
void construct_component_index(IndexContainer& index, HeaderContainer& header) { build_components_header(index.begin(), std::back_inserter(header), index.end() - index.begin()); link_components(index.begin(), header.begin(), index.end() - index.begin(), header.end() - header.begin()); }
void construct_component_index(IndexContainer& index, HeaderContainer& header) { typedef typename IndexContainer::value_type Integer; build_components_header(index.begin(), std::back_inserter(header), Integer(index.end() - index.begin())); link_components(index.begin(), header.begin(), Integer(index.end() - index.begin()), Integer(header.end() - header.begin())); }
void create_random_indices( IndexContainer &idx , size_t N , size_t n ) { idx.resize( N ); for( size_t i = 0 ; i < N ; ++i ) idx[i]; std::random_shuffle( idx.begin() , idx.end() ); idx.resize( n ); }