• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ erase函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: erase

void Queue::remove(DLink<VariableWithTimeStamp> *elt) {
    elt->content.timeStamp = -1;
    elt->content.incdec = NOTHING_EVENT;
    erase(elt, false);
}
开发者ID:AbdullahMohammad,项目名称:Numberjack,代码行数:5,代码来源:tb2queue.cpp


示例2: assert

void
NBNodeCont::joinNodeClusters(NodeClusters clusters,
                             NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc) {
    for (NodeClusters::iterator i = clusters.begin(); i != clusters.end(); ++i) {
        std::set<NBNode*> cluster = *i;
        assert(cluster.size() > 1);
        Position pos;
        bool setTL;
        std::string id;
        TrafficLightType type;
        analyzeCluster(cluster, id, pos, setTL, type);
        if (!insert(id, pos)) {
            // should not fail
            WRITE_WARNING("Could not join junctions " + id);
            continue;
        }
        NBNode* newNode = retrieve(id);
        if (setTL) {
            NBTrafficLightDefinition* tlDef = new NBOwnTLDef(id, newNode, 0, type);
            if (!tlc.insert(tlDef)) {
                // actually, nothing should fail here
                delete tlDef;
                throw ProcessError("Could not allocate tls '" + id + "'.");
            }
        }
        // collect edges
        std::set<NBEdge*> allEdges;
        for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
            const EdgeVector& edges = (*j)->getEdges();
            allEdges.insert(edges.begin(), edges.end());
        }

        // remap and remove edges which are completely within the new intersection
        for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end();) {
            NBEdge* e = (*j);
            NBNode* from = e->getFromNode();
            NBNode* to = e->getToNode();
            if (cluster.count(from) > 0 && cluster.count(to) > 0) {
                for (std::set<NBEdge*>::iterator l = allEdges.begin(); l != allEdges.end(); ++l) {
                    if (e != *l) {
                        (*l)->replaceInConnections(e, e->getConnections());
                    }
                }
                ec.erase(dc, e);
                allEdges.erase(j++); // erase does not invalidate the other iterators
            } else {
                ++j;
            }
        }

        // remap edges which are incoming / outgoing
        for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end(); ++j) {
            NBEdge* e = (*j);
            std::vector<NBEdge::Connection> conns = e->getConnections();
            const bool outgoing = cluster.count(e->getFromNode()) > 0;
            NBNode* from = outgoing ? newNode : e->getFromNode();
            NBNode* to   = outgoing ? e->getToNode() : newNode;
            e->reinitNodes(from, to);
            // re-add connections which previously existed and may still valid.
            // connections to removed edges will be ignored
            for (std::vector<NBEdge::Connection>::iterator k = conns.begin(); k != conns.end(); ++k) {
                e->addLane2LaneConnection((*k).fromLane, (*k).toEdge, (*k).toLane, NBEdge::L2L_USER, false, (*k).mayDefinitelyPass);
            }
        }
        // remove original nodes
        registerJoinedCluster(cluster);
        for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
            erase(*j);
        }
    }
}
开发者ID:rudhir-upretee,项目名称:Sumo17_With_Netsim,代码行数:71,代码来源:NBNodeCont.cpp


示例3: erase

CellLinkedList::ReverseIterator CellLinkedList::erase(CellLinkedList::ReverseIterator pos)
{
    Iterator it = (++pos).base();
    it = erase(it);
    return ReverseIterator(it);
}
开发者ID:gitter-badger,项目名称:vpaint,代码行数:6,代码来源:CellLinkedList.cpp


示例4: activate_sleeper

