-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample.java
More file actions
83 lines (68 loc) · 1.98 KB
/
Example.java
File metadata and controls
83 lines (68 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package decisiontree;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Ian Robertson
*/
public class Example<T> implements Iterable<String>{
//Atribute name and value
private LinkedHashMap<String, T> attributes;
//Goal predicate; outcome.
private T goal;
public Example(List<String> attributeList){
attributes = new LinkedHashMap<>();
for(String attribute : attributeList){
attributes.put(attribute, null);
}
}
public Example(T goal){
this.goal=goal;
attributes = new LinkedHashMap<>();
}
public Example(LinkedHashMap<String, T> attributes, T goal){
this.attributes=attributes;
this.goal=goal;
}
public void addAttribute(String attributeName){
attributes.put(attributeName, null);
}
public void addAttributeValue(String attribute, T value){
attributes.put(attribute, value);
}
public void addAttributeValue(int index, T value){
Object[] key = attributes.keySet().toArray();
attributes.put((String)key[index], value);
//System.out.println("Example addAttributeValue : "+value);
}
public T getGoal() {
return this.goal;
}
/*
* @return Returns Object value of @param attributeName
*/
public T getValue(String attributeName) {
return attributes.get(attributeName);
}
public String getAttribute(String attribute){
attributes.containsKey(attribute);
return attribute;
}
public HashMap accessData(){
return attributes;
}
public void setGoal(T goal){
this.goal=goal;
}
public int size(){
return attributes.size();
}
@Override
public Iterator<String> iterator() {
return attributes.keySet().iterator();
}
}