• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            的筆記

            隨時(shí)隨地編輯

            艾奴兒

            人人都愛奴兒

            Stack

            Manipulation(Offical API reforence 3.3 Stack Manipulation)

            The API o?ers the following functions for basic stack manipulation:
                  void lua_settop (lua_State *L, int index);
                  void lua_pushvalue (lua_State *L, int index);
                  void lua_remove (lua_State *L, int index);
                  void lua_insert (lua_State *L, int index);
                  void lua_replace (lua_State *L, int index);

               As an example, if the stack starts as 10 20 30 40 50* (from bottom to top; the ‘*’ marks the top), then
                     lua_pushvalue(L, 3) --> 10 20 30 40 50 30*
                     lua_pushvalue(L, -1) --> 10 20 30 40 50 30 30*
                     lua_remove(L, -3) --> 10 20 30 40 30 30*
                     lua_remove(L, 6) --> 10 20 30 40 30*
                     lua_insert(L, 1) --> 30 10 20 30 40*
                     lua_insert(L, -1) --> 30 10 20 30 40* (no effect)
                     lua_replace(L, 2) --> 30 40 20 30*
                     lua_settop(L, -3) --> 30 40*
                     lua_settop(L, 6) --> 30 40 nil nil nil nil*
                在lua.h中有macro:
                     #define lua_pop(L,n) lua_settop(L, -(n)-1)
                則
               pop(n)==settop(-n-1)
               settop(n)==pop(-n-1) == push(n)

            :出棧幾個(gè)元素,相當(dāng)于將這個(gè)數(shù)字加一,然后用和的相反數(shù)作為棧頂;從棧頂往下數(shù)了幾個(gè)數(shù)標(biāo)記為棧頂,則將這個(gè)數(shù)加一,然后用這個(gè)和數(shù)出棧。好比公司要擴(kuò)招了,就招n個(gè)伢,那就將n個(gè)伢入棧,工號(hào)一個(gè)個(gè)的加,加n次。或者要裁員了,就裁m個(gè)伢,則按順序?qū)⒐ぬ?hào)最大的前面m個(gè)伢遣散了,老員工暫時(shí)不動(dòng),公司裁員后的最大的工號(hào)嘛就將裁員人數(shù)加一后,往下數(shù)這個(gè)數(shù),數(shù)到哪個(gè),哪個(gè)就是工號(hào)最大的伢了。

            Querying(Offical lua api reference 3.4 Querying the Stack)

            To check the type of a stack element, the following functions are available:
                     int lua_type (lua_State *L, int index);
                     int lua_isnil (lua_State *L, int index);
                     int lua_isboolean (lua_State *L, int index);
                     int lua_isnumber (lua_State *L, int index);
                     int lua_isstring (lua_State *L, int index);
                     int lua_istable (lua_State *L, int index);
                     int lua_isfunction (lua_State *L, int index);
                     int lua_iscfunction (lua_State *L, int index);
                     int lua_isuserdata (lua_State *L, int index);
                     int lua_islightuserdata (lua_State *L, int index);

               The API also contains functions to compare two values in the stack:
                     int lua_equal (lua_State *L, int index1, int index2);
                     int lua_rawequal (lua_State *L, int index1, int index2);
                     int lua_lessthan (lua_State *L, int index1, int index2);

            :黃帝生眾人,眾人生萬(wàn)物,萬(wàn)物生八卦,八卦生努爾盞,lua棧就是眾生能觸摸到的祖先的氣。你可以在奴兒盞里隨心所欲的玩,逾矩的玩,窺視那些終生像:忠奸善惡,數(shù)串表函,是不是三聚氰胺防腐劑,是不是裸官醉駕二次碾壓.

             

            取棧值(offical api 3.5 Getting Values from the Stack)

            To translate a value in the stack to a speci?c C type, you can use the following conversion functions:

            int lua_toboolean (lua_State *L, int index);
            lua_Number lua_tonumber (lua_State *L, int index);
            const char *lua_tostring (lua_State *L, int index);
            size_t lua_strlen (lua_State *L, int index);
            lua_CFunction lua_tocfunction (lua_State *L, int index);
            void *lua_touserdata (lua_State *L, int index);
            lua_State *lua_tothread (lua_State *L, int index);
            void *lua_topointer (lua_State *L, int index);

            :可以將盞里的東西讀出來(lái):數(shù)、串、真、假、函、線、針。不管盞里放的是神馬五谷雜糧,都可以讀出來(lái)啦。

            存棧(offical api reference 3.6 Pushing Values onto the Stack)

            The API has the following functions to push C values onto the stack:

            void lua_pushboolean (lua_State *L, int b);
            void lua_pushnumber (lua_State *L, lua_Number n);
            void lua_pushlstring (lua_State *L, const char *s, size_t len);
            void lua_pushstring (lua_State *L, const char *s);
            void lua_pushnil (lua_State *L);
            void lua_pushcfunction (lua_State *L, lua_CFunction f);
            void lua_pushlightuserdata (lua_State *L, void *p);

            :五谷雜糧都可以往盞里裝。最好是五年藏梅花上的雪,夏日收在盞里。

            棧指針(offical api reference 3.2 The Stack and Indices)

                  A positive index represents an absolute stack position (starting at 1); 
                  a negative index represents an o?set from the top of the stack.

                  We say that an index is valid if it lies between 1 and the stack top (that is, if 1 <= abs(index) <= top).

                  At any time, you can get the index of the top element by calling lua_gettop:
                              int lua_gettop (lua_State *L);

                  grows the stack size to top + extra elements:
                              int lua_checkstack (lua_State *L, int extra);

                  Whenever Lua calls C, it ensures that at least LUA_MINSTACK stack positions are available.LUA_MINSTACK is de?ned in lua.h 
                              as 20

                  More formally, we de?ne an acceptable index as follows:
                              (index < 0 && abs(index) <= top) || (index > 0 && index <= stackspace)
                              Note that 0 is never an acceptable index

            :
                取棧中頂元指針的值,這個(gè)值既指明了棧中頂元的指針,也同時(shí)等于棧元的總數(shù)。
                你有責(zé)任使用有效的棧針,不要隨便拿個(gè)針就到處戳。
                可以增加棧,但不能收縮棧。
                0針是不能被接受的,不要用0針到處戳。

            posted on 2011-07-02 15:20 的筆記 閱讀(225) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            久久久国产乱子伦精品作者| 2021国产精品久久精品| 国产情侣久久久久aⅴ免费| 久久综合给合久久狠狠狠97色| 日日躁夜夜躁狠狠久久AV| AV无码久久久久不卡网站下载| 99久久国产主播综合精品| 热RE99久久精品国产66热| 亚洲色大成网站www久久九| 国产精品久久毛片完整版| 老司机午夜网站国内精品久久久久久久久 | 亚洲精品国精品久久99热一| 久久这里只有精品18| 国产精品99久久久久久宅男| 久久久无码精品亚洲日韩蜜臀浪潮| 99精品国产在热久久无毒不卡| 热久久国产欧美一区二区精品| 久久综合亚洲欧美成人| 一本久久a久久精品综合香蕉| www.久久99| 无遮挡粉嫩小泬久久久久久久| 99久久国产综合精品网成人影院| 99久久国产精品免费一区二区| 精品视频久久久久| 久久精品国产一区二区三区日韩| 国产毛片欧美毛片久久久| 久久久WWW成人免费精品| 国产韩国精品一区二区三区久久| 热久久最新网站获取| 国产—久久香蕉国产线看观看| 精品无码久久久久久尤物| 午夜不卡久久精品无码免费| 囯产极品美女高潮无套久久久| 久久国产成人午夜AV影院| Xx性欧美肥妇精品久久久久久 | 久久久久久亚洲精品成人| 久久精品国产欧美日韩99热| 久久伊人中文无码| 香蕉久久夜色精品国产2020| 人人狠狠综合久久亚洲| 久久久噜噜噜久久|