当前位置: 首页>>代码示例>>C++>>正文


C++ MAP函数代码示例

本文整理汇总了C++中MAP函数的典型用法代码示例。如果您正苦于以下问题:C++ MAP函数的具体用法?C++ MAP怎么用?C++ MAP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MAP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mma7361_update

upm_result_t mma7361_update(const mma7361_context dev)
{
  assert(dev != NULL);

  float sample;

  if (dev->aio_x)
    {
      if ((sample = (float)mraa_aio_read(dev->aio_x)) < 0.0)
        {
          printf("%s: mraa_aio_read(x) failed.\n", __FUNCTION__);
          return UPM_ERROR_OPERATION_FAILED;
        }

      dev->normalized_x = sample / dev->a_res;
      dev->volts_x = dev->normalized_x * dev->a_ref;
      dev->accel_x = MAP(dev->volts_x, 0.0, MMA_OUTPUT_AREF,
                         -dev->g_range, dev->g_range);
    }

  if (dev->aio_y)
    {
      if ((sample = (float)mraa_aio_read(dev->aio_y)) < 0.0)
        {
          printf("%s: mraa_aio_read(y) failed.\n", __FUNCTION__);
          return UPM_ERROR_OPERATION_FAILED;
        }

      dev->normalized_y = sample / dev->a_res;
      dev->volts_y = dev->normalized_y * dev->a_ref;
      dev->accel_y = MAP(dev->volts_y, 0.0, MMA_OUTPUT_AREF,
                         -dev->g_range, dev->g_range);
    }

  if (dev->aio_z)
    {
      if ((sample = (float)mraa_aio_read(dev->aio_z)) < 0.0)
        {
          printf("%s: mraa_aio_read(z) failed.\n", __FUNCTION__);
          return UPM_ERROR_OPERATION_FAILED;
        }

      dev->normalized_z = sample / dev->a_res;
      dev->volts_z = dev->normalized_z * dev->a_ref;
      dev->accel_z = MAP(dev->volts_z, 0.0, MMA_OUTPUT_AREF,
                         -dev->g_range, dev->g_range);
    }

  return UPM_SUCCESS;
}
开发者ID:stefan-andritoiu,项目名称:upm,代码行数:50,代码来源:mma7361.c

示例2: or_map

struct map *
or_map(struct map *mp1, struct map *mp2)
{
#ifdef MAP_DEBUG
    if (Mflag) {
	printf("Oring maps");
	print_map(mp1);
	printf(" and");
	print_map(mp2);
    }
#endif
    if (POSMAP(mp1))
	if (POSMAP(mp2))
	    mp1 = (struct map *)or_bitmap((struct bitmap *) mp1,
		(struct bitmap *) mp2);
	else
	    mp1 = NOT_MAP(bic_bitmap(MAP(mp2), (struct bitmap *) mp1));
    else if (POSMAP(mp2))
	mp1 = NOT_MAP(bic_bitmap(MAP(mp1), (struct bitmap *) mp2));
    else
	mp1 = NOT_MAP(and_bitmap(MAP(mp1), MAP(mp2)));
#ifdef MAP_DEBUG
    if (Mflag) {
	printf(" ->");
	print_map(mp1);
	printf("\n");
    }
#endif
    return mp1;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:30,代码来源:map.c

示例3: show_oidmap

static int show_oidmap(struct seq_file *m, void *unused)
{
	struct super_block *sb = m->private;
	struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
	struct reiserfs_super_block *rs = sb_info->s_rs;
	unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
	unsigned long total_used = 0;
	int i;

	for (i = 0; i < mapsize; ++i) {
		__u32 right;

		right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
		seq_printf(m, "%s: [ %x .. %x )\n",
			   (i & 1) ? "free" : "used", MAP(i), right);
		if (!(i & 1)) {
			total_used += right - MAP(i);
		}
	}
#if defined( REISERFS_USE_OIDMAPF )
	if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
		loff_t size = file_inode(sb_info->oidmap.mapf)->i_size;
		total_used += size / sizeof(reiserfs_oidinterval_d_t);
	}
#endif
	seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
		   mapsize,
		   mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
	return 0;
}
开发者ID:AeroGirl,项目名称:VAR-SOM-AM33-SDK7-Kernel,代码行数:30,代码来源:procfs.c

