//没登陆

欢迎您来到凯恩之角,奈非天!

帖子:226

符文:245

31#
加班写的头昏脑涨,打开凯恩又看了10分钟代码
发表于 2019-9-28 15:16:30 来自凯恩之角App |只看该作者 来自:北京

帖子:319

符文:70

32#
子车车车 发表于 2019-9-28 15:16
加班写的头昏脑涨,打开凯恩又看了10分钟代码

哈哈,今天加班可太惨了,连上8天嗷
发表于 2019-9-28 17:10:12 来自凯恩之角App |只看该作者 来自:江苏

帖子:1221

符文:801

33#
太牛逼了,程序员改变世界

点评

雪落丶丿寒  哈哈  发表于 2019-9-29 16:52
发表于 2019-9-28 20:32:03 来自凯恩之角App |只看该作者 来自:上海

帖子:319

符文:70

34#
顺便贴一个之前写的数据模型,这个数据模型底层通过红黑树进行维护,学过java的朋友应该一眼就能看出来是treeMap。此数据模型的插入和读取的时间复杂度为o(lgn),并且底层为自排序数列,通过迭代器iter输出的值是从小到大的。需要的可以直接拿去用。
  1. -- 红黑树--------------------------
  2. BLACK = false;
  3. Red = true;
  4. Map = {root = nil,size = 0};
  5. -----
  6. function Map:new(o,root)--新建对象
  7.         o =  o or {}
  8.         setmetatable(o,self)
  9.         self.__index=self
  10.         o.root = root
  11.         return o;
  12. end
  13. function Map:put(key,value)--存入键值对
  14.         local node = Node:new(key,value,BLACK)
  15.         self:insert(node);
  16. end
  17. function Map:get(key)--通过键获取值
  18.         local node = self:getNode(key);
  19.         return (node~=nil and {node.value} or {nil})[1];
  20. end
  21. function Map:remove(key)--删除
  22.         local node = self:getNode(key);
  23.         if node~=nil then self:delete(node) end;
  24. end
  25. function Map:length() return self.size end--获得集合长度
  26. -------------------
  27. Node = {key = nil,value=nil,left=nil,right=nil,parent=nil,color =nil};
  28. function Node:new (key,value,color,left,right,parent,o)
  29.         o = o or {}
  30.         setmetatable(o,self)
  31.         self.__index=self
  32.         o.key = key
  33.         o.value  = value
  34.         o.left = left
  35.         o.right = right
  36.         o.parent = parent
  37.         o.color = color
  38.         return o;
  39. end
  40. function Map:turn_left(x)--左旋
  41.         local y = x.right;
  42.         x.right = y.left;
  43.         if y.left ~= nil then y.left.parent = x end;
  44.         y.parent = x.parent;
  45.         if x.parent==nil then self.root=y elseif x.parent.left==x then x.parent.left=y else x.parent.right=y end
  46.         y.left = x;
  47.         x.parent = y;
  48. end
  49. function Map:turn_right(x)--右旋
  50.         local y = x.left;
  51.         x.left = y.right;
  52.         if y.right~=nil then y.right.parent=x end
  53.         y.parent = x.parent;
  54.         if x.parent==nil then self.root=y elseif x==x.parent.left then x.parent.left=y else  x.parent.right=y end
  55.         y.right = x;
  56.         x.parent = y;
  57. end
  58. function Map:getNode(key)
  59.         local x = self.root;
  60.         while x~=nil do
  61.                 if key==x.key then return x end
  62.                 x=(x.key>key and {x.left} or {x.right})[1];
  63.         end
  64.         return nil;
  65. end
  66. function Map:insert(node)--插入
  67.         local y = nil;
  68.         local x = self.root;
  69.         while x~=nil do
  70.                 if x.key==node.key then x.value=node.value;return 1 end
  71.                 y=x;
  72.                 x=(node.key<x.key and{x.left}or{x.right})[1]
  73.         end;
  74.         node.parent = y;
  75.         if y~=nil then if node.key<y.key then y.left=node else y.right=node end else self.root=node end;
  76.         node.color = RED;
  77.         self:insertFixUp(node);
  78.         self.size=self.size+1;
  79. end
  80. function Map:insertFixUp(node)--插入调整
  81.         local parent = node.parent
  82.         local gparent;
  83.         while (parent~=nil and parent.color==RED)do
  84.                 repeat
  85.                 gparent = parent.parent;
  86.                 if(parent==gparent.left)then
  87.                         local uncle = gparent.right;
  88.                         if(uncle~=nil)and(uncle.color==RED)then
  89.                                 uncle.color = BLACK;
  90.                                 parent.color = BLACK;               
  91.                                 gparent.color = RED;
  92.                                 node = gparent;
  93.                                 break;       
  94.                         end       
  95.                         if(parent.right==node)then
  96.                                 self:turn_left(parent);
  97.                                 local tmp = parent;
  98.                                 parent = node;
  99.                                 node = temp;
  100.                         end
  101.                         parent.color = BLACK;
  102.                         gparent.color = RED;
  103.                         self:turn_right(gparent);
  104.                 else
  105.                         local uncle = gparent.left;
  106.                         if(uncle~=nil)and(uncle.color==RED)then
  107.                                 uncle.color = BLACK;
  108.                                 parent.color = BLACK;               
  109.                                 gparent.color = RED;
  110.                                 node = gparent;
  111.                                 break;       
  112.                         end       
  113.                         if(parent.left==node)then
  114.                                 self:turn_right(parent);
  115.                                 local tmp = parent;
  116.                                 parent = node;
  117.                                 node = temp;
  118.                         end
  119.                         parent.color = BLACK;
  120.                         gparent.color = RED;
  121.                         self:turn_left(gparent);
  122.                 end
  123.                 until true;
  124.                 parent = node.parent;
  125.         end
  126.         self.root.color = BLACK;
  127. end
  128. function Map:delete(node)
  129.         local replace = nil;
  130.         local parent = nil;
  131.         if node.left~=nil and node.right~=nil then
  132.                 local x = node.right;
  133.                 while x.left~=nil do x = x.left end
  134.                 node.key=x.key;node.value=x.value;
  135.                 return self:delete(x);
  136.         end
  137.         if node.parent==nil then
  138.                 self.root=(node.left~=nil and {node.left} or {node.right})[1];
  139.                 replace=self.root;
  140.                 if self.root~=nil then self.root.parent=nil end;
  141.         else
  142.                 local child = (node.left~=nil and {node.left}or{node.right})[1];
  143.                 if node.parent.left==node then node.parent.left=child;
  144.                 else node.parent.right=child end;
  145.                 if child~=nil then child.parent=node.parent end
  146.                 replace = child;
  147.                 parent = node.parent;
  148.         end
  149.         if node.color==BLACK then self:deleteFixUp(replace,parent) end;
  150.         self.size = self.size-1;
  151. end
  152. function Map:deleteFixUp(replace,parent)
  153.         local brother = nil;
  154.         while replace==nil or replace.color==BLACK and replace~=self.root do
  155.                 if parent.left==replace then
  156.                         brother=parent.right;
  157.                         if brother.color==RED then
  158.                                 brother.color = BLACK;
  159.                                 parent.color = RED;
  160.                                 self:turn_left(parent);
  161.                                 brother=parent.right;
  162.                         end
  163.                         if(brother.left==nil or brother.left.color==BLACK)and(brother.right==nil or brother.right.color==BLACK)then
  164.                                 if parent.color==RED then
  165.                                         parent.color=BLACK;
  166.                                         brother.color=RED;
  167.                                         break;
  168.                                 else
  169.                                         brother.color=RED;
  170.                                         replace=parent;
  171.                                         parent=replace.parent;
  172.                                 end
  173.                         else
  174.                                 if brother.left~=nil and brother.left.color==RED then
  175.                                         brother.left.color=parent.color;
  176.                                         parent.color=BLACK;
  177.                                         self:turn_right(brother);
  178.                                         self:turn_left(parent);
  179.                                 elseif brother.right~=nil and brother.right.color==RED then
  180.                                         brother.color = parent.color;
  181.                                         parent.color = BLACK;
  182.                                         brother.right.color = BLACK;
  183.                                         self:turn_left(parent);
  184.                                 end
  185.                                 break;
  186.                         end
  187.                 else
  188.                         brother=parent.left;
  189.                         if brother.color==RED then
  190.                                 brother.color = BLACK;
  191.                                 parent.color = RED;
  192.                                 self:turn_right(parent);
  193.                                 brother=parent.left;
  194.                         end
  195.                         if(brother.left==nil or brother.left.color==BLACK)and(brother.right==nil or brother.right.color==BLACK)then
  196.                                 if parent.color==RED then
  197.                                         parent.color=BLACK;
  198.                                         brother.color=RED;
  199.                                         break;
  200.                                 else
  201.                                         brother.color=RED;
  202.                                         replace=parent;
  203.                                         parent=replace.parent;
  204.                                 end
  205.                         else
  206.                                 if brother.right~=nil and brother.right.color==RED then
  207.                                         brother.right.color=parent.color;
  208.                                         parent.color=BLACK;
  209.                                         self:turn_left(brother);
  210.                                         self:turn_right(parent);
  211.                                 elseif brother.left~=nil and brother.left.color==RED then
  212.                                         brother.color = parent.color;
  213.                                         parent.color = BLACK;
  214.                                         brother.left.color = BLACK;
  215.                                         self:turn_right(parent);
  216.                                 end
  217.                                 break;
  218.                         end
  219.                 end
  220.         end
  221.         if replace~=nil then replace.color=BLACK;end
  222. end
  223. function Map:iter()--迭代器
  224.         local node = self.root;
  225.         if node==nil then return nil end;
  226.         while(node.left~=nil)do node=node.left end;
  227.         return function()
  228.                 local prv = node;
  229.                 if node==nil then return nil end;
  230.                 if node.right~=nil then
  231.                         node=node.right;
  232.                         while(node.left~=nil)do
  233.                                 node=node.left  
  234.                         end
  235.                 else if node.parent==nil then return nil end;
  236.                         while(node.parent.left~=node)do node=node.parent if node.parent==nil then return prv end end
  237.                         node=node.parent;
  238.                 end
  239.                 return prv;
  240.         end
  241. end
  242. -- 红黑树  end---------------------
