git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7337 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
dad5818b40
commit
442497868d
@ -1,66 +0,0 @@
|
|||||||
package de.anomic.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author apfelmaennchen
|
|
||||||
*
|
|
||||||
* @param <K>
|
|
||||||
* @param <V>
|
|
||||||
*/
|
|
||||||
public class YMarkKeyValueEntry<K extends Comparable<K>,V extends Comparable<V>> extends Object implements Comparable<YMarkKeyValueEntry<K,V>> {
|
|
||||||
|
|
||||||
private K key;
|
|
||||||
private V value;
|
|
||||||
|
|
||||||
|
|
||||||
public YMarkKeyValueEntry() {
|
|
||||||
this.key = null;
|
|
||||||
this.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public YMarkKeyValueEntry(K key, V value) {
|
|
||||||
this.key = key;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The natural order of objects in this class is determind by their value components<br/>
|
|
||||||
* <b>Note:</b> this class has a natural ordering that is inconsistent with equals.
|
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public int compareTo(YMarkKeyValueEntry<K,V> e) {
|
|
||||||
return this.value.compareTo(e.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Two objects of this class are considered to be equal, if their keys are equal.<br/>
|
|
||||||
* <b>Note:</b> this class has a natural ordering that is inconsistent with equals.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(this.getClass() == obj.getClass())
|
|
||||||
return this.key.equals(((YMarkKeyValueEntry<K,V>)obj).getKey());
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public K getKey() {
|
|
||||||
return this.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public V getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(V value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(K key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(K key, V value) {
|
|
||||||
this.key = key;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package de.anomic.data;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.yacy.kelondro.data.word.Word;
|
||||||
|
|
||||||
|
public class YMarkWordCountComparator implements Comparator<String> {
|
||||||
|
|
||||||
|
private Map<String,Word> words;
|
||||||
|
|
||||||
|
public YMarkWordCountComparator(final Map<String,Word> words) {
|
||||||
|
this.words = words;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(final String k1, final String k2) {
|
||||||
|
final Word w1 = this.words.get(k1);
|
||||||
|
final Word w2 = this.words.get(k2);
|
||||||
|
|
||||||
|
if(w1.occurrences() > w2.occurrences())
|
||||||
|
return 1;
|
||||||
|
else if(w1.occurrences() < w2.occurrences())
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue