js笛卡尔积
来源:互联网 发布:单项软件开发资质 编辑:程序博客网 时间:2024/05/29 16:31
js笛卡尔积
可以用来模拟路径,或者标签的顺序。
//笛卡儿积组合function descartes(list){//parent上一级索引;count指针计数var point = {};var result = [];var pIndex = null;var tempCount = 0;var temp = [];//根据参数列生成指针对象for(var index in list){if(typeof list[index] == 'object'){point[index] = {'parent':pIndex,'count':0}pIndex = index;}}//单维度数据结构直接返回if(pIndex == null){return list;}//动态生成笛卡尔积while(true){for(var index in list){tempCount = point[index]['count'];temp.push(list[index][tempCount]);}//压入结果数组result.push(temp);temp = [];//检查指针最大值问题while(true){if(point[index]['count']+1 >= list[index].length){point[index]['count'] = 0;pIndex = point[index]['parent'];if(pIndex == null){return result;}//赋值parent进行再次检查index = pIndex;}else{point[index]['count']++;break;}}}}//var ss=descartes([[1,2,3],[1,2]]);<<--多重数组//var ss=descartes({"a":[1,2,3],"b":[1,2]});<<--json //console.log(ss);
阅读全文
0 0
- js 生成笛卡尔积
- js笛卡尔积
- js 笛卡尔
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- 笛卡尔积
- js 笛卡尔积算法与多重数组笛卡尔积的例子
- Js笛卡尔乘积
- 什么是笛卡尔积
- java 笛卡尔积实现
- 关于mysql配置主从同步,个人的见解与实现方法
- Android Handler 异步消息处理机制的妙用 创建强大的图片加载类
- Dropout
- Linux CentOS 6.5中安装与配置Tomcat-8方法
- Grafeas-来自谷歌,IBM, 红帽和 JFrog 的元数据标准
- js笛卡尔积
- angular中的常见过滤器
- Pcl1.8.0源代码编译与安装
- Laplacian Matrix
- wstring转string
- 答答租车系统java代码实现
- Android studio Xposed框架Hook小试
- 7-21 字符串循环左移(20 分)
- 被启迪-R画出我的心