示例4: sizeof

void IllCondDetector::EigenLap(EigenSp const &K)
{
	// Convert Eigen library storage into LAPACK storage

	N_ = K.cols();
	A_ = (double*)calloc(N_ * N_, sizeof(double));

	for (int i = 0; i < N_; i++)
	{
		for (int j = 0; j < N_; j++)
		{
			A_[MAP(i, j, N_)] = K.coeff(i, j);
		}
	}
	
	// 1-norm computing
	std::vector<double> tmp;
	for (int i = 0; i < N_; i++)
	{
		double sum = 0;
		for (int j = 0; j < N_; j++)
		{
			sum += A_[MAP(i, j, N_)];
		}
		tmp.push_back(sum);
	}
	auto max = std::max_element(tmp.begin(), tmp.end());
	Anorm_ = *max;
}
开发者ID:lock794779857,项目名称:FrameFab,代码行数:29,代码来源:IllCondDetector.cpp

示例5: dceslicecompose

int
dceslicecompose(DCEslice* s1, DCEslice* s2, DCEslice* result)
{
    int err = NC_NOERR;
    size_t lastx = 0;
    DCEslice sr; /* For back compatability so s1 and result can be same object */
#ifdef DEBUG1
slicedump("compose: s1",s1);
slicedump("compose: s2",s2);
#endif
    sr.node.sort = CES_SLICE;
    sr.stride    = s1->stride * s2->stride;
    sr.first     = MAP(s1,s2->first);
    if(sr.first > s1->last)
	return NC_EINVALCOORDS;
    lastx        = MAP(s1,s2->last);
    sr.last      = XMIN(s1->last,lastx);
    sr.length    = (sr.last + 1) - sr.first;
    sr.declsize = XMAX(s1->declsize,s2->declsize); /* use max declsize */
    /* fill in other fields */
    sr.count = (sr.length + (sr.stride - 1))/sr.stride;
    *result = sr;
#ifdef DEBUG1
slicedump("compose: result",result);
#endif
    return err;
}
开发者ID:ArtisticCoding,项目名称:libmesh,代码行数:27,代码来源:dceconstraints.c

示例6: fill

void SortRoutineGraphic::drawBackground()
{
	fill(pDarkGray);
	rect(fFrame.x, fFrame.y, fFrame.width, fFrame.height);

	fill(255);

		stroke(pWhite);
		strokeWeight(0.5);

		if (fAnimate) {
			// do a step in the sorter
			if (!fSorter->step()) {
				reset();
			}
		}

		// Draw the array of values scaled to fit the window
		for (int idx = 0; idx < nElems; idx++) {
			double mappedX = (int)MAP(idx, 0, nElems - 1, fFrame.x, fFrame.x + fFrame.width - 1);
			double mappedY = (int)MAP(fSorter->fElements[idx], 0, MAX_VALUE, fFrame.y + fFrame.height - 1, fFrame.y);

			point(mappedX, mappedY);

			if (fShowLines) {
				line(fFrame.x, fFrame.y + fFrame.height - 1, mappedX, mappedY);
			}
		
	}

	drawForeground();
}
开发者ID:Wiladams,项目名称:drawproc,代码行数:32,代码来源:SortRoutineGraphic.cpp

示例7: NV10EXAComposite

