本文整理汇总了C++中DLIList::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ DLIList::sort方法的具体用法?C++ DLIList::sort怎么用?C++ DLIList::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DLIList
的用法示例。
在下文中一共展示了DLIList::sort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort_and_print_ids
void CubitUtil::sort_and_print_ids( const char *const heading,
DLIList<int> &id_list,
int should_sort, int report_once,
int wrap )
{
// sort, if desired
if ( should_sort ) {
id_list.sort();
}
if ( report_once ) {
DLIList <int> id_list_2( id_list );
id_list_2.reset();
id_list.clean_out();
id_list.append( id_list_2.get_and_step() );
for ( int j = id_list_2.size()-1; j--; )
{
if ( id_list_2.get() != id_list_2.prev() )
id_list.append( id_list_2.get() );
id_list_2.step();
}
}
if( wrap == -1 )
{
// print out ranges
int begin = id_list.get_and_step();
int end = begin;
int current = -1;
PRINT_INFO(" The %d %s ids are %d", id_list.size(), heading, begin);
for (int i=id_list.size()-1; i > 0; i--) {
current = id_list.get_and_step();
if (current == end+1) {
end++;
}
else {
if (end == begin) {
PRINT_INFO(", %d", current);
}
else if (end == begin+1) {
PRINT_INFO(", %d, %d", end, current);
}
else {
PRINT_INFO(" to %d, %d", end, current);
}
begin = current;
end = begin;
}
}
if (current == begin + 1) {
PRINT_INFO(", %d", current);
}
else if (current != begin) {
PRINT_INFO(" to %d", current);
}
PRINT_INFO(".\n");
}
else
{
char pre_string[67];
sprintf( pre_string, " The %d %s ids are: ", id_list.size(),heading );
CubitUtil::list_entity_ids( pre_string, id_list, wrap, ".\n", CUBIT_FALSE,
CUBIT_FALSE );
}
}
示例2: process_entity_ids
void CubitUtil::process_entity_ids( int method,
CubitString &ret_str,
const char *pre_string,
DLIList<int> &id_list,
int max_len,
const char *post_string,
int sort, int unique,
int tab_len, const char *sep_string,
const char* post_string_none )
{
// Method: 0 - to a string
// 1 - to PRINT_INFO
char temp[200];
if ( id_list.size() == 0 ) {
if( method )
PRINT_INFO("%s%s", pre_string, post_string_none );
else
{
sprintf( temp, "%s%s", pre_string, post_string_none );
ret_str = temp;
}
if( fp )
fprintf( fp, "%s%s", pre_string, post_string_none );
return;
}
// sort
if( sort )
{
id_list.sort();
// make unique
if( unique )
{
int i;
DLIList <int> id_list_2( id_list );
id_list_2.reset();
id_list.clean_out();
id_list.append( id_list_2.get_and_step() );
for ( i=id_list_2.size()-1; i--; )
{
if ( id_list_2.get() != id_list_2.prev() )
id_list.append( id_list_2.get() );
id_list_2.step();
}
}
}
if( max_len < 0 )
max_len = CUBIT_INT_MAX/2;
// TODO: wrap prestring, if necessary
if( method )
PRINT_INFO( "%s", pre_string );
else
ret_str = pre_string;
if( fp )
fprintf( fp, "%s", pre_string );
// Keep track of length printed
int curr_len = strlen(pre_string);
int num = 0;
int begin = id_list.get();
int previous = begin;
int current;
int comma = 0; // Is comma needed
int beg_len, prev_len;
int sep_len = strlen( sep_string );
// Setup the tab
char* tab = new char[tab_len+1];
for( int i=0; i<tab_len; i++ )
tab[i] = ' ';
tab[tab_len] = '\0';
// Loop until all the ids are printed. Use ranges if possible.
while( num < id_list.size()+1 )
{
current = id_list.get_and_step();
num++;
// Handle last entity
if( num <= id_list.size() )
{
if( num==1 ) // Handle 1st time in loop
continue;
if( current==previous+1 )
{
previous = current;
continue;
}
}
// If we are here, we are no longer tracking a range and
// need to print the range or a number.
if( comma )
{
//.........这里部分代码省略.........
示例3: facet_factory
CubitStatus Faceter::facet_factory(FaceterPointData *curr_faceter_data,
CubitFacet *&new_facet,
DLIList <FaceterPointData*> &order_list)
{
double angle;
DLIList<CubitPoint*> loop_list;
new_facet = NULL;
if ( avoid_facet(curr_faceter_data, order_list) )
return CUBIT_SUCCESS;
FaceterPointData *prev = curr_faceter_data->get_prev();
FaceterPointData *next = curr_faceter_data->get_next();
//create the new facet.
//create a triangle from these three points.
new_facet = (CubitFacet*) new FaceterFacetData((CubitPoint*)prev,
(CubitPoint*)curr_faceter_data,
(CubitPoint*)next);
CubitVector facet_normal = new_facet->normal();
CubitVector surface_normal = thisRefFacePtr->normal_at(curr_faceter_data->coordinates());
double dot = facet_normal%surface_normal;
if ( dot < 0 )
{
//new need to try and do this in a different way...
delete new_facet;
new_facet = NULL;
if ( order_list.size() < 3 )
{
PRINT_DEBUG_129("Last triangle is inverted. (surface %d)\n",
thisRefFacePtr->id());
return CUBIT_FAILURE;
}
//Try and create facets on either side of this facet.
return CUBIT_FAILURE;
}
int debug = 1;
if ( debug )
GfxDebug::draw_facet(new_facet, CUBIT_RED);
//Now fix up the ordered_list.
//First update the angles.
prev->set_next(next);
next->set_prev(prev);
loop_list.clean_out();
loop_list.append(prev->get_prev());
loop_list.append(prev);
loop_list.append(next);
loop_list.step();
interior_angle(&loop_list, angle);
prev->set_interior_angle(angle);
loop_list.clean_out();
loop_list.append(prev);
loop_list.append(next);
loop_list.append(next->get_next());
loop_list.step();
interior_angle(&loop_list, angle);
next->set_interior_angle(angle);
//Now do basically a sort again. There is probably
//a faster way to do this but there are also much slower
//ways in worst case too. At least this has guaranteed O(nlogn).
order_list.sort(FaceterPointData::sort_by_angle);
CubitPoint *tmp_point = (CubitPoint*) curr_faceter_data;
gridSearchPtr->remove_point(tmp_point);
return CUBIT_SUCCESS;
}