本文整理汇总了C++中reorder函数的典型用法代码示例。如果您正苦于以下问题:C++ reorder函数的具体用法?C++ reorder怎么用?C++ reorder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reorder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
//
// Preparing drives for selected grunts.
//
void Manager::Prepare_Disks(int target)
{
int i, loop_start, loop_finish;
if (target == ALL_WORKERS) {
// Preparing all grunts at the same time. This requires a great
// amount of coordination on the part of Iometer to ensure that the
// grunts do not prepare the same drives.
for (i = 0; i < grunt_count; i++) {
if (!grunts[i]->Prepare_Disks()) {
// Send failure message back to Iometer.
msg.data = 0;
if (IsBigEndian()) {
(void)reorder(msg);
}
prt->Send(&msg);
return;
}
}
loop_start = 0;
loop_finish = grunt_count;
} else {
// Preparing a single grunt.
if (!grunts[target]->Prepare_Disks()) {
// Send failure message back to Iometer.
msg.data = 0;
if (IsBigEndian()) {
(void)reorder(msg);
}
prt->Send(&msg);
return;
}
loop_start = target;
loop_finish = loop_start + 1;
}
// Peek to see if the prepare was be canceled by the user.
for (i = loop_start; i < loop_finish; i++) {
while (grunts[i]->not_ready) {
if (prt->Peek()) {
prt->Receive(&msg);
if (IsBigEndian()) {
(void)reorder(msg);
}
Process_Message();
} else {
Sleep(LONG_DELAY);
}
}
grunts[i]->grunt_state = TestIdle;
}
// Send a message back to Iometer to indicate that we're done preparing.
msg.data = 1; // indicates success
if (IsBigEndian()) {
(void)reorder(msg);
}
prt->Send(&msg);
}
示例2: equals
bool equals(const DB::ASTPtr & lhs, const DB::ASTPtr & rhs)
{
DB::ASTPtr lhs_reordered = lhs->clone();
reorder(&*lhs_reordered);
DB::ASTPtr rhs_reordered = rhs->clone();
reorder(&*rhs_reordered);
return lhs_reordered->getTreeID() == rhs_reordered->getTreeID();
}
示例3: shortestPathPQ
/*
Note:
* change priority queue implementation
*/
Graph shortestPathPQ(Graph g, Vertex v)
{
Graph mst = newGraph(g->nV);
int *dist = malloc(sizeof(int) * g->nV); // create the distance array
int *pred = malloc(sizeof(int) * g->nV); // create the predecessor array, stores vertices passed through
PQueue q = newPQueue(); // create a new priority queue
Vertex currentVertex = 0, w = 0;
int i = 0;
int total = 0;
assert(dist != NULL && pred != NULL);
// clear all the memory blocks
setArray(dist, INF, g->nV);
setArray(pred, -1, g->nV);
dist[v] = 0;
for (i = 0; i < g->nV; i++){
joinPQueue(q, i, dist[i]);
}
reorder(q, NO_UPDATE, NO_UPDATE);
while ( !isEmptyPQ(q) ){ // while priority queue is not empty
currentVertex = leavePQueue(q);
for (w = 0; w < getnV(g); w++){
if (g->wt[currentVertex][w] == NO_WEIGHT) continue;
if (g->wt[currentVertex][w] + dist[currentVertex] < dist[w]){
dist[w] = g->wt[currentVertex][w] + dist[currentVertex];
pred[w] = currentVertex;
reorder(q, w, dist[w]); // updates the priority of vertex w as well
}
}
reorder(q, NO_UPDATE, NO_UPDATE);
}
// construct the mst graph
for (i = 0; i < getnV(g); i++){
if (pred[i] != NOT_ASSIGNED){
addEdge(mst, pred[i], i);
total += dist[i];
}
}
printf("Total = %d.\n", total);
deletePQueue(q);
free(dist);
free(pred);
return mst;
}
示例4: prepare_query
bool prepare_query(const char* entry) {
position = 0;
auto parsed_entry = parseEntry(entry);
std::vector<std::vector<bool>> queryset;
queryset.push_back(parsed_entry);
if (querypoint != nullptr)
delete[] querypoint;
if (numres != nullptr) {
delete numres[0];
delete[] numres;
}
if (results != nullptr) {
delete[] results[0];
delete[] results;
}
results = new UINT32*[1];
numres = new UINT32*[1];
numres[0] = new UINT32[B + 1];
querypoint = create_dataset(queryset);
if (r > 0) {
UINT8* new_query = new UINT8[B/8];
reorder(new_query, querypoint, 1, B, order);
delete[] querypoint;
querypoint = new_query;
}
return true;
}
示例5: while
//
// Manager runs assuming Iometer control. Returns TRUE if Dynamo should
// continue to run, otherwise FALSE.
//
BOOL Manager::Run()
{
while (TRUE) // Receive loop.
{
#ifdef _DEBUG
cout << "in while loop : Manager::Run() " << endl;
#endif
if ( prt->Receive( &msg ) == PORT_ERROR )
{
// Error receiving data message, stop running.
cout << "Error receiving message." << endl << flush;
return FALSE;
}
else
{
#ifdef BIG_ENDIAN_ARCH
(void) reorder(msg);
#endif
// Continue to process messages until manager indicates stopping.
if ( !Process_Message() )
return FALSE;
// On a reset, stop then restart running the manager.
if ( msg.purpose == RESET )
return TRUE;
}
}
}
示例6: Stop_Test
//
// Signalling to stop testing.
//
void Manager::Stop_Test(int target)
{
if (target == ALL_WORKERS) {
for (int i = 0; i < grunt_count; i++) {
grunts[i]->Stop_Test();
}
} else {
grunts[target]->Stop_Test();
}
cout << "Stopping..." << endl << flush;
if (target == ALL_WORKERS) {
for (int i = 0; i < grunt_count; i++) {
grunts[i]->Wait_For_Stop();
}
} else {
grunts[target]->Wait_For_Stop();
}
cout << " Stopped." << endl << flush;
// Reply that test has stopped.
if (IsBigEndian()) {
(void)reorder(msg);
}
prt->Send(&msg);
#if defined(IOMTR_OS_LINUX) || defined(IOMTR_OS_SOLARIS)
if (do_syslog) {
syslog(LOG_INFO, "I/O Stopped");
}
#endif
}
示例7: Get_Performance
//
// Stopping recording of test results.
//
void Manager::Record_Off( int target )
{
// Get performance data for end of test.
Get_Performance( WHOLE_TEST_PERF, LAST_SNAPSHOT );
Get_Performance( LAST_UPDATE_PERF, LAST_SNAPSHOT );
if ( target == ALL_WORKERS )
{
for ( int i = 0; i < grunt_count; i++ )
{
grunts[i]->Record_Off();
}
}
else
{
grunts[target]->Record_Off();
}
cout << " Stopped." << endl << flush;
record = FALSE; // No workers are recording data.
#if _DEBUG
cout << "Recording stopped." << endl << flush;
#endif
#ifdef BIG_ENDIAN_ARCH
(void) reorder(msg);
#endif
prt->Send( &msg );
}
示例8: levelOrderBottom
vector<vector<int> > levelOrderBottom(TreeNode *root) {
vector<vector<int>> retVec;
if (root == NULL) return retVec;
helper(root,retVec);
reorder(retVec);
return retVec;
}
示例9: reorder
inline void reorder(CPU_Results & var, int send_recv)
{
int i, j;
if (send_recv == RECV)
reorder(var.count);
for (i = 0; i < var.count; i++)
for (j = 0; j < CPU_RESULTS; j++)
reorder(var.CPU_utilization[i][j]);
if (send_recv == SEND)
reorder(var.count);
return;
}
示例10: px4_getopt
//
// px4_getopt
//
// returns:
// the valid option character
// '?' if any option is unknown
// -1 if no remaining options
//
// If the option takes an arg, myoptarg will be updated accordingly.
// After each call to px4_getopt, myoptind in incremented to the next
// unparsed arg index.
// Argv is changed to put all options and option args at the beginning,
// followed by non-options.
//
__EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myoptind, const char **myoptarg)
{
char *p;
char c;
int takesarg;
if (*myoptind == 1)
if (reorder(argc, argv, options) != 0)
return (int)'?';
p = argv[*myoptind];
if (*myoptarg == 0)
*myoptarg = argv[*myoptind];
if (p && options && myoptind && p[0] == '-') {
c = isvalidopt(p[1], options, &takesarg);
if (c == '?')
return (int)c;
*myoptind += 1;
if (takesarg) {
*myoptarg = argv[*myoptind];
*myoptind += 1;
}
return (int)c;
}
return -1;
}
示例11: defined
//
// Signalling all threads to begin performing I/O.
//
void Manager::Begin_IO(int target)
{
msg.data = TRUE;
cout << "Beginning to perform I/O..." << endl << flush;
#if defined(IOMTR_OS_LINUX) || defined(IOMTR_OS_SOLARIS)
if (do_syslog) {
syslog(LOG_INFO, "Beginning to perform I/O...");
}
#endif
if (target == ALL_WORKERS) {
for (int i = 0; i < grunt_count; i++) {
grunts[i]->Begin_IO();
if (grunts[i]->critical_error)
msg.data = FALSE;
}
} else {
grunts[target]->Begin_IO();
if (grunts[target]->critical_error)
msg.data = FALSE;
}
#ifdef _DEBUG
cout << " Performing I/O." << endl << flush;
#endif
// Reply that I/O has started.
if (IsBigEndian()) {
(void)reorder(msg);
}
prt->Send(&msg);
}
示例12: getChannelsHash
uint64_t RoboTVChannels::checkUpdates() {
cRwLock::Lock(false);
Channels.Lock(false);
cChannels* oldChannels = m_channels;
uint64_t oldHash = m_hash;
uint64_t newHash = getChannelsHash(&Channels);
if(newHash == oldHash) {
Channels.Unlock();
cRwLock::Unlock();
return oldHash;
}
cRwLock::Unlock();
cRwLock::Lock(true);
if((m_hash == oldHash) && (m_channels == oldChannels)) {
if(m_channels != &Channels) {
delete m_channels;
}
m_channels = reorder(&Channels);
m_hash = newHash;
}
else {
// Seems another thread has already updated the hash.
newHash = m_hash;
}
Channels.Unlock();
cRwLock::Unlock();
return newHash;
}
示例13: buffer_enque
int
buffer_enque(void* added_item, struct buffer * q)
{
if(!q->initialized){
return -1;
}
if(q->q_size>=q->capacity){
// Overflow
return -1;
}
if (q->q_tail >= q->capacity - 1){
reorder(q);
}
q->q_tail++;
q->q_size++;
//cprintf("addIndex=%d\n", q->q_tail);
q->buf[q->q_tail] = added_item;
//printf(1,"addAtAdd=%d\n", ((int*)q->buf[q->q_tail]));
//printf(1,"addPointer=%d\n", *((int*)q->buf[q->q_tail]));
return 0;
}
示例14: dnn_mem_t
dnn_mem_t(const dnn_mem_t &rhs, mkldnn_data_type_t dt,
mkldnn_format_tag_t tag = mkldnn_format_tag_undef,
mkldnn_engine_t engine = engine_ref)
: dnn_mem_t(rhs.md_, dt, tag, engine) {
if (active_)
reorder(rhs);
}
示例15: reorder
//
// Signalling all threads to begin performing I/O.
//
void Manager::Begin_IO( int target )
{
msg.data = TRUE;
cout << "Beginning to perform I/O..." << endl << flush;
if ( target == ALL_WORKERS )
{
for ( int i = 0; i < grunt_count; i++ )
{
grunts[i]->Begin_IO();
if ( grunts[i]->critical_error )
msg.data = FALSE;
}
}
else
{
grunts[target]->Begin_IO();
if ( grunts[target]->critical_error )
msg.data = FALSE;
}
#if _DEBUG
cout << " Performing I/O." << endl << flush;
#endif
// Reply that I/O has started.
#ifdef BIG_ENDIAN_ARCH
(void) reorder(msg);
#endif
prt->Send( &msg );
}