本文整理汇总了C++中Table::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Table::add方法的具体用法?C++ Table::add怎么用?C++ Table::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_lmk_params
void print_lmk_params()
{
#define LMK_DIR "/sys/module/lowmemorykiller/parameters/"
puts("Low-memory killer parameters:\n");
int notify_pages = str_to_int(read_whole_file(LMK_DIR "notify_trigger"), -1);
printf(" notify_trigger %d KB\n", pages_to_kb(notify_pages));
putchar('\n');
vector<int> oom_adjs;
{
stringstream ss(read_whole_file(LMK_DIR "adj"));
string item;
while (getline(ss, item, ',')) {
oom_adjs.push_back(str_to_int(item, -1));
}
}
vector<int> minfrees;
{
stringstream ss(read_whole_file(LMK_DIR "minfree"));
string item;
while (getline(ss, item, ',')) {
minfrees.push_back(pages_to_kb(str_to_int(item, -1)));
}
}
Table t;
t.start_row();
t.add("oom_adj");
t.add("min_free", Table::ALIGN_LEFT);
for (size_t i = 0; i < max(oom_adjs.size(), minfrees.size()); i++) {
t.start_row();
if (i < oom_adjs.size()) {
t.add(oom_adjs[i]);
} else {
t.add("");
}
if (i < minfrees.size()) {
t.add_fmt("%d KB", minfrees[i]);
} else {
t.add("");
}
}
t.print_with_indent(2);
#undef LMK_DIR
}
示例2: setupPulseDemo
void setupPulseDemo(ECA& eca) {
enable(eca, false);
flush(eca);
Table table;
//add rules for double pulse __--_____----___
table.add(TableEntry(EVT_DPULSE, OFFS0, MS_CH0_HI | MS_CH1_HI, CH_LVDS, 64));
table.add(TableEntry(EVT_DPULSE, OFFS1, MS_CH0_LO | MS_CH1_LO, CH_LVDS, 64));
table.add(TableEntry(EVT_DPULSE, OFFS2, MS_CH0_HI | MS_CH1_HI, CH_LVDS, 64));
table.add(TableEntry(EVT_DPULSE, OFFS3, MS_CH0_LO | MS_CH1_LO, CH_LVDS, 64));
//add rules for single pulses __--__
table.add(TableEntry(EVT_PULSE0, 0, MS_CHX_HI , CH_LVDS, 64));
table.add(TableEntry(EVT_PULSE0, 40/8, MS_CHX_LO , CH_LVDS, 64));
table.add(TableEntry(EVT_PULSE1, 0, MS_CH0_HI | MS_CH1_HI, CH_LVDS, 64));
table.add(TableEntry(EVT_PULSE1, 40/8, MS_CH0_LO | MS_CH1_LO, CH_LVDS, 64));
table.add(TableEntry(EVT_PULSEALL, 0, MS_CHX_HI, CH_LVDS, 64));
table.add(TableEntry(EVT_PULSEALL, 40/8, MS_CHX_LO, CH_LVDS, 64));
commit(eca, table);
//dump(eca)
//commit and arm
activate(eca, CH_LVDS);
enable(eca, true);
}
示例3: add
void TableMgr::add(int key, int gui_num, bool eye, bool chi)
{
Table* tbl = 0;
if(chi)
{
if(eye)
{
tbl = m_check_eye_table[gui_num];
}
else
{
tbl = m_check_table[gui_num];
}
}
else
{
if(eye)
{
tbl = m_check_feng_eye_table[gui_num];
}
else
{
tbl = m_check_feng_table[gui_num];
}
}
tbl->add(key);
}
示例4: setup
// inintialies everything
void setup(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST); // Enable depth testing.
// soposed to make stuff purdy
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_LINE_SMOOTH);
// bunch of bullet stuff
// Build the broadphase
broadphase = new btDbvtBroadphase();
// Set up the collision configuration and dispatcher
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
// The actual physics solver
solver = new btSequentialImpulseConstraintSolver;
// The world.
dynamicsWorld =
new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
dynamicsWorld->setGravity(btVector3(0,-20,0));
dynamicsWorld->setInternalTickCallback(myTickCallback);
// adds all objects to the simulation world
cup.add(dynamicsWorld);
table.add(dynamicsWorld);
rackBalls();
timer.start_clock();
}
示例5:
void
b2g_ps_add_table_headers(Table& t, bool show_threads)
{
t.start_row();
t.add("NAME");
t.add(show_threads ? "TID" : "PID");
t.add("PPID");
t.add("CPU(s)");
t.add("NICE");
t.add("USS");
t.add("PSS");
t.add("RSS");
t.add("VSIZE");
t.add("OOM_ADJ");
t.add("USER", Table::ALIGN_LEFT);
}
示例6: main
int main(int argc, const char** argv) {
Socket socket;
Device device;
MyHandler handler;
/* Setup connection to FPGA via PCIe */
socket.open();
socket.passive("dev/wbs0");
device.open(socket, "dev/wbm0");
/* Find the ECA */
std::vector<ECA> ecas;
ECA::probe(device, ecas);
assert (ecas.size() == 1);
ECA& eca = ecas[0];
assert (eca.channels.size() >= 2);
assert (!eca.channels[1].queue.empty());
handler.eca = &eca;
handler.aq = &eca.channels[1].queue.front();
/* Stop the ECA for now */
eca.disable(true);
eca.channels[1].drain(true);
/* Program a catch all to channel 1 rule */
Table table;
table.add(TableEntry(0, 0, 0xdeadbeef, 1, 0));
eca.store(table);
eca.flipTables();
/* Flush any crap pending in the AQ */
ActionEntry ae;
while (1) {
handler.aq->refresh();
if (!handler.aq->queued_actions) break;
handler.aq->pop(ae);
}
/* Hook arrival interrupts via PCIe */
std::vector<struct sdb_device> devs;
device.sdb_find_by_identity(0x651, 0x8a670e73, devs);
assert (devs.size() == 1);
mydevice.sdb_component.addr_first = devs[0].sdb_component.addr_first;
mydevice.sdb_component.addr_last = devs[0].sdb_component.addr_last;
socket.attach(&mydevice, &handler);
/* Enable interrupt delivery to us */
handler.aq->hook_arrival(true, mydevice.sdb_component.addr_first);
eca.channels[1].freeze(false);
eca.channels[1].drain(false);
eca.interrupt(true);
eca.disable(false);
/* Wait forever, pumping out the actions as they arrive */
while (true) socket.run();
return 0;
}
示例7: main
int main()
{
Table aTable;
Student s1("G30", 3.6);
Student s2("G50", 3.9);
Student s3("G40", 3.5);
Student s4("G10", 3.8);
aTable.add(s1.getId(), s1);
aTable.add(s2.getId(), s2);
aTable.add(s3.getId(), s3);
aTable.add(s4.getId(), s4);
aTable.listAll();
return 0;
}
示例8: initOutput
void Parallel::initOutput() {
if (output == NULL) {
output = new Table();
}
Table* out = (Table*)output;
out->clearNoDelete();
for (uint32_t i = 0; i < network_->size(); i++) {
out->add((Tensor<float>*)(*network_)[i]->output);
}
}
示例9: initOutput
void ParallelTable::initOutput() {
if (output == nullptr) {
output.reset(new Table());
}
Table* out = (Table*)output.get();
out->clear();
for (uint32_t i = 0; i < network_.size(); i++) {
out->add(network_[i]->output);
}
}
示例10: main
//.........这里部分代码省略.........
}
else
{
fprintf(stdout, "%s: succeeded to open %s (status %s)\n", argv[0], argv[1], eb_status(status));
}
/* Find the ECA */
ECA::probe(device, ecas);
if (ecas.size() == 1)
{
fprintf(stdout, "%s: found one eca unit!\n", argv[0]);
}
else
{
fprintf(stdout, "%s: missing eca unit!\n", argv[0]);
return 1;
}
ECA& eca = ecas[0];
/* Find the TLU */
TLU::probe(device, tlus);
assert (tlus.size() == 1);
TLU& tlu = tlus[0];
/* Configure the TLU to record rising edge timestamps */
tlu.hook(-1, false);
tlu.set_enable(false); // no interrupts, please
tlu.clear(-1);
tlu.listen(-1, true, true, 8); /* Listen on all inputs */
/* Find the IO reconfig to enable/disable outputs to specific IOs */
std::vector<sdb_device> devs;
device.sdb_find_by_identity(0x651, 0x4d78adfdU, devs);
assert (devs.size() == 1);
address_t ioconf = devs[0].sdb_component.addr_first;
device.write(ioconf, EB_DATA32, uIOConfig);
/* Show time */
eca.refresh();
fprintf(stdout, "%s: time (fmt): %s\n", argv[0], eca.date().c_str());
fprintf(stdout, "%s: time (hex): 0x%"PRIx64"\n", argv[0], eca.time);
/* Configure ECA to create IO pulses on GPIO and LVDS */
eca.channels[0].drain(false); // GPIO
eca.channels[1].drain(true); // PCIe
eca.channels[2].drain(true); // LVDS
eca.channels[0].freeze(false);
eca.channels[1].freeze(false);
eca.channels[2].freeze(false);
eca.disable(true);
eca.interrupt(false);
/* Build table */
for (int i = 0; i < EVENTS*EVENT_MULTI; ++i)
{
table.add(TableEntry(0xdeadbeef, i*(HIGH_NS+LOW_NS)/8, (0x1<<uShiftPosition), 0, 64));
table.add(TableEntry(0xdeadbeef, i*(HIGH_NS+LOW_NS)/8+(HIGH_NS/8), (0x1<<(uShiftPosition+16)), 0, 64));
/* Take care on shift position */
if(uShiftPosition==EVENTS-1) { uShiftPosition=0; }
else { uShiftPosition++; }
}
/* Manage ECA */
eca.store(table);
eca.flipTables();
eca.disable(false);
eca.refresh();
示例11: main
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
Window *main_window = new Window();
main_window->resize(-1,-1);
VBox *main_vbox = new VBox();
HBox *menu_hbox = new HBox();
pixbuf = new Pixbuf();
pixbuf->set_scale(5);
image = new Image();
image->set_from_pixbuf(pixbuf);
menu_hbox->add(image, 1, 1, 0);
VBox *s_vbox = new VBox();
Label *label = new Label("Sąsiedztwo: ");
s_vbox->add(label, 1, 1, 0);
Table *table = new Table();
s_vbox->add(table, 0, 0, 0);
for(int y = 0; y < 3; y++)
{
for(int x = 0; x < 3; x++)
{
sasiedztwo[x][y] = new ToggleButton();
sasiedztwo[x][y]->set_label(std::to_string(x + (y * 3) + 1));
if(x == 1 && y == 1)
{
table->add(new Label("x"), x, y, x + 1, y + 1);
continue;
};
table->add(sasiedztwo[x][y], x, y, x + 1, y + 1);
};
};
Label *label2 = new Label(" ");
s_vbox->add(label2, 1, 1, 0);
menu_hbox->add(s_vbox, 0, 0, 0);
main_vbox->add(menu_hbox, 1, 1, 0);
Button *start_button = new Button("Start");
start_button->set_on_clicked(line_fill);
main_vbox->add(start_button, 0, 0, 0);
Button *stop_button = new Button("Stop");
stop_button->set_on_clicked(stop);
main_vbox->add(stop_button, 0, 0, 0);
main_window->add(main_vbox);
clear_image(main_window->get_ref(), 0);
main_window->show();
g_timeout_add(50, refresh_screen, 0);
gtk_main();
return 0;
};
示例12: putchar
int
print_b2g_info(bool show_threads)
{
// TODO: switch between kb and mb for RSS etc.
// TODO: Sort processes?
Table t;
// This sits atop USS/PSS/RSS/VSIZE.
t.multi_col_header("megabytes", 3, 7);
if (!show_threads) {
b2g_ps_add_table_headers(t, /* show_threads */ false);
}
for (vector<Process*>::const_iterator it =
ProcessList::singleton().b2g_processes().begin();
it != ProcessList::singleton().b2g_processes().end(); ++it) {
if (show_threads) {
b2g_ps_add_table_headers(t, /* show_threads */ true);
}
Process* p = *it;
t.start_row();
t.add(p->name());
t.add(p->pid());
t.add(p->ppid());
t.add_fmt("%0.1f", p->stime_s() + p->utime_s());
t.add(p->nice());
t.add_fmt("%0.1f", p->uss_mb());
t.add_fmt("%0.1f", p->pss_mb());
t.add_fmt("%0.1f", p->rss_mb());
t.add_fmt("%0.1f", p->vsize_mb());
t.add(p->oom_adj());
t.add(p->user(), Table::ALIGN_LEFT);
if (show_threads) {
for (vector<Thread*>::const_iterator thread_it =
p->threads().begin();
thread_it != p->threads().end(); ++thread_it) {
t.start_row();
Thread* thread = *thread_it;
t.add(thread->name());
t.add(thread->tid());
t.add(thread->nice());
}
if (it + 1 != ProcessList::singleton().b2g_processes().end()) {
t.add_delimiter();
}
}
}
t.print();
putchar('\n');
print_system_meminfo();
putchar('\n');
print_lmk_params();
return 0;
}
示例13: print_system_meminfo
void print_system_meminfo()
{
// We can't use sysinfo() here because iit doesn't tell us how much cached
// memory we're using. (On B2G, this is often upwards of 30mb.)
//
// Instead, we have to parse /proc/meminfo.
FILE* meminfo = fopen("/proc/meminfo", "r");
if (!meminfo) {
perror("Couldn't open /proc/meminfo");
return;
}
// These are all in kb.
int total = -1;
int free = -1;
int buffers = -1;
int cached = -1;
char line[256];
while(fgets(line, sizeof(line), meminfo)) {
if (sscanf(line, "MemTotal: %d kB", &total) == 0 &&
sscanf(line, "MemFree: %d kB", &free) == 0 &&
sscanf(line, "Buffers: %d kB", &buffers) == 0 &&
sscanf(line, "Cached: %d kB", &cached)) {
// These four values should appear first in meminfo, so if this line
// doesn't match any of them, we're done parsing.
break;
}
}
fclose(meminfo);
if (total == -1 || free == -1 || buffers == -1 || cached == -1) {
fprintf(stderr, "Unable to parse /proc/meminfo.\n");
return;
}
int actually_used = total - free - buffers - cached;
puts("System memory info:\n");
Table t;
t.start_row();
t.add("Total");
t.add_fmt("%0.1f MB", kb_to_mb(total));
t.start_row();
t.add("Used - cache");
t.add_fmt("%0.1f MB", kb_to_mb(total - free - buffers - cached));
t.start_row();
t.add("B2G procs (PSS)");
int b2g_mem_kb = 0;
for (vector<Process*>::const_iterator it = ProcessList::singleton().b2g_processes().begin();
it != ProcessList::singleton().b2g_processes().end(); ++it) {
b2g_mem_kb += (*it)->pss_kb();
}
t.add_fmt("%0.1f MB", b2g_mem_kb / 1024.0);
t.start_row();
t.add("Non-B2G procs");
t.add_fmt("%0.1f MB", kb_to_mb(total - free - buffers - cached - b2g_mem_kb));
t.start_row();
t.add("Free + cache");
t.add_fmt("%0.1f MB", kb_to_mb(free + buffers + cached));
t.start_row();
t.add("Free");
t.add_fmt("%0.1f MB", kb_to_mb(free));
t.start_row();
t.add("Cache");
t.add_fmt("%0.1f MB", kb_to_mb(buffers + cached));
t.print_with_indent(2);
}
示例14: deleteQuery
void Database::deleteQuery(string queryCmd) {
// create necessary tables
Table returnTable = Table();
Table tableFrom = Table();
// get the indicies of the starting positions of the three parts of the query
int select_i = -1, from_i = -1, where_i = -1;
for (int i = 0; i < queryCmd.length(); i ++) {
if (queryCmd.substr(i,6).compare("SELECT") == 0) select_i = i + 6;
if (queryCmd.substr(i,4).compare("FROM") == 0) from_i = i + 4;
if (queryCmd.substr(i,5).compare("WHERE") == 0) where_i = i + 5;
}
// build a string vector of the attributes to return
string attrTemp = "";
vector<string> attrStrings;
for (int i = select_i; i < from_i - 4; i ++) {
if (queryCmd.substr(i,1).compare(",") != 0) attrTemp += queryCmd.substr(i,1);
if (queryCmd.substr(i,1).compare(",") == 0 || i == from_i - 4 - 1) {
trimWS(attrTemp);
attrStrings.push_back(attrTemp);
attrTemp = "";
}
}
// get the table to select from
string tableFromName = queryCmd.substr(from_i + 1, where_i - 5 - from_i - 2);
bool found = false;
for (int i = 0; i < getTables().size(); i ++) {
if (getTables()[i].getName().compare(tableFromName) == 0) {
tableFrom = Table(getTables()[i]);
found = true;
}
}
if (!found) throw Database_exception("Couldn't find the table specified [" + tableFromName + "]");
// put those attributes in returnTable
for (int i = 0; i < tableFrom.getAttributes().size(); i ++) {
returnTable.add(tableFrom.getAttributes()[i]);
}
// remove unessecary attributes
for (int i = 0; i < returnTable.getAttributes().size(); i ++) {
bool goodAttr = false;
for (int j = 0; j < attrStrings.size(); j ++) {
if (returnTable.getAttributes()[i].getAttribute().compare(attrStrings[j]) == 0 || attrStrings[0].compare("*") == 0) goodAttr = true;
}
if (!goodAttr) returnTable.deleteATT(returnTable.getAttributes()[i].getAttribute());
}
// at this point, returnTable has the correct aTTs, and fromTable is the table we're selecting from
// convert the where clause into postfix
string exp = queryCmd.substr(where_i + 1,queryCmd.length() - where_i);
queue<string> postfix = expressionToPostfix(exp);
// for each record, evaluate the postfix exp for it's values, then add it to the returnTable if it's true
for (int i = 0; i < tableFrom.getSize(); i ++) {
Record testRecord = tableFrom[i];
queue<string> testPostfix = postfix;
stack<string> t_stack;
while (!testPostfix.empty()) {
string token = testPostfix.front();
testPostfix.pop();
// if its a value, move it to the stack
if (!isOp(token)) t_stack.push(token);
// its an operator, pop off two values and evaluate them
else {
string op2 = t_stack.top();
t_stack.pop();
string op1 = t_stack.top();
t_stack.pop();
// evaluate
if (token.compare("=") == 0) {
t_stack.push(evalE(op1,op2, tableFrom, testRecord));
} else if (token.compare(">") == 0) {
t_stack.push(evalG(op1,op2, tableFrom, testRecord));
} else if (token.compare("<") == 0) {
t_stack.push(evalL(op1,op2, tableFrom, testRecord));
} else if (token.compare("!=") == 0) {
t_stack.push(evalNE(op1,op2, tableFrom, testRecord));
} else if (token.compare(">=") == 0) {
t_stack.push(evalGE(op1,op2, tableFrom, testRecord));
} else if (token.compare("<=") == 0) {
t_stack.push(evalLE(op1,op2, tableFrom, testRecord));
} else if (token.compare("&&") == 0) {
t_stack.push(evalA(op1,op2, tableFrom, testRecord));
} else if (token.compare("||") == 0) {
t_stack.push(evalO(op1,op2, tableFrom, testRecord));
} else throw Database_exception("Evaluation failed, likely bad query string");
}
}
//.........这里部分代码省略.........
示例15: main
int main()
{
Test test;
QTest::qExec(&test);
printf("\n\n\n");
Table *t = new Table;
char choice = '-';
char s[100];
HashFunc *f1 = new Func1;
HashFunc *f2 = new Func2;
while(choice != '0')
{
printf("0 - Exit\n");
printf("1 - Add string\n");
printf("2 - Del string\n");
printf("3 - Show stats\n");
printf("4 - Search string\n");
printf("5 - Select hash-function\n");
choice = getc(stdin);
getc(stdin);
printf("\n");
if (choice == '1')
{
printf("Enter the string: ");
fgets(s, 200, stdin);
t->add(s);
printf("\n\n");
}
else if (choice == '2')
{
printf("Enter the string: ");
fgets(s, 200, stdin);
t->del(s);
printf("\n\n");
}
else if (choice == '3')
{
printf("Enter the string: ");
fgets(s, 200, stdin);
if(t->exist(s))
printf("Yes");
else
printf("No");
printf("\n\n");
}
else if (choice == '4')
{
printf("Numer of cells: %i\n", t->cells());
t->stats();
printf("Load factor is %lf\n", t->loadFactor);
printf("Number of conflicts is %i\n", t->conflicts);
printf("Maximum length of conflict is %i\n\n", t->lconf);
}
else if (choice == '5')
{
printf("Enter the number of func (1/2): ");
char c = '-';
c = getc(stdin);
getc(stdin);
if (c == '1')
t->changeFunc(f1);
else if (c == '2')
t->changeFunc(f2);
}
}
delete t;
return 0;
}