本文整理汇总了C++中pre函数的典型用法代码示例。如果您正苦于以下问题:C++ pre函数的具体用法?C++ pre怎么用?C++ pre使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pre函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: input
void input()
{
pre();
int i;
printf("enter number of process\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter arrival time and head location of %d\n",i+1);
scanf("%d%d",&disk[i].arr_time,&disk[i].head_loc);
disk[i].process_pid=i+1;
done[i]=false;
}
printf("enter head position\n");
scanf("%d",&head_pos);
val=head_pos;
}
示例2: timestamp
/* time and memory management outputs */
void timestamp(const char* const fmt, ...)
{
pre(fmt != NULL);
va_list ap;
va_start(ap, fmt);
fflush(stdout);
fputc('\n', stderr);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
va_end(ap);
// fprintf(stderr, "%s\n", string);
time_t t1 = time(0);
fprintf(stderr, "%3.2f sec. elapsed\n", difftime(t1,t0));
fprintf(stderr, "--------------------------------------------\n");
}
示例3: isMatch
bool isMatch(string s, string p) {
int sLen = s.size(), pLen = p.size();
vector<bool> pre(pLen + 1, false), cur(pLen + 1, false);
pre[0] = true;
for (int pIter = 2; pIter <= pLen; pIter++) pre[pIter] = p[pIter - 1] == '*' && pre[pIter - 2];
for (int sIter = 1; sIter <= sLen; sIter++) {
cur[0] = false;
for (int pIter = 1; pIter <= pLen; pIter++) {
if (p[pIter - 1] == '*') cur[pIter] = cur[pIter - 2] || pre[pIter] && (s[sIter - 1] == p[pIter - 2] || p[pIter - 2] == '.');
else cur[pIter] = pre[pIter - 1] && (s[sIter - 1] == p[pIter - 1] || p[pIter - 1] == '.');
}
pre = cur;
}
return pre[pLen];
}
示例4: bindKeyDownEvent
void bimWorld::CameraManipulator::enableFirstPersonControl()
{
bindKeyDownEvent(KEY_W, beginMoveForward);
bindKeyUpEvent(KEY_W, endMoveForward);
bindKeyDownEvent(KEY_S, beginMoveBackward);
bindKeyUpEvent(KEY_S, endMoveBackward);
bindKeyDownEvent(KEY_A, beginMoveLeft);
bindKeyUpEvent(KEY_A, endMoveLeft);
bindKeyDownEvent(KEY_D, beginMoveRight);
bindKeyUpEvent(KEY_D, endMoveRight);
unbindMouseEvent(MIDDLE_MOUSE_BUTTON);
return;
//if (m_isFirstPersonManipEnabled)
// return;
//switchMatrixManipulator(ManipulatorType::Person);
//m_isFirstPersonManipEnabled = true;
//getBIMCameraManip()->setRotationHandleBtn(osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON);
//float totalFrame = 60.0f;
bimWorld::CameraOperation operation(getBIMCameraManip());
m_zoomForwardDelta = operation.getZoomDelta(totalFrame_FP);
std::function<void(float)> prefunc = [this/*, totalFrame*/](float frame){
//static int frame = 1;
//static float newF = 1;//-1 / totalFrame * frame*frame + frame;
bimWorld::CameraOperation operation(getBIMCameraManip());
operation.zoomForward(m_zoomForwardDelta, frame);
//if (newF < (totalFrame / 2.0f))
//{
// frame++;
// newF += frame;
//}
//else
//{
// frame--;
// newF -= frame;
//}
};
core::InstanceFunction<void(float)> pre(prefunc, this, "onPreEnableFirstPersonControl");
std::function<void(float)> postfunc = [](float){};
core::InstanceFunction<void(float)> post(postfunc, this, "onPostEnableFirstPersonControl");
m_host->_RenderingThreads()->setBlockAnimation((unsigned int)totalFrame_FP, pre, post);
}
示例5: look
int look()
{
pre();
printf("performing look\n\n");
int i,curr,j;
int tot_time=0;
int time_diff;
int time;
curr=head_pos;
time=0;
sort_headloc(disk,0,n-1);
while(1)
{
bool check =false;
for(i=0;i<n;i++)
if(done[i]==false)
check=true;
if(check==false)
break;
for(i=0;i<n;i++)
{
time_diff = disk[i].head_loc - head_pos;
if(time_diff + time >= disk[i].arr_time && done[i]==false)
{
done[i]=true;
printf("request serve for %d process\n",disk[i].process_pid);
time+=time_diff;
head_pos=disk[i].head_loc;
}
}
for(i=n-1;i>=0;i--)
{
time_diff = abs(head_pos-disk[i].head_loc);
if(time_diff + time >= disk[i].arr_time && done[i]==false)
{
done[i]=true;
printf("request serve for %d process\n",disk[i].process_pid);
time+=time_diff;
head_pos=disk[i].head_loc;
}
}
}
tot_time=time;
return tot_time;
}
示例6: func_hashtable
/* apply this function to every non-null bin in the hashtable */
void func_hashtable(hashtable* const hash,
void (*func)(bin* bin))
{
pre(func != NULL);
int i;
bin* iter;
bin* next;
for(i = 0; i < hash->size; i++){
iter = hash->bins[i];
while(iter){
next = iter->next;
func(iter);
iter = next;
}
}
}
示例7: PyObject_GetAttrString
EXPORT ICUException::ICUException(UParseError &pe, UErrorCode status)
{
PyObject *messages = PyObject_GetAttrString(PyExc_ICUError, "messages");
UnicodeString pre((const UChar *) pe.preContext, U_PARSE_CONTEXT_LEN);
UnicodeString post((const UChar *) pe.postContext, U_PARSE_CONTEXT_LEN);
PyObject *tuple = PyTuple_New(5);
ICUException::code = PyInt_FromLong((long) status);
PyTuple_SET_ITEM(tuple, 0, PyObject_GetItem(messages, code));
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(pe.line));
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(pe.offset));
PyTuple_SET_ITEM(tuple, 3, PyUnicode_FromUnicodeString(&pre));
PyTuple_SET_ITEM(tuple, 4, PyUnicode_FromUnicodeString(&post));
ICUException::msg = tuple;
Py_DECREF(messages);
}
示例8: isMatch
bool isMatch(const char *s, const char *p) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!s || !p || !initCheck(s, p))
return false;
if(!*p)
return !*s;
int len = strlen(p);
vector<bool> pre(len, false);
vector<bool> cur(len, false);
bool isFirst = true;
for(int i = 0; i < len; i++)
{
if(p[i] == '*')
pre[i] = (i == 0) || pre[i-1];
else if((*s == p[i] || p[i] == '?') && isFirst)
{
isFirst = false;
pre[i] = true;
}
else
break;
}
s++;
while(*s)
{
for(int i = 0; i < len; i++)
{
if(p[i] == '*')
{
cur[i] = pre[i] || (i != 0 && cur[i-1]);
}
else
{
cur[i] = (i != 0 && pre[i-1] && (p[i] == *s || p[i] == '?'));
}
}
pre.assign(cur.begin(), cur.end());
cur.assign(len, false);
s++;
}
return pre[len-1];
}
示例9: irg_walk_2_pre
/**
* specialized version of irg_walk_2, called if only pre callback exists
*/
static void irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void *env)
{
ir_graph *irg = get_irn_irg(node);
ir_visited_t visited = irg->visited;
set_irn_visited(node, visited);
pre(node, env);
if (!is_Block(node)) {
ir_node *pred = get_nodes_block(node);
if (pred->visited < visited)
irg_walk_2_pre(pred, pre, env);
}
foreach_irn_in_r(node, i, pred) {
if (pred->visited < visited)
irg_walk_2_pre(pred, pre, env);
}
}
示例10: longest_palindrome
// returns the center of the longest palindrome. for its length search for P[ans]
int longest_palindrome() {
pre();
int c=0; int r=0;
for(int i=1; i<N-1; i++) {
int mirror = 2*c-i;
P[i] = r>i ? min(r-i,P[mirror]) : 0;
while(A[i+1+P[i]]==A[i-1-P[i]])
P[i]++;
if(i+P[i] > r) {
c=i; r=i+P[i];
}
}
int maxlen=0; int centeri=0;
for(int i=1; i<n-1; i++) {
if(P[i]>maxlen) {
maxlen=P[i]; centeri=i;
}
}
return centeri;
}
示例11: main
int main() {
int cas, d;
cin >> cas;
for(int i = 0 ;i < cas;i ++) {
cin >> d;
a = 2013;
b = 3;
c = 24;
for(int f = 0 ; f < d;f++)
next();
printf("%d/%02d/%02d ", a, b, c);
a = 2013;
b = 3;
c = 24;
for(int f = 0 ; f < d;f++)
pre();
printf("%d/%02d/%02d\n", a, b, c);
}
return 0;
}
示例12: main
int main()
{
int i, n;
scanf("%d", &n);
getchar();
for(i=0; i<n; i++) {
char s[10];;
gets(s);
if(s[2] == '.') s[2]=0;
if(s[4] == '.') s[4]=0;
node[s[0]-'A'][0] = s[2];
node[s[0]-'A'][1] = s[4];
}
pre('A'); puts("");
in('A'); puts("");
post('A'); puts("");
return 0;
}
示例13: lookup_hashtable
/*look up the hash table to see an entry corresponding to the string of length
* len exists. Return the bin if it does exist*/
void* lookup_hashtable(hashtable* const hash,
const char* const name,
const int len)
{
pre(name != NULL);
uint32_t index = hashfunc(name, len);
index = index & hash->mask;
bin* iter = NULL;
bin* bin = NULL;
if(hash->bins[index] != NULL){
for(iter = hash->bins[index];iter; iter = iter->next){
if(strncmp(iter->name, name, len) == 0){
bin = iter;
}
}
}
return bin;
}
示例14: iterate_parallel_cluster
void
iterate_parallel_cluster(pccluster t, uint tname, uint pardepth,
void (*pre) (pccluster t, uint tname, void *data),
void (*post) (pccluster t, uint tname, void *data),
void *data)
{
uint *tname1, tname2;
#ifdef USE_OPENMP
uint nthreads; /* HACK: Solaris workaround */
#endif
uint i;
if (pre)
pre(t, tname, data);
if (t->sons > 0) {
tname1 = (uint *) allocmem((size_t) sizeof(uint) * t->sons);
tname2 = tname + 1;
for (i = 0; i < t->sons; i++) {
tname1[i] = tname2;
tname2 += t->son[i]->desc;
}
assert(tname2 == tname + t->desc);
#ifdef USE_OPENMP
nthreads = t->sons;
(void) nthreads;
#pragma omp parallel for if(pardepth > 0), num_threads(nthreads)
#endif
for (i = 0; i < t->sons; i++)
iterate_parallel_cluster(t->son[i], tname1[i],
(pardepth > 0 ? pardepth - 1 : 0), pre, post,
data);
freemem(tname1);
}
if (post)
post(t, tname, data);
}
示例15: configuration
nemo::Configuration
configuration(backend_t backend)
{
nemo::Configuration conf;
std::vector<float> pre(20);
std::vector<float> post(20);
for(unsigned i = 0; i < 20; ++i) {
int dt = i;
pre.at(i) = dwPre(-dt);
post.at(i) = dwPost(dt);
}
/* don't allow negative synapses to go much more negative.
* This is to avoid having large negative input currents,
* which will result in extra firing (by forcing 'u' to
* go highly negative) */
conf.setStdpFunction(pre, post, -0.5, 2*initWeight);
setBackend(backend, conf);
return conf;
}