这个状态机http://www.cnblogs.com/flytrace/p/5587033.html的lua版本

  1. -- LUA 有实现枚举值的好办法么
  2. local sc_enum =
  3. {
  4. -- event flow be broke up
  5. none = "none",
  6. -- event flow pass througth next state
  7. forward = "forward",
  8. -- deffer a speciafic event
  9. --deffer = 4
  10.  
  11. -- select by default(the first position in the list)
  12. shallow = "shallow",
  13. -- the state will remain actived state that last time was
  14. deep = "deep",
  15.  
  16. -- 不实现。该模式定义不良好。多个嵌套的子并行状态相对复杂,流程不清晰,数据结构也不直接。
  17. -- 还没找到比较良好的并行状态语义。
  18. -- only one substate can run at one time by default
  19. singleman = "singleman",
  20. -- the state will be enabled always, substate in parallel region can't transit to none-parallel region
  21. parallel = "parallel",
  22.  
  23. }
  24.  
  25. return sc_enum
  1. -- Date 2016-7-13
  2. -- yanfei
  3.  
  4. --[[
  5. 一个sc_fsm也是一个sc_state,状态机本身也可以作为一个状态,但目前子状态机只能视为状态,未能作为独立的机制运行
  6. sc_fsm
  7. {
  8. type2states -- save all states accord to their name in a dictionary
  9. }
  10. --]]
  11. sc_helper = require("fsm.sc_helper")
  12. require("utils.sc_list")
  13. local sc_queue = require("utils.sc_queue")
  14. local sc_enum = require("fsm.sc_enum")
  15. local sc_state = require("fsm.sc_state")
  16. local classprototype = require("utils.middleclass")
  17. -- a fsm is a state
  18. local fsm = classprototype("sc_fsm", sc_state)
  19.  
  20. -- 建立类型-状态表
  21. local function buildstates(fsm, astate)
  22. fsm.type2states[astate.statename] = astate
  23. if astate.substates then
  24. for statename_, state_ in ipairs(astate.substates) do
  25. assert(fsm.type2states[state_.statename] == nil, string.format("[%s]: has a state named [%s] already!", fsm.statename, state_.statename))
  26. buildstates(fsm, state_)
  27. end
  28. end
  29. end
  30.  
  31. -- 重载initialize
  32. -- @statename_ 状态名字
  33. -- @basestate_ 父状态
  34. -- @statemode_ 运行模式
  35. -- @operation_ 激活操作
  36. function fsm:initialize(statename_, basestate_, statemode_, operation_)
  37. sc_state.initialize(self, statename_, basestate_, statemode_, operation_)
  38. end
  39.  
  40. function fsm:init(initstatename)
  41. assert(type(self) == 'table', "Make sure that you are using 'fsm:init' instead of 'fsm.init'")
  42.  
  43. self.type2states = {}
  44. buildstates(self, self)
  45.  
  46. local initstate = self.type2states[initstatename]
  47. assert(initstate and initstate:isInstanceOf(sc_state), string.format("[%s] hasn't state named [%s]", self.statename, initstatename))
  48.  
  49. -- 建立主激活列表
  50. local astate = initstate
  51. while astate do
  52. astate.activesubstate = astate.substates and astate.substates[] or nil
  53. self.ineststate = astate.activesubstate and astate.activesubstate or astate
  54. astate = astate.activesubstate
  55. end
  56.  
  57. astate = initstate
  58. while astate ~= self do
  59. astate.basestate.activesubstate = astate
  60. astate = astate.basestate
  61. end
  62.  
  63. astate = self
  64. while astate.activesubstate ~= nil do
  65. if astate.activesubstate.enter then astate.activesubstate:enter(self) end
  66. astate = astate.activesubstate
  67. end
  68.  
  69. if not self.eventqueue then self.eventqueue = sc_queue:newqueue() end
  70. self.suspend = false
  71. self.__lockqueue = false
  72. self.__transiting = false
  73.  
  74. return true
  75. end
  76.  
  77. -- 跳转到目标状态
  78. function fsm:transit( targetname_ )
  79. assert(type(self) == 'table', "Make sure that you are using 'fsm:transit' instead of 'fsm.transit'")
  80.  
  81. if self.__transiting then
  82. self.__transiting = false
  83. return sc_enum.none
  84. end
  85.  
  86. self.__transiting = true;
  87.  
  88. local targetstate = self.type2states[targetname_]
  89. assert(targetstate and targetstate:isInstanceOf(sc_state), string.format("[%s] hasn't state named [%s]", self.statename, targetname_))
  90.  
  91. -- detect the whole active state list
  92. local astate = self.ineststate
  93. --
  94. local bstate = targetstate
  95. local dis = astate.depth - bstate.depth
  96. if dis < then
  97. bstate, astate = astate, targetstate
  98. end -- bstate is topper
  99.  
  100. dis = math.abs(dis)
  101. for i = , dis do astate = astate.basestate end --now they are both same depth
  102.  
  103. if astate == bstate then -- is family
  104. self.__transiting = false
  105. return sc_enum.none
  106. end
  107.  
  108. -- find nearest ancestor both
  109. while astate ~= bstate do
  110. astate, bstate = astate.basestate, bstate.basestate
  111. end
  112.  
  113. -- first we will call exit chain
  114. while self.ineststate ~= astate do
  115. if self.ineststate.exit then self.ineststate:exit(self) end
  116. self.ineststate = self.ineststate.basestate
  117. end
  118.  
  119. -- now we will decide the enter chain
  120.  
  121. -- build active chain down side
  122. local astate = targetstate
  123. while astate do
  124. astate.activesubstate = (astate.substates and astate.statemode == sc_enum.shallow)
  125. and astate.substates[] or astate.activesubstate
  126. self.ineststate = astate.activesubstate and astate.activesubstate or astate
  127. astate = astate.activesubstate
  128. end
  129.  
  130. -- build active chain up side
  131. astate = targetstate
  132. while astate ~= self do
  133. astate.basestate.activesubstate, astate = astate, astate.basestate
  134. end
  135.  
  136. -- call enter chain
  137. while bstate.activesubstate ~= nil do
  138. if bstate.activesubstate.enter then bstate.activesubstate:enter(self) end
  139. bstate = bstate.activesubstate
  140. end
  141.  
  142. return sc_enum.none
  143. end
  144.  
  145. function fsm:process_event( eventname_, ...)
  146. assert(type(self) == 'table', "Make sure that you are using 'fsm:process_event' instead of 'fsm.process_event'")
  147. if self.suspend then return nil end
  148. if self.__lockqueue then return nil end
  149.  
  150. local pevent = {...}
  151. pevent.eventname = eventname_
  152. if not self.eventqueue then self.eventqueue = sc_queue:newqueue() end
  153. local queue = self.eventqueue
  154. queue:push_back(pevent)
  155.  
  156. self.__lockqueue = true
  157. --local eventcount = queue:count()
  158. while true do
  159. --eventcount = eventcount - 1
  160. local astate = self
  161. local processflag_ = sc_enum.forward
  162. pevent = queue:pop_front()
  163. if not pevent then break end
  164. while astate.activesubstate ~= nil do
  165. processflag_ = astate.activesubstate:_internal_process(self, pevent)
  166. if processflag_ == sc_enum.none then
  167. return processflag_
  168. end
  169. astate = astate.activesubstate
  170. end
  171. end
  172.  
  173. self.__lockqueue = false
  174.  
  175. return processflag_
  176. end
  177.  
  178. --
  179. function fsm:post_event( eventname_, ... )
  180. local pevent = {...}
  181. pevent.eventname = eventname_
  182. self.eventqueue:push_back(pevent)
  183. end
  184.  
  185. function fsm:context( statename_ )
  186. local targetstate = self.type2states[targetname_]
  187. --assert(targetstate and targetstate:isInstanceOf(sc_state), string.format("[%s] hasn't state named [%s]", self.statename, targetname_))
  188. return targetstate
  189. end
  190.  
  191. return fsm
  1. -- Date 2016-7-13
  2. -- yanfei
  3.  
  4. --[[
  5. -- sc_state
  6. -- {
  7. statename, -- 状态名
  8. basestate, -- 父状态
  9. statemode, -- 历史模式
  10. operation, -- 操作,完成并行,筛选。目前保留字段
  11.  
  12. substates, -- 子状态列表
  13. activestate, -- 当前激活状态
  14.  
  15. events,, -- event-callback
  16. -- }
  17. -- 一个状态是一个节点,basestate指向父状态,substates指向子状态列表,所有状态形成一棵树
  18. --]]
  19.  
  20. require("utils.sc_list")
  21. local sc_enum = require("fsm.sc_enum")
  22. --require("fsm.sc_event")
  23. local classprototype = require("utils.middleclass")
  24. local sc_state = classprototype("sc_state")
  25.  
  26. local rawget = rawget
  27. local rawset = rawset
  28. local string = string
  29.  
  30. -- 重载initialize
  31. -- @statename_ 状态名字
  32. -- @basestate_ 父状态
  33. -- @statemode_ 运行模式
  34. -- @operation_ 激活操作
  35. function sc_state:initialize(statename_, basestate_, statemode_, operation_)
  36. assert(type(statename_) == "string","statename must be a string")
  37. self.statename = statename_
  38. self.statemode = statemode_ or sc_enum.shallow
  39. --self.operation = operation_ or sc_enum.singleman
  40.  
  41. -- 处理父子关系
  42. assert(basestate_ and basestate_:isInstanceOf(sc_state) or basestate_ == nil, string.format("[%s]: base state must be a sc_state", statename_))
  43. self.basestate = basestate_
  44. if basestate_ then basestate_:addsubstate(self) end
  45.  
  46. -- 状态深度 top state is 1
  47. self.depth = self.basestate and self.basestate.depth + or
  48.  
  49. end
  50.  
  51. -- 创建该状态的子状态
  52. function sc_state:createstate(statename_, statemode_, operation_)
  53. return sc_state:new(statename_, self, statemode_, operation_)
  54. end
  55.  
  56. -- 添加子状态
  57. function sc_state:addsubstate(...)
  58. -- 填充子状态列表
  59. self.substates = self.substates or {}
  60. for i, state_ in ipairs{...} do
  61. assert(state_:isInstanceOf(sc_state), "substate must be a sc_state")
  62. assert(self.substates[state_.statename] == nil, string.format("%s has a substate named [%s] already!", self.statename, state_.statename))
  63. table.insert(self.substates, state_)
  64. end
  65. end
  66.  
  67. -- 绑定事件
  68. -- @eventname_ 事件名
  69. -- @callbackname_ 事件处理函数名
  70. function sc_state:bind_event(eventname_, callbackname_)
  71. assert(type(self) == 'table', "Make sure that you are using 'sc_state:process_event' instead of 'sc_state.process_event'")
  72. assert(type(eventname_) == 'string', "Make sure that callbakname is a string")
  73. assert(type(callbackname_) == 'string', "Make sure that callbakname is a string")
  74. --local callback_ = self[callbackname_]
  75. local callback_ = rawget(self, callbackname_)
  76. assert(callback_, string.format("[%s] bind_event event[%s]: hasn't a function named [%s]", self.statename, eventname_, callbackname_))
  77. assert(type(callback_) == "function", string.format("[%s]:bind_event event[%s]: callback must be a function", self.statename, eventname_))
  78.  
  79. self.events = self.events or {}
  80. self.events[eventname_] = function(fsm, ...) return callback_(self, fsm, ...) end
  81. end
  82.  
  83. function sc_state:_internal_process(fsm, pevent)
  84. if not self.events then return sc_enum.forward end
  85. local callback_ = self.events[pevent.eventname]
  86. if not callback_ then return sc_enum.forward end
  87. return callback_(fsm, unpack(pevent))
  88. end
  89.  
  90. return sc_state
  1. --region *.lua
  2. --Date 2016.7.17
  3. -- yanfei
  4.  
  5. local queue = {}
  6.  
  7. function queue:newqueue()
  8. local o = {first = , last = -}
  9. setmetatable(o, self)
  10. self.__index = self
  11. return o
  12. end
  13.  
  14. function queue:push_front(v)
  15. local first = self.first -
  16. self.first = first
  17. self[first] = v
  18. end
  19.  
  20. function queue:pop_front()
  21. local first = self.first
  22. if first > self.last then return nil end
  23. local v = self[first]
  24. self[first] = nil
  25. self.first = first +
  26. return v
  27. end
  28.  
  29. function queue:push_back(v)
  30. local last = self.last +
  31. self.last = last
  32. self[last] = v
  33. end
  34.  
  35. function queue:pop_back()
  36. local last = self.last
  37. if last < self.first then return nil end
  38. local v = self[last]
  39. self[last] = nil
  40. self.last = last -
  41. return v
  42. end
  43.  
  44. function queue:count()
  45. return self.last - self.first +
  46. end
  47.  
  48. return queue
  49. --endregion
  1. --region *.lua
  2.  
  3. module ("sc_list", package.seeall)
  4.  
  5. --- An iterator over the elements of a list.
  6. -- @param l list to iterate over
  7. -- @return iterator function which returns successive elements of the list
  8. -- @return the list <code>l</code> as above
  9. -- @return <code>true</code>
  10. function elems (l)
  11. local n =
  12. return function (l)
  13. n = n +
  14. if n <= #l then
  15. return l[n]
  16. end
  17. end,
  18. l, true
  19. end
  20.  
  21. --- An iterator over the elements of a list, in reverse.
  22. -- @param l list to iterate over
  23. -- @return iterator function which returns precessive elements of the list
  24. -- @return the list <code>l</code> as above
  25. -- @return <code>true</code>
  26. function relems (l)
  27. local n = #l +
  28. return function (l)
  29. n = n -
  30. if n > then
  31. return l[n]
  32. end
  33. end,
  34. l, true
  35. end
  36.  
  37. --- Fold a binary function into an iterator.
  38. -- @param f function
  39. -- @param d initial first argument
  40. -- @param i iterator
  41. -- @return result
  42. function fold_x (f, d, i, t)
  43. local r = d
  44. for e in i (t) do
  45. r = f (r, e)
  46. end
  47. return r
  48. end
  49.  
  50. function fold (f, d, t)
  51. local r = d
  52. for e in elems (t) do
  53. r = f (r, e)
  54. end
  55. return r
  56. end
  57.  
  58. ----- Fold a binary function through a list right associatively.
  59. ---- @param f function
  60. ---- @param e element to place in right-most position
  61. ---- @param l list
  62. ---- @return result
  63. --function foldr (f, e, l)
  64. -- return _G.fold (function (x, y) return f (y, x) end,
  65. -- e, relems, l)
  66. --end
  67.  
  68. function find(f, t)
  69. for e in elems (t) do
  70. if f(e) then return e end
  71. end
  72. return nil
  73. end
  74.  
  75. function findall(f, t)
  76. local result = {}
  77. for e in elems(t) do
  78. if f(e) then result[#result+] = (e) end
  79. end
  80. return result
  81. end
  82.  
  83. function join(a, b)
  84. return {unpack(a), unpack(b)}
  85. end
  86.  
  87. function cons(a, t)
  88. return {a, unpack(t)}
  89. end
  90.  
  91. --endregion

使用

  1. -- 只是一个例子
  2.  
  3. local sc_enum = require("fsm.sc_enum")
  4. local sc_fsm_pt = require("fsm.sc_fsm")
  5.  
  6. local gamemain_fsm = sc_fsm_pt:new("gamemain_fsm")
  7.  
  8. local print = print
  9.  
  10. --[[
  11. -- gamemain_state
  12. --]]
  13. local gamemain_state = gamemain_fsm:createstate("gamemain_state")
  14. function gamemain_state:enter(fsm)
  15. print("enter "..self.statename)
  16. end
  17.  
  18. function gamemain_state:exit(fsm)
  19. print("exit "..self.statename)
  20. end
  21.  
  22. function gamemain_state:update(fsm, delta)
  23. print("update "..self.statename)
  24. print("timedelta: "..tostring(delta))
  25. end
  26.  
  27. gamemain_state:bind_event("game_update", "update")
  28.  
  29. --[[
  30. -- gamemain_init_state
  31. --]]
  32. local gamemain_init_state = gamemain_state:createstate("gamemain_init_state")
  33.  
  34. function gamemain_init_state:enter(fsm)
  35. print("enter "..self.statename)
  36. end
  37.  
  38. function gamemain_init_state:exit(fsm)
  39. print("exit "..self.statename)
  40. end
  41.  
  42. --[[
  43. -- gamemain_init_waiting_state
  44. --]]
  45. local gamemain_init_waiting_state = gamemain_init_state:createstate("gamemain_init_waiting_state")
  46.  
  47. function gamemain_init_waiting_state:enter(fsm)
  48. print("enter "..self.statename)
  49. end
  50.  
  51. function gamemain_init_waiting_state:exit(fsm)
  52. print("exit "..self.statename)
  53. end
  54.  
  55. --[[
  56. -- gamemain_idle_state
  57. --]]
  58. local gamemain_idle_state = gamemain_state:createstate("gamemain_idle_state")
  59.  
  60. function gamemain_idle_state:enter(fsm)
  61. print("enter "..self.statename)
  62. end
  63.  
  64. function gamemain_idle_state:exit(fsm)
  65. print("exit "..self.statename)
  66. end
  67.  
  68. function gamemain_idle_state:update(fsm, delta)
  69. print("update "..self.statename)
  70. print("timedelta: "..tostring(delta))
  71. --fsm:process_event("game_upadte", 0.0001)
  72. end
  73.  
  74. function gamemain_idle_state:tolobby(fsm, msg1, msg2)
  75. print(msg1..' '..msg2)
  76. print("ready to taransit to lobby")
  77. return fsm:transit("gamemain_lobby_state")
  78. end
  79.  
  80. gamemain_idle_state:bind_event("game_update", "update")
  81. gamemain_idle_state:bind_event("event_tolobby", "tolobby")
  82. --[[
  83. -- gamemain_net_state
  84. --]]
  85. local gamemain_net_state = gamemain_state:createstate("gamemain_net_state")
  86. function gamemain_net_state:enter(fsm)
  87. print("enter "..self.statename)
  88. end
  89.  
  90. function gamemain_net_state:exit(fsm)
  91. print("exit "..self.statename)
  92. end
  93.  
  94. --[[
  95. -- gamemain_net_send_state
  96. --]]
  97. local gamemain_net_send_state = gamemain_net_state:createstate("gamemain_net_send_state")
  98. function gamemain_net_send_state:enter(fsm)
  99. print("enter "..self.statename)
  100. end
  101.  
  102. function gamemain_net_send_state:exit(fsm)
  103. print("exit "..self.statename)
  104. end
  105.  
  106. --[[
  107. -- gamemain_net_receive_state
  108. --]]
  109. local gamemain_net_receive_state = gamemain_net_state:createstate("gamemain_net_receive_state")
  110. function gamemain_net_receive_state:enter(fsm)
  111. print("enter "..self.statename)
  112. end
  113.  
  114. function gamemain_net_receive_state:exit(fsm)
  115. print("exit "..self.statename)
  116. end
  117.  
  118. --[[
  119. -- gamemain_lobby_state
  120. --]]
  121. local gamemain_lobby_state = gamemain_state:createstate("gamemain_lobby_state")
  122. function gamemain_lobby_state:enter(fsm)
  123. print("enter "..self.statename)
  124. end
  125.  
  126. function gamemain_lobby_state:exit(fsm)
  127. print("exit "..self.statename)
  128. end
  129.  
  130. --[[
  131. -- gamemain_lobby_shop_state
  132. --]]
  133. local gamemain_lobby_shop_state = gamemain_lobby_state:createstate("gamemain_lobby_shop_state")
  134. function gamemain_lobby_shop_state:enter(fsm)
  135. print("enter "..self.statename)
  136. fsm:post_event("event_opendoor", "opendoor")
  137. end
  138.  
  139. function gamemain_lobby_shop_state:exit(fsm)
  140. print("exit "..self.statename)
  141. end
  142.  
  143. function gamemain_lobby_shop_state:update(fsm, delta)
  144. print("update "..self.statename)
  145. print("timedelta: "..tostring(delta))
  146. end
  147.  
  148. function gamemain_lobby_shop_state:opendoor(fsm)
  149. print("open the door")
  150. end
  151.  
  152. gamemain_lobby_shop_state:bind_event("game_update", "update")
  153. gamemain_lobby_shop_state:bind_event("event_opendoor", "opendoor")
  154.  
  155. --[[
  156. -- gamemain_lobby_dungeon_state
  157. --]]
  158. local gamemain_lobby_dungeon_state = gamemain_lobby_state:createstate("gamemain_lobby_dungeon_state")
  159. function gamemain_lobby_dungeon_state:enter(fsm)
  160. print("enter "..self.statename)
  161. end
  162.  
  163. function gamemain_lobby_dungeon_state:exit(fsm)
  164. print("exit "..self.statename)
  165. end
  166.  
  167. return gamemain_fsm
  1. --region *.lua
  2. --Date
  3.  
  4. sc_helper = require("fsm.sc_helper")
  5. local sc_event = require("fsm.sc_event")
  6. local queue = require("utils.sc_queue")
  7.  
  8. -- 获取定义好的gamemain状态机
  9. local gamemain_fsm = require("game.gamemain_fsm")
  10. -- 打印状态树
  11. sc_helper:printstates(gamemain_fsm)
  12.  
  13. -- 初始化状态机,初始状态为gamemain_init_state,进入gamemain_init_state时将自动进入其子状态gamemain_init_waiting_state
  14. -- 进入某个状态后,如果有子状态,会尝试进入其子状态
  15. gamemain_fsm:init("gamemain_init_state")
  16.  
  17. -- 自顶向下打印当前激活的状态链
  18. sc_helper:printactivestates(gamemain_fsm)
  19.  
  20. -- 状态迁移到gamemain_idle_state
  21. gamemain_fsm:transit("gamemain_idle_state")
  22.  
  23. sc_helper:printactivestates(gamemain_fsm)
  24.  
  25. -- 发送事件game_update gamemain_idle_state中注册了对该事件的响应
  26. gamemain_fsm:process_event("game_update", 0.0333333)
  27. -- 发送事件event_tolobby,在gamemain_idle_state中注册了对该事件的响应。在响应中将调用gamemain_fsm:transit迁移到gamemain_lobby_state
  28. gamemain_fsm:process_event("event_tolobby", "hello", "world")
  29. sc_helper:printactivestates(gamemain_fsm)
  30. gamemain_fsm:process_event("game_update", 0.0333333)
  31.  
  32. print("over")
  33. --endregion

lua版本的一个状态机的更多相关文章

  1. 编译lua版本问题

    Compile++ thumb  : game_shared <= main.cppjni/hellocpp/main.cpp: In function 'void Java_org_cocos ...

  2. 5-(基础入门篇)学会刷Wi-Fi模块固件(刷LUA版本固件)

    http://www.cnblogs.com/yangfengwu/p/9065559.html 基础教程源码链接请在淘宝介绍中下载,由于链接很容易失效,如果失效请联系卖家,谢谢 https://it ...

  3. 1-添加自己的Lua执行函数(ESP8266-SDK开发(lua版本))

    基础 lua_pushnumber (L, 1); lua_pushnumber (L,3); lua_pushnumber (L,4); return 3; c_sprintf(temp, &quo ...

  4. Java Secret: Using an enum to build a State machine(Java秘术:用枚举构建一个状态机)

    近期在读Hadoop#Yarn部分的源代码.读到状态机那一部分的时候,感到enmu的使用方法实在是太灵活了,在给并发编程网翻译一篇文章的时候,正好碰到一篇这种文章.就赶紧翻译下来,涨涨姿势. 原文链接 ...

  5. cocos2d-x3.0 lua学习(一个)

    最近开始学习Lua这里记录下一个写简单Lua代码,但我在写Lua代码.自己主动的代码提示的一些问题,谁希望提供下很好的解决方案,编辑我用SubLime Text2 test.lua.这里创建一个场景, ...

  6. git 超前一个版本 落后一个版本的解决方案

    在使用SourceTree的时候经常会遇见超前一个版本,落后N个版本的情况,遇见这种情况应该怎么办呢? 首先打开终端,最好是从SourceTree里面打开,菜单栏有个终端按钮. 然后输入: $ git ...

  7. xcode 运行 lua版本崩溃 解决方案

    问题描述:运行到LuaStack::init() 崩溃 原因: luajit不支持arm64 解决方案:编译luajit64位静态库 a.可以直接下载别人编译好的库,然后直接覆盖cocos2d\ext ...

  8. 用openresty(Lua)写一个获取YouTube直播状态的接口

    文章原发布于:https://www.chenxublog.com/2019/08/29/openresty-get-youtube-live-api.html 之前在QQ机器人上面加了个虚拟主播开播 ...

  9. [sqoop1.99.6] 基于1.99.6版本的一个小例子

    1.创建mysql数据库.表.以及测试数据mysql> desc test;+-------+-------------+------+-----+---------+------------- ...

随机推荐

  1. Zabbix实战-简易教程--动作(Actions)--自动发现

    一.概述 Zabbix提供了有效和非常灵活的网络自动发现功能. 设置网络发现后你可以: 加快Zabbix部署(自动添加主机.添加模板) 简化管理(自动删除主机.删除模板.禁用主机) 无需过多管理就能在 ...

  2. SSIS 延迟验证(DelayValidation)

    验证是一个事件,该事件在Package执行时,第一个被触发,验证能够避免SSIS引擎执行一个有异常的Package或Task.延迟验证(DelayValidation)是把验证操作延迟到Package ...

  3. c#中常用集合类和集合接口之接口系列【转】

    常用集合接口系列:http://www.cnblogs.com/fengxiaojiu/p/7997704.html 常用集合类系列:http://www.cnblogs.com/fengxiaoji ...

  4. IntelliJ IDEA 17和Maven构建javaWeb项目

    前言 电脑又断电了,眼看着写好的东西就没有了,这是第二次犯这个错误了.很难受呀!还是回到正题吧,我们来使用IDEA和Maven构建一个JavaWeb项目 软件环境: IDEA:2017.2.1 JDK ...

  5. POJ2689-Prime Distance-区间筛素数

    最近改自己的错误代码改到要上天,心累. 这是迄今为止写的最心累的博客. Prime Distance Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  6. 简单的面向对象(OO)练习

    学生设备管理系统: 每个学校都有很多班级,每个班级都有很多设备.(设备可以更新)每个设备都有购买价格,每种设备都有折旧率(如每年折旧10%) 按班级进行统计,指定的班级有多少的设数量? 按班级进行统计 ...

  7. js代码性能优化的几个方法

    相信写代码对于大部分人都不难,但想写出高性能的代码就需要一定的技术积累啦,下面是一些优化JavaScript代码性能的常见方法. 一.注意作用域 1.避免全局查找 使用全局变量和函数肯定要比局部的开销 ...

  8. radiobutton独特属性

    radiobutton是通过name来分组的,也就是说,使用相同的名字的radio,它们才是单选的,如果名字不同的radio,是不具备这个效果的,这个是第一要点. 第二,针对不同的radio(name ...

  9. MLlib--PIC算法

    转载请标明出处http://www.cnblogs.com/haozhengfei/p/82c3ef86303321055eb10f7e100eb84b.html PIC算法   幂迭代聚类     ...

  10. php常用数据结构

    # 常用数据结构--------------------------------------------------------------------------------## 树(Tree)- ...