您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sorted函数代码示例

51自学网 2021-06-03 08:07:08
  C++
这篇教程C++ sorted函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sorted函数的典型用法代码示例。如果您正苦于以下问题:C++ sorted函数的具体用法?C++ sorted怎么用?C++ sorted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sorted函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TEST

    // Call savePosition() on a reverse cursor without ever calling restorePosition().    // May be useful to run this test under valgrind to verify there are no leaks.    TEST( SortedDataInterface, SavePositionWithoutRestoreReversed ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT( sorted->isEmpty( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                ASSERT_OK( sorted->insert( opCtx.get(), key1, loc1, true ) );                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 1, sorted->numEntries( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            scoped_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor( opCtx.get(), -1 ) );            cursor->savePosition();        }    }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:31,


示例2: get_statistics

double get_statistics(const vector<int> & nodes, const vector<double> & scores, const int FLAG){    double statistic = 0.0;    const int size = nodes.size();    if(FLAG == GD_STAT_MEAN){        //compute average        for(int i = 0; i < size; ++i){            statistic += scores[nodes[i]];        }        statistic = statistic / double(size);    }    else if(FLAG == GD_STAT_STD){        //compute standard deviation        double mean = 0;        for(int i = 0; i < size; ++i){            mean += scores[nodes[i]];        }        mean = mean / double(size);        double square_sum = 0;        for(int i = 0; i < size; ++i){            square_sum += pow((double)(scores[nodes[i]] - mean),2);        }        statistic = square_sum / double(size);        statistic = sqrt(statistic);    }    else if(FLAG == GD_STAT_MED){        //compute median - currently using builtin vector sort        //Need to select sub-vector associated with nodes given in function call        vector<double> sorted(size);        for(int i = 0; i < size; ++i){            sorted[i] = scores[nodes[i]];        }        sort(sorted.begin(), sorted.end());        int middle = size / 2;        if(size % 2 == 1){            statistic = sorted[middle];        }        else {            //Adjust downwards since we index from 0, not 1            statistic = (sorted[middle] + sorted[middle - 1]) / 2;        }    }    else if(FLAG == GD_STAT_COUNT){        //Count number of non-negative scored vertices in bag.        for(int i = 0; i < size; ++i){            if(!(scores[nodes[i]] < 0)){                statistic++;            }        }    }    else {        fatal_error("Statistic must be one of GD_STAT_XXX from Util.h/n");    }    return statistic;} // get_statistics
开发者ID:jlothian,项目名称:INDDGO-survey,代码行数:60,


示例3: InitializeResponse

void MlSldaState::InitializeAssignments(bool random_init) {  InitializeResponse();  InitializeLength();  LdawnState::InitializeAssignments(random_init);  if (FLAGS_num_seed_docs > 0) {    const gsl_vector* y = static_cast<lib_corpora::ReviewCorpus*>      (corpus_.get())->train_ratings();    boost::shared_ptr<gsl_permutation> sorted(gsl_permutation_alloc(y->size),                                              gsl_permutation_free);    boost::shared_ptr<gsl_permutation> rank(gsl_permutation_alloc(y->size),                                            gsl_permutation_free);    std::vector< std::vector<int> > num_seeds_used;    num_seeds_used.resize(corpus_->num_languages());    for (int ii = 0; ii < corpus_->num_languages(); ++ii) {      num_seeds_used[ii].resize(num_topics_);    }    gsl_sort_vector_index(sorted.get(), y);    gsl_permutation_inverse(rank.get(), sorted.get());    // We add one for padding so we don't try to set a document to be equal to    // the number of topics.    double num_train = corpus_->num_train() + 1.0;    int train_seen = 0;    int num_docs = corpus_->num_docs();    for (int dd = 0; dd < num_docs; ++dd) {      MlSeqDoc* doc = corpus_->seq_doc(dd);      int lang = doc->language();      if (!corpus_->doc(dd)->is_test()) {        // We don't assign to topic zero, so it can be stopwordy        int val = (int) floor((num_topics_ - 1) *                              rank->data[train_seen] / num_train) + 1;        // Stop once we've used our limit of seed docs (too many leads to an        // overfit initial state)        if (num_seeds_used[lang][val] < FLAGS_num_seed_docs) {          cout << "Initializing doc " << lang << " " << dd << " to " << val <<            " score=" << truth_[dd] << endl;          for (int jj = 0; jj < (int)topic_assignments_[dd].size(); ++jj) {            int term = (*doc)[jj];            const topicmod_projects_ldawn::WordPaths word =              wordnet_->word(lang, term);            int num_paths = word.size();            if (num_paths > 0) {              ChangePath(dd, jj, val, rand() % num_paths);            } else {              if (use_aux_topics())                ChangeTopic(dd, jj, val);            }          }          ++num_seeds_used[lang][val];        }        ++train_seen;      }    }  }}
开发者ID:NetBUG,项目名称:topicmod,代码行数:60,


示例4: run

void run(std::vector<uint32_t>* input, size_t k){  std::vector<uint32_t> sorted(*input);    std::vector<uint32_t> copy(*input);    std::vector<uint32_t> tmp(input->size());    fast_sort<std::vector<uint32_t>,std::vector<uint32_t>>(&sorted, &tmp);  size_t ind2 = findkth<std::vector<uint32_t>, IntCompare, false>(&copy, k);  size_t ind1 = findkth<std::vector<uint32_t>, IntCompare, true>(&copy, k);  // Verify it's the median  if (sorted[k] != (*input)[ind2]) {    print_array(input);    print_array(&sorted);    printf("findkth returned %lu/n", ind2);     printf("sorted[%lu]=%u but input[findkth(k=%lu)]=%u/n", k, sorted[k], k, (*input)[ind2]);    PANIC("findkth (linear=false) returned wrong index/n");  }  if (sorted[k] != (*input)[ind1]) {    print_array(input);    print_array(&sorted);    printf("findkth returned %lu/n", ind1);     printf("sorted[%lu]=%u but input[findkth(k=%lu)]=%u/n", k, sorted[k], k, (*input)[ind1]);    PANIC("findkth (linear=true) returned wrong index/n");  }  // Verify we didn't mess with the array  for (size_t i=0; i<input->size(); i++) {    if ((*input)[i] != copy[i]) {      print_array(input);      print_array(&copy);      PANIC("findkth modified array. Input array (first) != copy (second)")    }  }
开发者ID:multilinear,项目名称:datastructures_C--11,代码行数:30,


示例5: OS

void OptionParser::print_usage(OptionPrefix& root, FILE *fp) {	static const char* blank29 = "                             "; // 29 spaces	static const char* blank25 = blank29 + 4;                     // 25 spaces	OStream OS(fp);	std::set<OptionEntry*> sorted(root.begin(),root.end());	for(std::set<OptionEntry*>::iterator i = sorted.begin(), e = sorted.end();			i != e; ++i) {		OptionEntry& oe = **i;		OS << "    " << root.get_name();		std::size_t name_len = root.size() + oe.print(OS);		if (name_len < (25-1)) {			OS << (blank25 + name_len);		} else {			OS << nl << blank29;		}		const char* c = oe.get_desc();		for (std::size_t i = 29; *c != 0; c++, i++) {			/* If we are at the end of the line, break it. */			if (i == 80) {				OS << nl << blank29;				i = 29;			}			OS << *c;		}		OS << nl;	}}
开发者ID:zapster,项目名称:cacao-travis,代码行数:31,


示例6: TEST

    // Add multiple compound keys using a bulk builder.    TEST( SortedDataInterface, BuilderAddMultipleCompoundKeys ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT( sorted->isEmpty( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            scoped_ptr<SortedDataBuilderInterface> builder(                    sorted->getBulkBuilder( opCtx.get(), true ) );            ASSERT_OK( builder->addKey( compoundKey1a, loc1 ) );            ASSERT_OK( builder->addKey( compoundKey1b, loc2 ) );            ASSERT_OK( builder->addKey( compoundKey1c, loc4 ) );            ASSERT_OK( builder->addKey( compoundKey2b, loc3 ) );            ASSERT_OK( builder->addKey( compoundKey3a, loc5 ) );            builder->commit( false );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 5, sorted->numEntries( opCtx.get() ) );        }    }
开发者ID:3rf,项目名称:mongo,代码行数:28,


示例7: sorted

std::string Timer::Show() {  std::string ret;  if (Counters().empty()) return ret;  auto const url = g_context->getRequestUrl(75);  folly::format(&ret, "/nJIT timers for {}/n", url);  auto const header = "{:<40} | {:>15} {:>15} {:>15}/n";  auto const row    = "{:<40} | {:>15} {:>13,}us {:>13,}ns/n";  folly::format(&ret, header, "name", "count", "total time", "average time");  folly::format(&ret, "{:-^40}-+{:-^48}/n", "", "");  std::map<std::string, Counter> sorted(s_counters->begin(), s_counters->end());  for (auto const& pair : sorted) {    auto& name = pair.first;    auto& counter = pair.second;    folly::format(&ret, row, name, counter.count, counter.total / 1000,                  counter.mean());  }  ret += '/n';  return ret;}
开发者ID:RdeWilde,项目名称:hhvm,代码行数:25,


示例8: sorted

// public, staticvoid Cvar::List( void ) {	console.Print( PrintLevel::Normal, "Listing cvars.../n" );	std::map<std::string, Cvar *> sorted( cvars.begin(), cvars.end() );	std::vector<std::string> keyValues;	keyValues.reserve( sorted.size() );	Indent indent( 1 );	size_t maxLen = 1u;	for ( const auto &cvar : sorted ) {		keyValues.push_back( String::Format( "%s = /"%s/"", cvar.first.c_str(), cvar.second->fullString.c_str() ) );		const size_t len = strlen( keyValues.back().c_str() );		if ( len > maxLen ) {			maxLen = len;		}	}	uint32_t i = 0;	for ( const auto &cvar : sorted ) {		console.Print( PrintLevel::Normal, "%-*s: %s/n",			maxLen + 1,			keyValues[i++].c_str(),			cvar.second->description.c_str()		);	}}
开发者ID:Razish,项目名称:xsngine,代码行数:26,


示例9: NumMultinomialWRBInit

void NumMultinomialWRBInit(real *m, int l, int if_sorted, int **a_ptr,                           real **p_ptr) {  pair *tl;  int i;  real q;  if (if_sorted) {    tl = array2tuples(m, l);  } else {    tl = sorted(m, l, 1);  }  int f = 0;  int r = l - 1;  int *a = NumNewHugeIntVec(l);  real *p = NumNewHugeVec(l);  for (i = 0; i < l; i++) p[tl[i].key] = tl[i].val * l;  while (1) {    if (p[tl[f].key] > 1 && p[tl[r].key] < 1) {  // rear underflow      q = 1 - p[tl[r].key];                      // underflow probability      a[tl[r].key] = tl[f].key;                  // alias      p[tl[f].key] -= q;                         // probability      r--;    } else if (p[tl[f].key] < 1 && p[tl[f + 1].key] > 1) {  // front underflow      q = 1 - p[tl[f].key];      a[tl[f].key] = tl[f + 1].key;      p[tl[f + 1].key] -= q;      f++;    } else      break;  }  free(tl);  *p_ptr = p;  *a_ptr = a;  return;}
开发者ID:dragonxlwang,项目名称:s3e,代码行数:34,


示例10: collect

// Collect regular file names recursively.// Files found in 'exclude' are abandoned.void collect(const string &path, vector<string> &files, set<string> &exclude) {  struct dirent *entry;  DIR *dp;  if ((dp = opendir(path.c_str())) == NULL) {    error("Util::fail open file: %s", path.c_str());  }  // TODO(billy): readdir_r should be thread safe to replace this  while ((entry = readdir(dp))) {    string name = string(entry->d_name);    if (!name.length() || name[0] == '.')  // ignore hidden or special files      continue;    if (exclude.find(name) != exclude.end())      continue;    name = path+"/"+name;    if (entry->d_type == DT_DIR) {      collect(name, files, exclude);    } else {      files.push_back(name);    }  }  set<string> sorted(files.begin(), files.end());  files.clear();  files.insert(files.begin(), sorted.begin(), sorted.end());  closedir(dp);  return;}
开发者ID:sleepsort,项目名称:se,代码行数:29,


示例11: sortColumn

void TableEditor::columnClicked(int col){    if(!sorting()) return;    //if(col==lastSortCol) asc=!asc; else lastSortCol=col,asc=TRUE;    sortColumn(col,1,1);	emit sorted();}
开发者ID:obrpasha,项目名称:votlis_krizh_gaz_nas,代码行数:7,


示例12: total

boolbasic_counts_t::print_results() {    std::cerr << TOOL_NAME << " results:/n";    std::cerr << "Total counts:/n";    std::cerr << std::setw(12) << total_instrs << " total (fetched) instructions/n";    std::cerr << std::setw(12) << total_instrs_nofetch <<        " total non-fetched instructions/n";    std::cerr << std::setw(12) << total_prefetches << " total prefetches/n";    std::cerr << std::setw(12) << total_loads << " total data loads/n";    std::cerr << std::setw(12) << total_stores << " total data stores/n";    std::cerr << std::setw(12) << total_threads << " total threads/n";    std::cerr << std::setw(12) << total_sched_markers << " total scheduling markers/n";    std::cerr << std::setw(12) << total_xfer_markers << " total transfer markers/n";    std::cerr << std::setw(12) << total_other_markers << " total other markers/n";    // Print the threads sorted by instrs.    std::vector<std::pair<memref_tid_t, int_least64_t>> sorted(thread_instrs.begin(),                                                               thread_instrs.end());    std::sort(sorted.begin(), sorted.end(), cmp_val);    for (const auto& keyvals : sorted) {        memref_tid_t tid = keyvals.first;        std::cerr << "Thread " << tid << " counts:/n";        std::cerr << std::setw(12) << thread_instrs[tid] << " (fetched) instructions/n";        std::cerr << std::setw(12) << thread_instrs_nofetch[tid] <<            " non-fetched instructions/n";        std::cerr << std::setw(12) << thread_prefetches[tid] << " prefetches/n";        std::cerr << std::setw(12) << thread_loads[tid] << " data loads/n";        std::cerr << std::setw(12) << thread_stores[tid] << " data stores/n";        std::cerr << std::setw(12) << thread_sched_markers[tid] <<            " scheduling markers/n";        std::cerr << std::setw(12) << thread_xfer_markers[tid] << " transfer markers/n";        std::cerr << std::setw(12) << thread_other_markers[tid] << " other markers/n";    }    return true;}
开发者ID:stoyannk,项目名称:dynamorio,代码行数:35,


示例13: sorted

voidDependencyResolverTest::simpleTest(){  DependencyResolver<int> resolver;  int mat3 = 3;  int mat1 = 1;  int mat2 = 2;  resolver.insertDependency(mat2, mat1);  resolver.insertDependency(mat3, mat1);  resolver.insertDependency(mat3, mat2);  std::vector<int> sorted(3);  sorted[0] = mat1;  sorted[1] = mat2;  sorted[2] = mat3;  /*const std::vector<std::set<int> > & sets =*/  resolver.getSortedValuesSets();  std::sort(sorted.begin(), sorted.end(), resolver);  CPPUNIT_ASSERT( sorted[0] == mat1);  CPPUNIT_ASSERT( sorted[1] == mat2);  CPPUNIT_ASSERT( sorted[2] == mat3);}
开发者ID:AhmedAly83,项目名称:moose,代码行数:27,


示例14: main

int main(int argc, char **argv){    srand(time(NULL));        int numbers[SIZE];        int i;    for (i = 0; i < SIZE; ++i)    {        numbers[i] = rand() % (SIZE + 1);     }        for (i = 0; i < SIZE; ++i)    {        printf("%d: %d/n", i, numbers[i]);    }        bubblesort (numbers, SIZE);        assert( sorted(numbers, SIZE));        return(0);    }
开发者ID:lquan,项目名称:OVS,代码行数:25,


示例15: minDeletionSize

 int minDeletionSize(vector<string>& A) {     int n = A.size();     int result = 0;     vector<bool> removed(A[0].size());     int last = 0;     for( int i = 0 ; i < n ; ++i ) A[i] = "a" + A[i];     for( int i = 1 ; i < A[0].size() ; ++i ){         bool b = false;         bool allDif = true;         for( int j = 1 ; j < n ; ++j ){             if( A[j][last] == A[j - 1][last] && A[j][i] < A[j - 1][i] ){                 b = true;                 result++;                 break;             }         }         if( !b ){             last = i;         }else             removed[i] = true;         if( sorted(A, removed) ) break;     }          return result; }
开发者ID:jariasf,项目名称:Online-Judges-Solutions,代码行数:25,


示例16: _setZWrite

	void Renderer::_renderCamera(Camera* cam)	{		RenderTarget* rt = cam->GetRenderTarget();		if (!rt)			return;		cameraRendering = cam;		rt->Bind();		_setZWrite(true);		_setZTest(true);		glClearColor(0, 0, 0, 1);		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		std::vector<Renderable*> sorted(renderables.begin(), renderables.end());		std::sort(sorted.begin(), sorted.end(), renderableCompare());		std::vector<Renderable*>::iterator rIt;		for (rIt = sorted.begin(); rIt != sorted.end(); rIt++)		{			(*rIt)->Update();			//_render(cam, (*rIt));			(*rIt)->Render(cam);		}		//Go through post-processes		_renderPostProcess(rt->GetPostProcess());	}
开发者ID:MegaMilkX,项目名称:Comet,代码行数:27,


示例17: merge

//Merge two vectors into one in sorted ordervoid merge(vector<int> *arr, int start, int mid, int end){	vector<int> sorted((end - start) + 1);	int sortPos = 0;	int leftPos = start;	int rightPos = mid+1;	while(sortPos < sorted.size())	{		if(!leftPos > mid && !rightPos > end)		{						if((*arr)[leftPos] < (*arr)[rightPos])				sorted[sortPos++] = (*arr)[leftPos++];			else				sorted[sortPos++] = (*arr)[rightPos++];		}		else		{			if(!leftPos > mid)				sorted[sortPos++] = (*arr)[leftPos++];			else if(!rightPos > end)				sorted[sortPos++] = (*arr)[rightPos++];			else				break;		}	}	for(int i = 0; i < sorted.size(); i++)	{		(*arr)[start + i] = sorted[i];	}}
开发者ID:travisperson,项目名称:Thread-Sort,代码行数:33,


示例18: sorted

QStringList SessionChildItem::users() const{    SortedUserModel sorted(session()->prefixModes(), m_usermodel);    QStringList names;    for (int i = 0; i < sorted.rowCount(QModelIndex()); ++i)        names += sorted.data(sorted.index(i, 0)).toString();    return names;}
开发者ID:MeliodasX,项目名称:communi,代码行数:8,


示例19: out

intHelpCmd::listCommands(){    for (const Command &cmd : sorted(Commands::list())) {        out() << Cmd{cmd.getName()} << " -- " << cmd.getDescr() << '/n';    }    return EXIT_SUCCESS;}
开发者ID:xaizek,项目名称:dit,代码行数:9,


示例20: TEST

    // Call getDirection() on a reverse cursor and verify the result equals -1.    TEST( SortedDataInterface, GetCursorDirectionReversed ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            scoped_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor( opCtx.get(), -1 ) );            ASSERT_EQUALS( -1, cursor->getDirection() );        }    }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:11,


示例21: main

int main(){   ListN numbers;   int tempint;   char *ifile = new char[25];   //get file name from user   cout << "Enter file name numbers are stored in: ";   cin >> ifile;   ifstream fin( ifile );   fin >> tempint;   //import numbers from a file   while( fin.good() )   {      numbers.insertAfter( tempint );      if( fin.good() )      fin >> tempint;   }   //sorts the array in ascending order   sortListN( numbers );   //gets the number of nodes in the array   numbers.getSize( tempint );   //declare an array based list the same size as the node based list   ListA sorted( tempint );   //copies the node based list to the array based list   sorted.copy( numbers );   cout << endl << "Sorted " << sorted;   int input;   //loops taking inputs and display the function result stops when -1 is input   while( input != -1 )   {      cout << "Enter number to search for or -1 to exit: ";      cin >> input;      //returns an index value unless the list is empty      if( input != -1 && !sorted.empty() )         cout << "index: " << binarysearch( sorted, tempint, input, 1 ) << endl;      else if( sorted.empty() )         cout << "index: Empty List No Index Available" << endl;   }   return 0;}
开发者ID:zasekle,项目名称:School,代码行数:54,


示例22: Cmd_ListCommands

	static void Cmd_ListCommands( const CommandContext &context ) {		console.Print( PrintLevel::Normal, "Listing commands.../n" );		Indent indent( 1 );		std::map<std::string, CommandFunc> sorted( commandTable.begin(), commandTable.end() );		for ( const auto &cmd : sorted ) {			console.Print( PrintLevel::Normal, "%s/n",				cmd.first.c_str()			);		}	}
开发者ID:Razish,项目名称:xsngine,代码行数:11,


示例23: wiggleSort

 void wiggleSort(vector<int>& nums) {     vector<int> sorted(nums);     std::sort(sorted.begin(), sorted.end());     int n = nums.size()-1;     for(int i = 0, j = n/2+1; n >= 0; --n) {         if(n & 0x1)             nums[n] = sorted[j++];         else             nums[n] = sorted[i++];     } }
开发者ID:bashell,项目名称:leetcode,代码行数:11,


示例24: WriteSortedListToFile

void CInsertion::WriteSortedListToFile(std::string filepath){	CLogger::Log(__LINE__, __FILE__, "Enter WriteSortedListToFile()");	std::ofstream sorted(filepath);	for (int i = 0; i < (int)listofnumbers.size(); ++i)	{		sorted << listofnumbers[i] << std::endl;	}	CLogger::Log(__LINE__, __FILE__, "Leave WriteSortedListToFile()");}
开发者ID:raokartikkumar24,项目名称:TAS,代码行数:11,


示例25: frequencySort

 string frequencySort(string s) {   int n = s.size();   vector<string> sorted(n+1, "");   vector<int> cnt(CHAR_MAX, 0);   for (char c : s) ++cnt[c];   for (int i = 0; i < CHAR_MAX; ++i)     sorted[cnt[i]] += string(cnt[i], i);   string ret;   for (string& e : sorted) ret = e + ret;   return ret; }
开发者ID:gongzhitaao,项目名称:oj,代码行数:12,


示例26: QLCChannel

void QLCChannel_Test::sortCapabilities(){    QLCChannel* channel = new QLCChannel();    QVERIFY(channel->capabilities().size() == 0);    QLCCapability* cap1 = new QLCCapability(10, 19, "10-19");    QVERIFY(channel->addCapability(cap1) == true);    QLCCapability* cap2 = new QLCCapability(50, 59, "50-59");    QVERIFY(channel->addCapability(cap2) == true);    QLCCapability* cap3 = new QLCCapability(40, 49, "40-49");    QVERIFY(channel->addCapability(cap3) == true);    QLCCapability* cap4 = new QLCCapability(0, 9, "0-9");    QVERIFY(channel->addCapability(cap4) == true);    QLCCapability* cap5 = new QLCCapability(200, 209, "200-209");    QVERIFY(channel->addCapability(cap5) == true);    QLCCapability* cap6 = new QLCCapability(30, 39, "30-39");    QVERIFY(channel->addCapability(cap6) == true);    QLCCapability* cap7 = new QLCCapability(26, 29, "26-29");    QVERIFY(channel->addCapability(cap7) == true);    QLCCapability* cap8 = new QLCCapability(20, 25, "20-25");    QVERIFY(channel->addCapability(cap8) == true);    QList <QLCCapability*> orig(channel->capabilities());    QVERIFY(orig.at(0) == cap1);    QVERIFY(orig.at(1) == cap2);    QVERIFY(orig.at(2) == cap3);    QVERIFY(orig.at(3) == cap4);    QVERIFY(orig.at(4) == cap5);    QVERIFY(orig.at(5) == cap6);    QVERIFY(orig.at(6) == cap7);    QVERIFY(orig.at(7) == cap8);    channel->sortCapabilities();    QList <QLCCapability*> sorted(channel->capabilities());    QVERIFY(sorted.at(0) == cap4);    QVERIFY(sorted.at(1) == cap1);    QVERIFY(sorted.at(2) == cap8);    QVERIFY(sorted.at(3) == cap7);    QVERIFY(sorted.at(4) == cap6);    QVERIFY(sorted.at(5) == cap3);    QVERIFY(sorted.at(6) == cap2);    QVERIFY(sorted.at(7) == cap5);    delete channel;}
开发者ID:alexpaulzor,项目名称:qlc,代码行数:53,


示例27: main

int main(int argc, char *argv[]) {    if(argc < 2) {         cout << "Error. Command is ./<name> <int>." << endl;        return 0;     }    cout << "pre-order/n";    preOrder(atoi(argv[1]));    cout << "post-order/n";    postOrder(atoi(argv[1]));    cout << "sorted/n";    sorted(atoi(argv[1]));}
开发者ID:TheirOwn,项目名称:cs14_15spr,代码行数:12,


示例28: sorted

void RectBinArrange::Arrange(const std::vector<ee::ImageSprite*>& sprs){// 	std::vector<ee::ImageSprite*> sorted(sprs);// 	sortByMaxEdge(sorted);// // 	std::vector<RectSize> input;// 	BeforePacking(sorted, input);// // 	std::vector<Rect> output;// 	GuillotineBinPackAlg(input, output);// // 	MaxRectsBinPackAlg(input, output);// // 	ShelfBinPackAlg(input, output);// // 	SkylineBinPackAlg(input, output);// 	// 	AfterPacking(sorted, output);	//////////////////////////////////////////////////////////////////////////	m_tex_account = 0;	std::vector<ee::ImageSprite*> sorted(sprs);	SortByMaxEdge(sorted);	int count = 0;	float x_offset = 0;	std::vector<ee::ImageSprite*> remains(sorted);	while (!remains.empty())	{		std::vector<RectSize> input;		BeforePacking(remains, input);		std::vector<Rect> output;		GuillotineBinPackAlg(input, output);		// 	MaxRectsBinPackAlg(input, output);		// 	ShelfBinPackAlg(input, output);		// 	SkylineBinPackAlg(input, output);		std::vector<ee::ImageSprite*> _remains;		AfterPacking(x_offset, remains, output, _remains);		remains = _remains;		x_offset += Context::Instance()->width * TEXTURE_X_OFFSET_FACTOR;		m_tex_account++;		if (count >= 100) {			break;		}		++count;	}}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:52,


示例29: main

int main() {    int a;    /*     * Считываем входное число.      */    scanf("%d", &a);    /*     * Выводим число, используя тренарный оператор.     */    printf("%s/n", sorted(a) ? "true" : "false");    return 0;}
开发者ID:dedstroyer,项目名称:mai-workshops-2013,代码行数:13,



注:本文中的sorted函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sorter函数代码示例
C++ sortList函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。