Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
11679d44
提交
11679d44
authored
6月 11, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use generics
上级
32955f2c
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
23 行删除
+33
-23
Optimizer.java
h2/src/main/org/h2/command/dml/Optimizer.java
+2
-2
Permutations.java
h2/src/main/org/h2/util/Permutations.java
+31
-21
没有找到文件。
h2/src/main/org/h2/command/dml/Optimizer.java
浏览文件 @
11679d44
...
@@ -104,7 +104,7 @@ public class Optimizer {
...
@@ -104,7 +104,7 @@ public class Optimizer {
private
void
calculateBruteForceAll
()
throws
SQLException
{
private
void
calculateBruteForceAll
()
throws
SQLException
{
TableFilter
[]
list
=
new
TableFilter
[
filters
.
length
];
TableFilter
[]
list
=
new
TableFilter
[
filters
.
length
];
Permutations
p
=
new
Permutations
(
filters
,
list
);
Permutations
<
TableFilter
>
p
=
Permutations
.
create
(
filters
,
list
);
for
(
int
x
=
0
;
!
canStop
(
x
)
&&
p
.
next
();
x
++)
{
for
(
int
x
=
0
;
!
canStop
(
x
)
&&
p
.
next
();
x
++)
{
testPlan
(
list
);
testPlan
(
list
);
}
}
...
@@ -113,7 +113,7 @@ public class Optimizer {
...
@@ -113,7 +113,7 @@ public class Optimizer {
private
void
calculateBruteForceSome
()
throws
SQLException
{
private
void
calculateBruteForceSome
()
throws
SQLException
{
int
bruteForce
=
getMaxBruteForceFilters
(
filters
.
length
);
int
bruteForce
=
getMaxBruteForceFilters
(
filters
.
length
);
TableFilter
[]
list
=
new
TableFilter
[
filters
.
length
];
TableFilter
[]
list
=
new
TableFilter
[
filters
.
length
];
Permutations
p
=
new
Permutations
(
filters
,
list
,
bruteForce
);
Permutations
<
TableFilter
>
p
=
Permutations
.
create
(
filters
,
list
,
bruteForce
);
for
(
int
x
=
0
;
!
canStop
(
x
)
&&
p
.
next
();
x
++)
{
for
(
int
x
=
0
;
!
canStop
(
x
)
&&
p
.
next
();
x
++)
{
// find out what filters are not used yet
// find out what filters are not used yet
for
(
TableFilter
f
:
filters
)
{
for
(
TableFilter
f
:
filters
)
{
...
...
h2/src/main/org/h2/util/Permutations.java
浏览文件 @
11679d44
...
@@ -12,33 +12,18 @@ import org.h2.message.Message;
...
@@ -12,33 +12,18 @@ import org.h2.message.Message;
* A class to iterate over all permutations of an array.
* A class to iterate over all permutations of an array.
* The algorithm is from Applied Combinatorics, by Alan Tucker as implemented in
* The algorithm is from Applied Combinatorics, by Alan Tucker as implemented in
* http://www.koders.com/java/fidD3445CD11B1DC687F6B8911075E7F01E23171553.aspx
* http://www.koders.com/java/fidD3445CD11B1DC687F6B8911075E7F01E23171553.aspx
*
* @param <T> the element type
*/
*/
public
class
Permutations
{
public
class
Permutations
<
T
>
{
private
Object
[]
in
;
private
T
[]
in
;
private
Object
[]
out
;
private
T
[]
out
;
private
int
n
,
m
;
private
int
n
,
m
;
private
int
[]
index
;
private
int
[]
index
;
private
boolean
hasNext
=
true
;
private
boolean
hasNext
=
true
;
/**
private
Permutations
(
T
[]
in
,
T
[]
out
,
int
m
)
{
* Create a new permutations object.
*
* @param in the source array
* @param out the target array
*/
public
Permutations
(
Object
[]
in
,
Object
[]
out
)
{
this
(
in
,
out
,
in
.
length
);
}
/**
* Create a new permutations object.
*
* @param in the source array
* @param out the target array
* @param m the number of output elements to generate
*/
public
Permutations
(
Object
[]
in
,
Object
[]
out
,
int
m
)
{
this
.
n
=
in
.
length
;
this
.
n
=
in
.
length
;
this
.
m
=
m
;
this
.
m
=
m
;
if
(
n
<
m
||
m
<
0
)
{
if
(
n
<
m
||
m
<
0
)
{
...
@@ -56,6 +41,31 @@ public class Permutations {
...
@@ -56,6 +41,31 @@ public class Permutations {
reverseAfter
(
m
-
1
);
reverseAfter
(
m
-
1
);
}
}
/**
* Create a new permutations object.
*
* @param <T> the type
* @param in the source array
* @param out the target array
* @return the generated permutations object
*/
public
static
<
T
>
Permutations
<
T
>
create
(
T
[]
in
,
T
[]
out
)
{
return
new
Permutations
<
T
>(
in
,
out
,
in
.
length
);
}
/**
* Create a new permutations object.
*
* @param <T> the type
* @param in the source array
* @param out the target array
* @param m the number of output elements to generate
* @return the generated permutations object
*/
public
static
<
T
>
Permutations
<
T
>
create
(
T
[]
in
,
T
[]
out
,
int
m
)
{
return
new
Permutations
<
T
>(
in
,
out
,
m
);
}
/**
/**
* Move the index forward a notch. The algorithm first finds the rightmost
* Move the index forward a notch. The algorithm first finds the rightmost
* index that is less than its neighbor to the right. This is the dip point.
* index that is less than its neighbor to the right. This is the dip point.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论