Skip to content

Commit

Permalink
JoinLossLessValidation V1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenWrong committed Mar 28, 2021
1 parent b8d9673 commit d164511
Show file tree
Hide file tree
Showing 26 changed files with 1,062 additions and 0 deletions.
6 changes: 6 additions & 0 deletions JoinLossLessValidation/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions JoinLossLessValidation/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lossless</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions JoinLossLessValidation/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions JoinLossLessValidation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# LossLessValidation
Algorithm Of Loss Less Validation Version-1.0

This is just the first version of the algorithm and there maybe exists some bugs. Besides, the style and the comment of this code is not so well but I will improve it later. Recently, I am preparing for the Post Graduate Entrance Examination.
Binary file added JoinLossLessValidation/bin/andrewguan/F.class
Binary file not shown.
Binary file not shown.
Binary file added JoinLossLessValidation/bin/andrewguan/R.class
Binary file not shown.
Binary file added JoinLossLessValidation/bin/andrewguan/Rho.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added JoinLossLessValidation/bin/andrewguan/Sort.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions JoinLossLessValidation/bin/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
A B C D E
5
A→C
B→C
C→D
DE→C
CE→A
5
R1(A,D)
R2(A,B)
R3(B,E)
R4(C,D,E)
R5(A,E)





Introduction:

The first line is the content of R.
The second line is the number of the function dependences that F contains.
And the following five line is the function dependences of F.
The next line is the number of the sub-schema in a schema decomposition.
And the following five line is the content of sub-schema.
6 changes: 6 additions & 0 deletions JoinLossLessValidation/bin/testCheckA.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5 5
a1 b12 b13 a4 b15
a1 a2 b23 b24 b25
b31 a2 b33 b34 a5
a1 a2 b34 a4 a5
a1 b52 b53 b54 a5
10 changes: 10 additions & 0 deletions JoinLossLessValidation/bin/testSort.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
9
a1a2
a1b22
b13a2
b14b24
b14b24
a1a2
b13b23
a1a2
b13a2
145 changes: 145 additions & 0 deletions JoinLossLessValidation/src/andrewguan/F.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package andrewguan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.Set;

public class F {
/**
* Key: the left part of the formula.
* Value: the right part of the formula. <br/>
*/
private LinkedHashMap<String, String> map;

public F() {
this.map = new LinkedHashMap<>();
}

/**
* User can input from console use this function. But I do not recommend
* you to use this function.
*/
public void input() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("Please input the number of the function dependences:");
int num = Integer.parseInt(reader.readLine());
for (int i = 0; i < num; i++) {
System.out.println("Please input the " + (i+1) + "-th function dependeces: (like A→C)");
String line = reader.readLine();
String[] strings = line.split("→");
this.map.put(strings[0], strings[1]);
}

} catch (IOException e) {
e.printStackTrace();
}
}

/**
* This function is called by the input function of LossLessValidation.java
* @param lines An array contains all the lines that needed to input.
*/
public void input(String[] lines) {
for (int i = 0; i < lines.length; i++) {
String[] strings = lines[i].split("→");
this.map.put(strings[0], strings[1]);
}
}

/**
* @return the length of the inner map.
*/
public int getLength() {
return this.map.size();
}

public Set<String> getKeys() {
return this.map.keySet();
}

/**
* Get key by index.
* @param index the index of key that you needed.
* @return key.
*/
public String getKey(int index) {
Set<String> ketSet = this.map.keySet();
int i = 0;
String result = "";
for (String string : ketSet) {
if (i == index) {
result += string;
break;
}
i++;
}
return result;
}

/**
* Get value of map by key.
* @param key
* @return
*/
public String get(String key) {
return this.map.get(key);
}

/**
* Get the index of a key.
* @param key
* @return index. If this map does not contain the key
* it will return -1.
*/
public int getKeyIndex(String key) {
Set<String> ketSet = this.map.keySet();
int i = 0;
for (String string : ketSet) {
if (string.equals(key)) {
return i;
} else {
i++;
}
}
return -1;
}

/**
* Get the index of value.
* @param value
* @return index. If this map does not contain the key
* it will return -1.
*/
public int getValueIndex(String value) {
Set<String> ketSet = this.map.keySet();
int i = 0;
for (String string : ketSet) {
if (this.map.get(string).equals(value)) {
return i;
} else {
i++;
}
}
return -1;
}

@Override
public String toString() {
String label = "→";
String result = "F={";
Set<Entry<String, String>> set = map.entrySet();
int i = 0;
for(Entry<String, String> entry : set) {
i++;
result += entry.getKey() + label + entry.getValue() ;
if (i != set.size()) {
result += " ";
}
}
return result + "}";
}
}
Loading

0 comments on commit d164511

Please sign in to comment.