void activate_sleeper(Creature *cr)
{
   int state=0;
   int choice=0;
   char havedead=0;

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      printfunds(0,1,"Money: ");
      
      move(0,0);
      addstr("Taking Undercover Action:   What will ");
      addstr(cr->name);
      addstr(" focus on?");

      printcreatureinfo(cr);

      makedelimiter(8,0);

      set_color(COLOR_WHITE,COLOR_BLACK,state=='a');
      move(10,1);
      addstr("A - Communication and Advocacy");

      set_color(COLOR_WHITE,COLOR_BLACK,state=='b');
      move(11,1);
      addstr("B - Espionage");

      set_color(COLOR_WHITE,COLOR_BLACK,state=='d');
      move(12,1);
      addstr("C - Join the Active LCS");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(20,40);
      addstr("Enter - Confirm Selection");

      switch(state)
      {
      case 'a':
         set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_NONE);
         move(10,40);
         addstr("1 - Lay Low");

         set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_SLEEPER_LIBERAL);
         move(11,40);
         addstr("2 - Advocate Liberalism");

         move(12,40);
         if(subordinatesleft(*cr))
         {
            set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_SLEEPER_RECRUIT);
            addstr("3 - Expand Sleeper Network");
         }
         else
         {
            set_color(COLOR_BLACK,COLOR_BLACK,1);
            if(cr->flag & CREATUREFLAG_BRAINWASHED)
               addstr("3 - [Enlightened Can't Recruit]");
            else
               addstr("3 - [Need More Juice to Recruit]");
         }
         break;
      case 'b':
         set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_SLEEPER_SPY);
         move(10,40);
         addstr("1 - Uncover Secrets");

         set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_SLEEPER_EMBEZZLE);
         move(11,40);
         addstr("2 - Embezzle Funds");

         set_color(COLOR_WHITE,COLOR_BLACK,cr->activity.type==ACTIVITY_SLEEPER_STEAL);
         move(12,40);
         addstr("3 - Steal Equipment");
         break;
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      switch(cr->activity.type)
      {
      case ACTIVITY_NONE:
         move(22,3);
         addstr(cr->name);
         addstr(" will stay out of trouble.");
         break;
      case ACTIVITY_SLEEPER_LIBERAL:
         move(22,3);
         addstr(cr->name);
         addstr(" will build support for Liberal causes.");
         break;
      case ACTIVITY_SLEEPER_RECRUIT:
         if(subordinatesleft(*cr))
         {
            move(22,3);
            addstr(cr->name);
            addstr(" will try to recruit additional sleeper agents.");
         }
         break;
//.........这里部分代码省略.........
开发者ID:gauffa,项目名称:liberalcrimesquad-gmod,代码行数:101,代码来源:activate_sleepers.cpp


示例5: main

int main(int argc, char **argv)
{
    int i, start, end, row, diff, flag, direction;
    const unsigned seed = (unsigned)time((time_t *)0);

#ifdef XCURSES
    Xinitscr(argc, argv);
#else
    initscr();
#endif
    nodelay(stdscr, TRUE);
    noecho();

    if (has_colors())
        start_color();

    for (i = 0; i < 8; i++)
        init_pair((short)i, color_table[i], COLOR_BLACK);

    srand(seed);
    flag = 0;

    while (getch() == ERR)      /* loop until a key is hit */
    {
        do {
            start = rand() % (COLS - 3);
            end = rand() % (COLS - 3);
            start = (start < 2) ? 2 : start;
            end = (end < 2) ? 2 : end;
            direction = (start > end) ? -1 : 1;
            diff = abs(start - end);

        } while (diff < 2 || diff >= LINES - 2);

        attrset(A_NORMAL);

        for (row = 0; row < diff; row++)
        {
            mvaddstr(LINES - row, row * direction + start,
                (direction < 0) ? "\\" : "/");

            if (flag++)
            {
                myrefresh();
                erase();
                flag = 0;
            }
        }

        if (flag++)
        {
            myrefresh();
            flag = 0;
        }

        explode(LINES - row, diff * direction + start);
        erase();
        myrefresh();
    }

    endwin();

    return 0;
}
开发者ID:Noiwex,项目名称:luajit-curses,代码行数:64,代码来源:firework.c


示例6: engine_exit

/** This stops ncurses on a sweet, gentle way. */
void engine_exit()
{
	erase();
	refresh();
	endwin();
}
开发者ID:liushizhe,项目名称:yetris,代码行数:7,代码来源:engine.c


示例7: open


//.........这里部分代码省略.........
	if (stat(filename, &st) != 0) {
		log("Failed to stat %s - %d\n", filename, (int)errno);
		tcsetattr(_io_fd, TCSANOW, &t_original);
		close(_io_fd);
		_io_fd = -1;
		return -errno;
	}
	fw_size = st.st_size;

	if (_fw_fd == -1) {
		tcsetattr(_io_fd, TCSANOW, &t_original);
		close(_io_fd);
		_io_fd = -1;
		return -ENOENT;
	}

	/* do the usual program thing - allow for failure */
	for (unsigned retries = 0; retries < 1; retries++) {
		if (retries > 0) {
			log("retrying update...");
			ret = sync();

			if (ret != OK) {
				/* this is immediately fatal */
				log("bootloader not responding");
				tcsetattr(_io_fd, TCSANOW, &t_original);
				close(_io_fd);
				_io_fd = -1;
				return -EIO;
			}
		}

		ret = get_info(INFO_BL_REV, bl_rev);

		if (ret == OK) {
			if (bl_rev <= BL_REV) {
				log("found bootloader revision: %d", bl_rev);
			} else {
				log("found unsupported bootloader revision %d, exiting", bl_rev);
				tcsetattr(_io_fd, TCSANOW, &t_original);
				close(_io_fd);
				_io_fd = -1;
				return OK;
			}
		}

		ret = erase();

		if (ret != OK) {
			log("erase failed");
			continue;
		}

		ret = program(fw_size);

		if (ret != OK) {
			log("program failed");
			continue;
		}

		if (bl_rev <= 2)
			ret = verify_rev2(fw_size);
		else if(bl_rev == 3) {
			ret = verify_rev3(fw_size);
		}

		if (ret != OK) {
			log("verify failed");
			continue;
		}

		ret = reboot();

		if (ret != OK) {
			log("reboot failed");
			tcsetattr(_io_fd, TCSANOW, &t_original);
			close(_io_fd);
			_io_fd = -1;
			return ret;
		}

		log("update complete");

		ret = OK;
		break;
	}

	/* reset uart to previous/default baudrate */
	tcsetattr(_io_fd, TCSANOW, &t_original);

	close(_fw_fd);
	close(_io_fd);
	_io_fd = -1;

        // sleep for enough time for the IO chip to boot. This makes
        // forceupdate more reliably startup IO again after update
        up_udelay(100*1000);

	return ret;
}
开发者ID:30rasheed,项目名称:x-VTOLdrone,代码行数:101,代码来源:px4io_uploader.cpp