void
NV10EXAComposite(PixmapPtr pix_dst,
		 int srcX, int srcY,
		 int maskX, int maskY,
		 int dstX, int dstY,
		 int width, int height)
{
	ScrnInfoPtr pScrn = xf86Screens[pix_dst->drawable.pScreen->myNum];
	NVPtr pNv = NVPTR(pScrn);
	struct nouveau_channel *chan = pNv->chan;
	struct nouveau_grobj *celsius = pNv->Nv3D;
	PicturePtr mask = pNv->pmpict,
		src = pNv->pspict;
	PictVector dstq[4] = QUAD(dstX, dstY, width, height),
		maskq[4] = QUAD(maskX, maskY, width, height),
		srcq[4] = QUAD(srcX, srcY, width, height);

	MAP(transform_vertex, src->transform, srcq);
	if (mask)
		MAP(transform_vertex, mask->transform, maskq);

	WAIT_RING (chan, 64);
	BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BEGIN_END, 1);
	OUT_RING  (chan, NV10TCL_VERTEX_BEGIN_END_QUADS);

	MAP(emit_vertex, pNv, dstq, srcq, mask ? maskq : NULL);

	BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BEGIN_END, 1);
	OUT_RING  (chan, NV10TCL_VERTEX_BEGIN_END_STOP);
}
开发者ID:Plombo,项目名称:xf86-video-nouveau,代码行数:30,代码来源:nv10_exa.c

示例8: town_adjust

void town_adjust(int *dungeon_hgt, int *dungeon_wid)
{
	bool small_town = ((p_ptr->stage < KHAZAD_DUM_TOWN) && !MAP(DUNGEON) &&
					   !MAP(FANILLA));
	
	(*dungeon_hgt) /= 3;
	(*dungeon_wid) /= (small_town ? 6 : 3);
}
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:8,代码来源:xtra2.c

示例9: add_map