复制代码


发表于 2019-10-12 21:50:12 |只看该作者 来自:浙江

帖子:170

符文:30

35#
貌似罗技已经被高得干残了
发表于 2019-10-12 22:06:54 来自凯恩之角App |只看该作者 来自:四川

帖子:319

符文:70

36#
ymmmmh 发表于 2019-10-12 22:06
貌似罗技已经被高得干残了

额,干残?没看懂,是方言么
发表于 2019-10-12 22:10:34 来自凯恩之角App |只看该作者 来自:浙江

帖子:17

符文:2

37#
请问find 的方法可以用来获取屏幕颜色吗? 罗技有没有这个功能啊?
发表于 2020-1-29 06:15:18 |只看该作者 来自:云南

帖子:17

符文:2

38#
罗技可以通过颜色判断来执行宏吗?
发表于 2020-1-29 06:46:44 |只看该作者 来自:云南

帖子:319

符文:70

39#
攻击地方水晶 发表于 2020-1-29 06:15
请问find 的方法可以用来获取屏幕颜色吗? 罗技有没有这个功能啊?

不可以,罗技仅可以通过截取屏幕颜色来改变罗技音响的颜色,而不可以直接在脚本中抓取
发表于 2020-2-1 13:42:28 来自凯恩之角App |只看该作者 来自:江苏