示例8: slk_test

static void slk_test(void)
/* exercise the soft keys */
{
    int	c, fmt = 1;
    char buf[9];

    c = CTRL('l');
    do {
	switch(c)
	{
	case CTRL('l'):
	    erase();
	    attron(A_BOLD);
	    mvaddstr(0, 20, "Soft Key Exerciser");
	    attroff(A_BOLD);

	    move(2, 0);
	    P("Available commands are:");
	    P("");
	    P("^L         -- refresh screen");
	    P("a          -- activate or restore soft keys");
	    P("d          -- disable soft keys");
	    P("c          -- set centered format for labels");
	    P("l          -- set left-justified format for labels");
	    P("r          -- set right-justified format for labels");
	    P("[12345678] -- set label; labels are numbered 1 through 8");
	    P("e          -- erase stdscr (should not erase labels)");
	    P("s          -- test scrolling of shortened screen");
	    P("x, q       -- return to main menu");
	    P("");
	    P("Note: if activating the soft keys causes your terminal to");
	    P("scroll up one line, your terminal auto-scrolls when anything");
	    P("is written to the last screen position.  The ncurses code");
	    P("does not yet handle this gracefully.");
	    refresh();
	    /* fall through */

	case 'a':
	    slk_restore();
	    break;

	case 'e':
	    wclear(stdscr);
	    break;

	case 's':
	    move(20, 0);
	    while ((c = getch()) != 'Q')
		addch(c);
	    break;

	case 'd':
	    slk_clear();
	    break;

	case 'l':
	    fmt = 0;
	    break;

	case 'c':
	    fmt = 1;
	    break;

	case 'r':
	    fmt = 2;
	    break;

	case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8':
	    (void) mvaddstr(20, 0, "Please enter the label value: ");
	    wgetnstr(stdscr, buf, 8);
	    slk_set((c - '0'), buf, fmt);
	    slk_refresh();
	    break;

	case 'x':
	case 'q':
	    goto done;

	default:
	    beep();
	}
    } while
	((c = getch()) != EOF);

 done:
    erase();
    endwin();
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:89,代码来源:ncurses.c


示例9: getFactors

 vector<vector<int>> getFactors(int n) {
     auto ans = f(n);
     ans.erase(ans.begin());
     return ans;
 }
开发者ID:andmej,项目名称:competitive_programming,代码行数:5,代码来源:factor.cpp


示例10: color_edit


//.........这里部分代码省略.........

	mvaddstr(COLORS + 3, 0,
	    "Use up/down to select a color, left/right to change fields.");
	mvaddstr(COLORS + 4, 0,
	    "Modify field by typing nnn=, nnn-, or nnn+.  ? for help.");

	move(2 + current, 0);

	switch (c = getch())
	{
	case KEY_UP:
	    current = (current == 0 ? (COLORS - 1) : current - 1);
	    value = 0;
	    break;

	case KEY_DOWN:
	    current = (current == (COLORS - 1) ? 0 : current + 1);
	    value = 0;
	    break;

	case KEY_RIGHT:
	    field = (field == 2 ? 0 : field + 1);
	    value = 0;
	    break;

	case KEY_LEFT:
	    field = (field == 0 ? 2 : field - 1);
	    value = 0;
	    break;

	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
	    do {
		value = value * 10 + (c - '0');
		c = getch();
	    } while
		(isdigit(c));
	    if (c != '+' && c != '-' && c != '=')
		beep();
	    else
		ungetch(c);
	    break;

	case '+':
	    usebase = 1;
	    goto changeit;

	case '-':
	    value = -value;
	    usebase = 1;
	    goto changeit;

	case '=':
	    usebase = 0;
	changeit:
	    color_content(current, &red, &green, &blue);
	    if (field == 0)
		red = red * usebase + value;
	    else if (field == 1)
		green = green * usebase + value;
	    else if (field == 2)
		blue = blue * usebase + value;
	    init_color(current, red, green, blue);
	    break;

	case '?':
	    erase();
    P("                      RGB Value Editing Help");
    P("");
    P("You are in the RGB value editor.  Use the arrow keys to select one of");
    P("the fields in one of the RGB triples of the current colors; the one");
    P("currently selected will be reverse-video highlighted.");
    P("");
    P("To change a field, enter the digits of the new value; they won't be");
    P("echoed.  Finish by typing `='; the change will take effect instantly.");
    P("To increment or decrement a value, use the same procedure, but finish");
    P("with a `+' or `-'.");
    P("");
    P("To quit, do `x' or 'q'");

	    move(LINES - 1, 0);
	    addstr("Press any key to continue... ");
	    (void) getch();
	    erase();
	    break;

	case 'x':
	case 'q':
	    break;

	default:
	    beep();
	    break;
	}
    } while
	(c != 'x' && c != 'q');

    erase();
    endwin();
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:101,代码来源:ncurses.c