struct map *
add_map(struct map *parm, int node)
{
    struct bitmap *map;
    int bit;
    int x, page;

#ifdef MAP_DEBUG
    if (Aflag) {
	printf("add_map: adding %d to [", node);
	print_map(parm);
	printf(" ] ");
    }
#endif
    bit = NUMBERTOBIT(node);
    x = NUMBERTOINDEX(node);
    page = NUMBERTOPAGE(node);

    bit = 1L << bit;;

    for (map = MAP(parm); map; map = map->m_next)
	if (map->m_page == page)
	    break;
    if (!map) {
	map = (struct bitmap *)malloc(sizeof *map);
	if (!map) {
#ifdef PRINT_MAP_ERROR
	    printf("No memory!\n");
#endif
	    free_map((struct map *)map);
	    return 0;
	}
	map->m_page = page;
	memset( map->m_data, 0, sizeof map->m_data);
	if (NEGMAP(parm)) {
	    int i;
	    for (i = 0; i < MDATA; ++i)
		map->m_data[i] = ~0;
	}
	map->m_next = MAP(parm);
	if (POSMAP(parm))
	    parm = (struct map *)map;
	else
	    parm = NOT_MAP(map);
    }
    if (POSMAP(parm))
	map->m_data[x] |= bit;
    else
	map->m_data[x] &= ~bit;
#ifdef MAP_DEBUG
    if (Aflag) {
	printf(" ->");
	print_map(parm);
	printf("\n");
    }
#endif
    return (struct map *)parm;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:58,代码来源:map.c

示例10: main

int main(int argc, char const **argv) {
	int fd;
	mcp3424 j2;
	mcp3424 j3;
	unsigned int iteration = 0;
	int i;

	int channels[4] = {
		MCP3424_CHANNEL_1,
		MCP3424_CHANNEL_2,
		MCP3424_CHANNEL_3,
		MCP3424_CHANNEL_4
	};
	unsigned int res[8];
	float v[8];

	fd = open("/dev/i2c-1", O_RDWR);
	if (fd == -1) {
		printf("error: open: %s\n", strerror(errno));
		exit(EXIT_FAILURE);
	}

	mcp3424_init(&j2, fd, 0x68, MCP3424_RESOLUTION_14);
	mcp3424_set_conversion_mode(&j2, MCP3424_CONVERSION_MODE_CONTINUOUS);
	mcp3424_init(&j3, fd, 0x69, MCP3424_RESOLUTION_14);
	mcp3424_set_conversion_mode(&j3, MCP3424_CONVERSION_MODE_CONTINUOUS);

	while (1) {
		for (i = 0; i < 4; i++) {
			res[i] = mcp3424_get_raw(&j2, channels[i]);
			if (j2.err) {
				printf("error: mcp3424_get_raw: %s\n", j2.errstr);
				close(fd);
				exit(EXIT_FAILURE);
			}
			v[i] = MAP(res[i], RAW_MIN, RAW_MAX_14, V_MIN, V_MAX);
		}
		for (i = 0; i < 4; i++) {
			res[i + 4] = mcp3424_get_raw(&j3, channels[i]);
			if (j3.err) {
				printf("error: mcp3424_get_raw: %s\n", j3.errstr);
				close(fd);
				exit(EXIT_FAILURE);
			}
			v[i + 4] = MAP(res[i + 4], RAW_MIN, RAW_MAX_14, V_MIN, V_MAX);
		}

		printf("iteration: %u\n", iteration++);
		for (i = 0; i < 8; i++) {
			printf("res[%d] = %u, v[%d] = %0.2f\n", i, res[i], i, v[i]);
		}
		printf("\n");
	}

	close(fd);

	return EXIT_SUCCESS;
}
开发者ID:alexyoung91,项目名称:mcp3424,代码行数:58,代码来源:main.c

示例11: driver_id

static driver_id_t driver_id(ripncode_t *r)
{
    struct {
        const char  *name;
        driver_id_t  id;
    } drivers[] = {
#define MAP(_name, _id) { #_name, DRIVER_##_id }
        MAP(device , DEVICE ),
        MAP(linux  , LINUX  ),
        MAP(aix    , AIX    ),
        MAP(bsdi   , BSDI   ),
        MAP(netbsd , NETBSD ),
        MAP(solaris, SOLARIS),
        MAP(cdrdao , CDRDAO ),
        MAP(bincue , BINCUE ),
        MAP(nrg    , NRG    ),
#undef MAP
        { NULL, -1 }
    }, *d;

    if (r->driver == NULL)
        r->driver = "device";

    for (d = drivers; d->name != NULL; d++)
        if (!strcmp(d->name, r->driver))
            return d->id;

    return DRIVER_UNKNOWN;
}
开发者ID:klihub,项目名称:ripncode,代码行数:29,代码来源:ripncode.c

示例12: drawDataPoints

void drawDataPoints(const int col)
{
	for (int row = 0; row < rowCount; row++){
		if (isValid(row, col)) {
			float value = getFloat(row, col);
			double x = MAP(data[row].year, yearMin, yearMax, plotX1, plotX2);
			double y = MAP(value, dataMin, dataMax, plotY2, plotY1);
			point(x, y);
		}
	}
}
开发者ID:IrinaRogozhkina,项目名称:drawproc,代码行数:11,代码来源:timeseries.cpp

示例13: RemoveShitNums

int RemoveShitNums(int* map, const int n, const int width, const int height){
	int num = 0;
	for(int y = 0; y < height; y++){
		for(int x = 0; x < width; x++){
			if(MAP(map, x, y) >= n+1){
				MAP(map, x, y) = 0;
				num++;
			}
		}
	}
	return num;
}
开发者ID:KNCT-KPC,项目名称:Bungo,代码行数:12,代码来源:FullSearch.cpp

示例14: dump_iface_list_stream_cb

static void LIBUSB_CALL
dump_iface_list_stream_cb(struct libusb_transfer *transfer)
{
    enum libusb_error   err;
    uhd_iface          *iface;

    assert(transfer != NULL);

    iface = (uhd_iface *)transfer->user_data;
    assert(uhd_iface_valid(iface));

    /* Clear interface "has transfer submitted" flag */
    iface->submitted = false;

    switch (transfer->status)
    {
        case LIBUSB_TRANSFER_COMPLETED:
            /* Dump the result */
            if (!stream_paused)
            {
                dump(iface, "STREAM",
                     transfer->buffer, transfer->actual_length);
                if (stream_feedback)
                    fputc('.', stderr);
            }
            /* Resubmit the transfer */
            err = libusb_submit_transfer(transfer);
            if (err != LIBUSB_SUCCESS)
                LIBUSB_IFACE_FAILURE(iface, "resubmit a transfer");
            else
            {
                /* Set interface "has transfer submitted" flag */
                iface->submitted = true;
            }
            break;

#define MAP(_name, _desc) \
    case LIBUSB_TRANSFER_##_name: \
        IFACE_ERROR(iface, _desc);  \
        break

        MAP(ERROR,      "Interrupt transfer failed");
        MAP(TIMED_OUT,  "Interrupt transfer timed out");
        MAP(STALL,      "Interrupt transfer halted (endpoint stalled)");
        MAP(NO_DEVICE,  "Device was disconnected");
        MAP(OVERFLOW,   "Interrupt transfer overflowed "
                        "(device sent more data than requested)");
#undef MAP

        case LIBUSB_TRANSFER_CANCELLED:
            break;
    }
}
开发者ID:DIGImend,项目名称:usbhid-dump,代码行数:53,代码来源:usbhid-dump.c

示例15: rockchip_cpu_axi_init

static int __init rockchip_cpu_axi_init(void)
{
	struct device_node *np, *gp, *cp;
	void __iomem *base;

	np = of_find_compatible_node(NULL, NULL, "rockchip,cpu_axi_bus");
	if (!np)
		return -ENODEV;

#define MAP(base) if (!base) base = of_iomap(cp, 0); if (!base) continue;

	gp = of_get_child_by_name(np, "qos");
	if (gp) {
		for_each_child_of_node(gp, cp) {
			u32 priority[2], mode, bandwidth, saturation, extcontrol;
			base = NULL;
#ifdef DEBUG
			{
				struct resource r;
				of_address_to_resource(cp, 0, &r);
				pr_debug("qos: %s [%x ~ %x]\n", cp->name, r.start, r.end);
			}
#endif
			if (!of_property_read_u32_array(cp, "rockchip,priority", priority, ARRAY_SIZE(priority))) {
				MAP(base);
				CPU_AXI_SET_QOS_PRIORITY(priority[0], priority[1], base);
				pr_debug("qos: %s priority %x %x\n", cp->name, priority[0], priority[1]);
			}
			if (!of_property_read_u32(cp, "rockchip,mode", &mode)) {
				MAP(base);
				CPU_AXI_SET_QOS_MODE(mode, base);
				pr_debug("qos: %s mode %x\n", cp->name, mode);
			}
			if (!of_property_read_u32(cp, "rockchip,bandwidth", &bandwidth)) {
				MAP(base);
				CPU_AXI_SET_QOS_BANDWIDTH(bandwidth, base);
				pr_debug("qos: %s bandwidth %x\n", cp->name, bandwidth);
			}
			if (!of_property_read_u32(cp, "rockchip,saturation", &saturation)) {
				MAP(base);
				CPU_AXI_SET_QOS_SATURATION(saturation, base);
				pr_debug("qos: %s saturation %x\n", cp->name, saturation);
			}
			if (!of_property_read_u32(cp, "rockchip,extcontrol", &extcontrol)) {
				MAP(base);
				CPU_AXI_SET_QOS_EXTCONTROL(extcontrol, base);
				pr_debug("qos: %s extcontrol %x\n", cp->name, extcontrol);
			}
			if (base)
				iounmap(base);
		}
	};
开发者ID:aloksinha2001,项目名称:3.10-kernel,代码行数:52,代码来源:common.c


注:本文中的MAP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。