本文整理汇总了C++中reorder函数的典型用法代码示例。如果您正苦于以下问题:C++ reorder函数的具体用法?C++ reorder怎么用?C++ reorder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reorder函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:62,代码来源:IOManager.cpp
示例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();
}
开发者ID:Aahart911,项目名称:ClickHouse,代码行数:10,代码来源:in_join_subqueries_preprocessor.cpp
示例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;
}
开发者ID:matthewT53,项目名称:Data-structures-and-algorithms,代码行数:54,代码来源:graph.c
示例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;
}
开发者ID:maumueller,项目名称:ann-benchmarks,代码行数:27,代码来源:lib-mih-wrapper.cpp
示例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;
}
}
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:32,代码来源:IOManager.cpp
示例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
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:37,代码来源:IOManager.cpp
示例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 );
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:31,代码来源:IOManager.cpp
示例8: levelOrderBottom
vector<vector<int> > levelOrderBottom(TreeNode *root) {
vector<vector<int>> retVec;
if (root == NULL) return retVec;
helper(root,retVec);
reorder(retVec);
return retVec;
}
开发者ID:buptjz,项目名称:AlgoPrac,代码行数:7,代码来源:BinaryTreeLevelOrderTraversalII.cpp
示例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;
}
开发者ID:blusjune,项目名称:.bsrc,代码行数:16,代码来源:ByteOrder.cpp
示例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;
}
开发者ID:Bjarne-Madsen,项目名称:Firmware,代码行数:42,代码来源:px4_getopt.c
示例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);
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:35,代码来源:IOManager.cpp
示例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;
}
开发者ID:vitmod,项目名称:vdr-plugin-robotv,代码行数:34,代码来源:robotvchannels.cpp
示例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;
}
开发者ID:RonBarabash,项目名称:OS132-Ass2,代码行数:25,代码来源:buffer.c
示例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);
}
开发者ID:zeno40,项目名称:convnet,代码行数:7,代码来源:mkldnn_memory.hpp
示例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 );
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:33,代码来源:IOManager.cpp
示例16: reorder
void PixelMappingCircle::startNewFunction(int newIdFunction, int perno)
{
reorder(newIdFunction, perno);
idFunction = newIdFunction;
active = true;
rectPos.x = -1;
}
开发者ID:mauro-ferrario,项目名称:MagicLightCircle,代码行数:7,代码来源:PixelMappingCircle.cpp
示例17: while
/** Renumber the nodes to make lookups use CPU and disk caches more effectively.
*
* First group the nodes into blocks so that each block contains the
* root of a subtrie and as many levels of its descendants as will fit.
* This way, after the root is paged in, the next few lookup
* steps need not page in anything else. Then, sort the nodes of each
* block in depth-first order. That should give each lookup almost
* 1/2 chance to find the next node immediately adjacent.
*
* With a block size of 1024 bytes, this renumbering reduces the time
* required for random lookups by about 1.1%, compared to a plain
* depth-first order. However, it's still 2.3% slower than the
* database optimized by MaxMind. */
void
binary_trie::reorder_in_blocks(
std::size_t bytes_per_block)
{
const edge_type none = -1;
std::vector<edge_type> old_to_new, new_to_old;
size_t bytes_left = bytes_per_block;
old_to_new.resize(nodes.size(), none);
new_to_old.reserve(nodes.size());
for (edge_type subtrie = 0; subtrie < nodes.size(); ++subtrie) {
// If subtrie has already been added to the output, ignore it.
if (old_to_new[subtrie] != none)
continue;
// Walk breadth-first from subtrie until we have a
// block full of nodes or the subtrie runs out.
// Don't add these nodes immediately to the output, however.
// Instead just list them in nodes_in_block.
std::set<edge_type> nodes_in_block;
std::queue<edge_type> breadth_first;
breadth_first.push(subtrie);
if (bytes_left <= 0)
bytes_left += bytes_per_block;
while (bytes_left > 0 && !breadth_first.empty()) {
edge_type edge = breadth_first.front();
breadth_first.pop();
if (edge >= nodes.size())
continue;
// Let the last node of the block straddle the
// block boundary. That's better than making
// the hotter first node do so.
bytes_left -= 6;
nodes_in_block.insert(edge);
breadth_first.push(nodes[edge].edges[0]);
breadth_first.push(nodes[edge].edges[1]);
}
// Add the nodes from nodes_in_block to the output in depth-first order.
// This assumes they are all reachable from subtrie.
std::stack<edge_type> depth_first;
depth_first.push(subtrie);
while (!depth_first.empty()) {
edge_type edge = depth_first.top();
depth_first.pop();
if (nodes_in_block.find(edge)
== nodes_in_block.end())
continue;
old_to_new[edge] = new_to_old.size();
new_to_old.push_back(edge);
depth_first.push(nodes[edge].edges[1]);
depth_first.push(nodes[edge].edges[0]);
}
}
reorder(old_to_new, new_to_old);
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:72,代码来源:GeoIP.csv2dat.cpp
示例18: reorder
void Line::del_driver( Driver& d )
{
auto driver_iter = std::find(drivers_->begin(),drivers_->end(),d);
if (driver_iter != drivers_->end()) {
drivers_->erase(driver_iter);
}
reorder();
}
开发者ID:canyudeguang,项目名称:TrafficLight,代码行数:8,代码来源:Line.cpp
示例19: main
int main (int argc, char const * argv [])
{
static char const * optv [] =
{
"cdst",
PUTOPTV_S_FUNNEL,
"enumerate html/xhtml/xml document fragments",
"c\tprint CSS stylesheet on stdout",
"d\tprint document as text",
"s\tprint document as stream",
"t\tprint document as tree",
(char const *)(0)
};
struct node node;
void (* xmldump) (struct node const *) = xmlindent;
signed c;
while (~ (c = getoptv (argc, argv, optv)))
{
switch (c)
{
case 'c':
xmldump = csstree;
break;
case 'd':
xmldump = xmlindent;
break;
case 's':
xmldump = xmlstream;
break;
case 't':
xmldump = xmltree;
break;
default:
break;
}
}
argc -= optind;
argv += optind;
if (!argc)
{
error (1, ENOTSUP, "No filenames given!");
}
while ((argc) && (* argv))
{
xmlread (& node, * argv);
xmlscan (& node);
reorder (& node);
xmldump (& node);
xmlfree (& node);
argc--;
argv++;
}
return (0);
}
开发者ID:wol22,项目名称:MotleyTools,代码行数:55,代码来源:xml.c
示例20: reorder
ListNode* reorder(ListNode *head, bool flag) {
if (!head) return head;
if (flag) {
head->next = reorder(head->next, !flag);
return head;
} else {
ListNode *p = head, *prev = NULL;
while (p->next) {
prev = p;
p = p->next;
}
if (prev) {
prev->next = NULL;
p->next = reorder(head, !flag);
return p;
} else {
return head;
}
}
}
开发者ID:Lawrenceh,项目名称:AC_Monster,代码行数:20,代码来源:143.+Reorder+List.cpp
注:本文中的reorder函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论