帖子:1

符文:0

40#
可以执行什么宏,让鼠标亮什么颜色灯吗,我看罗技有控制RGB的函数
发表于 2020-2-25 15:25:58 |只看该作者 来自:湖北

帖子:45

符文:18

41#
这种帖子,跪着也看不懂
发表于 2020-2-26 22:49:50 来自凯恩之角App |只看该作者 来自:湖北

帖子:8

符文:166

42#
一脸懵逼   帮顶
发表于 2020-3-3 23:41:42 来自凯恩之角App |只看该作者 来自:河南

帖子:97

符文:8

43#
本帖最后由 倚石护青烟 于 2020-3-4 07:23 编辑

你说的这些先不管对不对,至少暗黑3这游戏不需要。你那个奶妈的例子很不恰当,可能你对奶妈的玩法有误解。
发表于 2020-3-4 07:22:28 来自凯恩之角App |只看该作者 来自:德国

帖子:1

符文:0

44#
可太厉害了,一直鼠标脚本只能执行一个录制宏。按别的会切换,用了楼主的框架简直太方便了。
发表于 2020-3-10 04:25:56 |只看该作者 来自:内蒙古

帖子:319

符文:70

45#
倚石护青烟 发表于 2020-3-4 07:22
你说的这些先不管对不对,至少暗黑3这游戏不需要。你那个奶妈的例子很不恰当,可能你对奶妈的玩法有误解。

哦?说说看,哪里是不恰当之处
发表于 2020-3-16 20:25:48 来自凯恩之角App |只看该作者 来自:江苏
您需要登录后才可以回帖 登录 | 注册网易通行证