示例11: getch_test

static void getch_test(void)
/* test the keypad feature */
{
char buf[BUFSIZ];
unsigned int c;
int incount = 0, firsttime = 0;
bool blocking = TRUE;

      refresh();

     (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
     echo();
     getstr(buf);
     noecho();

     if (isdigit(buf[0]))
     {
 	timeout(atoi(buf) * 100);
 	blocking = FALSE;
     }

      c = '?';
     for (;;)
     {
	if (firsttime++)
	{
	    printw("Key pressed: %04o ", c);
	    if (c >= KEY_MIN)
	    {
		(void) addstr(keyname(c));
		addch('\n');
	    }
	    else if (c > 0x80)
	    {
		if (isprint(c & ~0x80))
		    (void) printw("M-%c", c);
		else
		    (void) printw("M-%s", unctrl(c));
		addstr(" (high-half character)\n");
	    }
	    else
	    {
		if (isprint(c))
		    (void) printw("%c (ASCII printable character)\n", c);
		else
		    (void) printw("%s (ASCII control character)\n", unctrl(c));
	    }
	}
	if (c == 'x' || c == 'q')
	    break;
	if (c == '?')
	    addstr("Type any key to see its keypad value, `q' to quit, `?' for help.\n");

	while ((c = getch()) == ERR)
	    if (!blocking)
		(void) printw("%05d: input timed out\n", incount++);
    }

    timeout(-1);
    erase();
    endwin();
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:62,代码来源:ncurses.c


示例12: erase

void TimeSigMap::del(int tick)
      {
      erase(tick);
      normalize();
      }
开发者ID:Mistobaan,项目名称:MuseScore,代码行数:5,代码来源:sig.cpp


示例13: entry

bool
OfferStream::step ()
{
    // Modifying the order or logic of these
    // operations causes a protocol breaking change.

    for(;;)
    {
        // BookTip::step deletes the current offer from the view before
        // advancing to the next (unless the ledger entry is missing).
        if (! m_tip.step())
            return false;

        SLE::pointer const& entry (m_tip.entry());

        // Remove if missing
        if (! entry)
        {
            erase (view());
            erase (view_cancel());
            continue;
        }

        // Remove if expired
        if (entry->isFieldPresent (sfExpiration) &&
                entry->getFieldU32 (sfExpiration) <= m_when)
        {
            view_cancel().offerDelete (entry->getIndex());
            if (m_journal.trace) m_journal.trace <<
                                                     "Removing expired offer " << entry->getIndex();
            continue;
        }

        m_offer = Offer (entry, m_tip.quality());

        Amounts const amount (m_offer.amount());

        // Remove if either amount is zero
        if (amount.empty())
        {
            view_cancel().offerDelete (entry->getIndex());
            if (m_journal.warning) m_journal.warning <<
                        "Removing bad offer " << entry->getIndex();
            m_offer = Offer{};
            continue;
        }

        // Calculate owner funds
        // NIKB NOTE The calling code also checks the funds, how expensive is
        //           looking up the funds twice?
        Amount const owner_funds (view().accountFunds (
                                      m_offer.account(), m_offer.amount().out, fhZERO_IF_FROZEN));

        // Check for unfunded offer
        if (owner_funds <= zero)
        {
            // If the owner's balance in the pristine view is the same,
            // we haven't modified the balance and therefore the
            // offer is "found unfunded" versus "became unfunded"
            if (view_cancel().accountFunds (m_offer.account(),
                                            m_offer.amount().out, fhZERO_IF_FROZEN) == owner_funds)
            {
                view_cancel().offerDelete (entry->getIndex());
                if (m_journal.trace) m_journal.trace <<
                                                         "Removing unfunded offer " << entry->getIndex();
            }
            else
            {
                if (m_journal.trace) m_journal.trace <<
                                                         "Removing became unfunded offer " << entry->getIndex();
            }
            m_offer = Offer{};
            continue;
        }

        break;
    }

    return true;
}
开发者ID:jjuran,项目名称:rippled,代码行数:80,代码来源:OfferStream.cpp


示例14: main


//.........这里部分代码省略.........

            if( auto_mode ) {
                mvprintw(LINES / 2 + 3, COLS / 2 - 6, "Restarting..");
                refresh();

                /* reset the game */
                killworm(&worm);
                newnode(&worm, 1 + rand() % (COLS - 2), 6 + rand() % (LINES - 7));
                erow = 6 + rand() % (LINES - 7);
                ecol = 1 + rand() % (COLS - 2);
                score = level = eating = tricks = moves = 0;
                n = 1;

                sleep(2); /* leave that the user tastes the messsage :-) */
                continue;
            }
            else {
                mvprintw(LINES / 2 + 2, COLS / 2 - 10, "Press a key to exit..");

                nodelay(stdscr, FALSE);
                getch(); /* wait for input */

                break;
            }
        }

        eating = n; /* needed for the wormshow() call */

        /* If it's eating */
        while( iseat(worm, erow, ecol) ) {
            /* Add a node on the top of worm (new head) */
            current = worm;
            while( current->next != NULL )
                current = current->next;
            newnode(&current->next, worm->y, worm->x);

            /* Change the eat's position */
            erow = 6 + rand() % (LINES - 7);
            ecol = 1 + rand() % (COLS - 2);
            ++n; /* Change the eat's number */

            score += level + 1; /* increment the points */

            /* Increase the level */
            if( !(n % LEVEAT) ) {
                ++level;
            }
        }

        erase(); /* clear the screen */
        box(stdscr, ACS_VLINE, ACS_HLINE); /* create the borders */
        mvprintw(erow, ecol, "%d", n); /* draw the eat */

        /* Show the status window (and its elemets) */
        mvwprintw(stdscr, 1, COLS / 2 - 37 / 2, /* Copy */
                  "The Hermit worm - (C) 2006 Claudio M."); /* left */
        box(wstat, ACS_VLINE, ACS_HLINE); /* status box */
        mvwhline(stdscr, 5, 1, ACS_HLINE, COLS - 2); /* new top limit */

        /* Show the worm position */
        box(wepos, ACS_VLINE, ACS_HLINE); /* status box */
        mvwprintw(stdscr, 1, 3, "Worm Curs");
        mvwprintw(wepos, 1, 2, "%.2dx%.2d", erow, ecol);

        /* Show the eat position */
        box(wpos, ACS_VLINE, ACS_HLINE); /* status box */
        mvwprintw(stdscr, 1, COLS - 12, "Eat Curs");
        mvwprintw(wpos, 1, 2, "%.2dx%.2d", worm->x, worm->y);

        /* Show the informations */
        mvwprintw(wstat, 1, 3,
                  "TS:%.2dx%.2d | " /* Terminal size */
                  "SL:%.2d | "      /* Speed level */
                  "EM:%.2d | "      /* Eats missing */
                  "UM:%.3d | "      /* User moves */
                  "UT:%.2d | "      /* User tricks */
                  "Ss:%.3d",        /* Scores */
                  LINES, COLS, level + 1, LEVEAT - (n % LEVEAT),
                  moves, tricks, score);

        /*
         * Show the whole "new" worm
         * NOTE: this statement is not optimized - trash statement :-)
        */
        if( iseat(worm, erow + 1, ecol) || iseat(worm, erow - 1, ecol) ||
                iseat(worm, erow, ecol + 1) || iseat(worm, erow, ecol - 1) ) {
            wormshow(worm, WORM, EATH);
        }
        else
            wormshow(worm, WORM, HEAD);

        usleep( 100000 - level * 10000 );
    }

    endwin(); /* end of session */

    puts("\nEnd of game.");

    return 0;
} /* E0F main */
开发者ID:faruzzy,项目名称:misc,代码行数:101,代码来源:worm.c


