void rubiks_cube(QStringList list, QString color) { QString rubiks_cube = "empty,yellow,empty,"+color+",empty,empty"; QStringList yellow_wall; foreach (const QString &str, list) { if (str.contains("yellow") && str.count('\n') == 2) { yellow_wall += str; } } yellow_wall = order(yellow_wall, "yellow"); QString help; help = yellow_wall.at(0); rubiks_cube.replace(rubiks_cube.indexOf("empty"), QString::fromStdString("empty").count(), help.section('\n', 1, 1)); rubiks_cube.replace(rubiks_cube.indexOf("empty"), QString::fromStdString("empty").count(), help.section('\n', 2, 2)); for(int i = 1; i < yellow_wall.count(); i++) { if(!yellow_wall.at(i).contains(help.section('\n', 1, 1)) && !yellow_wall.at(i).contains(help.section('\n', 2, 2))) { help = yellow_wall.at(i); rubiks_cube.replace(rubiks_cube.indexOf("empty"), QString::fromStdString("empty").count(),help.section('\n', 2, 2)); rubiks_cube.replace(rubiks_cube.indexOf("empty"), QString::fromStdString("empty").count(),help.section('\n', 1, 1)); } } QStringList color_short; for(int i = 0; i <= rubiks_cube.count(','); i++) { help = rubiks_cube.section(',', i, i); help.remove(1, help.count()-1); help = help.toUpper(); color_short << help; } print_rubiks_cube(color_short); }
void Foam::hierarchGeomDecomp::setDecompOrder() { word order(geomDecomDict_.lookup("order")); if (order.size() != 3) { FatalIOErrorIn ( "hierarchGeomDecomp::hierarchGeomDecomp" "(const dictionary& decompositionDict)", decompositionDict_ ) << "number of characters in order (" << order << ") != 3" << exit(FatalIOError); } for (label i = 0; i < 3; i++) { if (order[i] == 'x') { decompOrder_[i] = 0; } else if (order[i] == 'y') { decompOrder_[i] = 1; } else if (order[i] == 'z') { decompOrder_[i] = 2; } else { FatalIOErrorIn ( "hierarchGeomDecomp::hierarchGeomDecomp" "(const dictionary& decompositionDict)", decompositionDict_ ) << "Illegal decomposition order " << order << endl << "It should only contain x, y or z" << exit(FatalError); } } }
void solve(string s, size_t pos, size_t depth, set<string> &res) { bool neg; auto o = order(s, neg); if (o == 0) { if(neg == false) res.insert(s); return; } if (depth == 0) return; //cout << "s=" << s << " pos=" << pos << " depth=" << depth << endl; for (int i = pos; i < s.size(); i++) { if (s[i] == '(') { string tmp = s; tmp.erase(i, 1); solve(tmp, i, depth-1, res); } } }
//=========================================================================== void SplineCurve::makeKnotStartRegular() //=========================================================================== { // Testing whether knotstart is already d+1-regular. if (basis_.begin()[0] < basis_.begin()[order() - 1]) { double tpar = basis_.startparam(); int ti = order() - 1; // Index of last occurence of tpar (in other_curve). int mt = 1; // Multiplicity of tpar. while ((basis_.begin()[ti - mt] == tpar) && (mt < order())) ++mt; std::vector<double> new_knots; for (int i = 0; i < order() - mt; ++i) new_knots.push_back(tpar); insertKnot(new_knots); coefs_.erase(coefs_begin(), coefs_begin() + (order() - mt) * dim_); basis_ = BsplineBasis(order(), basis_.begin() + order() - mt, basis_.end()); } }
QList<Model::CanceledOrder> CanceledOrder::getAll() { QList<Model::CanceledOrder> canceledOrders; DatabaseManager mgr; QSqlQuery query("SELECT * from order_canceled"); query.exec(); while(query.next()) { int id = query.value(0).toInt(); int order_id = query.value(1).toInt(); QDateTime cancel_time = query.value(2).toDateTime(); Model::Order order(order_id); Model::CanceledOrder canceledOrder(id, order, cancel_time); canceledOrders.append(canceledOrder); } return canceledOrders; }
std::vector<long> listEccentricities(const Graph & g) { dMatrix dist = distanceMatrix(g); long n = order(g); std::vector<long> res(n); for (long i = 0; i < n; i++) { long m = 0; for (long j = 0; j < n; j++) { if (m < dist[i][j]) { m = dist[i][j]; } } res[i] = m; } make_heap(res.begin(), res.end()); sort_heap(res.begin(), res.end()); return res; }
void sort( /* sort primitives according to pcmp */ FILE *infp, int (*pcmp)() /* compares pointers to pointers to primitives! */ ) { PRIMITIVE *prims[PBSIZE]; /* pointers to primitives */ PLIST primlist; /* our primitives list */ int nprims; short done; do { for (nprims = 0; nprims < PBSIZE; nprims++) { /* read to global */ if ((prims[nprims] = palloc()) == NULL) error(SYSTEM, "memory exhausted in sort"); readp(prims[nprims], infp); if (isglob(prims[nprims]->com)) break; } qsort(prims, nprims, sizeof(*prims), pcmp); /* sort pointer array */ if (nprims < PBSIZE) /* tack on global if one */ nprims++; order(prims, nprims, &primlist); /* make array into list */ sendsort(&primlist, pcmp); /* send to merge sorter */ done = primlist.pbot->com == PEOF; plfree(&primlist); /* free up array */ } while (!done); }
void Application::onMessage( const FIX42::NewOrderSingle& message, const FIX::SessionID& ) { FIX::SenderCompID senderCompID; FIX::TargetCompID targetCompID; FIX::ClOrdID clOrdID; FIX::Symbol symbol; FIX::Side side; FIX::OrdType ordType; FIX::Price price; FIX::OrderQty orderQty; FIX::TimeInForce timeInForce( FIX::TimeInForce_DAY ); message.getHeader().get( senderCompID ); message.getHeader().get( targetCompID ); message.get( clOrdID ); message.get( symbol ); message.get( side ); message.get( ordType ); if ( ordType == FIX::OrdType_LIMIT ) message.get( price ); message.get( orderQty ); if ( message.isSetField( timeInForce ) ) message.get( timeInForce ); try { if ( timeInForce != FIX::TimeInForce_DAY ) throw std::logic_error( "Unsupported TIF, use Day" ); Order order( clOrdID, symbol, senderCompID, targetCompID, convert( side ), convert( ordType ), price, (long)orderQty ); processOrder( order ); } catch ( std::exception & e ) { rejectOrder( senderCompID, targetCompID, clOrdID, symbol, side, e.what() ); } }
int run(){ const int order_ = 20; int numshape = (order_+1)*(order_+1)*(order_+1); TPZVec<REAL> point(3,0.); TPZVec<int> id(8); int i; for(i = 0; i< 8; i ++) { id[i] = i; } TPZVec<int> order(19); for(i = 0; i< 19; i ++) { order[i] = order_; } TPZCompEl::SetgOrder(order_); TPZVec<FADREAL> phi(numshape); TPZFMatrix OldPhi(numshape,1), OldDPhi(3,numshape); TPZFMatrix DiffPhi(numshape,1), DiffDPhi(3,numshape); TPZShapeCube::ShapeCube(point, id, order, phi); TPZShapeCube::ShapeCube(point, id, order, OldPhi, OldDPhi); /*cout << "Calculated by Fad" << phi; cout << "Old derivative method (phi)\n" << OldPhi; cout << "Old derivative method (dPhi)\n" << OldDPhi; shapeFAD::ExplodeDerivatives(phi, DiffPhi, DiffDPhi); DiffPhi-=OldPhi; DiffDPhi-=OldDPhi;*/ //cout << "FAD derivative method (phi)\n" << /*TPZFMatrix (OldPhi -*/ DiffPhi; //cout << "FAD derivative method (dPhi)\n" <</* TPZFMatrix (OldDPhi -*/ DiffDPhi; return 0; }
void main() { int choice = 0; menu(); scanf("%d", &choice); while(choice) { switch(choice) { case 1: init(); break; case 2: search(); break; case 3: del(); break; case 4: modify(); break; case 5: insert(); break; case 6: order(); break; case 7: total(); break; default: break; } getchar(); menu(); scanf("%d", &choice); } getchar(); return; }
long radius(const Graph & g) { dMatrix mat = distanceMatrix(g); long n = order(g); long rad = INF; for (long i = 0; i < n; ++i) { long max = -1; for (long j = 0; j < n; ++j) { if (mat[i][j] > max) { max = mat[i][j]; } } if (max < rad) { rad = max; } } return rad; }
int main() { int i; int src[10]; printf("input 10 number : "); for(i = 0; i < 10; i++) { scanf("%d",&src[i]); } order(src); printf("output ordering munber is :"); for(i = 0; i < 10; i++) { printf("%d ",src[i]); } printf("\n"); return 0; }
int main() { std::priority_queue<order, std::vector<order>, order> q; std::vector<order> v; int n; scanf("%d", &n); for(int i = 1; i <= n; i++) { int x, y; scanf("%d %d", &x, &y); v.push_back(order(x, y, i)); } std::sort(v.begin(), v.end(), [] (const order& a, const order& b) { return a.deadline < b.deadline; }); for(auto it = v.begin(); it < v.end(); it++) { if(it->deadline == q.size() && q.top().reward < it->reward) { // The size of q is equal to the day number, if it surpasses the deadline of the // current order, we can't meet it, so we (possibly) replace some earlier order q.pop(); q.push(*it); } else if(it->deadline > q.size()) q.push(*it); } printf("%d\n", q.size()); std::vector<order> ans; while(!q.empty()) { ans.push_back(q.top()); q.pop(); } std::sort(ans.begin(), ans.end(), [] (const order& o1, const order& o2) { return o1.deadline < o2.deadline; } ); for(auto it = ans.begin(); it < ans.end(); it++) printf("%d ", it->number); return 0; }
lsdouble SchedulingNativeFunction::call(const LSNativeContext& context) { vector<int> order(p.numJobs); if (context.count() < varCount()) return numeric_limits<double>::lowest(); for (int i = 0; i < p.numJobs; i++) { order[i] = static_cast<int>(context.getIntValue(i)); if (order[i] == Project::UNSCHEDULED) return numeric_limits<double>::lowest(); } SGSResult result = decode(order, context); lsdouble profit = static_cast<lsdouble>(p.calcProfit(result)); if (tr != nullptr) { if(profit > bks) bks = profit; tr->intervalTrace(static_cast<float>(bks)); } // TODO: result.numSchedulesGenerated return profit; }
long eccentricConnectivity(const Graph & g) { long res = 0, n = order(g); dMatrix dist = distanceMatrix(g); for (long i = 0; i < n; i++) { long ecc = 0, deg = 0; for (long j = 0; j < n; j++) { if (edge(i,j,g).second) { deg++; } if (dist[i][j] > ecc) { ecc = dist[i][j]; } } res += ecc * deg; } return res; }
int main() { auto src = std::vector<int> { 6, 4, 4, 2, 2, 3, 3, 3, 3 }; auto const N = src.size(); auto ord = std::vector<int> {}; ord.reserve(N); iota_n(std::back_inserter(ord), N, 0); auto rnk = std::vector<double> {}; rnk.reserve(N); iota_n(std::back_inserter(rnk), N, 0.0); std::cout << "unsorted data \n\n"; std::cout << "i --> s o r \n"; std::cout << "=========== \n"; for (std::size_t i = 0; i < N; ++i) std::cout << i << " --> " << src[i] << " " << ord[i] << " " << rnk[i] << "\n"; order(begin(src), end(src), begin(ord)); rank(begin(src), end(src), begin(ord), begin(rnk)); std::cout << "sorted data \n\n"; std::cout << "i --> s o r \n"; std::cout << "=========== \n"; for (std::size_t i = 0; i < N; ++i) std::cout << i << " --> " << src[i] << " " << ord[i] << " " << rnk[i] << "\n"; /* // show sorted indices and tie-adjusted ranks // cout << "i --> v I R \n============= \n"; for (size_t i=0; i<orig.size(); i++) cout << i << " --> " << orig[i] << " " << idxs[i] << " " << rnks[i] << endl; cout << "i --> v I R\n"; */ // }
order PossessorPlayer::getOrder() { if (getHUD() != nullptr && getHUD()->getUIState() != nullptr && getHUD()->getUIState()->ui_active) { //do nothing return order(); } assert(player); order o; auto method = player->getInputMethod(); vector2F v = method->getMovementVector(); if (v.getMagnitude() > 1) v.setMagnitude(1); o.movement = v; o.movement_magnitude_procuntual = true; if (method->getAction(InputMethod::AIM)) { o.movement=aim_dir; o.aim=aim_dir; o.stand_in_place=true; } else if (!o.movement.isZero()&&!o.stand_in_place) { aim_dir={0,0}; aiming=false; } if (method->getAction(InputMethod::ATTACK_0)) { o.attack_type=0; o.do_attack=true; } if (method->getAction(InputMethod::ATTACK_1)) { o.attack_type=1; o.do_attack=true; } if (method->getAction(InputMethod::ATTACK_2)) { o.attack_type = 2; o.do_attack = true; } o.do_context_sensitive = method->getAction(InputMethod::CONTEXT_SENSITIVE); o.dash = method->getAction(InputMethod::DASH); return o; }
void StickerSetInner::installDone(const MTPBool &result) { StickerSets &sets(cRefStickerSets()); sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags)).value().stickers = _pack; int32 insertAtIndex = 0; StickerSetsOrder &order(cRefStickerSetsOrder()); for (int32 s = order.size(); insertAtIndex < s; ++insertAtIndex) { StickerSets::const_iterator i = sets.constFind(order.at(insertAtIndex)); if (i == sets.cend() || !(i->flags & MTPDstickerSet_flag_official)) { break; } } int32 currentIndex = cStickerSetsOrder().indexOf(_setId); if (currentIndex != insertAtIndex) { if (currentIndex > 0) { order.removeAt(currentIndex); if (currentIndex < insertAtIndex) { --insertAtIndex; } } order.insert(insertAtIndex, _setId); } StickerSets::iterator custom = sets.find(CustomStickerSetId); if (custom != sets.cend()) { for (int32 i = 0, l = _pack.size(); i < l; ++i) { custom->stickers.removeOne(_pack.at(i)); } if (custom->stickers.isEmpty()) { sets.erase(custom); } } cSetStickersHash(QByteArray()); Local::writeStickers(); emit installed(_setId); App::wnd()->hideLayer(); }
void metadb_handle_list::remove_duplicates(bool b_release) { unsigned count = get_count(); if (count>0) { bit_array_bittable mask(count); mem_block_t<int> order(count); sort_by_format_get_order(order,"%_path_raw%|$num(%_subsong%,9)",0); unsigned n; for(n=0;n<count-1;n++) { if (get_item(order[n])==get_item(order[n+1])) { mask.set(order[n+1],true); } } if (b_release) delete_mask(mask); else remove_mask(mask); } }
/** If an entry referring to a database with name aFullName does not exist in the container, a new entry will be created, a connection with the database established. If an entry with the specified name already exists, no new entry wil be created, the reference counter of the existing one will be incremented. @param aFullName The full database name, including the path. @param aSettings Per-database background compaction settings @leave KErrNoMemory, an out of memory condition has occurred; Note that the function may also leave with some other database specific errors categorised as ESqlDbError, and other system-wide error codes. @panic SqlDb 4 In _DEBUG mode. Too short or too long database name (aFullName parameter) @panic SqlDb 7 In _DEBUG mode. An entry with the specified name has been found but the entry is NULL. */ void CSqlCompactor::AddEntryL(const TDesC& aFullName, const TSqlCompactSettings& aSettings) { __ASSERT_DEBUG(aFullName.Length() > 0 && aFullName.Length() <= KMaxFileName, __SQLPANIC(ESqlPanicBadArgument)); SQLCOMPACTOR_INVARIANT(); CSqlCompactEntry* entry = NULL; TInt idx = iEntries.FindInOrder(aFullName, &CSqlCompactor::Search); if(idx == KErrNotFound) { SQL_TRACE_COMPACT(OstTraceExt4(TRACE_INTERNALS, CSQLCOMPACTOR_ADDENTRYL1, "0x%X;CSqlCompactor::AddEntryL;New entry;aFullName=%S;iStepLength=%d;iFreePageThreashold=%d", (TUint)this, __SQLPRNSTR(aFullName), aSettings.iStepLength, aSettings.iFreePageThresholdKb)); entry = CSqlCompactEntry::NewLC(aFullName, iConnFactoryL, aSettings, *iTimer); TLinearOrder<CSqlCompactEntry> order(&CSqlCompactor::Compare); __SQLLEAVE_IF_ERROR(iEntries.InsertInOrder(entry, order)); CleanupStack::Pop(entry); } else { SQL_TRACE_COMPACT(OstTraceExt4(TRACE_INTERNALS, CSQLCOMPACTOR_ADDENTRYL2, "0x%X;CSqlCompactor::AddEntryL;Reuse entry;aFullName=%S;iStepLength=%d;iFreePageThreashold=%d", (TUint)this, __SQLPRNSTR(aFullName), aSettings.iStepLength, aSettings.iFreePageThresholdKb)); entry = iEntries[idx]; __ASSERT_DEBUG(entry != NULL, __SQLPANIC(ESqlPanicInternalError)); (void)entry->AddRef(); } SQLCOMPACTOR_INVARIANT(); }
typename property_traits<ColorMap>::value_type sequential_vertex_coloring(const VertexListGraph& G, ColorMap color) { typedef typename graph_traits<VertexListGraph>::vertex_descriptor vertex_descriptor; typedef typename graph_traits<VertexListGraph>::vertex_iterator vertex_iterator; std::pair<vertex_iterator, vertex_iterator> v = vertices(G); #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS std::vector<vertex_descriptor> order(v.first, v.second); #else std::vector<vertex_descriptor> order; order.reserve(std::distance(v.first, v.second)); while (v.first != v.second) order.push_back(*v.first++); #endif return sequential_vertex_coloring (G, make_iterator_property_map (order.begin(), identity_property_map(), graph_traits<VertexListGraph>::null_vertex()), color); }
multimap<double, IndexDocument*, std::greater<double> > VectorModelSpace::search(Query query) { multimap<double, IndexDocument*, std::greater<double> > results; if (mDocuments && mIndex && mDictionary) { unordered_map<unsigned int, Query::QueryTerm*> terms = query.mTerms; unordered_map<unsigned int, Query::QueryTerm*>::iterator it = terms.begin(); unordered_map<unsigned int, Query::QueryTerm*>::iterator end = terms.end(); //writing terms for (; it != end; ++it) { Term* term = mDictionary->find(it->second->text); //calculate weight if (term) { //f(t) it->second->term = *term; //w(t) it->second->weightQuery = 1*log2(mCollectionSize/term->frequency); //for each (d, f(d,t)) recoverIndexTerms(*term, &query); } else it->second->weightQuery = 0; } //Cosine order(&query); multimap<double, IndexDocument*, std::greater<double> > ordered(query.mIndexDocuments.begin(), query.mIndexDocuments.end()); results = ordered; } else cout << "initSearch before use search method!" << endl; return results; }
void LocalizerImpl::loadTable(const vector<string> &raw, const string &language) { vector<int> order(raw.size()); for (size_t k = 0; k<raw.size(); k++) order[k] = k; // Optimize insertation order permute(order); table.clear(); this->language = language; for (size_t k=0;k<raw.size();k++) { const string &s = raw[order[k]]; int pos = s.find_first_of('='); if (pos==string::npos) throw std::exception("Bad file format."); int spos = pos; int epos = pos+1; while (spos>0 && s[spos-1]==' ') spos--; while (unsigned(epos)<s.size() && s[epos]==' ') epos++; string key = s.substr(0, spos); string value = s.substr(epos); int nl = value.find("\\n"); while (nl!=string::npos) { value.replace(nl, 2, newline); nl = value.find("\\n"); } table[key] = value; } }
bool tictactoe::field::check_win_condition(const size_type index, tile state) const { (*this)[index]; // op[] checks the index and throws in case of an invalid index // so from here on, index is guaranteed to be valid // check a winning line using this->order() elements, starting with the i // index passed for begin and then increasing by skip steps - this model can // handle all four (see below) distinct winning conditions auto check_winning_line = [this, index, state](size_type begin, const size_type skip) { unsigned num_elements = order(); for(; num_elements--; begin += skip) { if ( // this is the tile index that is currently checked: // *assume* equality for it without checking for the actual value! begin != index && // other tiles in the range much contain the given state tiles[begin] != state ) { return false; } } return true; }; // possible point for optimization, however: no premature optimization! // algorithmic complexity (time: O(this->order()), mem: O(1)) couldn't be // improved anyway - the rest are integer arithmetic and comparisons: // in any case well enough for a quick tictactoe writeup return // row check_winning_line(index - index % order(), 1) || // column check_winning_line(index % order(), order()) || // diagonal (\) check_winning_line(0, order() + 1) || // diagonal (/) check_winning_line(order() - 1, order() - 1); }
// --------------------------------------------------------------------------- // CSsmLangSelCmd::InitializeL // --------------------------------------------------------------------------- // void CSsmLangSelCmd::InitializeL() { FUNC_LOG; ASSERT_TRACE( iEnv ); iValidLanguages = new ( ELeave ) CArrayFixFlat<TInt>( KLanguageListGranularity ); RFs* fsSession = &( const_cast<RFs&>( iEnv->Rfs() ) ); //Get the list of installed languages TInt errorCode = SysLangUtil::GetInstalledLanguages( iValidLanguages, fsSession ); ERROR( errorCode, "Failed to get installed languages" ); User::LeaveIfError( errorCode ); //Initialize the Language and Region mapping hash set InitializeRegionMappingL(); //Get the number of installed languages const TInt validLangCount = iValidLanguages->Count(); TLinearOrder<TLanguageRegion> order(&CompareLanguageMapping); //Get the mapped regions for the installed languages for(TInt index = 0; index < validLangCount; ++index) { TLanguageRegion region = iLangRegionMappingHashSet.FindL(TLanguageRegion(iValidLanguages->At(index))); INFO_2( "Found Region code = %d for language %d", region.iRegion, region.iLanguage ); iRegionsArray.InsertInOrderL(region, order); } //Connect to Misc adaptation errorCode = iAdaptation.Connect(); ERROR( errorCode, "Failed to connect to RSsmMiscAdaptation" ); User::LeaveIfError( errorCode ); }
string customSortString(string S, string T) { vector<int> order(30, -1); vector<int> letter(30); for (int i = 0; i < (int) S.length(); i++) { order[S[i] - 'a'] = i; letter[i] = S[i] - 'a'; } string result = ""; vector<int> count(30, 0); for (int i = 0; i < (int)T.length(); i++) { if(order[T[i] - 'a'] != -1) { count[order[T[i] - 'a']]++; } else { result += T[i]; } } for (int i = 0; i < 26; i++) { while (count[i]--) { result += ('a' + letter[i]); } } return result; }
Model::CanceledOrder CanceledOrder::getById(int id) { QList<Model::CanceledOrder> canceledOrders; DatabaseManager mgr; QSqlQuery query; query.prepare("SELECT * from order_canceled WHERE id = ?"); query.addBindValue(id); query.exec(); while(query.next()) { int id = query.value(0).toInt(); int order_id = query.value(1).toInt(); QDateTime cancel_time = query.value(2).toDateTime(); Model::Order order(order_id); Model::CanceledOrder canceledOrder(id, order, cancel_time); canceledOrders.append(canceledOrder); } return canceledOrders.first(); }
void ListBaseTestCase::ColumnsOrder() { #ifdef wxHAS_LISTCTRL_COLUMN_ORDER wxListCtrl* const list = GetList(); int n; wxListItem li; li.SetMask(wxLIST_MASK_TEXT); // first set up some columns static const int NUM_COLS = 3; list->InsertColumn(0, "Column 0"); list->InsertColumn(1, "Column 1"); list->InsertColumn(2, "Column 2"); // and a couple of test items too list->InsertItem(0, "Item 0"); list->SetItem(0, 1, "first in first"); list->InsertItem(1, "Item 1"); list->SetItem(1, 2, "second in second"); // check that the order is natural in the beginning const wxArrayInt orderOrig = list->GetColumnsOrder(); for ( n = 0; n < NUM_COLS; n++ ) CPPUNIT_ASSERT_EQUAL( n, orderOrig[n] ); // then rearrange them: using { 2, 0, 1 } order means that column 2 is // shown first, then column 0 and finally column 1 wxArrayInt order(3); order[0] = 2; order[1] = 0; order[2] = 1; list->SetColumnsOrder(order); // check that we get back the same order as we set const wxArrayInt orderNew = list->GetColumnsOrder(); for ( n = 0; n < NUM_COLS; n++ ) CPPUNIT_ASSERT_EQUAL( order[n], orderNew[n] ); // and the order -> index mappings for individual columns for ( n = 0; n < NUM_COLS; n++ ) CPPUNIT_ASSERT_EQUAL( order[n], list->GetColumnIndexFromOrder(n) ); // and also the reverse mapping CPPUNIT_ASSERT_EQUAL( 1, list->GetColumnOrder(0) ); CPPUNIT_ASSERT_EQUAL( 2, list->GetColumnOrder(1) ); CPPUNIT_ASSERT_EQUAL( 0, list->GetColumnOrder(2) ); // finally check that accessors still use indices, not order CPPUNIT_ASSERT( list->GetColumn(0, li) ); CPPUNIT_ASSERT_EQUAL( "Column 0", li.GetText() ); li.SetId(0); li.SetColumn(1); CPPUNIT_ASSERT( list->GetItem(li) ); CPPUNIT_ASSERT_EQUAL( "first in first", li.GetText() ); li.SetId(1); li.SetColumn(2); CPPUNIT_ASSERT( list->GetItem(li) ); CPPUNIT_ASSERT_EQUAL( "second in second", li.GetText() ); //tidy up when we are finished list->ClearAll(); #endif // wxHAS_LISTCTRL_COLUMN_ORDER }
TEST(SizeOrderTest, IrreflexivityTest) { gl::internal::SizeOrder<std::vector<int> > order; ASSERT_FALSE(order(100,100)); }
TEST(WidthOrderTest, IrreflexivityTest) { gl::internal::WidthOrder<std::pair<int,int> > order; ASSERT_FALSE(order(std::make_pair(100,100),std::make_pair(100,100))); }