摘要: 下载交叉编译器http://pan.baidu.com/share/link?shareid=984027778&uk=388424485第一步进行解压:tar -zxvf 文件第二部将解压后的目录拷贝在/usr/local/下 这里可以选择解压中的某个文件目录即可,比如我的4.4.3/第三步配置文件修改vim /exc/profile添加一句 pathmunge /usr/local/4.4.3/bin保存退出输入命令:source /exc/profilel使用该命令进行查看是够添加成功:echo $PATH又表示成功了arm-linux-gcc -v 查看版本 阅读全文
posted @ 2013-06-24 21:28 heity 阅读(499) 评论(0) 推荐(0) 编辑
摘要: 整数划分问题(递归法) 整数划分问题是算法中的一个经典命题之一,有关这个问题的讲述在讲解到递归时基本都将涉及。所谓整数划分,是指把一个正整数n写成如下形式: n=m1+m2+...+mi; (其中mi为正整数,并且1 <= mi <= n),则{m1,m2,...,mi}为n的一个划分。 如果{m1,m2,...,mi}中的最大值不超过m,即max(m1,m2,...,mi)<=m,则称它属于n的一个m划分。这里我们记n的m划分的个数为f(n,m); 例如但n=4时,他有5个划分,{4},{3,1},{2,2},{2,1,1},{1,1,1,1}; 注意4=1+3 和 4=3 阅读全文
posted @ 2012-11-18 17:25 heity 阅读(232) 评论(0) 推荐(0) 编辑
--构建四叉树

local quadTree = class("quadTree")

function  quadTree:ctor(rect,max_objects,max_level,level)
    self._rect = rect
    self._max_objects = max_objects or 8
    self._max_level = max_level or 4
    self._level = level
    self._trees = {}
    self._objects = {}
end

--分裂树
function quadTree:splitTree()
    local width = self._rect.width/2
    local height = self._rect.height/2
    local x = self._rect.x + width
    local y = self._rect.y + height
    local level = self._level + 1
    self._trees[1] = quadTree.new({x = x + width,y = y + height,width = width,height = height},self._max_objects,self._max_level,level)
    self._trees[2] = quadTree.new({x = x,y = y + height,width = width,height = height},self._max_objects,self._max_level,level)
    self._trees[3] = quadTree.new({x = x,y = y,width = width,height = height},self._max_objects,self._max_level,level)
    self._trees[4] = quadTree.new({x = x + width ,y = y,width = width,height = height},self._max_objects,self._max_level,level)
end
--
--- y—————————————————h
--- |       |       |
--- |    2  |   1   |
--- |       |       |
--- |————————————————
--- |       |       |
--- |    3  |   4   |
--- |       |       |
--- x—————————————————w
---
--所属子树index
function quadTree:getTreeIndexs(rect)
    local treeIndexs = {}

    local c_x = self._rect.x + self._rect.width/2
    local c_y = self._rect.y + self._rect.height/2

    local is_left = rect.x < c_x
    local is_top = rect.y > c_y
    local end_left = rect.x + rect.width < c_x
    local end_top = rect.y + rect.height > c_y
    --1
    if (is_top and not end_left) or (not is_left and end_top) then
        table.insert( treeIndexs,1)
    end
    --2
    if (is_top and end_left) or (is_left and end_top ) then
        table.insert( treeIndexs,2)
    end
    --3
    if (not is_top and end_left) or (is_left and not end_top) then
        table.insert( treeIndexs,3)
    end
    --4
    if (not is_top and not end_left) or (not is_left and not end_top) then
        table.insert( treeIndexs,4)
    end
    return treeIndexs
end

--插入
function quadTree:insert(rect)
    if self._trees and next(self._trees) then
        local treeIndexs = self:getTreeIndexs(rect)
        for k,index in ipairs(treeIndexs) do
            self._trees[index]:insert(rect)
        end
        return 
    end
    table.insert( self._objects,rect)
    if #self._objects > self._max_objects and self._level <= self._max_level then
        if not (self._trees and next(self._trees)) then
            self:splitTree()
        end
        for i,k in ipairs(self._objects) do
            local k_indexs = self:getTreeIndexs(k)
            for _,index in ipairs(k_indexs) do
                self._trees[index]:insert(k)
            end
        end
        self._objects = {}
    end

end
--
function quadTree:hashCode(_object)
    local tag = _object.x..'_'.._object.y.."_".._object.width.."_".._object.height
    return tag
end

--列表相加 并且去重
function quadTree:tableAdd(table1,table2)
    local hashTags = {}
    local newTables = table1 or {}
    for _,value in ipairs(newTables) do
        hashTags[self:hashCode(value)] = true
    end
    if table2 and next(table2) then
        for _,value in ipairs(table2) do
            local hashtag = self:hashCode(value)
            if not hashTags[hashtag] then
                hashTags[hashtag] = true
                table.insert( newTables,value)
            end
        end
    end
    return newTables
end

--取回同一组object
function quadTree:retrieve(rect)
    local newObjects = self._objects
    if self._trees and next(self._trees) then
        local treeIndexs = self:getTreeIndexs(rect)
        for _,index in ipairs(treeIndexs) do
            newObjects = self:tableAdd(newObjects,self._trees[index]:retrieve(rect))
        end
    end
    return newObjects
end

function quadTree:clearTree()
    self._objects = {}
    for _,tree in pairs(self._trees) do
        tree:clearTree()
    end
end

function quadTree:dumpTree()
    sys.log("[quadTree]-level="..self._level)
    if self._objects and next(self._objects) then
        sys.log("[quadTree]-objects:")
        sys.dump(self._objects)
    end
    for index,child_tree in pairs(self._trees) do
        sys.log("[quadTree]-index="..index)
        child_tree:dumpTree()
    end
end

return quadTree

 

posted @ 2020-08-10 14:13 heity 阅读(476) 评论(0) 推荐(0) 编辑
摘要: #ifndef __CALCULATIONFORMULA_HEAD__ #define __CALCULATIONFORMULA_HEAD__ #include #include #include #include #include using namespace std; class CalculatiomFormula { public: CalculatiomForm... 阅读全文
posted @ 2017-10-27 11:53 heity 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 获取当前任务所占的内存:#include #include // 任务占用内存double usedMemory(){#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) task_basic_info_data_t taskInfo; mach_msg... 阅读全文
posted @ 2015-07-06 10:37 heity 阅读(341) 评论(0) 推荐(0) 编辑
摘要: 一、java 调用c/c++步骤: 1、在java类中创建一个native关键字声明的函数 2、使用javah生成对应的.h文件 3、在c/c++中实现对应的方法 4、使用vs2012创建一个win32空白项目,将jdk中的jni.h和jni_md.h文件拷贝到工程中,修改项目属性为(属性-... 阅读全文
posted @ 2015-06-14 01:18 heity 阅读(201) 评论(0) 推荐(0) 编辑
摘要: /****yy_room*2015-3-6***/#include #include using namespace std;/** # 表示将一个宏的参数转换为字符串字面量* ## 将两边记号连接在一起**/#define MACRO_GET_SET(T,VarName,FuncName) pro... 阅读全文
posted @ 2015-03-06 15:20 heity 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 方案1: 点击“项目”-->“属性” --> “清单工具”, 然后选择"输入和输出’ --> ‘嵌入清单’,将后面的‘是’改成‘否’就可以了方案2: 在VS安装目录搜索cvtres.exe 发现有两个cvtres.exe文件,有的网友选择用最新的文件覆盖掉所有旧的cvtres.exe... 阅读全文
posted @ 2014-12-30 10:33 heity 阅读(408) 评论(0) 推荐(0) 编辑
摘要: 本文转载自:http://www.cnblogs.com/linux-ios/archive/2013/04/09/3010779.htmlbool HelloWorld::init(){ ////////////////////////////// // 1. super init f... 阅读全文
posted @ 2014-10-11 17:55 heity 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 1、我们在VS中找到"解决方案资源管理器", 在解决方案"HelloCocos"上点击右键, 选择添加现有项目. 在弹出的对话框中选择*************\cocos2d\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcx... 阅读全文
posted @ 2014-09-23 22:10 heity 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 2048之军衔篇 反馈 有事留言 阅读全文
posted @ 2014-09-23 11:59 heity 阅读(326) 评论(0) 推荐(0) 编辑
摘要: http 错误代码表所有 HTTP 状态代码及其定义。 代码指示2xx成功200正常;请求已完成。201正常;紧接 POST 命令。202正常;已接受用于处理,但处理尚未完成。203正常;部分信息 — 返回的信息只是一部分。204正常;无响应 — 已接收请求,但不存在要回送的信息。3xx重定向301... 阅读全文
posted @ 2014-07-30 22:35 heity 阅读(186) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示