本文整理汇总了C++中R_MAX函数的典型用法代码示例。如果您正苦于以下问题:C++ R_MAX函数的具体用法?C++ R_MAX怎么用?C++ R_MAX使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_MAX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFontValues
void setFontValues(struct Tracker_Windows *window){
double width3 = R_MAX(get_text_width("D#6"), R_MAX(get_text_width("MUL"), get_text_width("STP")));
window->fontwidth = (int)ceil(width3/3.0);
window->fontheight = get_text_height("D#6");
//window->fontheight = pango_font_description_get_size(font_description)/PANGO_SCALE;
window->org_fontheight = window->fontheight;
}
示例2: TRACK_get_max_pitch
float TRACK_get_max_pitch(const struct Tracks *track){
float max_pitch = -1;
int num_pitches = 0;
{
struct Notes *note = track->notes;
while(note!=NULL){
max_pitch = R_MAX(note->note, max_pitch);
num_pitches ++;
struct Pitches *pitch = note->pitches;
while(pitch != NULL){
max_pitch = R_MAX(pitch->note, max_pitch);
num_pitches ++;
pitch = NextPitch(pitch);
}
note = NextNote(note);
}
}
if (num_pitches==0)
return -1;
else
return max_pitch;
}
示例3: r_diff_buffers_distance_myers
// Eugene W. Myers' O(ND) diff algorithm
// Returns edit distance with costs: insertion=1, deletion=1, no substitution
R_API bool r_diff_buffers_distance_myers(RDiff *diff, const ut8 *a, ut32 la, const ut8 *b, ut32 lb, ut32 *distance, double *similarity) {
const bool verbose = diff ? diff->verbose: false;
if (!a || !b) {
return false;
}
const ut32 length = la + lb;
const ut8 *ea = a + la, *eb = b + lb;
// Strip prefix
for (; a < ea && b < eb && *a == *b; a++, b++) {}
// Strip suffix
for (; a < ea && b < eb && ea[-1] == eb[-1]; ea--, eb--) {}
la = ea - a;
lb = eb - b;
ut32 *v0, *v;
st64 m = (st64)la + lb, di = 0, low, high, i, x, y;
if (m + 2 > SIZE_MAX / sizeof (st64) || !(v0 = malloc ((m + 2) * sizeof (ut32)))) {
return false;
}
v = v0 + lb;
v[1] = 0;
for (di = 0; di <= m; di++) {
low = -di + 2 * R_MAX (0, di - (st64)lb);
high = di - 2 * R_MAX (0, di - (st64)la);
for (i = low; i <= high; i += 2) {
x = i == -di || (i != di && v[i-1] < v[i+1]) ? v[i+1] : v[i-1] + 1;
y = x - i;
while (x < la && y < lb && a[x] == b[y]) {
x++;
y++;
}
v[i] = x;
if (x == la && y == lb) {
goto out;
}
}
if (verbose && di % 10000 == 0) {
eprintf ("\rProcessing dist %" PFMT64d " of max %" PFMT64d "\r", di, m);
}
}
out:
if (verbose) {
eprintf ("\n");
}
free (v0);
//Clean up output on loop exit (purely aesthetic)
if (distance) {
*distance = di;
}
if (similarity) {
*similarity = length ? 1.0 - (double)di / length : 1.0;
}
return true;
}
示例4: SetCursorPosConcrete
bool SetCursorPosConcrete(
struct Tracker_Windows *window,
struct WBlocks *wblock,
NInt tracknum,
int subtrack
){
struct WTracks *wtrack;
int ret=0,tempret;
if(tracknum>=wblock->block->num_tracks || tracknum<TEMPOTRACK) return false;
if(tracknum<0){
if(tracknum==window->curr_track) return true;
if(tracknum>window->curr_track){
while(window->curr_track!=tracknum){
tempret=CursorRight(window,wblock);
ret=R_MAX(tempret,ret);
}
}else{
while(window->curr_track!=tracknum){
tempret=CursorLeft(window,wblock);
ret=R_MAX(tempret,ret);
}
}
}else{
wtrack=ListFindElement1(&wblock->wtracks->l,tracknum);
int num_subtracks = GetNumSubtracks(wtrack);
subtrack=R_MIN(num_subtracks-1,subtrack);
if(tracknum==window->curr_track && subtrack==window->curr_track_sub)
return 0;
if(tracknum>window->curr_track || (tracknum==window->curr_track && subtrack>window->curr_track_sub)){
while(window->curr_track!=tracknum || window->curr_track_sub!=subtrack){
tempret=CursorRight(window,wblock);
//printf("wtrack->num: %d, curr_track: %d, num_tracks: %d\n",wtrack->l.num, window->curr_track,wblock->block->num_tracks);
ret=R_MAX(tempret,ret);
}
}else{
while(window->curr_track!=tracknum || window->curr_track_sub!=subtrack){
tempret=CursorLeft(window,wblock);
ret=R_MAX(tempret,ret);
}
}
}
return true;
}
示例5: InsertLines_notes
void InsertLines_notes(
void *tonote,
struct ListHeader3 *l,
int line,
int toinsert
){
struct Notes *note=(struct Notes *)l;
struct Blocks *block=blocktobelongtoforinsertlines_notes_a_terrible_hack;
Place p2;
PlaceSetLastPos(block,&p2);
// p2.line-=toinsert;
// printf("toinsert: %d, note->end.line: %d, p2->line: %d\n",toinsert,note->end.line,p2.line);
if(note->end.line>=line){
// printf("block: %d, note->end.line: %d, p2->line: %d\n",block->l.num,note->end.line,p2.line);
if(PlaceGreaterOrEqual(¬e->end,&p2) && note->l.p.line<line){
PlaceSetLastPos(block,&p2);
PlaceCopy(¬e->end,&p2);
note->noend=1;
}else{
note->end.line+=toinsert;
note->end.line=R_MAX(note->end.line,line);
}
List_InsertLines3(¬e->velocities,¬e->velocities->l,line,toinsert,NULL);
List_InsertLines3(¬e->pitches,¬e->pitches->l,line,toinsert,NULL);
}
}
示例6: sdb_fmt_tobin
// TODO: return false if array length != fmt length
SDB_API int sdb_fmt_tobin(const char *_str, const char *fmt, void *stru) {
int n, idx = 0;
char *next, *str, *ptr, *word, *e_str;
if (!_str || !*_str || !fmt)
return 0;
str = ptr = strdup (_str);
for (; *fmt; fmt++) {
word = sdb_anext (ptr, &next);
if (!word || !*word)
break;
n = 4; // ALIGN
switch (*fmt) {
case 'b': *((ut8*)(stru + idx)) = (ut8)sdb_atoi (word); break;
case 'd': *((int*)(stru + idx)) = (int)sdb_atoi (word); break;
case 'q': *((ut64*)(stru + idx)) = sdb_atoi (word); n=8; break;
case 'h': *((short*)(stru + idx)) = (short)sdb_atoi (word); break;
case 's':
e_str = (char*)sdb_decode (word, 0);
*((char**)(stru + idx)) = (char*)strdup (e_str?e_str:word);
free (e_str);
break;
case 'z':
*((char**)(stru + idx)) = (char*)strdup (word);
break;
case 'p': *((void**)(stru + idx)) = (void*)(size_t)sdb_atoi (word);
break;
}
idx += R_MAX((long)sizeof (void*), n); // align
if (!next)
break;
ptr = next;
}
free (str);
return 1;
}
示例7: AddStopsElements
void AddStopsElements(
struct Tracker_Windows *window,
struct WBlocks *wblock,
struct WTracks *wtrack
){
int realline = 0;
struct Stops *stop=wtrack->track->stops;
while(stop!=NULL){
realline=FindRealLineFor(wblock,R_MAX(stop->Tline,realline),&stop->l.p);
int subrealline=FindSubRealLine(window,wblock,realline,&stop->l.p);
InsertTRLElementS(
wtrack,
NULL,
realline,
TRE_STOPLINE,0,
(float)subrealline,(float)subrealline,0.0f,(float)(wtrack->fxwidth-2),
stop
);
if(wtrack->trackreallines[realline].note!=0){
wtrack->trackreallines[realline].note=NOTE_MUL;
}else{
wtrack->trackreallines[realline].note=NOTE_STP;
}
wtrack->trackreallines[realline].dasnote=NULL;
stop=NextStop(stop);
}
}
示例8: r_debug_pid_list
// TODO: deprecate list/iterate functions from core apis? keep them for easiness?
R_API int r_debug_pid_list(RDebug *dbg, int pid, char fmt) {
RList *list;
RListIter *iter;
RDebugPid *p;
if (dbg && dbg->h && dbg->h->pids) {
list = dbg->h->pids (R_MAX (0, pid));
if (list == NULL)
return R_FALSE;
if (fmt == 'j')
dbg->cb_printf ("[");
r_list_foreach (list, iter, p) {
switch (fmt) {
case 'j':
dbg->cb_printf ("{\"pid\":%d,"
"\"status\":\"%c\","
"\"path\":\"%s\"}%s",
p->pid, p->status, p->path,
iter->n?",":"");
break;
default:
dbg->cb_printf (" %c %d %c %s\n",
dbg->pid==p->pid?'*':'-',
p->pid, p->status, p->path);
break;
}
}
if (fmt == 'j')
dbg->cb_printf ("]\n");
r_list_free (list);
}
示例9: Invert_notes
void Invert_notes(
struct Notes *note,
Place *p1,
Place *p2,
bool firsttime,
int last
){
int next=0;
if(note==NULL) return;
if(PlaceGreaterOrEqual(¬e->l.p,p1)){
if(PlaceGreaterOrEqual(¬e->l.p,p2)) return;
next=note->note;
if(firsttime==false){
note->note=R_MAX(1,R_MIN(127,2*last-note->note));
}else{
firsttime=false;
}
}
Invert_notes(NextNote(note),p1,p2,firsttime,next);
}
示例10: TRACK_get_min_and_max_pitches
bool TRACK_get_min_and_max_pitches(const struct Tracks *track, float *ret_min_pitch, float *ret_max_pitch){
float min_pitch = 10000.0f;
float max_pitch = -10000.0f;
int num_pitches = 0;
// find min_pitch and max_pitch
{
struct Notes *note = track->notes;
while(note!=NULL){
min_pitch = R_MIN(note->note, min_pitch);
max_pitch = R_MAX(note->note, max_pitch);
num_pitches ++;
struct Pitches *pitch = note->pitches;
while(pitch != NULL){
min_pitch = R_MIN(pitch->note, min_pitch);
max_pitch = R_MAX(pitch->note, max_pitch);
num_pitches ++;
pitch = NextPitch(pitch);
}
note = NextNote(note);
}
float pitch_range = max_pitch - min_pitch;
min_pitch = min_pitch - pitch_range/8.0f;
if(min_pitch < 0)
min_pitch = 0;
max_pitch = max_pitch + pitch_range/8.0f;
if(max_pitch >127)
max_pitch = 127;
}
if(min_pitch == 10000.0f)
return false;
else {
if (num_pitches>3) {
*ret_min_pitch = min_pitch;
*ret_max_pitch = max_pitch;
} else {
*ret_min_pitch = 0;
*ret_max_pitch = 128;
}
return true;
}
}
示例11: setFontValues
void setFontValues(struct Tracker_Windows *tvisual){
EditorWidget *editor=(EditorWidget *)tvisual->os_visual.widget;
editor->cursorbuffer_painter->setFont(editor->font);
//editor->paintbuffer_painter->setFont(editor->font);
GE_set_font(editor->font);
const QFont &font=editor->font;
QFontMetrics fm(font);
double width3 = R_MAX(fm.width("D#6"), R_MAX(fm.width("MUL"), fm.width("STP")));
tvisual->fontwidth = (int)(width3/3.0) + 1;
tvisual->org_fontheight = fm.height() - 1;
tvisual->fontheight = tvisual->org_fontheight;
}
示例12: setSize
void setSize(int size){
size = R_MAX(0, R_MIN(buffer_size-1, size));
if (size != iHslider0) {
iHslider0 = size;
if (can_pipe_instead == true)
can_pipe_instead = false;
}
}
示例13: create_data
void *create_plugin_data(const SoundPluginType *plugin_type, struct SoundPlugin *plugin, hash_t *state, float sample_rate, int block_size, bool is_loading){
const char *input_portnames[R_MAX(1, plugin_type->num_outputs)]; // R_MAX is here to make the undefined sanitizer be quiet
const char *output_portnames[R_MAX(1, plugin_type->num_inputs)]; // R_MAX is here to make the undefined sanitizer be quiet
int i;
for(i=0;i<plugin_type->num_outputs;i++)
input_portnames[i] = state==NULL ? NULL : HASH_get_chars_at(state, "input_portname",i);
for(i=0;i<plugin_type->num_inputs;i++)
output_portnames[i] = state==NULL ? NULL : HASH_get_chars_at(state, "output_portname",i);
return create_data(plugin_type,
(jack_client_t*)plugin_type->data,
plugin_type->num_inputs,
plugin_type->num_outputs,
input_portnames,
output_portnames
);
}
示例14: gdbr_write_memory
int gdbr_write_memory(libgdbr_t *g, ut64 address, const uint8_t *data, ut64 len) {
int ret = 0;
int command_len, pkt, max_cmd_len = 64;
ut64 num_pkts, last, data_sz;
char *tmp;
if (!g || !data) {
return -1;
}
g->stub_features.pkt_sz = R_MAX (g->stub_features.pkt_sz, 64);
data_sz = g->stub_features.pkt_sz / 2;
if (data_sz < 1) {
return -1;
}
num_pkts = len / data_sz;
last = len % data_sz;
if (!(tmp = calloc (max_cmd_len + g->stub_features.pkt_sz, sizeof (char)))) {
return -1;
}
for (pkt = num_pkts - 1; pkt >= 0; pkt--) {
if ((command_len = snprintf (tmp, max_cmd_len,
"%s%016"PFMT64x ",%"PFMT64x ":", CMD_WRITEMEM,
address + (pkt * data_sz), data_sz)) < 0) {
goto fail;
}
pack_hex ((char *) data + (pkt * data_sz), data_sz, (tmp + command_len));
if ((ret = send_msg (g, tmp)) < 0) {
goto fail;
}
if ((ret = read_packet (g)) < 0) {
goto fail;
}
if ((ret = handle_M (g)) < 0) {
goto fail;
}
}
if (last) {
if ((command_len = snprintf (tmp, max_cmd_len,
"%s%016"PFMT64x ",%"PFMT64x ":", CMD_WRITEMEM,
address + (num_pkts * data_sz), last)) < 0) {
goto fail;
}
pack_hex ((char *) data + (num_pkts * data_sz), last, (tmp + command_len));
if ((ret = send_msg (g, tmp)) < 0) {
goto fail;
}
if ((ret = read_packet (g)) < 0) {
goto fail;
}
if ((ret = handle_M (g)) < 0) {
goto fail;
}
}
free (tmp);
return 0;
fail:
free (tmp);
return -1;
}
示例15: CursorNextTrack
int CursorNextTrack(struct Tracker_Windows *window,struct WBlocks *wblock){
int curr_track=window->curr_track;
int ret=0,tempret;
while(curr_track==window->curr_track){
tempret=CursorRight(window,wblock);
ret=R_MAX(tempret,ret);
}
return ret;
}