当前位置: 首页>>代码示例>>Java>>正文


Java TreeSet.lower方法代码示例

本文整理汇总了Java中java.util.TreeSet.lower方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSet.lower方法的具体用法?Java TreeSet.lower怎么用?Java TreeSet.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.TreeSet的用法示例。


在下文中一共展示了TreeSet.lower方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLower

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * lower returns preceding element
 */
public void testLower() {
    TreeSet q = set5();
    Object e1 = q.lower(three);
    assertEquals(two, e1);

    Object e2 = q.lower(six);
    assertEquals(five, e2);

    Object e3 = q.lower(one);
    assertNull(e3);

    Object e4 = q.lower(zero);
    assertNull(e4);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TreeSetTest.java

示例2: getLockPath

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected String getLockPath(String createdZNode, List<String> children) throws IOException {
  TreeSet<String> sortedChildren =
      new TreeSet<String>(ZNodeComparator.COMPARATOR);
  sortedChildren.addAll(children);
  String pathToWatch = sortedChildren.lower(createdZNode);
  if (pathToWatch != null) {
    String nodeHoldingLock = sortedChildren.first();
    String znode = ZKUtil.joinZNode(parentLockNode, nodeHoldingLock);
    handleLockMetadata(znode);
  }
  return pathToWatch;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:ZKInterProcessWriteLock.java

示例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;
}
 
开发者ID:zhuyuqing,项目名称:bestconf,代码行数:66,代码来源:ConfigSampler.java

示例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;
}
 
开发者ID:zhuyuqing,项目名称:bestconf,代码行数:57,代码来源:ConfigSampler.java

示例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;
}
 
开发者ID:zhuyuqing,项目名称:bestconf,代码行数:57,代码来源:BestConf.java


注:本文中的java.util.TreeSet.lower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。