<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## lua_next lua_next(L,index):先把 表(lua棧 index所指的表), 的當前索引彈出,再把table 當前索引的值彈出,也就是先彈出 table的索引,再彈出table索引的值 舉例: ``` local t = { ["a"] = 1, ["b"] = 2, ["c"] = 3 } ``` 使用`lua_next`遍歷table `t` ```c int traversing(lua_State *L) { lua_pushnil(L); /*此時棧的狀態 ------- | -1 nil | -2 table NUMBER_TABLE ------- */ while (lua_next(L, -2)) { /*此時棧的狀態 ------- | -1 value | -2 key | -3 table NUMBER_TABLE ------- */ if (lua_isnumber(L, -2)) printf("nkey: %d\t", luaL_checkinteger(L, -2)); else if (lua_isstring(L, -2)) printf("skey: %s\t", luaL_checkstring(L, -2)); if (lua_isnumber(L, -1)) printf("nvalue: %d\t", luaL_checkinteger(L, -1)); else if (lua_isstring(L, -1)) printf("svalue: %s\t", luaL_checkstring(L, -1)); /*此時棧的狀態 ------- | -1 value | -2 key | -3 table NUMBER_TABLE ------- */ lua_pop(L, 1); /*此時棧的狀態 ------- | -1 key | -2 table NUMBER_TABLE ------- */ } lua_pop(L, 1); /*此時棧的狀態 ------- | -1 table NUMBER_TABLE ------- */ return 0; } ``` lua_next(L, -2) 這個函數的工作過程是: 1) 先從棧頂彈出一個 `key` 2) 從棧指定位置的 `table` 里取下一對 key-value,先將 `key` 入棧,再將 `value` 入棧 3) 如果第 2 步成功則返回非 0 值,否則返回 0,并且不向棧中壓入任何值, 第 2 步中從 `table` 里取出"下一對 `key-value`"是相對于第 1 步中彈出的 key 的。`table` 里第一對 `key-value` 的前面沒有數據,所以先用 `lua_pushnil()` 壓入一個 `nil` 充當初始 `key`。 https://blog.csdn.net/mydreamremindme/article/details/47702901
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看