示例15: mode_base

void mode_base(void)
{
   short buyer=0;

   char forcewait,canseethings;
   int nonsighttime=0;
   int oldforcemonth=month;

   int length=0;

   int l = 0;

   do
   {
      forcewait=1;
      canseethings=0;
      cantseereason=CANTSEE_OTHER;
      if(!disbanding)
      {
         for(int p=0;p<(int)pool.size();p++)
         {
            if(pool[p]->alive&&
               pool[p]->align==1&&
               pool[p]->dating==0&&
               pool[p]->hiding==0&&
               !(pool[p]->flag & CREATUREFLAG_SLEEPER))
            {
               if(!location[pool[p]->location]->part_of_justice_system())
               {
                  canseethings=1;
                  if(pool[p]->clinic==0){forcewait=0;break;}
               }
            }
            else
            {
               if(pool[p]->dating==1 && cantseereason>CANTSEE_DATING) cantseereason=CANTSEE_DATING;
               else if(pool[p]->hiding!=0 && cantseereason>CANTSEE_HIDING) cantseereason=CANTSEE_HIDING;
            }
         }
      }
      else
      {
         cantseereason=CANTSEE_DISBANDING;
      }

      if(disbanding)
      {
         disbanding = show_disbanding_screen(oldforcemonth);
      }

      if(!forcewait)
      {
         if(nonsighttime>=365*4)
         {
            erase();
            char str[100];
            if(nonsighttime>=365*16) {
               strcpy(str,"How long since you've heard these sounds...  times have changed.");
            } else if(nonsighttime>=365*8) {
               strcpy(str,"It has been a long time.  A lot must have changed...");
            } else {
               strcpy(str,"It sure has been a while.  Things might have changed a bit.");
            }
            set_color(COLOR_WHITE,COLOR_BLACK,1);
            move(12,39-((strlen(str)-1)>>1));
            addstr(str, gamelog);
            gamelog.nextMessage(); //Write out buffer to prepare for the next message.

            refresh();
            getch();
         }

         nonsighttime=0;
      }

      int partysize=0;
      int partydead=0;
      if(activesquad!=NULL)
      {
         for(int p=0;p<6;p++)
         {
            if(activesquad->squad[p]!=NULL)partysize++;
            else
            {
               if(p==buyer)buyer=0;
               continue;
            }
            if(!partysize)
            {
               delete activesquad;
               activesquad=NULL;
            }

            if(!activesquad->squad[p]->alive)partydead++;
         }
      }

      int safenumber=0;
      for(l=0;l<(int)location.size();l++)if(location[l]->is_lcs_safehouse())safenumber++;

//.........这里部分代码省略.........
开发者ID:TerminalHunter,项目名称:lunar-crime-squad,代码行数:101,代码来源:basemode.cpp


示例16: erase_key

 inline typename result_of::erase_key<Sequence const, Key>::type
 erase_key(Sequence const& seq)
 {
     return erase(seq, find<Key>(seq));
 }
开发者ID:03050903,项目名称:turbulenz_engine,代码行数:5,代码来源:erase_key.hpp


示例17: show_disbanding_screen

bool show_disbanding_screen(int& oldforcemonth)
{
   if(oldforcemonth == month) return true;

   for(int p=pool.size()-1;p>=0;p--)
   {
      int targetjuice=0;
      for(int i=0;i<(year-disbandtime)+1;i++)
      {
         targetjuice+=LCSrandom(100);
      }
      if(targetjuice>1000)
      {
         targetjuice=1000;
      }
      if(pool[p]->juice<targetjuice)
      {
         if(pool[p]->hireid!=-1 && !(pool[p]->flag & CREATUREFLAG_SLEEPER))
            pool[p]->alive=0; // Kill for the purposes of disbanding all contacts below
      }
   }
   oldforcemonth=month;
   erase();
   move(0,0);
   char num[20];
   itoa(year,num,10);
   set_color(COLOR_WHITE,COLOR_BLACK,1);
   addstr(getmonth(month));
   addstr(" ");
   addstr(num);


   //int y=2;

   set_alignment_color(exec[EXEC_PRESIDENT], true);
   mvaddstr(1,0,"President: ");
   addstr(execname[EXEC_PRESIDENT]);addstr(", ");
   switch(exec[EXEC_PRESIDENT])
   {
      case -2:addstr("Arch-Conservative");break;
      case -1:addstr("Conservative");break;
      case 0:addstr("moderate");break;
      case 1:addstr("Liberal");break;
      case 2:addstr("Elite Liberal");break;
   }
   if(execterm==1)addstr(", 1st Term");
   else addstr(", 2nd Term");

   int housemake[5]={0,0,0,0,0};
   for(int h=0;h<435;h++)
      housemake[house[h]+2]++;
   int lsum=housemake[3]+housemake[4]-housemake[0]-housemake[1];
   if(lsum<=-145)set_color(COLOR_RED,COLOR_BLACK,1);
   else if(lsum<0)set_color(COLOR_MAGENTA,COLOR_BLACK,1);
   else if(lsum<145)set_color(COLOR_YELLOW,COLOR_BLACK,1);
   else if(housemake[4]<290)set_color(COLOR_CYAN,COLOR_BLACK,1);
   else set_color(COLOR_GREEN,COLOR_BLACK,1);
   move(2,0);
   addstr("House: ");
   itoa(housemake[4],num,10);
   addstr(num);addstr("Lib+, ");
   itoa(housemake[3],num,10);
   addstr(num);addstr("Lib, ");
   itoa(housemake[2],num,10);
   addstr(num);addstr("Mod, ");
   itoa(housemake[1],num,10);
   addstr(num);addstr("Cons, ");
   itoa(housemake[0],num,10);
   addstr(num);addstr("Cons+");

   int senatemake[5]={0,0,0,0,0};
   for(int s=0;s<100;s++)
      senatemake[senate[s]+2]++;
   lsum=senatemake[3]+senatemake[4]-senatemake[0]-senatemake[1];
   if(lsum<=-33)set_color(COLOR_RED,COLOR_BLACK,1);
   else if(lsum<0)set_color(COLOR_MAGENTA,COLOR_BLACK,1);
   else if(lsum<33)set_color(COLOR_YELLOW,COLOR_BLACK,1);
   else if(senatemake[4]<67)set_color(COLOR_CYAN,COLOR_BLACK,1);
   else set_color(COLOR_GREEN,COLOR_BLACK,1);
   move(3,0);
   addstr("Senate: ");
   itoa(senatemake[4],num,10);
   addstr(num);addstr("Lib+, ");
   itoa(senatemake[3],num,10);
   addstr(num);addstr("Lib, ");
   itoa(senatemake[2],num,10);
   addstr(num);addstr("Mod, ");
   itoa(senatemake[1],num,10);
   addstr(num);addstr("Cons, ");
   itoa(senatemake[0],num,10);
   addstr(num);addstr("Cons+");

   int courtmake[5]={0,0,0,0,0};
   for(int s=0;s<9;s++)
   {
      courtmake[court[s]+2]++;
   }
   lsum=courtmake[3]+courtmake[4]
         -courtmake[0]-courtmake[1];
   if(courtmake[0]>=5)set_alignment_color(ALIGN_ARCHCONSERVATIVE, true);
//.........这里部分代码省略.........
开发者ID:TerminalHunter,项目名称:lunar-crime-squad,代码行数:101,代码来源:basemode.cpp


示例18: erase

void PrimaryTree::erase(std::string string) {
	root_ = erase(root_, string);
}
开发者ID:nicolas0p,项目名称:GerenciaDeArquivosEmDisco,代码行数:3,代码来源:PrimaryTree.cpp


示例19: keypress

void keypress(XEvent *ev) {
	XKeyEvent *e = &ev->xkey;
	KeySym sym = XkbKeycodeToKeysym(dpy, (KeyCode)e->keycode, 0, 0);
	int mod = ((e->state & ~Mod2Mask) & ~LockMask);
	if (mod == (ControlMask | ShiftMask)) {
		if (sym == XK_q) {
			spect->fex = 0;
			running = False;
		}
		if (sym == XK_j || sym == XK_Down) threshold(-0.05);
		else if (sym == XK_k || sym == XK_Up) threshold(0.05);
		else if (sym == XK_h || sym == XK_Left) sp_floor(-0.05);
		else if (sym == XK_l || sym == XK_Right) sp_floor(0.05);
		else if (sym == XK_p) play(0.1666);
	}
	else if (mod == (Mod1Mask | ShiftMask)) {
		if (sym == XK_p) play(0.08333);
	}
	else if (mod == ControlMask) {
		if (sym == XK_q) running = False;
		else if (sym == XK_f) series_export();
		else if (sym == XK_s) screenshot();
		else if (sym == XK_i) img_draw();
		else if (sym == XK_j || sym == XK_Down) zoom(-0.025);
		else if (sym == XK_k || sym == XK_Up) zoom(0.025);
		else if (sym == XK_h || sym == XK_Left) return;
		else if (sym == XK_l || sym == XK_Right) return;
		else if (sym == XK_p) play(0.33);
	}
	else if (mod == Mod1Mask) {
		if (sym == XK_j || sym == XK_Down) eraser_cursor(-1,-1);
		else if (sym == XK_k || sym == XK_Up) eraser_cursor(1,1);
		else if (sym == XK_h || sym == XK_Left) eraser_cursor(-1,1);
		else if (sym == XK_l || sym == XK_Right) eraser_cursor(1,-1);
		else if (sym == XK_p) play(0.25);
	}
	else if (mod == ShiftMask) {
		if (sym == XK_j || sym == XK_Down) pt_line(-0.2,0);
		else if (sym == XK_k || sym == XK_Up) pt_line(0.2,0);
		else if (sym == XK_h || sym == XK_Left) pt_line(0,-0.2);
		else if (sym == XK_l || sym == XK_Right) pt_line(0,0.2);
		else if (sym == XK_p) play(0.5);
	}
	else if (sym == XK_j || sym == XK_Down) move(0,0.02);
	else if (sym == XK_k || sym == XK_Up) move(0,-0.02);
	else if (sym == XK_h || sym == XK_Left) move(0.02,0);
	else if (sym == XK_l || sym == XK_Right) move(-0.02,0);
	else if (sym == XK_F1) {
		if (fork() == 0) {
			close(ConnectionNumber(dpy));
			fclose(stderr);
			fclose(stdout);
			execvp(conf.help_cmd[0],(char * const *)conf.help_cmd);
		}
	}
	else if (sym == XK_F2) {
		if ( (info->vis = !info->vis) ) XMapRaised(dpy,info->win);
		else XUnmapWindow(dpy,info->win);
		XFlush(dpy);
	}
	else if (sym == XK_e) {
		//mode = MODE_ERASE & (mode ^= MODE_ERASE);
		mode = (mode & MODE_ERASE ? 0 : MODE_ERASE);
		eraser_cursor(0,0);
		info->draw(info);
	}
	else if (sym == XK_c) {
		//mode = MODE_CROP & (mode ^= MODE_CROP);
		mode = (mode & MODE_CROP ? 0 : MODE_CROP);
		if (!(mode & MODE_CROP)) XDefineCursor(dpy, win, None);
		else XDefineCursor(dpy, win, XCreateFontCursor(dpy, 34));
		info->draw(info);
	}
	else if (sym == XK_Escape) {
		mode = MODE_NULL;
		XDefineCursor(dpy, win, None);
		info->draw(info);
	}
	else if (sym == XK_p) play(1.0);
	else if (sym == XK_t) {
		conf.layers = !conf.layers;
		spectro_draw();
		XCopyArea(dpy, buf, win, gc, 0, 0, ww, wh, 0, 0);
	}
	else if (sym == XK_u && mode & (MODE_ERASE)) erase(-1,-1);
	while(XCheckMaskEvent(dpy, KeyPressMask, ev));
}
开发者ID:BehaviorEnterprises,项目名称:Fex,代码行数:87,代码来源:xlib_events.c


示例20: envfs_save

/**
 * Make the current environment persistent
 * @param[in] filename where to store
 * @param[in] dirname what to store (all files in this dir)
 * @param[in] flags superblock flags (refer ENVFS_FLAGS_* macros)
 * @return 0 on success, anything else in case of failure
 *
 * Note: This function will also be used on the host! See note in the header
 * of this file.
 */
int envfs_save(const char *filename, const char *dirname, unsigned flags)
{
	struct envfs_super *super;
	int envfd, size, ret;
	struct action_data data = {};
	void *buf = NULL, *wbuf;
	struct envfs_entry *env;

	if (!filename)
		filename = default_environment_path_get();

	if (!dirname)
		dirname = "/env";

	data.writep = NULL;
	data.base = dirname;

#ifdef __BAREBOX__
	defaultenv_load(TMPDIR, 0);
#endif

	if (flags & ENVFS_FLAGS_FORCE_BUILT_IN) {
		size = 0; /* force no content */
	} else {
		/* first pass: calculate size */
		recursive_action(dirname, ACTION_RECURSE, file_action,
				NULL, &data, 0);
		recursive_action("/.defaultenv", ACTION_RECURSE,
				file_remove_action, NULL, &data, 0);
		size = 0;

		for (env = data.env; env; env = env->next) {
			size += PAD4(env->size);
			size += sizeof(struct envfs_inode);
			size += PAD4(strlen(env->name) + 1);
			size += sizeof(struct envfs_inode_end);
		}
	}

	buf = xzalloc(size + sizeof(struct envfs_super));
	data.writep = buf + sizeof(struct envfs_super);

	super = buf;
	super->magic = ENVFS_32(ENVFS_MAGIC);
	super->major = ENVFS_MAJOR;
	super->minor = ENVFS_MINOR;
	super->size = ENVFS_32(size);
	super->flags = ENVFS_32(flags);

	if (!(flags & ENVFS_FLAGS_FORCE_BUILT_IN)) {
		/* second pass: copy files to buffer */
		env = data.env;
		while (env) {
			struct envfs_entry *next = env->next;

			envfs_save_inode(&data, env);

			free(env->buf);
			free(env->name);
			free(env);
			env = next;
		}
	}

	super->crc = ENVFS_32(crc32(0, buf + sizeof(struct envfs_super), size));
	super->sb_crc = ENVFS_32(crc32(0, buf, sizeof(struct envfs_super) - 4));

	envfd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
	if (envfd < 0) {
		printf("could not open %s: %s\n", filename, errno_str());
		ret = -errno;
		goto out1;
	}

	ret = protect(envfd, ~0, 0, 0);

	/* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */
	if (ret && errno != ENOSYS && errno != EOPNOTSUPP) {
		printf("could not unprotect %s: %s\n", filename, errno_str());
		goto out;
	}

	ret = erase(envfd, ERASE_SIZE_ALL, 0);

	/* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */
	if (ret && errno != ENOSYS && errno != EOPNOTSUPP) {
		printf("could not erase %s: %s\n", filename, errno_str());
		goto out;
	}

//.........这里部分代码省略.........
开发者ID:Tractorfirmware,项目名称:barebox,代码行数:101,代码来源:environment.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ eraseDisplay函数代码示例发布时间:2022-05-30
下一篇:
C++ eraise函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap