本文整理汇总了C++中print_map函数的典型用法代码示例。如果您正苦于以下问题:C++ print_map函数的具体用法?C++ print_map怎么用?C++ print_map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_map函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//printf("Some random hashes:\n");
//printf("\tBazinga: %d\n", map_hash_key("Bazinga"));
//printf("\tFlabagoobie: %d\n", map_hash_key("Flabagoobie"));
//printf("\tScooby: %d\n", map_hash_key("Scooby"));
//printf("\tMcDooby: %d\n", map_hash_key("McDooby"));
//printf("\tagnizaB: %d\n", map_hash_key("agnizaB"));
Map map;
map_init(&map);
map_set(&map, "bazinga", "bazonga");
map_set(&map, "zabinga", "zabonga");
map_set(&map, "zabniga", "maponya");
map_set(&map, "kabanooga", "daboogawoofa");
MapItem *item;
print_map(&map);
map_get(&map, "abzinga");
printf("================================\n");
print_map(&map);
map_free(&map);
}
示例2: ikev2_pld_eap
int
ikev2_pld_eap(struct iked *env, struct ikev2_payload *pld,
struct iked_message *msg, size_t offset, size_t left)
{
struct eap_header hdr;
struct eap_message *eap = NULL;
struct iked_sa *sa = msg->msg_sa;
size_t len;
if (ikev2_validate_eap(msg, offset, left, pld, &hdr))
return (-1);
len = betoh16(hdr.eap_length);
if (len < sizeof(*eap)) {
log_info("%s: %s id %d length %d", __func__,
print_map(hdr.eap_code, eap_code_map),
hdr.eap_id, betoh16(hdr.eap_length));
} else {
/* Now try to get the indicated length */
if ((eap = ibuf_seek(msg->msg_data, offset, len)) == NULL) {
log_debug("%s: invalid EAP length", __func__);
return (-1);
}
log_info("%s: %s id %d length %d EAP-%s", __func__,
print_map(eap->eap_code, eap_code_map),
eap->eap_id, betoh16(eap->eap_length),
print_map(eap->eap_type, eap_type_map));
}
if (eap_parse(env, sa, &hdr, msg->msg_response) == -1)
return (-1);
return (0);
}
示例3: main
int main(int argc, char* argv[]) {
//Set
std::cout << "Set:" << std::endl;
std::set<int> std_set;
std_set.insert(20);
std_set.insert(20);
std_set.insert(10);
print_container(std_set);
//MultiSet
std::cout << "MultiSet:" << std::endl;
std::multiset<int> std_multiset;
std_multiset.insert(20);
std_multiset.insert(20);
std_multiset.insert(10);
print_container(std_multiset);
//Map
std::cout << "Map:" << std::endl;
std::map<std::string, int> std_map;
std_map.insert(std::pair<std::string ,int>("Hello", 10));
std_map["World"]=20;
std_map.insert(std::pair<std::string ,int>("Hello", 20));
print_map(std_map);
//MultiMap
std::cout << "MultiMap:" << std::endl;
std::multimap<std::string, int> std_multimap;
std_multimap.insert(std::pair<std::string ,int>("Hello", 10));
std_multimap.insert(std::pair<std::string ,int>("World", 20));
std_multimap.insert(std::pair<std::string ,int>("Hello", 20));
print_map(std_multimap);
}
示例4: main
int main()
{
Stack s;
init_stack(&s);
int i = 0;
sElemType start = {
0,
{
1,
1,
}
};
sElemType curpos = start;
welcome();
printf("\n\n");
print_map();
printf("\n\nI'm going...........................\n\n");
i = walk_maze(&curpos, s);
printf("(@[email protected])\n\n");
print_map();
if(i == 1)
printf("\n\nDone!\n\n");
else
printf("\n\nI'm missing!\n\n");
return 0;
}
示例5: 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;
}
示例6: 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;
}
示例7: Drone_pick_up
void Drone_pick_up(void *self, int id){
Drone *obj = self;
setPosition((*obj).curr_y, (*obj).curr_x, id);
print_map();
printf("\x1b[32mDrone %d ready for pick up \n\x1b[0m", id);
sleep(1);
print_map();
printf("\x1b[33mDrone %d requesting payload \n\x1b[0m", id);
sleep(1);
print_map();
printf("\x1b[32mDrone %d payload picked up \n\x1b[0m", id);
Drone_return_home(self, id);
}
示例8: main
/********************MAIN*****************/
int main(int argc, char **argv){
srand(time(NULL));
initialize("cyclotron.dat");
print_map(map);
max=0;RANGE=13; /* Set max and RANGE*/
search(map); /* Searching*/
show_result(optimum,max); /* Show result*/
printf("\n");
max=0; RANGE=13; /* Reset max and RANGE*/
print_map(map1);
search(map1);
show_result(optimum,max);
return 0;
}
示例9: main
int main(int argc, char** argv) {
madness::World& world = madness::initialize(argc,argv);
std::size_t m = 20;
std::size_t n = 10;
std::size_t M = 200;
std::size_t N = 100;
std::shared_ptr<TiledArray::Pmap> blocked_pmap(new TiledArray::detail::BlockedPmap(world, m * n));
std::vector<ProcessID> blocked_map = make_map(m, n, blocked_pmap);
std::shared_ptr<TiledArray::Pmap> cyclic_pmap(new TiledArray::detail::CyclicPmap(world, m, n, M, N));
std::vector<ProcessID> cyclic_map = make_map(m, n, cyclic_pmap);
std::shared_ptr<TiledArray::Pmap> hash_pmap(new TiledArray::detail::HashPmap(world, m * n));
std::vector<ProcessID> hash_map = make_map(m, n, hash_pmap);
if(world.rank() == 0) {
std::cout << "Block\n";
print_map(m, n, blocked_map);
std::cout << "\n";
}
print_local(world, blocked_pmap);
world.gop.fence();
if(world.rank() == 0) {
std::cout << "\n\nCyclic\n";
print_map(m, n, cyclic_map);
std::cout << "\n";
}
print_local(world, cyclic_pmap);
world.gop.fence();
if(world.rank() == 0) {
std::cout << "\n\nHash\n";
print_map(m, n, hash_map);
std::cout << "\n";
}
print_local(world, hash_pmap);
madness::finalize();
return 0;
}
示例10: copy_map
struct map *
copy_map(struct map *parm)
{
struct bitmap *result, **mpp, *map;
#ifdef MAP_DEBUG
if (Mflag) {
printf("copymap:");
print_map(parm);
printf("\n");
}
#endif
map = MAP(parm);
for (mpp = &result; (*mpp = 0), map; map = map->m_next) {
*mpp = (struct bitmap *)malloc(sizeof **mpp);
if (!*mpp) {
#ifdef MAP_DEBUG
if (Mflag)
printf("copy_map: out of memory\n");
#endif
free_map((struct map *)result);
result = 0;
break;
}
**mpp = *map;
mpp = &(*mpp)->m_next;
}
if (NEGMAP(parm))
return NOT_MAP(result);
else
return (struct map *)result;
}
示例11: main
int main(int ac, char **av)
{
int i;
int j;
char *tab;
t_sq sq;
char **map;
(void)ac;
j = 1;
while (av[j])
{
i = 0;
tab = read_file(av[j]);
write(1, "lo1", 3);
map = map_error(tab);
write(1, "lo2", 3);
sq = bsq(map);
write(1, "lo3", 3);
print_map(map, &sq);
write(1, "lo4", 3);
++j;
}
return(0);
}
示例12: MemAllocFree
void MemAllocFree(MemAlloc *ma, void *addr)
{
MemAllocChunk *c;
assert(ma != NULL);
if (addr == NULL) {
return;
}
c = (MemAllocChunk *)(((int8_t *) addr) - sizeof (MemAllocChunk));
c->id = MEMALLOC_CHUNK_ID_FREE;
if (c->next != 0) {
MemAllocChunk *nc = next_chunk(c);
if (nc->id == MEMALLOC_CHUNK_ID_FREE) {
c->size += sizeof (MemAllocChunk) + nc->size;
c->next = nc->next;
}
}
if (c->prev != 0) {
MemAllocChunk *pc = prev_chunk(c);
if (pc->id == MEMALLOC_CHUNK_ID_FREE) {
pc->size += sizeof (MemAllocChunk) + c->size;
pc->next = c->next;
}
}
#ifdef ENABLE_PRINT_MAP
print_map(ma);
#endif
}
示例13: assert
void *MemAllocAllocate(MemAlloc *ma, size_t size)
{
size_t sz;
assert(ma != NULL);
sz = (size + (MEMALLOC_ALIGN_SIZE - 1)) / MEMALLOC_ALIGN_SIZE * MEMALLOC_ALIGN_SIZE;
MemAllocChunk *c = ma->top;
while (!0) {
if (c->id == MEMALLOC_CHUNK_ID_FREE && c->size >= sz) {
break;
}
if (c->next == 0) {
return NULL;
}
c = next_chunk(c);
}
if (c->size > sizeof (MemAllocChunk) + sz) {
MemAllocChunk *c2 = (MemAllocChunk *)(((int8_t *) c) + sizeof (MemAllocChunk) + sz);
c2->id = MEMALLOC_CHUNK_ID_FREE;
c2->size = c->size - sizeof (MemAllocChunk) - sz;
c2->prev = sizeof (MemAllocChunk) + sz;
c2->next = c->next;
c->next = c2->prev;
}
c->id = MEMALLOC_CHUNK_ID_USED;
c->size = sz;
#ifdef ENABLE_PRINT_MAP
print_map(ma);
#endif
return ((int8_t *) c) + sizeof (MemAllocChunk);
}
示例14: ikev2_msg_send
int
ikev2_msg_send(struct iked *env, struct iked_message *msg)
{
struct ibuf *buf = msg->msg_data;
u_int32_t natt = 0x00000000;
struct ike_header *hdr;
if (buf == NULL || (hdr = ibuf_seek(msg->msg_data,
msg->msg_offset, sizeof(*hdr))) == NULL)
return (-1);
log_info("%s: %s from %s to %s, %ld bytes", __func__,
print_map(hdr->ike_exchange, ikev2_exchange_map),
print_host(&msg->msg_local, NULL, 0),
print_host(&msg->msg_peer, NULL, 0),
ibuf_length(buf));
if (msg->msg_natt || (msg->msg_sa && msg->msg_sa->sa_natt)) {
if (ibuf_prepend(buf, &natt, sizeof(natt)) == -1) {
log_debug("%s: failed to set NAT-T", __func__);
return (-1);
}
}
if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0,
(struct sockaddr *)&msg->msg_peer, msg->msg_peerlen)) == -1) {
log_warn("%s: sendto", __func__);
return (-1);
}
return (0);
}
示例15: count_map
int
count_map(struct map *parm)
{
int nf;
struct bitmap *map;
int i, j;
nf = 0;
for (map = MAP(parm); map; map = map->m_next) {
for (i = 0; i < MDATA; ++i) {
if (!map->m_data[i])
;
else if (!~map->m_data[i])
nf += (1 << LSHIFT);
else
for (j = 0; j < (1L << LSHIFT); ++j)
if (map->m_data[i] & (1L << j))
++nf;
}
}
if (NEGMAP(parm))
nf = ~nf; /* note 1's complement */
#ifdef MAP_DEBUG
if (Mflag) {
printf("countmap:");
print_map(parm);
printf(" -> %d\n", nf);
}
#endif
return nf;
}