本文整理汇总了C++中IN_RANGE函数的典型用法代码示例。如果您正苦于以下问题:C++ IN_RANGE函数的具体用法?C++ IN_RANGE怎么用?C++ IN_RANGE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IN_RANGE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detectBoundaries
void Duck::detectBoundaries()
{
//If we're outside the screen's x range...
if (!IN_RANGE(sprite.GetPosition().x, buffer[LEFT], buffer[RIGHT])) {
sprite.SetX(buffer[sprite.GetPosition().x < buffer[LEFT] ? LEFT : RIGHT]);
velocity.x *= -1;
}
//If we're outside the screen's y range...
if (state == DuckState::FLYING_AROUND) { //The ducks ignore up and down boundaries if flying in or out
float temp = SCREEN.GetHeight()*.6;
if (!IN_RANGE(sprite.GetPosition().y, buffer[UP], temp)) {
sprite.SetY(sprite.GetPosition().y < temp ? buffer[UP] : temp);
velocity.y *= -1;
}
}
}
示例2: opengl_depth_buffer_set_pixel
void opengl_depth_buffer_set_pixel(struct opengl_depth_buffer_t *db, int x, int y, float depth_val)
{
/* Invalid X coordinate */
if (!IN_RANGE(x, 0, db->width - 1))
{
warning("%s: invalid X coordinate", __FUNCTION__);
return;
}
/* Invalid Y coordinate */
if (!IN_RANGE(y, 0, db->height - 1))
{
warning("%s: invalid Y coordinate", __FUNCTION__);
return;
}
db->buffer[y * db->width + x] = depth_val;
}
示例3: ImageProcess_ColorMask
//REMEMBER BGR FORMAT
void OpenCVItemProcessing::ImageProcess_ColorMask(Mat image)
{
image.forEach<Pixel>([](Pixel& pixel,const int* position)->void
{
if (IN_RANGE(pixel.z, r_min, r_max) && IN_RANGE(pixel.y, g_min, g_max) && IN_RANGE(pixel.x, b_min, b_max))
{
pixel.x = 255;
pixel.y = 255;
pixel.z = 255;
}
else
{
pixel.x = 0;
pixel.y = 0;
pixel.z = 0;
}
});
}
示例4: uri_parse_authority
static int uri_parse_authority(const char *authority, struct uri *uri) {
const char *portsep;
const char *host_start, *host_end;
char *tail;
/* We do not support "user:[email protected]" userinfo. The proxy has no use for it. */
if (strchr(authority, '@') != NULL)
return -1;
/* Find the beginning and end of the host. */
host_start = authority;
if (*host_start == '[') {
/* IPv6 address in brackets. */
host_start++;
host_end = strchr(host_start, ']');
if (host_end == NULL)
return -1;
portsep = host_end + 1;
if (!(*portsep == ':' || *portsep == '\0'))
return -1;
} else {
portsep = strrchr(authority, ':');
if (portsep == NULL)
portsep = strchr(authority, '\0');
host_end = portsep;
}
/* Get the port number. */
if (*portsep == ':' && *(portsep + 1) != '\0') {
long n;
errno = 0;
n = parse_long(portsep + 1, &tail);
if (errno || *tail || (tail == (portsep + 1)) || !IN_RANGE(n, 1, 65535))
return -1;
uri->port = n;
} else {
uri->port = -1;
}
/* Get the host. */
uri->host = mkstr(host_start, host_end);
if (percent_decode(uri->host) < 0) {
free(uri->host);
uri->host = NULL;
return -1;
}
return 1;
}
示例5: borderselect_gplayer_frames
/* select the frames in this layer that occur within the bounds specified */
void borderselect_gplayer_frames (bGPDlayer *gpl, float min, float max, short select_mode)
{
bGPDframe *gpf;
/* only select those frames which are in bounds */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (IN_RANGE(gpf->framenum, min, max))
gpframe_select(gpf, select_mode);
}
}
示例6: if
void MenuStage::OnMouseButtonPress(uint32 x, uint32 y, bool left)
{
if (IN_RANGE(x,y, WIDTH-350, WIDTH, 50, 50+80))
{
sApplication->SetStage(STAGE_GAMESETTINGS, 100);
return;
}
else if (IN_RANGE(x,y, WIDTH-350, WIDTH, 160, 160+80))
{
sNetwork->Connect(sConfig->HostName.c_str(), sConfig->NetworkPort);
sApplication->SetStage(STAGE_GAMESETTINGS);
return;
}
else if (IN_RANGE(x,y, WIDTH-350, WIDTH, 270, 270+80))
{
exit(0);
return;
}
}
示例7: PJ_DEF
/* Register strerror handle. */
PJ_DEF(pj_status_t) pj_register_strerror( pj_status_t start,
pj_status_t space,
pj_error_callback f)
{
unsigned i;
/* Check arguments. */
PJ_ASSERT_RETURN(start && space && f, PJ_EINVAL);
/* Check if there aren't too many handlers registered. */
PJ_ASSERT_RETURN(err_msg_hnd_cnt < PJ_ARRAY_SIZE(err_msg_hnd),
PJ_ETOOMANY);
/* Start error must be greater than PJ_ERRNO_START_USER */
PJ_ASSERT_RETURN(start >= PJ_ERRNO_START_USER, PJ_EEXISTS);
/* Check that no existing handler has covered the specified range. */
for (i=0; i<err_msg_hnd_cnt; ++i) {
if (IN_RANGE(start, err_msg_hnd[i].begin, err_msg_hnd[i].end) ||
IN_RANGE(start+space-1, err_msg_hnd[i].begin, err_msg_hnd[i].end))
{
if (err_msg_hnd[i].begin == start &&
err_msg_hnd[i].end == (start+space) &&
err_msg_hnd[i].strerror == f)
{
/* The same range and handler has already been registered */
return PJ_SUCCESS;
}
return PJ_EEXISTS;
}
}
/* Register the handler. */
err_msg_hnd[err_msg_hnd_cnt].begin = start;
err_msg_hnd[err_msg_hnd_cnt].end = start + space;
err_msg_hnd[err_msg_hnd_cnt].strerror = f;
++err_msg_hnd_cnt;
return PJ_SUCCESS;
}
示例8: register_no_elim_operand_1
static inline int
register_no_elim_operand_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
#line 513 "../.././gcc/config/i386/predicates.md"
{
if (GET_CODE (op) == SUBREG)
op = SUBREG_REG (op);
return !(op == arg_pointer_rtx
|| op == frame_pointer_rtx
|| IN_RANGE (REGNO (op),
FIRST_PSEUDO_REGISTER, LAST_VIRTUAL_REGISTER));
}
示例9: mincore
/*
* mincore -- interpose on libc mincore(2)
*
* Return 0 only for specified regions, otherwise return -1 with
* errno = ENOMEM.
*/
int
mincore(void *addr, size_t length, unsigned char *vec)
{
for (int i = 0; i < Nregions; i++) {
if (IN_RANGE(addr, length, Mincore[i].addr, Mincore[i].len))
return 0;
}
errno = ENOMEM;
return -1;
}
示例10:
struct vi_mod_t *vi_net_get_mod(struct vi_net_t *net, int node_index)
{
struct vi_net_node_t *node;
/* Check bounds */
if (!IN_RANGE(node_index, 0, net->node_list->count - 1))
panic("%s: node index out of bounds", __FUNCTION__);
/* Return */
node = list_get(net->node_list, node_index);
return node->mod;
}
示例11: dir_entry_set_owner
void dir_entry_set_owner(struct dir_t *dir, int x, int y, int z, int node)
{
struct dir_entry_t *dir_entry;
/* Set owner */
assert(node == DIR_ENTRY_OWNER_NONE || IN_RANGE(node, 0, dir->num_nodes - 1));
dir_entry = dir_entry_get(dir, x, y, z);
dir_entry->owner = node;
/* Trace */
mem_trace("mem.set_owner dir=\"%s\" x=%d y=%d z=%d owner=%d\n",
dir->name, x, y, z, node);
}
示例12: ED_masklayer_frames_select_border
/* select the frames in this layer that occur within the bounds specified */
void ED_masklayer_frames_select_border(MaskLayer *masklay, float min, float max, short select_mode)
{
MaskLayerShape *masklay_shape;
if (masklay == NULL)
return;
/* only select those frames which are in bounds */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
if (IN_RANGE(masklay_shape->frame, min, max))
masklayshape_select(masklay_shape, select_mode);
}
}
示例13: si2bin_arg_create
struct si2bin_arg_t *si2bin_arg_create_vector_register(int id)
{
struct si2bin_arg_t *arg;
arg = si2bin_arg_create();
arg->type = si2bin_arg_vector_register;
arg->value.vector_register.id = id;
if (!IN_RANGE(arg->value.vector_register.id, 0, 255))
si2bin_yyerror_fmt("vector register out of range: v%d", id);
return arg;
}
示例14: gc_start
static void gc_start(void) {
scm_val v = NIL, *p ;
STACK_INIT() ;
for (p = stack_start; p != (scm_val *)&p; p += stack_dir)
if (IN_RANGE(*p)) GRAY(*p) ;
FOREACH(v, roots) {
scm_val r = *(scm_val *)(CAR(v).p) ;
v.c->flags = FL_GC_BLACK ;
if (PTR_AND_NO_FLAG(r, FL_GC_GRAY)) GRAY(r) ;
}
示例15: frm_arg_create
struct frm_arg_t *frm_arg_create_scalar_register(char *name)
{
struct frm_arg_t *arg;
arg = frm_arg_create();
arg->type = frm_arg_scalar_register;
assert(name[0] == 'R');
arg->value.scalar_register.id = atoi(name + 1);
if (!IN_RANGE(arg->value.scalar_register.id, 0, 62))
frm2bin_yyerror_fmt("register out of range: %s", name);
return arg;
}