本文整理匯總了Java中java.util.TreeSet.higher方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeSet.higher方法的具體用法?Java TreeSet.higher怎麽用?Java TreeSet.higher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.higher方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextValue
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns either the next value, or the first value of the tree if the
* given value is the last one of the tree.
*/
private static double nextValue(TreeSet<Double> tree, double value) {
if(tree.higher(value)==null)
return tree.first();
else
return tree.higher(value);
}
示例2: testHigher
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* higher returns next element
*/
public void testHigher() {
TreeSet q = set5();
Object e1 = q.higher(three);
assertEquals(four, e1);
Object e2 = q.higher(zero);
assertEquals(one, e2);
Object e3 = q.higher(five);
assertNull(e3);
Object e4 = q.higher(six);
assertNull(e4);
}
示例3: scaleDownNeighbordists
import java.util.TreeSet; //導入方法依賴的package包/類
private static ArrayList<Attribute> scaleDownNeighbordists(Instances previousSet, Instance center){
ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
int attNum = center.numAttributes();
int pos = -1;
if(previousSet.attribute(PerformanceAttName)!=null)
pos = previousSet.attribute(PerformanceAttName).index();
//traverse each dimension
Enumeration<Instance> enu;
double[] minDists = new double[2];
double val;
for(int i=0;i<attNum;i++){
if(i==pos)
continue;
enu = previousSet.enumerateInstances();
minDists[0] = 1-Double.MAX_VALUE;
minDists[1] = Double.MAX_VALUE;
while(enu.hasMoreElements()){
Instance ins = enu.nextElement();
if(!ins.equals(center)){
val = ins.value(i)-center.value(i);
if(val<0)
minDists[0] = Math.max((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[0]);
else
minDists[1] = Math.min((double)((int)((ins.value(i)-center.value(i))*1000))/1000.0, minDists[1]);
}
}
//now we set the range
Properties p1 = new Properties();
double upper = center.value(i)+minDists[1], lower=center.value(i)+minDists[0];
TreeSet<Double> detourSet = new TreeSet<Double>();
detourSet.add(upper);
detourSet.add(lower);
detourSet.add(previousSet.attribute(i).getUpperNumericBound());
detourSet.add(previousSet.attribute(i).getLowerNumericBound());
switch(detourSet.size()){
case 1:
upper=lower=detourSet.first();
break;
case 2:
upper = detourSet.last();
lower = detourSet.first();
break;
case 3:
upper=lower=detourSet.higher(detourSet.first());
break;
default://case 4:
upper=detourSet.lower(detourSet.last());
lower=detourSet.higher(detourSet.first());
break;
}
p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
ProtectedProperties prop1 = new ProtectedProperties(p1);
localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
}
return localAtts;
}
示例4: scaleDownMindists
import java.util.TreeSet; //導入方法依賴的package包/類
private static ArrayList<Attribute> scaleDownMindists(Instances previousSet, Instance center){
ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
int attNum = center.numAttributes();
int pos = previousSet.attribute(PerformanceAttName).index();
//traverse each dimension
Enumeration<Instance> enu;
double minDis;
for(int i=0;i<attNum;i++){
if(i==pos)
continue;
enu = previousSet.enumerateInstances();
minDis = Double.MAX_VALUE;
while(enu.hasMoreElements()){
Instance ins = enu.nextElement();
if(!ins.equals(center))
minDis = Math.min((double)((int)(Math.abs(ins.value(i)-center.value(i))*1000))/1000.0, minDis);
}
//now we set the range
Properties p1 = new Properties();
double upper = center.value(i)+minDis, lower=center.value(i)-minDis;
TreeSet<Double> detourSet = new TreeSet<Double>();
detourSet.add(upper);
detourSet.add(lower);
detourSet.add(previousSet.attribute(i).getUpperNumericBound());
detourSet.add(previousSet.attribute(i).getLowerNumericBound());
switch(detourSet.size()){
case 1:
upper=lower=detourSet.first();
break;
case 2:
upper = detourSet.last();
lower = detourSet.first();
break;
case 3:
upper=lower=detourSet.higher(detourSet.first());
break;
default://case 4:
upper=detourSet.lower(detourSet.last());
lower=detourSet.higher(detourSet.first());
break;
}
p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
ProtectedProperties prop1 = new ProtectedProperties(p1);
localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
}
return localAtts;
}
示例5: scaleDownDetour
import java.util.TreeSet; //導入方法依賴的package包/類
public static ArrayList<Attribute> scaleDownDetour(Instances previousSet, Instance center){
ArrayList<Attribute> localAtts = new ArrayList<Attribute>();
int attNum = center.numAttributes();
int pos = previousSet.attribute(PerformanceAttName).index();
//traverse each dimension
Enumeration<Instance> enu;
double minDis;
for(int i=0;i<attNum;i++){
if(i==pos)
continue;
enu = previousSet.enumerateInstances();
minDis = Double.MAX_VALUE;
while(enu.hasMoreElements()){
Instance ins = enu.nextElement();
if(!ins.equals(center))
minDis = Math.min((double)((int)(Math.abs(ins.value(i)-center.value(i))*100))/100.0, minDis);
}
//now we set the range
Properties p1 = new Properties();
double upper = center.value(i)+minDis, lower=center.value(i)-minDis;
TreeSet<Double> detourSet = new TreeSet<Double>();
detourSet.add(upper);
detourSet.add(lower);
detourSet.add(previousSet.attribute(i).getUpperNumericBound());
detourSet.add(previousSet.attribute(i).getLowerNumericBound());
switch(detourSet.size()){
case 1:
upper=lower=detourSet.first();
break;
case 2:
upper = detourSet.last();
lower = detourSet.first();
break;
case 3:
upper=lower=detourSet.higher(detourSet.first());
break;
default://case 4:
upper=detourSet.lower(detourSet.last());
lower=detourSet.higher(detourSet.first());
break;
}
p1.setProperty("range", "["+String.valueOf(lower)+","+String.valueOf(upper)+"]");
ProtectedProperties prop1 = new ProtectedProperties(p1);
localAtts.add(new Attribute(previousSet.attribute(i).name(), prop1));
}
return localAtts;
}