johnson-trotter:Johnson-Trotter 置换算法的实现

时间:2021-06-20 11:45:08
【文件属性】:
文件名称:johnson-trotter:Johnson-Trotter 置换算法的实现
文件大小:6KB
文件格式:ZIP
更新时间:2021-06-20 11:45:08
JavaScript 约翰逊-特罗特.js 置换算法的实现。 用法 要迭代给定数组的排列,只需执行以下操作: var permute = require ( 'johnson-trotter' ) ; var arr = [ 'foo' , 'bar' , 'baz' ] ; var iter = permute ( arr ) ; while ( iter . hasNext ( ) ) { iter . next ( ) ; //=> ['foo', 'bar', 'baz'] //=> ['foo', 'baz', 'bar'] //=> ['baz', 'foo', 'bar'] //=> ['baz', 'bar', 'foo'] //=> ['bar', 'baz', 'foo'] //=> ['bar', 'foo', 'baz'] } 注意: 每次调用nex
【文件预览】:
johnson-trotter-master
----.travis.yml(152B)
----example()
--------index.js(321B)
----index.js(2KB)
----package.json(742B)
----test()
--------index.js(3KB)
----LICENSE(1KB)
----.gitignore(48B)
----README.md(2KB)
----.jshintrc(273B)
----.editorconfig(147B)

网友评论